Hello Guest

Having trouble getting indices from obj file through Assimp. Other data is fine.

  • 3 Replies
  • 1506 Views
I'm having trouble figuring out how to get indices from an assimp face. Other data seems to be fine. AIFace.Buffer.get() is returning a list of zeroes. I'd really appreciate some advice if possible. I tried to follow the demo, but no luck. Here is my indices method (still in debug phase obvs):

Code: [Select]
private int[] processIndices(AIMesh mesh) {
try (MemoryStack stack = MemoryStack.stackPush()) {
IntBuffer indices = stack.mallocInt(mesh.mNumFaces() * 3);
AIFace.Buffer aiFaces = mesh.mFaces();
while (aiFaces.remaining() > 0) {
AIFace aiFace = aiFaces.get();
indices.put(aiFace.mIndices());
}
indices.flip();
int[] arr = new int[mesh.mNumFaces() * 3];
indices.put(arr);
}
return new int[0];
}

The arr array is filled with only zeroes. Attached is the very simple .obj file it's processing.

I would really appreciate someone letting me know what I'm doing wrong trying to get the indices from the obj file.

*

Offline KaiHH

  • ****
  • 260
I tried to follow the demo
What "demo" are you talking about. Please specify the exact link.
Also, do have a look at this: https://github.com/LWJGL/lwjgl3-demos/blob/master/src/org/lwjgl/demo/opengl/assimp/WavefrontObjDemo.java

Yes, the LWJGL demo is what I meant.

*

Offline KaiHH

  • ****
  • 260
Then simply do the loading as that demo does it. When I exchange the magnet.obj with your supplied test obj file, I get the following indices:
Code: [Select]
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 3, 21, 4, 22, 23, 24, 9, 25, 10, 12, 26, 13, 15, 27, 16]