1+ package assimp.collada
2+
3+ import assimp.AiAnimBehaviour
4+ import assimp.Importer
5+ import glm_.mat4x4.Mat4
6+ import glm_.quat.Quat
7+ import glm_.vec3.Vec3
8+ import io.kotlintest.shouldBe
9+ import java.net.URL
10+
11+ object voyager {
12+
13+ operator fun invoke (url : URL ) {
14+
15+ with (Importer ().readFile(url)!! ) {
16+
17+ flags shouldBe 0
18+
19+ // with(rootNode) {
20+ // name shouldBe "Array Test 001"
21+ // transformation shouldBe Mat4(
22+ // 1f, 0f, 0f, 0f,
23+ // 0f, 0f, -1f, 0f,
24+ // 0f, 1f, 0f, 0f,
25+ // 0f, 0f, 0f, 1f)
26+ // parent shouldBe null
27+ // numChildren shouldBe 1
28+ //
29+ // with(children[0]) {
30+ // name shouldBe "Box001"
31+ // transformation shouldBe Mat4(
32+ // 1f, 5.235988e-08f, 0f, 0f,
33+ // -5.235988e-08f, 1f, 0f, 0f,
34+ // 0f, 0f, 1f, 0f,
35+ // 0f, 0f, 0f, 1f)
36+ // (parent === rootNode) shouldBe true
37+ // numChildren shouldBe 2
38+ //
39+ // with(children[0]) {
40+ // name shouldBe "Box001-Pivot"
41+ // transformation shouldBe Mat4(
42+ // 1f, 0f, 0f, 0f,
43+ // 0f, 1f, 0f, 0f,
44+ // 0f, 0f, 1f, 0f,
45+ // 0.185947001f, 0f, 0f, 1f)
46+ // (parent === rootNode.children[0]) shouldBe true
47+ // numChildren shouldBe 0
48+ //
49+ // numMeshes shouldBe 1
50+ // meshes[0] shouldBe 0
51+ // metaData.isEmpty() shouldBe true
52+ // }
53+ //
54+ // with(children[1]) {
55+ // name shouldBe "Box002"
56+ // transformation shouldBe Mat4(
57+ // 1f, 5.235988e-08f, 0f, 0f,
58+ // -5.235988e-08f, 1f, 0f, 0f,
59+ // 0f, 0f, 1f, 0f,
60+ // 0f, 0f, 0f, 1f)
61+ // (parent === rootNode.children[0]) shouldBe true
62+ // numChildren shouldBe 2
63+ //
64+ // with(children[0]) {
65+ // name shouldBe "Box002-Pivot"
66+ // transformation shouldBe Mat4(
67+ // 1f, 0f, 0f, 0f,
68+ // 0f, 1f, 0f, 0f,
69+ // 0f, 0f, 1f, 0f,
70+ // 0.185947001f, 1.89182305f, 0f, 1f)
71+ // (parent === rootNode.children[0].children[1]) shouldBe true
72+ // numChildren shouldBe 0
73+ //
74+ // numMeshes shouldBe 1
75+ // meshes[0] shouldBe 1
76+ // metaData.isEmpty() shouldBe true
77+ // }
78+ //
79+ // with(children[1]) {
80+ // name shouldBe "Box003"
81+ // transformation shouldBe Mat4(
82+ // 1f, 5.235988e-08f, 0f, 0f,
83+ // -5.235988e-08f, 1f, 0f, 0f,
84+ // 0f, 0f, 1f, 0f,
85+ // 0f, 0f, 0f, 1f)
86+ // (parent === rootNode.children[0].children[1]) shouldBe true
87+ // numChildren shouldBe 2
88+ //
89+ // // TODO continue?
90+ //
91+ // numMeshes shouldBe 0
92+ // meshes.isEmpty() shouldBe true
93+ // metaData.isEmpty() shouldBe true
94+ // }
95+ //
96+ // numMeshes shouldBe 0
97+ // meshes.isEmpty() shouldBe true
98+ // metaData.isEmpty() shouldBe true
99+ // }
100+ //
101+ // numMeshes shouldBe 0
102+ // meshes.isEmpty() shouldBe true
103+ // metaData.isEmpty() shouldBe true
104+ // }
105+ // }
106+
107+ numMeshes shouldBe 6
108+
109+ // with(meshes[0]) {
110+ //
111+ // primitiveTypes shouldBe 8
112+ // numVertices shouldBe 24
113+ // numFaces shouldBe 6
114+ //
115+ // vertices[0] shouldBe Vec3(-0.5f, -0.5f, 0f)
116+ // vertices[11] shouldBe Vec3(-0.5f, -0.5f, 1f)
117+ // vertices[23] shouldBe Vec3(-0.5f, 0.5f, 1f)
118+ //
119+ // normals[0] shouldBe Vec3(0f, 0f, -1f)
120+ // normals[11] shouldBe Vec3(0f, -1f, 0f)
121+ // normals[23] shouldBe Vec3(-1f, 0f, 0f)
122+ //
123+ // textureCoords[0][0][0] shouldBe 1f
124+ // textureCoords[0][0][1] shouldBe 0f
125+ // textureCoords[0][11][0] shouldBe 0f
126+ // textureCoords[0][11][1] shouldBe 1f
127+ // textureCoords[0][23][0] shouldBe 0f
128+ // textureCoords[0][23][1] shouldBe 1f
129+ //
130+ // for (i in 0..23 step 4) faces[i / 4] shouldBe mutableListOf(i, i + 1, i + 2, i + 3)
131+ //
132+ // name shouldBe "Box001Mesh"
133+ // }
134+ //
135+ // // for further mesh test, follow this issue, https://github.com/assimp/assimp/issues/1561
136+ //
137+ // numMaterials shouldBe 1
138+ //
139+ // with(materials[0]) {
140+ // color!!.diffuse shouldBe Vec3(0.600000024f)
141+ // name shouldBe "DefaultMaterial"
142+ // }
143+ //
144+ // numAnimations shouldBe 1
145+ //
146+ // with(animations[0]) {
147+ //
148+ // name shouldBe ""
149+ // duration shouldBe 11.966667175292969
150+ // ticksPerSecond shouldBe 1.0
151+ // numChannels shouldBe 64
152+ //
153+ // with(channels[0]!!) {
154+ // nodeName shouldBe "Box001"
155+ // numPositionKeys shouldBe 5
156+ // with(positionKeys[0]) {
157+ // time shouldBe 0.033332999795675278
158+ // value shouldBe Vec3()
159+ // }
160+ // with(positionKeys[2]) {
161+ // time shouldBe 6.0
162+ // value shouldBe Vec3()
163+ // }
164+ // with(positionKeys[4]) {
165+ // time shouldBe 11.966667175292969
166+ // value shouldBe Vec3()
167+ // }
168+ // numRotationKeys shouldBe 5
169+ // with(rotationKeys[0]) {
170+ // time shouldBe 0.033332999795675278
171+ // value shouldBe Quat(1f, 0f, 0f, 2.38497613e-08f)
172+ // }
173+ // with(rotationKeys[2]) {
174+ // time shouldBe 6.0
175+ // value shouldBe Quat(2.90066708e-07f, 0f, 0f, 1f)
176+ // }
177+ // with(rotationKeys[4]) {
178+ // time shouldBe 11.966667175292969
179+ // value shouldBe Quat(1f, 0f, 0f, 3.49691106e-07f)
180+ // }
181+ // numScalingKeys shouldBe 5
182+ // with(scalingKeys[0]) {
183+ // time shouldBe 0.033332999795675278
184+ // value shouldBe Vec3(1f)
185+ // }
186+ // with(scalingKeys[2]) {
187+ // time shouldBe 6.0
188+ // value shouldBe Vec3(1f)
189+ // }
190+ // with(scalingKeys[4]) {
191+ // time shouldBe 11.966667175292969
192+ // value shouldBe Vec3(1f)
193+ // }
194+ // preState shouldBe AiAnimBehaviour.DEFAULT
195+ // postState shouldBe AiAnimBehaviour.DEFAULT
196+ // }
197+ //
198+ // with(channels[31]!!) {
199+ // nodeName shouldBe "Box032"
200+ // numPositionKeys shouldBe 5
201+ // with(positionKeys[0]) {
202+ // time shouldBe 0.033332999795675278
203+ // value shouldBe Vec3()
204+ // }
205+ // with(positionKeys[2]) {
206+ // time shouldBe 6.0
207+ // value shouldBe Vec3()
208+ // }
209+ // with(positionKeys[4]) {
210+ // time shouldBe 11.966667175292969
211+ // value shouldBe Vec3()
212+ // }
213+ // numRotationKeys shouldBe 5
214+ // with(rotationKeys[0]) {
215+ // time shouldBe 0.033332999795675278
216+ // value shouldBe Quat(1f, 0f, 0f, 2.38497613e-08f)
217+ // }
218+ // with(rotationKeys[2]) {
219+ // time shouldBe 6.0
220+ // value shouldBe Quat(2.90066708e-07f, 0f, 0f, 1f)
221+ // }
222+ // with(rotationKeys[4]) {
223+ // time shouldBe 11.966667175292969
224+ // value shouldBe Quat(1f, 0f, 0f, 3.49691106e-07f)
225+ // }
226+ // numScalingKeys shouldBe 5
227+ // with(scalingKeys[0]) {
228+ // time shouldBe 0.033332999795675278
229+ // value shouldBe Vec3(1f)
230+ // }
231+ // with(scalingKeys[2]) {
232+ // time shouldBe 6.0
233+ // value shouldBe Vec3(1f)
234+ // }
235+ // with(scalingKeys[4]) {
236+ // time shouldBe 11.966667175292969
237+ // value shouldBe Vec3(1f)
238+ // }
239+ // preState shouldBe AiAnimBehaviour.DEFAULT
240+ // postState shouldBe AiAnimBehaviour.DEFAULT
241+ // }
242+ //
243+ // with(channels[63]!!) {
244+ // nodeName shouldBe "Box064"
245+ // numPositionKeys shouldBe 5
246+ // with(positionKeys[0]) {
247+ // time shouldBe 0.033332999795675278
248+ // value shouldBe Vec3()
249+ // }
250+ // with(positionKeys[2]) {
251+ // time shouldBe 6.0
252+ // value shouldBe Vec3()
253+ // }
254+ // with(positionKeys[4]) {
255+ // time shouldBe 11.966667175292969
256+ // value shouldBe Vec3()
257+ // }
258+ // numRotationKeys shouldBe 5
259+ // with(rotationKeys[0]) {
260+ // time shouldBe 0.033332999795675278
261+ // value shouldBe Quat(1f, 0f, 0f, 2.38497613e-08f)
262+ // }
263+ // with(rotationKeys[2]) {
264+ // time shouldBe 6.0
265+ // value shouldBe Quat(2.90066708e-07f, 0f, 0f, 1f)
266+ // }
267+ // with(rotationKeys[4]) {
268+ // time shouldBe 11.966667175292969
269+ // value shouldBe Quat(1f, 0f, 0f, 3.49691106e-07f)
270+ // }
271+ // numScalingKeys shouldBe 5
272+ // with(scalingKeys[0]) {
273+ // time shouldBe 0.033332999795675278
274+ // value shouldBe Vec3(1f)
275+ // }
276+ // with(scalingKeys[2]) {
277+ // time shouldBe 6.0
278+ // value shouldBe Vec3(1f)
279+ // }
280+ // with(scalingKeys[4]) {
281+ // time shouldBe 11.966667175292969
282+ // value shouldBe Vec3(1f)
283+ // }
284+ // preState shouldBe AiAnimBehaviour.DEFAULT
285+ // postState shouldBe AiAnimBehaviour.DEFAULT
286+ // }
287+ // }
288+ }
289+ }
290+ }
0 commit comments