Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 64da59d

Browse filesBrowse files
committed
working
1 parent 3c41d0d commit 64da59d
Copy full SHA for 64da59d

File tree

Expand file treeCollapse file tree

3 files changed

+25
-6
lines changed
Filter options
Expand file treeCollapse file tree

3 files changed

+25
-6
lines changed

‎build.gradle

Copy file name to clipboardExpand all lines: build.gradle
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ dependencies {
2525
compile 'com.github.kotlin-graphics:glm:4711d0f44930262d53f4c3b9a799edb4f6a4401d'
2626
compile 'com.github.kotlin-graphics:gli:4f94c22fac4a6fad4cf84a8d3a436b2ade10453c'
2727
compile 'com.github.kotlin-graphics:uno-sdk:3faa2cb28044564b80e8e2d2b4342a007142a083'
28-
compile 'com.github.java-graphics:assimp:v0.12'
28+
compile 'com.github.java-graphics:assimp:ab7cf7e5a6ead86e3ef726e17b053164b3312f1c'
2929

3030
// testCompile("io.kotlintest:kotlintest:2.0.0")
3131

‎src/main/kotlin/learnOpenGL/common/Model.kt

Copy file name to clipboardExpand all lines: src/main/kotlin/learnOpenGL/common/Model.kt
+19-5Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
package learnOpenGL.common
22

3-
import assimp.AiMesh
4-
import assimp.AiNode
5-
import assimp.Importer
3+
import assimp.*
64
import assimp.AiPostProcessSteps.*
7-
import assimp.AiScene
85
import glm.vec2.Vec2
96

107
/**
@@ -20,7 +17,7 @@ class Model(path: String, val gammaCorrection: Boolean = false) {
2017
init {
2118
// Read file via ASSIMP
2219
val importer = Importer()
23-
val scene = importer.readFile(this::class.java, "objects/nanosuit/nanosuit.obj", Triangulate.i or FlipUVs.i or CalcTangentSpace.i)
20+
val scene = importer.readFile(this::class.java, path, Triangulate.i or FlipUVs.i or CalcTangentSpace.i)
2421
// Check for errors
2522
if (scene == null) // if is Not Zero
2623
// if(!scene || scene->mFlags & AI_SCENE_FLAGS_INCOMPLETE || !scene->mRootNode) // if is Not Zero
@@ -33,6 +30,9 @@ class Model(path: String, val gammaCorrection: Boolean = false) {
3330
//
3431
// // Process ASSIMP's root node recursively
3532
processNode(scene.mRootNode, scene)
33+
34+
// Load all Diffuse, Specular, Normal and Height maps
35+
3636
}
3737

3838
/** Processes a node in a recursive fashion. Processes each individual mesh located at the node and repeats this
@@ -52,6 +52,7 @@ class Model(path: String, val gammaCorrection: Boolean = false) {
5252
// Data to fill
5353
val vertices = ArrayList<Vertex>()
5454
val indices = ArrayList<Int>()
55+
val textures = ArrayList<Texture>()
5556

5657
// Walk through each of the mesh's vertices
5758
for (i in 0 until mesh.mNumVertices)
@@ -86,6 +87,19 @@ class Model(path: String, val gammaCorrection: Boolean = false) {
8687
Specular: texture_specularN
8788
Normal: texture_normalN */
8889

90+
// Load all Diffuse, Specular, Normal and Height maps
91+
textures.addAll(loadMaterialTextures(material, AiTexture.Type.diffuse, "texture_diffuse"))
8992
}
9093
}
94+
95+
/**
96+
* Checks all material textures of a given type and loads the textures if they're not loaded yet.
97+
* The required info is returned as a Texture struct.
98+
*/
99+
fun loadMaterialTextures(mat: AiMaterial, type: AiTexture.Type, typeName: String): List<Texture> {
100+
101+
val textures = ArrayList<Texture>()
102+
103+
104+
}
91105
}

‎src/main/kotlin/learnOpenGL/common/mesh.kt

Copy file name to clipboardExpand all lines: src/main/kotlin/learnOpenGL/common/mesh.kt
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,9 @@ class Vertex(
1919
// Bitangent
2020
val bitangent: Vec3)
2121

22+
class Texture(
23+
val id: Int,
24+
val type: String,
25+
val path: String)
26+
2227
class mesh

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.