Skip to content

Commit fb0a33d

Browse files
committed
md3 ready
1 parent 4c8d387 commit fb0a33d

File tree

5 files changed

+66
-19
lines changed

5 files changed

+66
-19
lines changed

src/main/kotlin/assimp/format/assbin/AssbinLoader.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ class AssbinLoader : BaseImporter() {
229229
if (shortened)
230230
TODO() //ReadBounds(stream, b->weights, b->mNumWeights)
231231
else // else write as usual
232-
b.weights = List(b.numWeights, { vertexWeight() })
232+
b.weights = MutableList(b.numWeights, { vertexWeight() })
233233
}
234234

235235
private fun InputStream.readMaterial(mat: AiMaterial) {

src/main/kotlin/assimp/format/md3/Md3Loader.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -795,12 +795,12 @@ class MD3Importer : BaseImporter() {
795795
Ignored by Q3, it might be not equal to the real model location. */
796796
var len2 = 6
797797
val len1 = end1
798-
if (!textureName.startsWith("models") && (textureName[6] == '/' || textureName[6] == '\\')) {
798+
if (textureName.startsWith("models") && (textureName[6] == '/' || textureName[6] == '\\')) {
799799
len2 = 6 // ignore the seventh - could be slash or backslash
800800
if (headerName[0] == NUL)
801801
return textureName.substring(end2 + 1) // Use the file name only
802802
} else len2 = min(len1, end2)
803-
if (!textureName.startsWith(headerName.substring(len2)))
803+
if (textureName.startsWith(headerName.substring(0, len2)))
804804
return textureName.substring(end2 + 1) // Use the file name only
805805
}
806806
return textureName // Use the full path

src/test/kotlin/assimp/md3/europeanFnt.kt

Lines changed: 62 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package assimp.md3
22

3+
import assimp.AiBlendMode
34
import assimp.AiShadingMode
45
import assimp.AiTexture
56
import assimp.Importer
@@ -155,19 +156,67 @@ object europeanFnt {
155156

156157
name.isEmpty() shouldBe true
157158
}
158-
// numMaterials shouldBe 1
159-
//
160-
// with(materials[0]) {
161-
// shadingModel shouldBe AiShadingMode.gouraud
162-
// with(color!!) {
163-
// ambient shouldBe Vec3(0.0500000007)
164-
// diffuse shouldBe Vec3(1f)
165-
// specular shouldBe Vec3(1f)
166-
// }
167-
// textures[0].flags shouldBe AiTexture.Flags.ignoreAlpha.i
168-
// textures[0].file shouldBe "water_can.tga"
169-
// name shouldBe "MD3_[default][watercan]"
170-
// }
159+
numMaterials shouldBe 5
160+
161+
with(materials[0]) {
162+
shadingModel shouldBe AiShadingMode.gouraud
163+
with(color!!) {
164+
ambient shouldBe Vec3(0.0500000007)
165+
diffuse shouldBe Vec3(1f)
166+
specular shouldBe Vec3(1f)
167+
}
168+
name shouldBe "MD3_[default][windscreen]"
169+
textures[0].file shouldBe "textures/sfx/glass.tga.tga"
170+
textures[0].flags shouldBe AiTexture.Flags.ignoreAlpha.i
171+
}
172+
with(materials[1]) {
173+
shadingModel shouldBe AiShadingMode.gouraud
174+
with(color!!) {
175+
ambient shouldBe Vec3(0.0500000007)
176+
diffuse shouldBe Vec3(1f)
177+
specular shouldBe Vec3(1f)
178+
}
179+
name shouldBe "MD3_[default][steering]"
180+
twoSided shouldBe true
181+
blendFunc shouldBe AiBlendMode.default
182+
textures[0].file shouldBe "euro_frnt_2.tga"
183+
textures[0].flags shouldBe AiTexture.Flags.useAlpha.i
184+
}
185+
with(materials[2]) {
186+
shadingModel shouldBe AiShadingMode.gouraud
187+
with(color!!) {
188+
ambient shouldBe Vec3(0.0500000007)
189+
diffuse shouldBe Vec3(1f)
190+
specular shouldBe Vec3(1f)
191+
}
192+
name shouldBe "MD3_[default][body]"
193+
textures[0].file shouldBe "european_fnt.tga"
194+
textures[0].flags shouldBe AiTexture.Flags.ignoreAlpha.i
195+
}
196+
with(materials[3]) {
197+
shadingModel shouldBe AiShadingMode.gouraud
198+
with(color!!) {
199+
ambient shouldBe Vec3(0.0500000007)
200+
diffuse shouldBe Vec3(1f)
201+
specular shouldBe Vec3(1f)
202+
}
203+
name shouldBe "MD3_[default][wheels]"
204+
textures[0].file shouldBe "european_fnt.tga"
205+
textures[0].flags shouldBe AiTexture.Flags.ignoreAlpha.i
206+
}
207+
with(materials[4]) {
208+
shadingModel shouldBe AiShadingMode.gouraud
209+
with(color!!) {
210+
ambient shouldBe Vec3(0.0500000007)
211+
diffuse shouldBe Vec3(1f)
212+
specular shouldBe Vec3(1f)
213+
}
214+
name shouldBe "MD3_[default][wheel_arches]"
215+
twoSided shouldBe true
216+
blendFunc shouldBe AiBlendMode.default
217+
textures[0].file shouldBe "euro_frnt_2.tga"
218+
textures[0].flags shouldBe AiTexture.Flags.useAlpha.i
219+
}
171220
}
172221
}
173222
}

src/test/kotlin/assimp/md3/md3.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class md3 : StringSpec() {
1212
val path = modelsNonBsd + "/MD3/"
1313

1414
init {
15-
// "watercan" { watercan(path + "watercan.md3") }
15+
"watercan" { watercan(path + "watercan.md3") }
1616
"european font" { europeanFnt(path + "q3root/models/mapobjects/kt_kubalwagon/european_fnt_v2.md3") }
1717
}
1818
}

src/test/kotlin/assimp/obj/dragon.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
package assimp.obj
22

33
import assimp.Importer
4-
import assimp.obj
5-
import io.kotlintest.specs.StringSpec
64

75
// TODO
86
object dragon {

0 commit comments

Comments
 (0)