-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from dwursteisen/object-tree
Object tree
- Loading branch information
Showing
34 changed files
with
971 additions
and
235 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 12 additions & 11 deletions
23
gltf-api/src/commonMain/kotlin/com.dwursteisen.minigdx.scene.api/camera/Camera.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,39 @@ | ||
package com.dwursteisen.minigdx.scene.api.camera | ||
|
||
import com.dwursteisen.minigdx.scene.api.common.Id | ||
import com.dwursteisen.minigdx.scene.api.common.Transformation | ||
import kotlinx.serialization.Serializable | ||
import kotlinx.serialization.protobuf.ProtoId | ||
|
||
interface Camera { | ||
val id: Id | ||
val name: String | ||
val transformation: Transformation | ||
} | ||
|
||
@Serializable | ||
data class PerspectiveCamera( | ||
@ProtoId(0) | ||
override val name: String, | ||
override val id: Id, | ||
@ProtoId(1) | ||
val far: Float, | ||
override val name: String, | ||
@ProtoId(2) | ||
val near: Float, | ||
val far: Float, | ||
@ProtoId(3) | ||
val fov: Float, | ||
val near: Float, | ||
@ProtoId(4) | ||
override val transformation: Transformation | ||
val fov: Float | ||
) : Camera | ||
|
||
@Serializable | ||
data class OrthographicCamera( | ||
@ProtoId(0) | ||
override val name: String, | ||
override val id: Id, | ||
@ProtoId(1) | ||
val far: Float, | ||
override val name: String, | ||
@ProtoId(2) | ||
val near: Float, | ||
val far: Float, | ||
@ProtoId(3) | ||
val scale: Float, | ||
val near: Float, | ||
@ProtoId(4) | ||
override val transformation: Transformation | ||
val scale: Float | ||
) : Camera |
27 changes: 26 additions & 1 deletion
27
gltf-api/src/commonMain/kotlin/com.dwursteisen.minigdx.scene.api/common/Id.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,28 @@ | ||
package com.dwursteisen.minigdx.scene.api.common | ||
|
||
typealias Id = Int | ||
import kotlinx.serialization.Serializable | ||
import kotlinx.serialization.protobuf.ProtoId | ||
import kotlin.random.Random | ||
|
||
@Serializable | ||
data class Id( | ||
@ProtoId(0) | ||
val value: String = generate() | ||
) { | ||
|
||
companion object { | ||
private fun generate(): String { | ||
val randomValues = ByteArray(ID_SIZE) | ||
Random.nextBytes(randomValues) | ||
return randomValues.map { it.toInt() and 0x0F } | ||
.joinToString("") { CONVERT[it] } | ||
|
||
} | ||
|
||
private const val ID_SIZE = 8 | ||
|
||
private val CONVERT = arrayOf("0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F") | ||
|
||
val None = Id("NONE") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 10 additions & 4 deletions
14
gltf-api/src/commonMain/kotlin/com.dwursteisen.minigdx.scene.api/light/PointLight.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,24 @@ | ||
package com.dwursteisen.minigdx.scene.api.light | ||
|
||
import com.dwursteisen.minigdx.scene.api.common.Id | ||
import com.dwursteisen.minigdx.scene.api.model.Color | ||
import com.dwursteisen.minigdx.scene.api.model.Position | ||
import kotlinx.serialization.Serializable | ||
import kotlinx.serialization.protobuf.ProtoId | ||
|
||
|
||
interface Light { | ||
val id: Id | ||
val name: String | ||
} | ||
|
||
@Serializable | ||
data class PointLight( | ||
@ProtoId(0) | ||
val name: String, | ||
override val id: Id, | ||
@ProtoId(1) | ||
val position: Position, | ||
override val name: String, | ||
@ProtoId(2) | ||
val color: Color, | ||
@ProtoId(3) | ||
val intensity: Int | ||
) | ||
) : Light |
9 changes: 6 additions & 3 deletions
9
gltf-api/src/commonMain/kotlin/com.dwursteisen.minigdx.scene.api/material/Material.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,21 @@ | ||
package com.dwursteisen.minigdx.scene.api.material | ||
|
||
import com.dwursteisen.minigdx.scene.api.common.Id | ||
import kotlinx.serialization.Serializable | ||
import kotlinx.serialization.protobuf.ProtoId | ||
|
||
@Serializable | ||
class Material( | ||
@ProtoId(0) | ||
val name: String, | ||
val id: Id, | ||
@ProtoId(1) | ||
val id: Int, | ||
val name: String, | ||
@ProtoId(2) | ||
val width: Int, | ||
@ProtoId(3) | ||
val height: Int, | ||
@ProtoId(4) | ||
val data: ByteArray | ||
val data: ByteArray, | ||
@ProtoId(5) | ||
val hasAlpha: Boolean = false | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 3 additions & 2 deletions
5
gltf-api/src/commonMain/kotlin/com.dwursteisen.minigdx.scene.api/relation/ObjectType.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
package com.dwursteisen.minigdx.scene.api.relation | ||
|
||
enum class ObjectType { | ||
MODEL, | ||
ARMATURE, | ||
BOX, | ||
CAMERA, | ||
LIGHT | ||
LIGHT, | ||
MODEL | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.