PDA

View Full Version : Assimp and unique vertices



jnewlin
06-04-2012, 09:01 AM
Hi,

I am using Assimp to load obj files into my program. I want to take that data and construct my own data structure. My problem is that Assimp by default loads in repeated vertices, based on however many faces point to each vertex. So for a cube, I would want Assimp to load only 8 vertices.

For a more explicit example, here is part of the obj file maya outputs for a simple cube:

v -1.000000 -1.000000 1.000000
v 1.000000 -1.000000 1.000000
v -1.000000 1.000000 1.000000
v 1.000000 1.000000 1.000000
v -1.000000 1.000000 -1.000000
v 1.000000 1.000000 -1.000000
v -1.000000 -1.000000 -1.000000
v 1.000000 -1.000000 -1.000000

...

f 1 2 4 3
f 3 4 6 5
f 5 6 8 7
f 7 8 2 1
f 2 8 6 4
f 7 1 3 5

I would like assimp to give me that data. Instead, it gives me indices from 1->23, and repeats the vertices to match those indices.

I tried using aiProcess_JoinIdenticalVertices in my call to Importer::ReadFile, but that did not have the desired effect.

Has anyone had a similar problem and found a fix?

Thanks!

Alfonse Reinheart
06-04-2012, 09:40 AM
here is part of the obj file maya outputs for a simple cube

Where's the rest of it? You know, the part that shows that these are not identical vertices. The normals, colors, texture coordinates, etc.

See, what Open Asset is doing is properly preparing your data for rendering, which does not allow the kind of thing you're trying to do. You cannot render (without effort) using separate index lists for each attribute. You get one index, which indexes into all attributes at the same time. So if a position is used by two different normals, it must be split into two positions.

Unless you are not trying to render with this mesh, I suggest you let Open Asset do its job. And if you need Open Asset to do what you're suggesting... you can't. Its mesh system and data structures simply do not allow each attribute to have a separate index.

jnewlin
06-04-2012, 09:48 AM
I guess I don't really want to render directly from this mesh then. I want to make my own mesh and render from that. The reason for that is all of my other code is based on my own structure, so I was trying to make assimp conform to that.