Defining custom meshes - how to deal with multiple data points at same vertex?

I am working on a loader for a 3D format I’ve been developing. I am loading the data into JME using a custom mesh. I don’t know what the best way would be to represent verteces that need to have several points of data. For example, for smooth shapes, I just need get the average normal for all faces adjoining a vertex, but for sharp or jagged geometry, I need to store the normals for each face. There is a similar issue for sharp transitions between textures. The obvious way is to generate unique verteces for each triangle (instead of reusing verteces) but this sounds rather inefficient. So I’m wondering if there is a smarter way?

@ags1 said: I am working on a loader for a 3D format I've been developing. I am loading the data into JME using a custom mesh. I don't know what the best way would be to represent verteces that need to have several points of data. For example, for smooth shapes, I just need get the average normal for all faces adjoining a vertex, but for sharp or jagged geometry, I need to store the normals for each face. There is a similar issue for sharp transitions between textures. The obvious way is to generate unique verteces for each triangle (instead of reusing verteces) but this sounds rather inefficient. So I'm wondering if there is a smarter way?
That's how every single 3D engine that I know do it. This is not as inefficient as you may think, it's ok to add some vertices in a mesh as todays graphic cards loves to crunch polygons. And you need this kind of separation when feeding them to opengl. I may add that since you use JME you don't really have any other option, because we do it like this. A vertex with 2 different normals is actually 2 vertices. Also you may have to split vertex when they also different uv coordinates in the same uv set.

Thanks, I will plough ahead then. :slight_smile:

My head’s hurting, I think I will just explicitly define duplicate geometry in the model when needed, and just assume I can reuse all verteces.

It’s easy. You (I think) are mistaking what a “vertex” is in OpenGL. You think a “vertex” is a position. But a position is a position and a vertex is a bunch of things.

A vertex is: position + normal + texture coordinate + tangent + whatever else you associated with the vertex. color, size, etc.

The “vertex” can then only be shared from one triangle to another when all of those things match… otherwise it’s a different vertex.

1 Like