Skip to content

Commit

Permalink
Add animations to the model
Browse files Browse the repository at this point in the history
  • Loading branch information
dwursteisen committed Feb 29, 2020
1 parent eab6ab4 commit 2b5681a
Show file tree
Hide file tree
Showing 24 changed files with 157 additions and 21 deletions.
5 changes: 5 additions & 0 deletions collada-api/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ kotlin {
api("org.jetbrains.kotlinx:kotlinx-serialization-runtime:0.14.0")
}
}
jvm().compilations["test"].defaultSourceSet {
dependencies {
implementation(kotlin("test-junit"))
}
}

js().compilations["main"].defaultSourceSet {
dependencies {
Expand Down
36 changes: 36 additions & 0 deletions collada-api/src/commonMain/kotlin/collada/Animations.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package collada

import kotlinx.serialization.SerialId
import kotlinx.serialization.Serializable

interface AnimationsDescription

@Serializable
object EmptyAnimations : AnimationsDescription

@Serializable
class Animations(
@SerialId(1)
val animations: List<Animation> = emptyList()
) : AnimationsDescription


@Serializable
class Animation(
@SerialId(1)
val name: String,
@SerialId(2)
val boneId: String,
@SerialId(3)
val keyFrames: List<KeyFrame>
)

@Serializable
class KeyFrame(
@SerialId(1)
val time: Float,
@SerialId(2)
val transformation: Transformation,
@SerialId(3)
val interpolation: String // not used now
)
17 changes: 15 additions & 2 deletions collada-api/src/commonMain/kotlin/collada/Model.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@ class Model(
@SerialId(1)
val mesh: Mesh,
@SerialId(2)
@Polymorphic val armature: ArmatureDescription
@Polymorphic val armature: ArmatureDescription,
@SerialId(3)
@Polymorphic val skin: SkinDescription,
@SerialId(4)
@Polymorphic val animations: AnimationsDescription
) {

companion object {
Expand All @@ -28,12 +32,21 @@ class Model(
return deserializer.load(serializer(), data)
}

fun serialModule(): SerialModule {
private fun serialModule(): SerialModule {
return SerializersModule {
polymorphic<ArmatureDescription> {
Armature::class with Armature.serializer()
EmptyArmature::class with EmptyArmature.serializer()
}
polymorphic<AnimationsDescription> {
Animations::class with Animations.serializer()
EmptyAnimations::class with EmptyAnimations.serializer()
}

polymorphic<SkinDescription> {
Skin::class with Skin.serializer()
EmptySkin::class with EmptySkin.serializer()
}
}
}

Expand Down
21 changes: 19 additions & 2 deletions collada-api/src/commonMain/kotlin/collada/Skin.kt
Original file line number Diff line number Diff line change
@@ -1,9 +1,26 @@
package collada

import kotlinx.serialization.SerialId
import kotlinx.serialization.Serializable

interface SkinDescription

@Serializable
object EmptySkin : SkinDescription

class Skin(
@Serializable
class WeightInfluence(
@SerialId(1)
val boneId: String,
@SerialId(2)
val weight: Float
)

) : SkinDescription
@Serializable
class Influence(@SerialId(1) val weights: List<WeightInfluence> = emptyList())

@Serializable
class Skin(
@SerialId(1)
val influences: List<Influence> = emptyList()
) : SkinDescription
1 change: 0 additions & 1 deletion collada-api/src/commonTest/kotlin/collada/ReadWriteTest.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package collada

import kotlin.test.Ignore
import kotlin.test.Test

interface Content<T> {
Expand Down
2 changes: 1 addition & 1 deletion collada-api/src/commonTest/resources/armature.json

Large diffs are not rendered by default.

Binary file modified collada-api/src/commonTest/resources/armature.protobuf
Binary file not shown.
2 changes: 1 addition & 1 deletion collada-api/src/commonTest/resources/cube.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"mesh":{"vertices":[{"position":{"x":-1.0,"y":-1.0,"z":1.0},"color":{"r":1.0,"g":0.0,"b":0.0,"a":1.0},"normal":{"x":-1.0,"y":0.0,"z":0.0}},{"position":{"x":-1.0,"y":1.0,"z":-1.0},"color":{"r":1.0,"g":0.0,"b":0.0,"a":1.0},"normal":{"x":-1.0,"y":0.0,"z":0.0}},{"position":{"x":-1.0,"y":-1.0,"z":-1.0},"color":{"r":1.0,"g":0.0,"b":0.0,"a":1.0},"normal":{"x":-1.0,"y":0.0,"z":0.0}},{"position":{"x":-1.0,"y":1.0,"z":1.0},"color":{"r":1.0,"g":0.0,"b":0.0,"a":1.0},"normal":{"x":0.0,"y":1.0,"z":0.0}},{"position":{"x":1.0,"y":1.0,"z":-1.0},"color":{"r":1.0,"g":0.0,"b":0.0,"a":1.0},"normal":{"x":0.0,"y":1.0,"z":0.0}},{"position":{"x":-1.0,"y":1.0,"z":-1.0},"color":{"r":1.0,"g":0.0,"b":0.0,"a":1.0},"normal":{"x":0.0,"y":1.0,"z":0.0}},{"position":{"x":1.0,"y":1.0,"z":1.0},"color":{"r":1.0,"g":0.0,"b":0.0,"a":1.0},"normal":{"x":1.0,"y":0.0,"z":0.0}},{"position":{"x":1.0,"y":-1.0,"z":-1.0},"color":{"r":1.0,"g":0.0,"b":0.0,"a":1.0},"normal":{"x":1.0,"y":0.0,"z":0.0}},{"position":{"x":1.0,"y":1.0,"z":-1.0},"color":{"r":1.0,"g":0.0,"b":0.0,"a":1.0},"normal":{"x":1.0,"y":0.0,"z":0.0}},{"position":{"x":1.0,"y":-1.0,"z":1.0},"color":{"r":1.0,"g":0.0,"b":0.0,"a":1.0},"normal":{"x":0.0,"y":-1.0,"z":0.0}},{"position":{"x":-1.0,"y":-1.0,"z":-1.0},"color":{"r":1.0,"g":0.0,"b":0.0,"a":1.0},"normal":{"x":0.0,"y":-1.0,"z":0.0}},{"position":{"x":1.0,"y":-1.0,"z":-1.0},"color":{"r":1.0,"g":0.0,"b":0.0,"a":1.0},"normal":{"x":0.0,"y":-1.0,"z":0.0}},{"position":{"x":1.0,"y":1.0,"z":-1.0},"color":{"r":1.0,"g":0.0,"b":0.0,"a":1.0},"normal":{"x":0.0,"y":0.0,"z":-1.0}},{"position":{"x":-1.0,"y":-1.0,"z":-1.0},"color":{"r":1.0,"g":0.0,"b":0.0,"a":1.0},"normal":{"x":0.0,"y":0.0,"z":-1.0}},{"position":{"x":-1.0,"y":1.0,"z":-1.0},"color":{"r":1.0,"g":0.0,"b":0.0,"a":1.0},"normal":{"x":0.0,"y":0.0,"z":-1.0}},{"position":{"x":-1.0,"y":1.0,"z":1.0},"color":{"r":1.0,"g":0.0,"b":0.0,"a":1.0},"normal":{"x":0.0,"y":0.0,"z":1.0}},{"position":{"x":1.0,"y":-1.0,"z":1.0},"color":{"r":1.0,"g":0.0,"b":0.0,"a":1.0},"normal":{"x":0.0,"y":0.0,"z":1.0}},{"position":{"x":1.0,"y":1.0,"z":1.0},"color":{"r":1.0,"g":0.0,"b":0.0,"a":1.0},"normal":{"x":0.0,"y":0.0,"z":1.0}},{"position":{"x":-1.0,"y":1.0,"z":1.0},"color":{"r":1.0,"g":0.0,"b":0.0,"a":1.0},"normal":{"x":-1.0,"y":0.0,"z":0.0}},{"position":{"x":1.0,"y":1.0,"z":1.0},"color":{"r":1.0,"g":0.0,"b":0.0,"a":1.0},"normal":{"x":0.0,"y":1.0,"z":0.0}},{"position":{"x":1.0,"y":-1.0,"z":1.0},"color":{"r":1.0,"g":0.0,"b":0.0,"a":1.0},"normal":{"x":1.0,"y":0.0,"z":0.0}},{"position":{"x":-1.0,"y":-1.0,"z":1.0},"color":{"r":1.0,"g":0.0,"b":0.0,"a":1.0},"normal":{"x":0.0,"y":-1.0,"z":0.0}},{"position":{"x":1.0,"y":-1.0,"z":-1.0},"color":{"r":1.0,"g":0.0,"b":0.0,"a":1.0},"normal":{"x":0.0,"y":0.0,"z":-1.0}},{"position":{"x":-1.0,"y":-1.0,"z":1.0},"color":{"r":1.0,"g":0.0,"b":0.0,"a":1.0},"normal":{"x":0.0,"y":0.0,"z":1.0}}],"verticesOrder":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,0,18,1,3,19,4,6,20,7,9,21,10,12,22,13,15,23,16]},"armature":{"type":"collada.EmptyArmature"}}
{"mesh":{"vertices":[{"position":{"x":-1.0,"y":-1.0,"z":1.0},"color":{"r":1.0,"g":0.0,"b":0.0,"a":1.0},"normal":{"x":-1.0,"y":0.0,"z":0.0}},{"position":{"x":-1.0,"y":1.0,"z":-1.0},"color":{"r":1.0,"g":0.0,"b":0.0,"a":1.0},"normal":{"x":-1.0,"y":0.0,"z":0.0}},{"position":{"x":-1.0,"y":-1.0,"z":-1.0},"color":{"r":1.0,"g":0.0,"b":0.0,"a":1.0},"normal":{"x":-1.0,"y":0.0,"z":0.0}},{"position":{"x":-1.0,"y":1.0,"z":1.0},"color":{"r":1.0,"g":0.0,"b":0.0,"a":1.0},"normal":{"x":0.0,"y":1.0,"z":0.0}},{"position":{"x":1.0,"y":1.0,"z":-1.0},"color":{"r":1.0,"g":0.0,"b":0.0,"a":1.0},"normal":{"x":0.0,"y":1.0,"z":0.0}},{"position":{"x":-1.0,"y":1.0,"z":-1.0},"color":{"r":1.0,"g":0.0,"b":0.0,"a":1.0},"normal":{"x":0.0,"y":1.0,"z":0.0}},{"position":{"x":1.0,"y":1.0,"z":1.0},"color":{"r":1.0,"g":0.0,"b":0.0,"a":1.0},"normal":{"x":1.0,"y":0.0,"z":0.0}},{"position":{"x":1.0,"y":-1.0,"z":-1.0},"color":{"r":1.0,"g":0.0,"b":0.0,"a":1.0},"normal":{"x":1.0,"y":0.0,"z":0.0}},{"position":{"x":1.0,"y":1.0,"z":-1.0},"color":{"r":1.0,"g":0.0,"b":0.0,"a":1.0},"normal":{"x":1.0,"y":0.0,"z":0.0}},{"position":{"x":1.0,"y":-1.0,"z":1.0},"color":{"r":1.0,"g":0.0,"b":0.0,"a":1.0},"normal":{"x":0.0,"y":-1.0,"z":0.0}},{"position":{"x":-1.0,"y":-1.0,"z":-1.0},"color":{"r":1.0,"g":0.0,"b":0.0,"a":1.0},"normal":{"x":0.0,"y":-1.0,"z":0.0}},{"position":{"x":1.0,"y":-1.0,"z":-1.0},"color":{"r":1.0,"g":0.0,"b":0.0,"a":1.0},"normal":{"x":0.0,"y":-1.0,"z":0.0}},{"position":{"x":1.0,"y":1.0,"z":-1.0},"color":{"r":1.0,"g":0.0,"b":0.0,"a":1.0},"normal":{"x":0.0,"y":0.0,"z":-1.0}},{"position":{"x":-1.0,"y":-1.0,"z":-1.0},"color":{"r":1.0,"g":0.0,"b":0.0,"a":1.0},"normal":{"x":0.0,"y":0.0,"z":-1.0}},{"position":{"x":-1.0,"y":1.0,"z":-1.0},"color":{"r":1.0,"g":0.0,"b":0.0,"a":1.0},"normal":{"x":0.0,"y":0.0,"z":-1.0}},{"position":{"x":-1.0,"y":1.0,"z":1.0},"color":{"r":1.0,"g":0.0,"b":0.0,"a":1.0},"normal":{"x":0.0,"y":0.0,"z":1.0}},{"position":{"x":1.0,"y":-1.0,"z":1.0},"color":{"r":1.0,"g":0.0,"b":0.0,"a":1.0},"normal":{"x":0.0,"y":0.0,"z":1.0}},{"position":{"x":1.0,"y":1.0,"z":1.0},"color":{"r":1.0,"g":0.0,"b":0.0,"a":1.0},"normal":{"x":0.0,"y":0.0,"z":1.0}},{"position":{"x":-1.0,"y":1.0,"z":1.0},"color":{"r":1.0,"g":0.0,"b":0.0,"a":1.0},"normal":{"x":-1.0,"y":0.0,"z":0.0}},{"position":{"x":1.0,"y":1.0,"z":1.0},"color":{"r":1.0,"g":0.0,"b":0.0,"a":1.0},"normal":{"x":0.0,"y":1.0,"z":0.0}},{"position":{"x":1.0,"y":-1.0,"z":1.0},"color":{"r":1.0,"g":0.0,"b":0.0,"a":1.0},"normal":{"x":1.0,"y":0.0,"z":0.0}},{"position":{"x":-1.0,"y":-1.0,"z":1.0},"color":{"r":1.0,"g":0.0,"b":0.0,"a":1.0},"normal":{"x":0.0,"y":-1.0,"z":0.0}},{"position":{"x":1.0,"y":-1.0,"z":-1.0},"color":{"r":1.0,"g":0.0,"b":0.0,"a":1.0},"normal":{"x":0.0,"y":0.0,"z":-1.0}},{"position":{"x":-1.0,"y":-1.0,"z":1.0},"color":{"r":1.0,"g":0.0,"b":0.0,"a":1.0},"normal":{"x":0.0,"y":0.0,"z":1.0}}],"verticesOrder":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,0,18,1,3,19,4,6,20,7,9,21,10,12,22,13,15,23,16]},"armature":{"type":"collada.EmptyArmature"},"skin":{"type":"collada.EmptySkin"},"animations":{"type":"collada.EmptyAnimations"}}
Binary file modified collada-api/src/commonTest/resources/cube.protobuf
Binary file not shown.
2 changes: 1 addition & 1 deletion collada-api/src/commonTest/resources/cube_color.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"mesh":{"vertices":[{"position":{"x":-1.0,"y":1.0,"z":1.0},"color":{"r":1.0,"g":0.4431372,"b":0.7254902,"a":1.0},"normal":{"x":0.0,"y":0.0,"z":1.0}},{"position":{"x":1.0,"y":-1.0,"z":1.0},"color":{"r":1.0,"g":0.4431372,"b":0.7254902,"a":1.0},"normal":{"x":0.0,"y":0.0,"z":1.0}},{"position":{"x":1.0,"y":1.0,"z":1.0},"color":{"r":1.0,"g":0.4431372,"b":0.7254902,"a":1.0},"normal":{"x":0.0,"y":0.0,"z":1.0}},{"position":{"x":1.0,"y":-1.0,"z":1.0},"color":{"r":0.1294118,"g":0.0,"b":1.0,"a":1.0},"normal":{"x":0.0,"y":-1.0,"z":0.0}},{"position":{"x":-1.0,"y":-1.0,"z":-1.0},"color":{"r":0.1294118,"g":0.0,"b":1.0,"a":1.0},"normal":{"x":0.0,"y":-1.0,"z":0.0}},{"position":{"x":1.0,"y":-1.0,"z":-1.0},"color":{"r":0.1294118,"g":0.0,"b":1.0,"a":1.0},"normal":{"x":0.0,"y":-1.0,"z":0.0}},{"position":{"x":-1.0,"y":-1.0,"z":1.0},"color":{"r":0.5019608,"g":1.0,"b":0.772549,"a":1.0},"normal":{"x":-1.0,"y":0.0,"z":0.0}},{"position":{"x":-1.0,"y":1.0,"z":-1.0},"color":{"r":0.5019608,"g":1.0,"b":0.772549,"a":1.0},"normal":{"x":-1.0,"y":0.0,"z":0.0}},{"position":{"x":-1.0,"y":-1.0,"z":-1.0},"color":{"r":0.5019608,"g":1.0,"b":0.772549,"a":1.0},"normal":{"x":-1.0,"y":0.0,"z":0.0}},{"position":{"x":1.0,"y":1.0,"z":-1.0},"color":{"r":0.5019608,"g":1.0,"b":0.772549,"a":1.0},"normal":{"x":0.0,"y":0.0,"z":-1.0}},{"position":{"x":-1.0,"y":-1.0,"z":-1.0},"color":{"r":0.5019608,"g":1.0,"b":0.772549,"a":1.0},"normal":{"x":0.0,"y":0.0,"z":-1.0}},{"position":{"x":-1.0,"y":1.0,"z":-1.0},"color":{"r":0.5019608,"g":1.0,"b":0.772549,"a":1.0},"normal":{"x":0.0,"y":0.0,"z":-1.0}},{"position":{"x":1.0,"y":1.0,"z":1.0},"color":{"r":0.5019608,"g":1.0,"b":0.772549,"a":1.0},"normal":{"x":1.0,"y":0.0,"z":0.0}},{"position":{"x":1.0,"y":-1.0,"z":-1.0},"color":{"r":0.5019608,"g":1.0,"b":0.772549,"a":1.0},"normal":{"x":1.0,"y":0.0,"z":0.0}},{"position":{"x":1.0,"y":1.0,"z":-1.0},"color":{"r":0.5019608,"g":1.0,"b":0.772549,"a":1.0},"normal":{"x":1.0,"y":0.0,"z":0.0}},{"position":{"x":-1.0,"y":1.0,"z":1.0},"color":{"r":0.5019608,"g":1.0,"b":0.772549,"a":1.0},"normal":{"x":0.0,"y":1.0,"z":0.0}},{"position":{"x":1.0,"y":1.0,"z":-1.0},"color":{"r":0.5019608,"g":1.0,"b":0.772549,"a":1.0},"normal":{"x":0.0,"y":1.0,"z":0.0}},{"position":{"x":-1.0,"y":1.0,"z":-1.0},"color":{"r":0.5019608,"g":1.0,"b":0.772549,"a":1.0},"normal":{"x":0.0,"y":1.0,"z":0.0}},{"position":{"x":-1.0,"y":1.0,"z":1.0},"color":{"r":1.0,"g":0.4431372,"b":0.7254902,"a":1.0},"normal":{"x":0.0,"y":0.0,"z":1.0}},{"position":{"x":-1.0,"y":-1.0,"z":1.0},"color":{"r":1.0,"g":0.4431372,"b":0.7254902,"a":1.0},"normal":{"x":0.0,"y":0.0,"z":1.0}},{"position":{"x":1.0,"y":-1.0,"z":1.0},"color":{"r":1.0,"g":0.4431372,"b":0.7254902,"a":1.0},"normal":{"x":0.0,"y":0.0,"z":1.0}},{"position":{"x":1.0,"y":-1.0,"z":1.0},"color":{"r":0.1294118,"g":0.0,"b":1.0,"a":1.0},"normal":{"x":0.0,"y":-1.0,"z":0.0}},{"position":{"x":-1.0,"y":-1.0,"z":1.0},"color":{"r":0.1294118,"g":0.0,"b":1.0,"a":1.0},"normal":{"x":0.0,"y":-1.0,"z":0.0}},{"position":{"x":-1.0,"y":-1.0,"z":-1.0},"color":{"r":0.1294118,"g":0.0,"b":1.0,"a":1.0},"normal":{"x":0.0,"y":-1.0,"z":0.0}},{"position":{"x":-1.0,"y":-1.0,"z":1.0},"color":{"r":0.5019608,"g":1.0,"b":0.772549,"a":1.0},"normal":{"x":-1.0,"y":0.0,"z":0.0}},{"position":{"x":-1.0,"y":1.0,"z":1.0},"color":{"r":0.5019608,"g":1.0,"b":0.772549,"a":1.0},"normal":{"x":-1.0,"y":0.0,"z":0.0}},{"position":{"x":-1.0,"y":1.0,"z":-1.0},"color":{"r":0.5019608,"g":1.0,"b":0.772549,"a":1.0},"normal":{"x":-1.0,"y":0.0,"z":0.0}},{"position":{"x":1.0,"y":1.0,"z":-1.0},"color":{"r":0.5019608,"g":1.0,"b":0.772549,"a":1.0},"normal":{"x":0.0,"y":0.0,"z":-1.0}},{"position":{"x":1.0,"y":-1.0,"z":-1.0},"color":{"r":0.5019608,"g":1.0,"b":0.772549,"a":1.0},"normal":{"x":0.0,"y":0.0,"z":-1.0}},{"position":{"x":-1.0,"y":-1.0,"z":-1.0},"color":{"r":0.5019608,"g":1.0,"b":0.772549,"a":1.0},"normal":{"x":0.0,"y":0.0,"z":-1.0}},{"position":{"x":1.0,"y":1.0,"z":1.0},"color":{"r":0.5019608,"g":1.0,"b":0.772549,"a":1.0},"normal":{"x":1.0,"y":0.0,"z":0.0}},{"position":{"x":1.0,"y":-1.0,"z":1.0},"color":{"r":0.5019608,"g":1.0,"b":0.772549,"a":1.0},"normal":{"x":1.0,"y":0.0,"z":0.0}},{"position":{"x":1.0,"y":-1.0,"z":-1.0},"color":{"r":0.5019608,"g":1.0,"b":0.772549,"a":1.0},"normal":{"x":1.0,"y":0.0,"z":0.0}},{"position":{"x":-1.0,"y":1.0,"z":1.0},"color":{"r":0.5019608,"g":1.0,"b":0.772549,"a":1.0},"normal":{"x":0.0,"y":1.0,"z":0.0}},{"position":{"x":1.0,"y":1.0,"z":1.0},"color":{"r":0.5019608,"g":1.0,"b":0.772549,"a":1.0},"normal":{"x":0.0,"y":1.0,"z":0.0}},{"position":{"x":1.0,"y":1.0,"z":-1.0},"color":{"r":0.5019608,"g":1.0,"b":0.772549,"a":1.0},"normal":{"x":0.0,"y":1.0,"z":0.0}}],"verticesOrder":[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]},"armature":{"type":"collada.EmptyArmature"}}
{"mesh":{"vertices":[{"position":{"x":-1.0,"y":1.0,"z":1.0},"color":{"r":1.0,"g":0.4431372,"b":0.7254902,"a":1.0},"normal":{"x":0.0,"y":0.0,"z":1.0}},{"position":{"x":1.0,"y":-1.0,"z":1.0},"color":{"r":1.0,"g":0.4431372,"b":0.7254902,"a":1.0},"normal":{"x":0.0,"y":0.0,"z":1.0}},{"position":{"x":1.0,"y":1.0,"z":1.0},"color":{"r":1.0,"g":0.4431372,"b":0.7254902,"a":1.0},"normal":{"x":0.0,"y":0.0,"z":1.0}},{"position":{"x":1.0,"y":-1.0,"z":1.0},"color":{"r":0.1294118,"g":0.0,"b":1.0,"a":1.0},"normal":{"x":0.0,"y":-1.0,"z":0.0}},{"position":{"x":-1.0,"y":-1.0,"z":-1.0},"color":{"r":0.1294118,"g":0.0,"b":1.0,"a":1.0},"normal":{"x":0.0,"y":-1.0,"z":0.0}},{"position":{"x":1.0,"y":-1.0,"z":-1.0},"color":{"r":0.1294118,"g":0.0,"b":1.0,"a":1.0},"normal":{"x":0.0,"y":-1.0,"z":0.0}},{"position":{"x":-1.0,"y":-1.0,"z":1.0},"color":{"r":0.5019608,"g":1.0,"b":0.772549,"a":1.0},"normal":{"x":-1.0,"y":0.0,"z":0.0}},{"position":{"x":-1.0,"y":1.0,"z":-1.0},"color":{"r":0.5019608,"g":1.0,"b":0.772549,"a":1.0},"normal":{"x":-1.0,"y":0.0,"z":0.0}},{"position":{"x":-1.0,"y":-1.0,"z":-1.0},"color":{"r":0.5019608,"g":1.0,"b":0.772549,"a":1.0},"normal":{"x":-1.0,"y":0.0,"z":0.0}},{"position":{"x":1.0,"y":1.0,"z":-1.0},"color":{"r":0.5019608,"g":1.0,"b":0.772549,"a":1.0},"normal":{"x":0.0,"y":0.0,"z":-1.0}},{"position":{"x":-1.0,"y":-1.0,"z":-1.0},"color":{"r":0.5019608,"g":1.0,"b":0.772549,"a":1.0},"normal":{"x":0.0,"y":0.0,"z":-1.0}},{"position":{"x":-1.0,"y":1.0,"z":-1.0},"color":{"r":0.5019608,"g":1.0,"b":0.772549,"a":1.0},"normal":{"x":0.0,"y":0.0,"z":-1.0}},{"position":{"x":1.0,"y":1.0,"z":1.0},"color":{"r":0.5019608,"g":1.0,"b":0.772549,"a":1.0},"normal":{"x":1.0,"y":0.0,"z":0.0}},{"position":{"x":1.0,"y":-1.0,"z":-1.0},"color":{"r":0.5019608,"g":1.0,"b":0.772549,"a":1.0},"normal":{"x":1.0,"y":0.0,"z":0.0}},{"position":{"x":1.0,"y":1.0,"z":-1.0},"color":{"r":0.5019608,"g":1.0,"b":0.772549,"a":1.0},"normal":{"x":1.0,"y":0.0,"z":0.0}},{"position":{"x":-1.0,"y":1.0,"z":1.0},"color":{"r":0.5019608,"g":1.0,"b":0.772549,"a":1.0},"normal":{"x":0.0,"y":1.0,"z":0.0}},{"position":{"x":1.0,"y":1.0,"z":-1.0},"color":{"r":0.5019608,"g":1.0,"b":0.772549,"a":1.0},"normal":{"x":0.0,"y":1.0,"z":0.0}},{"position":{"x":-1.0,"y":1.0,"z":-1.0},"color":{"r":0.5019608,"g":1.0,"b":0.772549,"a":1.0},"normal":{"x":0.0,"y":1.0,"z":0.0}},{"position":{"x":-1.0,"y":1.0,"z":1.0},"color":{"r":1.0,"g":0.4431372,"b":0.7254902,"a":1.0},"normal":{"x":0.0,"y":0.0,"z":1.0}},{"position":{"x":-1.0,"y":-1.0,"z":1.0},"color":{"r":1.0,"g":0.4431372,"b":0.7254902,"a":1.0},"normal":{"x":0.0,"y":0.0,"z":1.0}},{"position":{"x":1.0,"y":-1.0,"z":1.0},"color":{"r":1.0,"g":0.4431372,"b":0.7254902,"a":1.0},"normal":{"x":0.0,"y":0.0,"z":1.0}},{"position":{"x":1.0,"y":-1.0,"z":1.0},"color":{"r":0.1294118,"g":0.0,"b":1.0,"a":1.0},"normal":{"x":0.0,"y":-1.0,"z":0.0}},{"position":{"x":-1.0,"y":-1.0,"z":1.0},"color":{"r":0.1294118,"g":0.0,"b":1.0,"a":1.0},"normal":{"x":0.0,"y":-1.0,"z":0.0}},{"position":{"x":-1.0,"y":-1.0,"z":-1.0},"color":{"r":0.1294118,"g":0.0,"b":1.0,"a":1.0},"normal":{"x":0.0,"y":-1.0,"z":0.0}},{"position":{"x":-1.0,"y":-1.0,"z":1.0},"color":{"r":0.5019608,"g":1.0,"b":0.772549,"a":1.0},"normal":{"x":-1.0,"y":0.0,"z":0.0}},{"position":{"x":-1.0,"y":1.0,"z":1.0},"color":{"r":0.5019608,"g":1.0,"b":0.772549,"a":1.0},"normal":{"x":-1.0,"y":0.0,"z":0.0}},{"position":{"x":-1.0,"y":1.0,"z":-1.0},"color":{"r":0.5019608,"g":1.0,"b":0.772549,"a":1.0},"normal":{"x":-1.0,"y":0.0,"z":0.0}},{"position":{"x":1.0,"y":1.0,"z":-1.0},"color":{"r":0.5019608,"g":1.0,"b":0.772549,"a":1.0},"normal":{"x":0.0,"y":0.0,"z":-1.0}},{"position":{"x":1.0,"y":-1.0,"z":-1.0},"color":{"r":0.5019608,"g":1.0,"b":0.772549,"a":1.0},"normal":{"x":0.0,"y":0.0,"z":-1.0}},{"position":{"x":-1.0,"y":-1.0,"z":-1.0},"color":{"r":0.5019608,"g":1.0,"b":0.772549,"a":1.0},"normal":{"x":0.0,"y":0.0,"z":-1.0}},{"position":{"x":1.0,"y":1.0,"z":1.0},"color":{"r":0.5019608,"g":1.0,"b":0.772549,"a":1.0},"normal":{"x":1.0,"y":0.0,"z":0.0}},{"position":{"x":1.0,"y":-1.0,"z":1.0},"color":{"r":0.5019608,"g":1.0,"b":0.772549,"a":1.0},"normal":{"x":1.0,"y":0.0,"z":0.0}},{"position":{"x":1.0,"y":-1.0,"z":-1.0},"color":{"r":0.5019608,"g":1.0,"b":0.772549,"a":1.0},"normal":{"x":1.0,"y":0.0,"z":0.0}},{"position":{"x":-1.0,"y":1.0,"z":1.0},"color":{"r":0.5019608,"g":1.0,"b":0.772549,"a":1.0},"normal":{"x":0.0,"y":1.0,"z":0.0}},{"position":{"x":1.0,"y":1.0,"z":1.0},"color":{"r":0.5019608,"g":1.0,"b":0.772549,"a":1.0},"normal":{"x":0.0,"y":1.0,"z":0.0}},{"position":{"x":1.0,"y":1.0,"z":-1.0},"color":{"r":0.5019608,"g":1.0,"b":0.772549,"a":1.0},"normal":{"x":0.0,"y":1.0,"z":0.0}}],"verticesOrder":[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]},"armature":{"type":"collada.EmptyArmature"},"skin":{"type":"collada.EmptySkin"},"animations":{"type":"collada.EmptyAnimations"}}
Binary file modified collada-api/src/commonTest/resources/cube_color.protobuf
Binary file not shown.
2 changes: 1 addition & 1 deletion collada-api/src/commonTest/resources/monkey.json

Large diffs are not rendered by default.

Binary file modified collada-api/src/commonTest/resources/monkey.protobuf
Binary file not shown.
2 changes: 1 addition & 1 deletion collada-api/src/commonTest/resources/monkey_color.json

Large diffs are not rendered by default.

Binary file modified collada-api/src/commonTest/resources/monkey_color.protobuf
Binary file not shown.
2 changes: 1 addition & 1 deletion collada-api/src/commonTest/resources/monkey_color2.json

Large diffs are not rendered by default.

Binary file modified collada-api/src/commonTest/resources/monkey_color2.protobuf
Binary file not shown.
2 changes: 1 addition & 1 deletion collada-api/src/commonTest/resources/sample.json

Large diffs are not rendered by default.

Binary file modified collada-api/src/commonTest/resources/sample.protobuf
Binary file not shown.
2 changes: 1 addition & 1 deletion collada-api/src/jvmTest/kotlin/collada/FileHandler.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class SyncContent<T>(private val content: T) : Content<T> {
actual class FileHandler {

actual fun readBytes(name: String): Content<ByteArray> {
return SyncContent(File(name).readBytes())
return SyncContent(File("src/commonTest/resources/$name").readBytes())
}

actual companion object {
Expand Down
7 changes: 6 additions & 1 deletion collada-parser/src/main/kotlin/collada/Converter.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package collada

import collada.internal.AnimationConverter
import collada.internal.ArmatureConverter
import collada.internal.MeshConverter
import collada.internal.SkinConverter
Expand Down Expand Up @@ -29,16 +30,20 @@ class Converter(private val input: File) {
private val meshConverter = MeshConverter()
private val armatureConverter = ArmatureConverter()
private val skinConverter = SkinConverter()
private val animationsConverter = AnimationConverter()

private fun convertToModel(): Model {
val document: Document = Jsoup.parse(input.readText(), "", Parser.xmlParser())
val mesh = meshConverter.convert(document)
val armature = armatureConverter.convert(document)
val skin = skinConverter.convert(document)
val animations = animationsConverter.convert(document)

val model = Model(
mesh = mesh,
armature = armature
armature = armature,
skin = skin,
animations = animations
)
return model
}
Expand Down
Loading

0 comments on commit 2b5681a

Please sign in to comment.