Please login or register.

Login with username, password and session length

Author Topic: Assimp: Getting a float from material in Collada file  (Read 606 times)


  • Newbie
  • *
  • Offline Offline
  • Posts: 5
Assimp: Getting a float from material in Collada file
« 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);

Supposedly, I should get 50 on the console instead of the 0.0 I always end up getting. What have I done wrong?  ??? ??? ???


  • Administrator
  • Nerdus Imperius
  • *****
  • Offline Offline
  • Posts: 1957
Re: Assimp: Getting a float from material in Collada file
« Reply #1 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.