LWJGL Forum

Programming => Lightweight Java Gaming Library => Topic started by: DanielUnleashed on April 04, 2017, 15:46:23

Title: Assimp: Getting a float from material in Collada file
Post by: DanielUnleashed on April 04, 2017, 15:46:23
I've been struggling with Assimp since I first started using it. I have to say that I'm ussing Java and it's very maddening trying to search info on the internet and only finding out that everything is on another language and that all the methods are different.

So this is what I do:
Code: [Select]
PointerBuffer materials = scene.mMaterials();
AIMaterial material = AIMaterial.create(materials.get(0));
IntBuffer size = BufferUtils.createIntBuffer(1);
FloatBuffer floatBuf = BufferUtils.createFloatBuffer(1);
Assimp.aiGetMaterialFloatArray(material, Assimp.AI_MATKEY_SHININESS, Assimp.aiTextureType_NONE, 0, floatBuf, size);
System.out.println(floatBuf.get(0));

Supposedly, I should get 50 on the console instead of the 0.0 I always end up getting. What have I done wrong?  ??? ??? ???
Title: Re: Assimp: Getting a float from material in Collada file
Post by: spasi on April 04, 2017, 19:00:07
When in doubt, read the provided javadoc. The last parameter (IntBuffer pMax) is an input/output parameter. You must fill the size buffer with the number of floats available to be written in floatBuf (1 in this case). With the code above, size is initialized to 0, so Assimp thinks there's no room to write the float value.