1
+ package assimp.obj
2
+
3
+ import assimp.*
4
+ import glm_.mat4x4.Mat4
5
+ import glm_.vec3.Vec3
6
+ import io.kotlintest.shouldBe
7
+ import uno.kotlin.uri
8
+ import uno.kotlin.url
9
+
10
+ /* *
11
+ * Created by elect on 16/11/2016.
12
+ */
13
+
14
+ object cube {
15
+
16
+ operator fun invoke (fileName : String ) {
17
+
18
+ with (Importer ().readFile(getResource(fileName))!! ) {
19
+
20
+ // with(rootNode) {
21
+ //
22
+ // name shouldBe "box.obj"
23
+ // transformation shouldBe Mat4()
24
+ // numChildren shouldBe 1
25
+ //
26
+ // with(children[0]) {
27
+ //
28
+ // name shouldBe "1"
29
+ // transformation shouldBe Mat4()
30
+ // numChildren shouldBe 0
31
+ // numMeshes shouldBe 1
32
+ // meshes[0] shouldBe 0
33
+ // }
34
+ // numMeshes shouldBe 0
35
+ // }
36
+ // numMeshes shouldBe 1
37
+ // with(meshes[0]) {
38
+ // primitiveTypes shouldBe AiPrimitiveType.POLYGON.i
39
+ // numVertices shouldBe 24
40
+ // numFaces shouldBe 6
41
+ //
42
+ // vertices[0] shouldBe Vec3(-0.5, +0.5, +0.5)
43
+ // vertices[5] shouldBe Vec3(+0.5, -0.5, -0.5)
44
+ // vertices[10] shouldBe Vec3(+0.5, -0.5, -0.5)
45
+ // vertices[15] shouldBe Vec3(-0.5, +0.5, +0.5)
46
+ // vertices[20] shouldBe Vec3(+0.5, -0.5, -0.5)
47
+ // vertices[23] shouldBe Vec3(+0.5, -0.5, +0.5)
48
+ //
49
+ // var i = 0
50
+ // faces.forEach {
51
+ // it.size shouldBe 4
52
+ // it shouldBe mutableListOf(i++, i++, i++, i++)
53
+ // }
54
+ // }
55
+ // with(materials[0]) {
56
+ // name shouldBe AI_DEFAULT_MATERIAL_NAME
57
+ // shadingModel shouldBe AiShadingMode.gouraud
58
+ // with(color!!) {
59
+ // ambient shouldBe Vec3()
60
+ // diffuse shouldBe Vec3(0.6)
61
+ // specular shouldBe Vec3()
62
+ // emissive shouldBe Vec3()
63
+ // shininess shouldBe 0f
64
+ // opacity shouldBe 1f
65
+ // refracti shouldBe 1f
66
+ // }
67
+ // }
68
+ // }
69
+ // }
70
+
71
+
72
+ // val concavePolygon = "concave_polygon.obj"
73
+ //
74
+ // concavePolygon
75
+ // {
76
+ //
77
+ // with(Importer().readFile(obj + concavePolygon)!!) {
78
+ //
79
+ // with(rootNode) {
80
+ //
81
+ // name shouldBe "concave_polygon.obj"
82
+ // transformation shouldBe Mat4()
83
+ // numChildren shouldBe 2
84
+ //
85
+ // with(children[0]) {
86
+ //
87
+ // name shouldBe "concave_test.obj"
88
+ // transformation shouldBe Mat4()
89
+ // parent === rootNode
90
+ // numChildren shouldBe 0
91
+ // numMeshes shouldBe 0
92
+ // }
93
+ // with(children[1]) {
94
+ //
95
+ // name shouldBe "default"
96
+ // transformation shouldBe Mat4()
97
+ // parent === rootNode
98
+ // numChildren shouldBe 0
99
+ // numMeshes shouldBe 1
100
+ // meshes[0] shouldBe 0
101
+ // }
102
+ // }
103
+ // with(meshes[0]) {
104
+ //
105
+ // primitiveTypes shouldBe AiPrimitiveType.POLYGON.i
106
+ // numVertices shouldBe 66
107
+ // numFaces shouldBe 1
108
+ //
109
+ // vertices[0] shouldBe Vec3(-1.14600003, 2.25515008, 3.07623005)
110
+ // vertices[10] shouldBe Vec3(-1.14600003, 1.78262997, 1.93549001)
111
+ // vertices[20] shouldBe Vec3(-1.14600003, 3.01736999, 1.93549001)
112
+ // vertices[30] shouldBe Vec3(-1.14600003, 2.54485, 3.07623005)
113
+ // vertices[40] shouldBe Vec3(-1.14600003, 3.08750010, 2.34999990)
114
+ // vertices[50] shouldBe Vec3(-1.14600003, 2.13690996, 1.71483)
115
+ // vertices[60] shouldBe Vec3(-1.14600003, 1.91386, 2.83613992)
116
+ // vertices[65] shouldBe Vec3(-1.14600003, 2.40000010, 3.0905)
117
+ //
118
+ // normals.forEach { it shouldBe Vec3(1, 0, -0.0) }
119
+ // var i = 0
120
+ // faces[0].forEach { it shouldBe i++ }
121
+ //
122
+ // materialIndex shouldBe 1
123
+ //
124
+ // name shouldBe "default"
125
+ // }
126
+ // numMaterials shouldBe 2
127
+ //
128
+ // with(materials[0]) {
129
+ //
130
+ // name shouldBe "DefaultMaterial"
131
+ //
132
+ // shadingModel shouldBe AiShadingMode.gouraud
133
+ //
134
+ // with(color!!) {
135
+ //
136
+ // ambient!! shouldBe Vec3(0)
137
+ // diffuse!! shouldBe Vec3(0.600000024)
138
+ // specular!! shouldBe Vec3(0)
139
+ // emissive!! shouldBe Vec3(0)
140
+ // shininess!! shouldBe 0f
141
+ // opacity!! shouldBe 1f
142
+ // refracti!! shouldBe 1f
143
+ // }
144
+ // }
145
+ //
146
+ // with(materials[1]) {
147
+ //
148
+ // name shouldBe "test"
149
+ //
150
+ // shadingModel shouldBe AiShadingMode.gouraud
151
+ //
152
+ // with(color!!) {
153
+ //
154
+ // ambient!! shouldBe Vec3(0)
155
+ // diffuse!! shouldBe Vec3(0.141176000, 0.184313998, 0.411765009)
156
+ // specular!! shouldBe Vec3(0)
157
+ // emissive!! shouldBe Vec3(0)
158
+ // shininess!! shouldBe 400f
159
+ // opacity!! shouldBe 1f
160
+ // refracti!! shouldBe 1f
161
+ // }
162
+ // }
163
+ }
164
+ }
165
+ }
0 commit comments