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

Started by WeBeJammin, January 12, 2020, 06:09:21

Previous topic - Next topic

WeBeJammin

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):

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.



KaiHH

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:
[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]