Skip to content

Commit c005eb5

Browse files
committed
- moved everything from default package
1 parent 7fd888f commit c005eb5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+804
-420
lines changed

build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ dependencies {
3131
testCompile("io.kotlintest:kotlintest:1.3.5")
3232
// testCompile("io.kotlintest:kotlintest:2.0-SNAPSHOT")
3333
compile("com.github.elect86:kotlin-unsigned:-SNAPSHOT")
34-
compile("com.github.elect86:glm:245ba298c4")
34+
compile("com.github.elect86:glm:30982dc750")
3535
}
3636

3737
allprojects {

src/main/kotlin/collada/ColladaLoader.kt

Lines changed: 0 additions & 88 deletions
This file was deleted.

src/main/kotlin/collada/ColladaHelper.kt renamed to src/main/kotlin/format/collada/ColladaHelper.kt

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,11 @@
1-
package collada
1+
package format.collada
22

33
/**
44
* Created by elect on 23/01/2017.
55
*/
66

7-
import AiLightSourceType
8-
import AiColor3D
9-
import AiColor4D
10-
import AiVector3D
11-
import java.nio.ByteBuffer
12-
import AiUVTransform
13-
import com.sun.deploy.xml.XMLNode
147
import i
15-
import org.w3c.dom.Element
16-
8+
import main.*
179
import org.w3c.dom.Node as XmlNode
1810

1911
/** Collada file versions which evolved during the years ... */
Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
package format.collada
2+
3+
import main.BaseImporter
4+
import java.net.URI
5+
import main.AiScene
6+
import main.AiMesh
7+
import main.AiMaterial
8+
import main.*
9+
10+
/**
11+
* Created by elect on 23/01/2017.
12+
*/
13+
14+
class ColladaLoader : BaseImporter() {
15+
16+
companion object {
17+
18+
val desc = AiImporterDesc(
19+
mName = "Collada Importer",
20+
mComments = "http://collada.org",
21+
mFlags = main.AiImporterFlags.SupportTextFlavour.i,
22+
mMinMajor = 1, mMinMinor = 3,
23+
mMaxMajor = 1, mMaxMinor = 5,
24+
mFileExtensions = "dae"
25+
)
26+
}
27+
28+
/** Filename, for a verbose error message */
29+
lateinit var mFileName: URI
30+
31+
/** Which mesh-material compound was stored under which mesh ID */
32+
val mMeshIndexByID = mutableMapOf<ColladaMeshIndex, Int>()
33+
34+
/** Which material was stored under which index in the scene */
35+
val mMaterialIndexByName = mutableMapOf<String, Int>()
36+
37+
/** Accumulated meshes for the target scene */
38+
val mMeshes = ArrayList<AiMesh>()
39+
40+
/** Temporary material list */
41+
val newMats = ArrayList<Pair<Effect, AiMaterial>>()
42+
43+
/** Temporary camera list */
44+
val mCameras = ArrayList<AiCamera>()
45+
46+
/** Temporary light list */
47+
val mLights = ArrayList<AiLightSourceType>()
48+
49+
/** Temporary texture list */
50+
val mTextures = ArrayList<AiTexture>()
51+
52+
/** Accumulated animations for the target scene */
53+
// val mAnims = ArrayList<AiAnimation>()
54+
55+
val noSkeletonMesh = false
56+
val ignoreUpDirection = false
57+
58+
/** Used by FindNameForNode() to generate unique node names */
59+
val mNodeNameCounter = 0
60+
61+
// ------------------------------------------------------------------------------------------------
62+
// Returns whether the class can handle the format of the given file.
63+
override fun canRead(pFile: URI, checkSig: Boolean): Boolean {
64+
65+
// check file extension
66+
val extension = pFile.s.substring(pFile.s.lastIndexOf('.') + 1)
67+
68+
if (extension == "dae")
69+
return true
70+
71+
// XML - too generic, we need to open the file and search for typical keywords
72+
if (extension == "xml" || extension.isEmpty() || checkSig) {
73+
//TODO
74+
}
75+
return false
76+
}
77+
78+
// ------------------------------------------------------------------------------------------------
79+
// Imports the given file into the given scene structure.
80+
override fun internReadFile(pFile: URI, pScene: AiScene) {
81+
82+
mFileName = pFile
83+
84+
// parse the input file
85+
val parser = ColladaParser(pFile)
86+
87+
if (parser.mRootNode == null)
88+
throw Error("Collada: File came out empty. Something is wrong here.")
89+
90+
// create the materials first, for the meshes to find
91+
buildMaterials(parser)
92+
}
93+
94+
/** Constructs materials from the collada material definitions */
95+
protected fun buildMaterials(pParser: ColladaParser) = pParser.mMaterialLibrary.forEach { id, material ->
96+
97+
// a material is only a reference to an effect
98+
pParser.mEffectLibrary[material.mEffect]?.let { effect ->
99+
100+
// create material
101+
val mat = AiMaterial(name = if (material.mName.isEmpty()) id else material.mName)
102+
103+
// store the material
104+
// mMaterialIndexByName[matIt->first] = newMats.size();
105+
// newMats.push_back(std::pair < Collada::Effect *, aiMaterial * >(& effect, mat) );
106+
}
107+
}
108+
109+
110+
class ColladaMeshIndex(
111+
112+
var mMeshID: String = "",
113+
var mSubMesh: Int = 0,
114+
var mMaterial: String = "") {
115+
116+
operator fun compareTo(p: ColladaMeshIndex): Int =
117+
if (mMeshID == p.mMeshID)
118+
if (mSubMesh == p.mSubMesh)
119+
mMaterial.compareTo(p.mMaterial)
120+
else
121+
mSubMesh.compareTo(p.mSubMesh)
122+
else
123+
mMeshID.compareTo(p.mMeshID)
124+
}
125+
}

0 commit comments

Comments
 (0)