Updating USD golden file and exporter_test.py
This commit is contained in:
+33
-15
@@ -5,7 +5,7 @@
|
|||||||
"""
|
"""
|
||||||
endTimeCode = 1
|
endTimeCode = 1
|
||||||
startTimeCode = 0
|
startTimeCode = 0
|
||||||
timeCodesPerSecond = 24
|
timeCodesPerSecond = 60
|
||||||
upAxis = "Z"
|
upAxis = "Z"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -13,48 +13,66 @@ def Xform "World"
|
|||||||
{
|
{
|
||||||
def Xform "Light_Xform_0"
|
def Xform "Light_Xform_0"
|
||||||
{
|
{
|
||||||
double3 xformOp:translate
|
double3 xformOp:translate.timeSamples = {
|
||||||
|
0: (0, -3.674234628677368, 3.674234628677368),
|
||||||
|
}
|
||||||
uniform token[] xformOpOrder = ["xformOp:translate"]
|
uniform token[] xformOpOrder = ["xformOp:translate"]
|
||||||
|
|
||||||
def SphereLight "Light_0"
|
def SphereLight "Light_0"
|
||||||
{
|
{
|
||||||
|
color3f inputs:color = (0.4, 0.4, 0.4)
|
||||||
|
float inputs:intensity = 10000
|
||||||
bool inputs:normalize = 1
|
bool inputs:normalize = 1
|
||||||
float inputs:radius = 0.3
|
float inputs:radius = 0.3
|
||||||
bool treatAsPoint = 0
|
bool treatAsPoint = 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def Xform "CubeMesh_Xform_white_box"
|
def Xform "Camera_Xform_closeup"
|
||||||
{
|
{
|
||||||
matrix4d xformOp:transform.timeSamples = {
|
matrix4d xformOp:transform.timeSamples = {
|
||||||
0: ( (0, 0, 0, 0), (0, 0, 0, 0), (0, 0, 0, 0), (0, 0, 0, 1) ),
|
0: ( (1, 0, -0, 0), (0, 0.009999499656260014, 0.9999499917030334, 0), (0, -0.9999499917030334, 0.009999499656260014, 0), (0, -6, 0, 1) ),
|
||||||
}
|
}
|
||||||
uniform token[] xformOpOrder = ["xformOp:transform"]
|
uniform token[] xformOpOrder = ["xformOp:transform"]
|
||||||
|
|
||||||
def Mesh "CubeMesh_white_box" (
|
def Camera "Camera_closeup"
|
||||||
|
{
|
||||||
|
float2 clippingRange = (0.0001, 1000000)
|
||||||
|
float focalLength = 12
|
||||||
|
float focusDistance = 400
|
||||||
|
float horizontalAperture = 12
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
def Xform "Mesh_Xform_white_box_id0_geom"
|
||||||
|
{
|
||||||
|
token visibility.timeSamples = {
|
||||||
|
0: "inherited",
|
||||||
|
1: "invisible",
|
||||||
|
}
|
||||||
|
float3 xformOp:scale
|
||||||
|
matrix4d xformOp:transform.timeSamples = {
|
||||||
|
0: ( (1, 0, 0, 0), (0, 1, 0, 0), (0, 0, 1, 0), (0, 0, 0, 1) ),
|
||||||
|
}
|
||||||
|
uniform token[] xformOpOrder = ["xformOp:transform", "xformOp:scale"]
|
||||||
|
|
||||||
|
def Mesh "Mesh_white_box_id0_geom" (
|
||||||
apiSchemas = ["MaterialBindingAPI"]
|
apiSchemas = ["MaterialBindingAPI"]
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
int[] faceVertexCounts = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]
|
int[] faceVertexCounts = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]
|
||||||
int[] faceVertexIndices = [4, 7, 5, 4, 6, 7, 0, 2, 4, 2, 6, 4, 0, 1, 2, 1, 3, 2, 1, 5, 7, 1, 7, 3, 2, 3, 7, 2, 7, 6, 0, 4, 1, 1, 4, 5]
|
int[] faceVertexIndices = [4, 7, 5, 4, 6, 7, 0, 2, 4, 2, 6, 4, 0, 1, 2, 1, 3, 2, 1, 5, 7, 1, 7, 3, 2, 3, 7, 2, 7, 6, 0, 4, 1, 1, 4, 5]
|
||||||
rel material:binding = </World/_materials/Material_white_box>
|
rel material:binding = </World/_materials/Material_white_box_id0_geom>
|
||||||
point3f[] points = [(-1, -1, -1), (1, -1, -1), (-1, -1, 1), (1, -1, 1), (-1, 1, -1), (1, 1, -1), (-1, 1, 1), (1, 1, 1)]
|
point3f[] points = [(-1, -1, -1), (1, -1, -1), (-1, -1, 1), (1, -1, 1), (-1, 1, -1), (1, 1, -1), (-1, 1, 1), (1, 1, 1)]
|
||||||
texCoord2f[] primvars:UVMap = [] (
|
|
||||||
interpolation = "faceVarying"
|
|
||||||
)
|
|
||||||
int[] primvars:UVMap:indices = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35]
|
|
||||||
uniform token subdivisionScheme = "none"
|
uniform token subdivisionScheme = "none"
|
||||||
token visibility.timeSamples = {
|
|
||||||
0: "inherited",
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def "_materials"
|
def "_materials"
|
||||||
{
|
{
|
||||||
def Material "Material_white_box"
|
def Material "Material_white_box_id0_geom"
|
||||||
{
|
{
|
||||||
token outputs:surface.connect = </World/_materials/Material_white_box/Principled_BSDF.outputs:surface>
|
token outputs:surface.connect = </World/_materials/Material_white_box_id0_geom/Principled_BSDF.outputs:surface>
|
||||||
|
|
||||||
def Shader "Principled_BSDF"
|
def Shader "Principled_BSDF"
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -79,7 +79,10 @@ if __name__ == '__main__':
|
|||||||
)
|
)
|
||||||
|
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'--camera_names', type=str, nargs='+', help='cameras to include in usd'
|
'--camera_names',
|
||||||
|
type=str,
|
||||||
|
nargs='+',
|
||||||
|
help='cameras to include in usd'
|
||||||
)
|
)
|
||||||
|
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
|
|||||||
@@ -194,7 +194,6 @@ class USDExporter:
|
|||||||
|
|
||||||
if self.updates == 0:
|
if self.updates == 0:
|
||||||
self._initialize_usd_stage()
|
self._initialize_usd_stage()
|
||||||
|
|
||||||
self._load_lights()
|
self._load_lights()
|
||||||
self._load_cameras()
|
self._load_cameras()
|
||||||
|
|
||||||
|
|||||||
@@ -22,12 +22,12 @@ from etils import epath
|
|||||||
import mujoco
|
import mujoco
|
||||||
|
|
||||||
|
|
||||||
# Open3D and USD are not fully supported on all MuJoCo architectures.
|
# USD is not fully supported on all MuJoCo architectures.
|
||||||
execute_test = True
|
execute_test = True
|
||||||
try:
|
try:
|
||||||
from mujoco.usd import exporter as exporter_module # pylint: disable=g-import-not-at-top
|
from mujoco.usd import exporter as exporter_module # pylint: disable=g-import-not-at-top
|
||||||
except ImportError:
|
except ImportError:
|
||||||
logging.warning('Skipping test due to missing import')
|
logging.warning("Skipping test due to missing import")
|
||||||
execute_test = False
|
execute_test = False
|
||||||
|
|
||||||
|
|
||||||
@@ -35,9 +35,10 @@ class ExporterTest(absltest.TestCase):
|
|||||||
|
|
||||||
def test_usd_export(self):
|
def test_usd_export(self):
|
||||||
if not execute_test:
|
if not execute_test:
|
||||||
return
|
self.fail("Test test_usd_export failed to execute.")
|
||||||
|
|
||||||
output_dir = os.getenv('TEST_UNDECLARED_OUTPUTS_DIR')
|
output_dir_root = os.getenv("TEST_UNDECLARED_OUTPUTS_DIR")
|
||||||
|
output_dir_name = "usd_test"
|
||||||
xml = """
|
xml = """
|
||||||
<mujoco>
|
<mujoco>
|
||||||
<worldbody>
|
<worldbody>
|
||||||
@@ -50,19 +51,26 @@ class ExporterTest(absltest.TestCase):
|
|||||||
data = mujoco.MjData(model)
|
data = mujoco.MjData(model)
|
||||||
exporter = exporter_module.USDExporter(
|
exporter = exporter_module.USDExporter(
|
||||||
model,
|
model,
|
||||||
output_directory_name='mujoco_usdpkg',
|
output_directory_name=output_dir_name,
|
||||||
output_directory_root=output_dir,
|
output_directory_root=output_dir_root,
|
||||||
|
camera_names=["closeup"]
|
||||||
)
|
)
|
||||||
|
mujoco.mj_step(model, data)
|
||||||
exporter.update_scene(data)
|
exporter.update_scene(data)
|
||||||
exporter.save_scene('export.usda')
|
exporter.save_scene("usda")
|
||||||
|
|
||||||
with open(os.path.join(
|
with open(os.path.join(
|
||||||
output_dir, 'mujoco_usdpkg/frames', 'frame_1.export.usda'), 'r') as f:
|
output_dir_root,
|
||||||
|
f"{output_dir_name}/frames",
|
||||||
|
"frame_1.usda"), "r", encoding="utf-8"
|
||||||
|
) as f:
|
||||||
golden_path = os.path.join(
|
golden_path = os.path.join(
|
||||||
epath.resource_path('mujoco'), 'testdata', 'usd_golden.usda')
|
epath.resource_path("mujoco"),
|
||||||
with open(golden_path, 'r') as golden_file:
|
"testdata",
|
||||||
self.assertEqual(f.read(), golden_file.read())
|
"usd_golden.usda"
|
||||||
|
)
|
||||||
|
with open(golden_path, "r", encoding="utf-8") as golden_file:
|
||||||
|
self.assertEqual(f.readlines(), golden_file.readlines())
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
if __name__ == '__main__':
|
|
||||||
absltest.main()
|
absltest.main()
|
||||||
|
|||||||
@@ -254,14 +254,14 @@ class TriangleMesh:
|
|||||||
|
|
||||||
return TriangleMesh(vertices, triangles, triangle_uvs)
|
return TriangleMesh(vertices, triangles, triangle_uvs)
|
||||||
|
|
||||||
def translate(self, translation: np.array):
|
def translate(self, translation: np.ndarray) -> None:
|
||||||
self.vertices = self.vertices + translation
|
self.vertices = self.vertices + translation
|
||||||
|
|
||||||
def rotate(self, rotation: np.array, center: Tuple[float, ...]):
|
def rotate(self, rotation: np.ndarray, center: Tuple[float, ...]) -> None:
|
||||||
translated_point = self.vertices - center
|
translated_point = self.vertices - center
|
||||||
self.vertices = np.dot(translated_point, rotation) + center
|
self.vertices = np.dot(translated_point, rotation) + center
|
||||||
|
|
||||||
def scale(self, scale: np.array):
|
def scale(self, scale: np.ndarray) -> None:
|
||||||
self.vertices = self.vertices * scale
|
self.vertices = self.vertices * scale
|
||||||
|
|
||||||
def get_center(self):
|
def get_center(self):
|
||||||
|
|||||||
@@ -58,4 +58,5 @@ mujoco = [
|
|||||||
"include/mujoco/*.h",
|
"include/mujoco/*.h",
|
||||||
"testdata/*.xml",
|
"testdata/*.xml",
|
||||||
"testdata/*.msh",
|
"testdata/*.msh",
|
||||||
|
"testdata/*.usda",
|
||||||
]
|
]
|
||||||
|
|||||||
Reference in New Issue
Block a user