Skip to content

Commit 04a75f1

Browse files
authored
Convert DAE to USD (#36)
1 parent bcf7391 commit 04a75f1

23 files changed

+1767
-55
lines changed

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ dependencies = [
1010
"usd-exchange>=2.2.0rc2", # locked to USD 25.05
1111
"numpy-stl>=3.2",
1212
"tinyobjloader>=2.0.0rc13",
13+
"pycollada>=0.9.2",
1314
]
1415

1516
[project.urls]

tests/data/assets/box.dae

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<COLLADA xmlns="http://www.collada.org/2005/11/COLLADASchema" version="1.4.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
3+
<asset>
4+
<unit name="meter" meter="1"/>
5+
<up_axis>Z_UP</up_axis>
6+
</asset>
7+
<library_effects>
8+
<effect id="Material-effect">
9+
<profile_COMMON>
10+
<technique sid="common">
11+
<lambert>
12+
<emission>
13+
<color sid="emission">0 0 0 1</color>
14+
</emission>
15+
<diffuse>
16+
<color sid="diffuse">0.8 0.8 0.8 1</color>
17+
</diffuse>
18+
<index_of_refraction>
19+
<float sid="ior">1.45</float>
20+
</index_of_refraction>
21+
</lambert>
22+
</technique>
23+
</profile_COMMON>
24+
</effect>
25+
</library_effects>
26+
<library_images/>
27+
<library_materials>
28+
<material id="Material-material" name="Material">
29+
<instance_effect url="#Material-effect"/>
30+
</material>
31+
</library_materials>
32+
<library_geometries>
33+
<geometry id="Cube-mesh" name="Cube">
34+
<mesh>
35+
<source id="Cube-mesh-positions">
36+
<float_array id="Cube-mesh-positions-array" count="24">1 1 1 1 1 -1 1 -1 1 1 -1 -1 -1 1 1 -1 1 -1 -1 -1 1 -1 -1 -1</float_array>
37+
<technique_common>
38+
<accessor source="#Cube-mesh-positions-array" count="8" stride="3">
39+
<param name="X" type="float"/>
40+
<param name="Y" type="float"/>
41+
<param name="Z" type="float"/>
42+
</accessor>
43+
</technique_common>
44+
</source>
45+
<source id="Cube-mesh-normals">
46+
<float_array id="Cube-mesh-normals-array" count="36">0 0 1 0 -1 0 -1 0 0 0 0 -1 1 0 0 0 1 0 0 0 1 0 -1 0 -1 0 0 0 0 -1 1 0 0 0 1 0</float_array>
47+
<technique_common>
48+
<accessor source="#Cube-mesh-normals-array" count="12" stride="3">
49+
<param name="X" type="float"/>
50+
<param name="Y" type="float"/>
51+
<param name="Z" type="float"/>
52+
</accessor>
53+
</technique_common>
54+
</source>
55+
<source id="Cube-mesh-map-0">
56+
<float_array id="Cube-mesh-map-0-array" count="72">0.875 0.5 0.625 0.75 0.625 0.5 0.625 0.75 0.375 1 0.375 0.75 0.625 0 0.375 0.25 0.375 0 0.375 0.5 0.125 0.75 0.125 0.5 0.625 0.5 0.375 0.75 0.375 0.5 0.625 0.25 0.375 0.5 0.375 0.25 0.875 0.5 0.875 0.75 0.625 0.75 0.625 0.75 0.625 1 0.375 1 0.625 0 0.625 0.25 0.375 0.25 0.375 0.5 0.375 0.75 0.125 0.75 0.625 0.5 0.625 0.75 0.375 0.75 0.625 0.25 0.625 0.5 0.375 0.5</float_array>
57+
<technique_common>
58+
<accessor source="#Cube-mesh-map-0-array" count="36" stride="2">
59+
<param name="S" type="float"/>
60+
<param name="T" type="float"/>
61+
</accessor>
62+
</technique_common>
63+
</source>
64+
<vertices id="Cube-mesh-vertices">
65+
<input semantic="POSITION" source="#Cube-mesh-positions"/>
66+
</vertices>
67+
<triangles material="Material-material" count="12">
68+
<input semantic="VERTEX" source="#Cube-mesh-vertices" offset="0"/>
69+
<input semantic="NORMAL" source="#Cube-mesh-normals" offset="1"/>
70+
<input semantic="TEXCOORD" source="#Cube-mesh-map-0" offset="2" set="0"/>
71+
<p>4 0 0 2 0 1 0 0 2 2 1 3 7 1 4 3 1 5 6 2 6 5 2 7 7 2 8 1 3 9 7 3 10 5 3 11 0 4 12 3 4 13 1 4 14 4 5 15 1 5 16 5 5 17 4 6 18 6 6 19 2 6 20 2 7 21 6 7 22 7 7 23 6 8 24 4 8 25 5 8 26 1 9 27 3 9 28 7 9 29 0 10 30 2 10 31 3 10 32 4 11 33 0 11 34 1 11 35</p>
72+
</triangles>
73+
</mesh>
74+
</geometry>
75+
</library_geometries>
76+
<library_visual_scenes>
77+
<visual_scene id="Scene" name="Scene">
78+
<node id="Cube" name="Cube" type="NODE">
79+
<matrix sid="transform">0.5 0 0 0 0 0.5 0 0 0 0 0.5 0 0 0 0 1</matrix>
80+
<instance_geometry url="#Cube-mesh" name="Cube">
81+
<bind_material>
82+
<technique_common>
83+
<instance_material symbol="Material-material" target="#Material-material">
84+
<bind_vertex_input semantic="UVMap" input_semantic="TEXCOORD" input_set="0"/>
85+
</instance_material>
86+
</technique_common>
87+
</bind_material>
88+
</instance_geometry>
89+
</node>
90+
</visual_scene>
91+
</library_visual_scenes>
92+
<scene>
93+
<instance_visual_scene url="#Scene"/>
94+
</scene>
95+
</COLLADA>
Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<COLLADA xmlns="http://www.collada.org/2005/11/COLLADASchema" version="1.4.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
3+
<asset>
4+
<unit name="meter" meter="1"/>
5+
<up_axis>Z_UP</up_axis>
6+
</asset>
7+
<library_effects>
8+
<effect id="Material_red-effect">
9+
<profile_COMMON>
10+
<technique sid="common">
11+
<lambert>
12+
<emission>
13+
<color sid="emission">0 0 0 1</color>
14+
</emission>
15+
<diffuse>
16+
<color sid="diffuse">1 0 0 1</color>
17+
</diffuse>
18+
<index_of_refraction>
19+
<float sid="ior">1.45</float>
20+
</index_of_refraction>
21+
</lambert>
22+
</technique>
23+
</profile_COMMON>
24+
</effect>
25+
<effect id="Material_green-effect">
26+
<profile_COMMON>
27+
<technique sid="common">
28+
<lambert>
29+
<emission>
30+
<color sid="emission">0 0 0 1</color>
31+
</emission>
32+
<diffuse>
33+
<color sid="diffuse">0 1 0 1</color>
34+
</diffuse>
35+
<index_of_refraction>
36+
<float sid="ior">1.5</float>
37+
</index_of_refraction>
38+
</lambert>
39+
</technique>
40+
</profile_COMMON>
41+
</effect>
42+
</library_effects>
43+
<library_images/>
44+
<library_materials>
45+
<material id="Material_red-material" name="Material_red">
46+
<instance_effect url="#Material_red-effect"/>
47+
</material>
48+
<material id="Material_green-material" name="Material_green">
49+
<instance_effect url="#Material_green-effect"/>
50+
</material>
51+
</library_materials>
52+
<library_geometries>
53+
<geometry id="Cube-mesh" name="Cube">
54+
<mesh>
55+
<source id="Cube-mesh-positions">
56+
<float_array id="Cube-mesh-positions-array" count="24">1 1 1 1 1 -1 1 -1 1 1 -1 -1 -1 1 1 -1 1 -1 -1 -1 1 -1 -1 -1</float_array>
57+
<technique_common>
58+
<accessor source="#Cube-mesh-positions-array" count="8" stride="3">
59+
<param name="X" type="float"/>
60+
<param name="Y" type="float"/>
61+
<param name="Z" type="float"/>
62+
</accessor>
63+
</technique_common>
64+
</source>
65+
<source id="Cube-mesh-normals">
66+
<float_array id="Cube-mesh-normals-array" count="36">0 0 1 0 -1 0 -1 0 0 0 0 -1 1 0 0 0 1 0 0 0 1 0 -1 0 -1 0 0 0 0 -1 1 0 0 0 1 0</float_array>
67+
<technique_common>
68+
<accessor source="#Cube-mesh-normals-array" count="12" stride="3">
69+
<param name="X" type="float"/>
70+
<param name="Y" type="float"/>
71+
<param name="Z" type="float"/>
72+
</accessor>
73+
</technique_common>
74+
</source>
75+
<source id="Cube-mesh-map-0">
76+
<float_array id="Cube-mesh-map-0-array" count="72">0.875 0.5 0.625 0.75 0.625 0.5 0.625 0.75 0.375 1 0.375 0.75 0.625 0 0.375 0.25 0.375 0 0.375 0.5 0.125 0.75 0.125 0.5 0.625 0.5 0.375 0.75 0.375 0.5 0.625 0.25 0.375 0.5 0.375 0.25 0.875 0.5 0.875 0.75 0.625 0.75 0.625 0.75 0.625 1 0.375 1 0.625 0 0.625 0.25 0.375 0.25 0.375 0.5 0.375 0.75 0.125 0.75 0.625 0.5 0.625 0.75 0.375 0.75 0.625 0.25 0.625 0.5 0.375 0.5</float_array>
77+
<technique_common>
78+
<accessor source="#Cube-mesh-map-0-array" count="36" stride="2">
79+
<param name="S" type="float"/>
80+
<param name="T" type="float"/>
81+
</accessor>
82+
</technique_common>
83+
</source>
84+
<vertices id="Cube-mesh-vertices">
85+
<input semantic="POSITION" source="#Cube-mesh-positions"/>
86+
</vertices>
87+
<triangles material="Material_red-material" count="6">
88+
<input semantic="VERTEX" source="#Cube-mesh-vertices" offset="0"/>
89+
<input semantic="NORMAL" source="#Cube-mesh-normals" offset="1"/>
90+
<input semantic="TEXCOORD" source="#Cube-mesh-map-0" offset="2" set="0"/>
91+
<p>2 1 3 7 1 4 3 1 5 6 2 6 5 2 7 7 2 8 1 3 9 7 3 10 5 3 11 2 7 21 6 7 22 7 7 23 6 8 24 4 8 25 5 8 26 1 9 27 3 9 28 7 9 29</p>
92+
</triangles>
93+
<triangles material="Material_green-material" count="6">
94+
<input semantic="VERTEX" source="#Cube-mesh-vertices" offset="0"/>
95+
<input semantic="NORMAL" source="#Cube-mesh-normals" offset="1"/>
96+
<input semantic="TEXCOORD" source="#Cube-mesh-map-0" offset="2" set="0"/>
97+
<p>4 0 0 2 0 1 0 0 2 0 4 12 3 4 13 1 4 14 4 5 15 1 5 16 5 5 17 4 6 18 6 6 19 2 6 20 0 10 30 2 10 31 3 10 32 4 11 33 0 11 34 1 11 35</p>
98+
</triangles>
99+
</mesh>
100+
</geometry>
101+
</library_geometries>
102+
<library_visual_scenes>
103+
<visual_scene id="Scene" name="Scene">
104+
<node id="Cube" name="Cube" type="NODE">
105+
<matrix sid="transform">0.5 0 0 0 0 0.5 0 0 0 0 0.5 0 0 0 0 1</matrix>
106+
<instance_geometry url="#Cube-mesh" name="Cube">
107+
<bind_material>
108+
<technique_common>
109+
<instance_material symbol="Material_red-material" target="#Material_red-material">
110+
<bind_vertex_input semantic="UVMap" input_semantic="TEXCOORD" input_set="0"/>
111+
</instance_material>
112+
<instance_material symbol="Material_green-material" target="#Material_green-material">
113+
<bind_vertex_input semantic="UVMap" input_semantic="TEXCOORD" input_set="0"/>
114+
</instance_material>
115+
</technique_common>
116+
</bind_material>
117+
</instance_geometry>
118+
</node>
119+
</visual_scene>
120+
</library_visual_scenes>
121+
<scene>
122+
<instance_visual_scene url="#Scene"/>
123+
</scene>
124+
</COLLADA>

tests/data/assets/box_unit_cm.dae

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<COLLADA xmlns="http://www.collada.org/2005/11/COLLADASchema" version="1.4.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
3+
<asset>
4+
<unit name="meter" meter="0.01"/>
5+
<up_axis>Z_UP</up_axis>
6+
</asset>
7+
<library_effects>
8+
<effect id="Material-effect">
9+
<profile_COMMON>
10+
<technique sid="common">
11+
<lambert>
12+
<emission>
13+
<color sid="emission">0 0 0 1</color>
14+
</emission>
15+
<diffuse>
16+
<color sid="diffuse">0.8 0.8 0.8 1</color>
17+
</diffuse>
18+
<index_of_refraction>
19+
<float sid="ior">1.45</float>
20+
</index_of_refraction>
21+
</lambert>
22+
</technique>
23+
</profile_COMMON>
24+
</effect>
25+
</library_effects>
26+
<library_images/>
27+
<library_materials>
28+
<material id="Material-material" name="Material">
29+
<instance_effect url="#Material-effect"/>
30+
</material>
31+
</library_materials>
32+
<library_geometries>
33+
<geometry id="Cube-mesh" name="Cube">
34+
<mesh>
35+
<source id="Cube-mesh-positions">
36+
<float_array id="Cube-mesh-positions-array" count="24">100 100 100 100 100 -100 100 -100 100 100 -100 -100 -100 100 100 -100 100 -100 -100 -100 100 -100 -100 -100</float_array>
37+
<technique_common>
38+
<accessor source="#Cube-mesh-positions-array" count="8" stride="3">
39+
<param name="X" type="float"/>
40+
<param name="Y" type="float"/>
41+
<param name="Z" type="float"/>
42+
</accessor>
43+
</technique_common>
44+
</source>
45+
<source id="Cube-mesh-normals">
46+
<float_array id="Cube-mesh-normals-array" count="36">0 0 1 0 -1 0 -1 0 0 0 0 -1 1 0 0 0 1 0 0 0 1 0 -1 0 -1 0 0 0 0 -1 1 0 0 0 1 0</float_array>
47+
<technique_common>
48+
<accessor source="#Cube-mesh-normals-array" count="12" stride="3">
49+
<param name="X" type="float"/>
50+
<param name="Y" type="float"/>
51+
<param name="Z" type="float"/>
52+
</accessor>
53+
</technique_common>
54+
</source>
55+
<source id="Cube-mesh-map-0">
56+
<float_array id="Cube-mesh-map-0-array" count="72">0.875 0.5 0.625 0.75 0.625 0.5 0.625 0.75 0.375 1 0.375 0.75 0.625 0 0.375 0.25 0.375 0 0.375 0.5 0.125 0.75 0.125 0.5 0.625 0.5 0.375 0.75 0.375 0.5 0.625 0.25 0.375 0.5 0.375 0.25 0.875 0.5 0.875 0.75 0.625 0.75 0.625 0.75 0.625 1 0.375 1 0.625 0 0.625 0.25 0.375 0.25 0.375 0.5 0.375 0.75 0.125 0.75 0.625 0.5 0.625 0.75 0.375 0.75 0.625 0.25 0.625 0.5 0.375 0.5</float_array>
57+
<technique_common>
58+
<accessor source="#Cube-mesh-map-0-array" count="36" stride="2">
59+
<param name="S" type="float"/>
60+
<param name="T" type="float"/>
61+
</accessor>
62+
</technique_common>
63+
</source>
64+
<vertices id="Cube-mesh-vertices">
65+
<input semantic="POSITION" source="#Cube-mesh-positions"/>
66+
</vertices>
67+
<triangles material="Material-material" count="12">
68+
<input semantic="VERTEX" source="#Cube-mesh-vertices" offset="0"/>
69+
<input semantic="NORMAL" source="#Cube-mesh-normals" offset="1"/>
70+
<input semantic="TEXCOORD" source="#Cube-mesh-map-0" offset="2" set="0"/>
71+
<p>4 0 0 2 0 1 0 0 2 2 1 3 7 1 4 3 1 5 6 2 6 5 2 7 7 2 8 1 3 9 7 3 10 5 3 11 0 4 12 3 4 13 1 4 14 4 5 15 1 5 16 5 5 17 4 6 18 6 6 19 2 6 20 2 7 21 6 7 22 7 7 23 6 8 24 4 8 25 5 8 26 1 9 27 3 9 28 7 9 29 0 10 30 2 10 31 3 10 32 4 11 33 0 11 34 1 11 35</p>
72+
</triangles>
73+
</mesh>
74+
</geometry>
75+
</library_geometries>
76+
<library_visual_scenes>
77+
<visual_scene id="Scene" name="Scene">
78+
<node id="Cube" name="Cube" type="NODE">
79+
<matrix sid="transform">0.5 0 0 0 0 0.5 0 0 0 0 0.5 0 0 0 0 1</matrix>
80+
<instance_geometry url="#Cube-mesh" name="Cube">
81+
<bind_material>
82+
<technique_common>
83+
<instance_material symbol="Material-material" target="#Material-material">
84+
<bind_vertex_input semantic="UVMap" input_semantic="TEXCOORD" input_set="0"/>
85+
</instance_material>
86+
</technique_common>
87+
</bind_material>
88+
</instance_geometry>
89+
</node>
90+
</visual_scene>
91+
</library_visual_scenes>
92+
<scene>
93+
<instance_visual_scene url="#Scene"/>
94+
</scene>
95+
</COLLADA>

0 commit comments

Comments
 (0)