Created
May 3, 2018 05:33
-
-
Save mudlee/25e734d77c1cb2542ce772e77eb3e18e to your computer and use it in GitHub Desktop.
Assimp
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
OUTPUT | |
[20:42:27.567] 1095 [main] DEBUG com.intermetto.engine.util.StaticMeshLoader - # Processing 2 materials... | |
[20:42:27.568] 1096 [main] DEBUG com.intermetto.engine.util.StaticMeshLoader - Processing [0] material... | |
0.6-0.6-0.6 - result: 0 | |
0.0-0.0-0.0 - result: 0 | |
0.0-0.0-0.0 - result: 0 | |
[20:42:27.572] 1100 [main] DEBUG com.intermetto.engine.util.StaticMeshLoader - Material [0] loaded. | |
[20:42:27.572] 1100 [main] DEBUG com.intermetto.engine.util.StaticMeshLoader - Processing [1] material... | |
0.6-0.6-0.6 - result: 0 | |
0.0-0.0-0.0 - result: 0 | |
0.0-0.0-0.0 - result: 0 | |
[20:42:27.572] 1100 [main] DEBUG com.intermetto.engine.util.StaticMeshLoader - Material [1] loaded. | |
[20:42:27.573] 1101 [main] DEBUG com.intermetto.engine.util.StaticMeshLoader - # Model /models/monkey.obj has been loaded. Meshes: 1, Materials: 2 | |
... | |
List<Material> materials = new ArrayList<>(); | |
for (int i = 0; i < numMaterials; i++) { | |
LOGGER.debug("Processing [{}] material...", i); | |
AIMaterial aiMaterial = AIMaterial.create(aiMaterials.get(i)); | |
Material material = processMaterial(aiMaterial); | |
LOGGER.debug("Material [{}] loaded.", i); | |
materials.add(material); | |
} | |
... | |
private static Material processMaterial(AIMaterial aiMaterial) { | |
AIString path = AIString.calloc(); | |
Assimp.aiGetMaterialTexture(aiMaterial, Assimp.aiTextureType_DIFFUSE, 0, path, (IntBuffer) null,null, null, null, null, null); | |
printColor(aiMaterial,Assimp.AI_MATKEY_COLOR_DIFFUSE); | |
printColor(aiMaterial,Assimp.AI_MATKEY_COLOR_AMBIENT); | |
printColor(aiMaterial,Assimp.AI_MATKEY_COLOR_SPECULAR); | |
printTexture(aiMaterial,Assimp.aiTextureType_DIFFUSE); | |
printTexture(aiMaterial,Assimp.aiTextureType_SPECULAR); | |
printTexture(aiMaterial,Assimp.aiTextureType_AMBIENT); | |
printTexture(aiMaterial,Assimp.aiTextureType_EMISSIVE); | |
printTexture(aiMaterial,Assimp.aiTextureType_HEIGHT); | |
printTexture(aiMaterial,Assimp.aiTextureType_NORMALS); | |
printTexture(aiMaterial,Assimp.aiTextureType_SHININESS); | |
printTexture(aiMaterial,Assimp.aiTextureType_OPACITY); | |
printTexture(aiMaterial,Assimp.aiTextureType_DISPLACEMENT); | |
printTexture(aiMaterial,Assimp.aiTextureType_LIGHTMAP); | |
printTexture(aiMaterial,Assimp.aiTextureType_REFLECTION); | |
printTexture(aiMaterial,Assimp.aiTextureType_UNKNOWN); | |
return null; | |
} | |
private static void printTexture(AIMaterial aiMaterial, int what){ | |
AIString path = AIString.calloc(); | |
Assimp.aiGetMaterialTexture(aiMaterial, what, 0, path, (IntBuffer) null,null, null, null, null, null); | |
String textPath = path.dataString(); | |
System.out.println(textPath); | |
} | |
private static void printColor(AIMaterial aiMaterial, String what){ | |
AIColor4D colour = AIColor4D.create(); | |
int result = Assimp.aiGetMaterialColor(aiMaterial, what, Assimp.aiTextureType_NONE, 0,colour); | |
System.out.println(colour.r()+"-"+colour.g()+"-"+colour.b()+" - result: "+result); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment