I've never used Assimp before but decided that since it came so nicely bundled that I might as well - has to be better than my own home brewed collada importer. Now I'm trying to extract the diffuse colour of one of the materials but the function doesn't seem to be finding it and I must admit I'm a little confused since the definition of this function is different to the standard Assimp one (has the extra "type" and "index" parameters).
Some code to demonstrate the problem:
//Get the material
int materialIndex = mesh.mMaterialIndex();
AIMaterial mtl = AIMaterial.create(scene.mMaterials().get(materialIndex));
//Try to get the diffuse colour
AIColor4D mtlDiffuse = AIColor4D.create();
int success = aiGetMaterialColor(mtl, AI_MATKEY_COLOR_DIFFUSE, aiTextureType_DIFFUSE, 0, mtlDiffuse);
switch(success) {
case aiReturn_SUCCESS:
System.out.println("aiReturn_SUCCESS");
break;
case aiReturn_FAILURE:
System.out.println("aiReturn_FAILURE");
break;
case aiReturn_OUTOFMEMORY:
System.out.println("aiReturn_OUTOFMEMORY");
break;
default:
break;
}
//List all the properties and whether they match
PointerBuffer props = mtl.mProperties();
for(int j = 0; j < mtl.mNumProperties(); j++) {
AIMaterialProperty prop = AIMaterialProperty.create(props.get());
System.out.println(
"key=\"" + prop.mKey().dataString() +
"\", type=" + prop.mType() +
", index=" + prop.mIndex() +
" (" + (prop.mKey().dataString().equals(AI_MATKEY_COLOR_DIFFUSE) &&
prop.mType() == aiTextureType_DIFFUSE &&
prop.mIndex() == 0)
+ ")"
);
}
And the important bits of the output:
aiReturn_FAILURE
key="?mat.name", type=3, index=0 (false)
key="$clr.diffuse", type=1, index=0 (true)
key="$clr.specular", type=1, index=0 (false)
key="$mat.shininess", type=1, index=0 (false)
key="$clr.ambient", type=1, index=0 (false)
key="$clr.reflective", type=1, index=0 (false)
key="$mat.blend.diffuse.color", type=1, index=0 (false)
So obviously there is a property matching the colour I want but the function fails to find it. The model I'm trying to load has a single material which is just the base colours with no associated textures which I feel is perhaps the reason why but I don't see why it should be impossible because of that.
So anyone more familiar with Assimp know what I'm supposed to do in this situation? Or anyone more familiar with the LWJGL binding know what the extra parameters are supposed to be?
Thanks everyone.