开发者

Suggested Ways To Handle Meshes in OpenGL

I'm looking for better ways to handle having a mesh than my current implementation which is basically the .obj format in the form of a class.

My Current Structure is

Class Vertex
{
    float[3] Pos;
}

Class Face
{
    Vertex[3] Verts;
    float[3][3] Norm;
    float[3][3] Tex;
}

Class Mesh
{
    Face[] MeshData;
}

I can use this just fine in most cases, but I'd like to be able to do things such as manipulate a vertex and move it randomly. I did it, however the connected faces wouldn't move with it.

That could probably be fixed by makin开发者_运维问答g all references to a vertex in the same position, a reference to the same vertex, but I don't know how to do that beforehand and I can't imagine removing double vertices would be an even remotely fast operation with my setup.


If you're going to be manipulating the mesh and rendering speed is secondary look into the half-edge data structure.

If rendering speed is paramount flatten everything out into a interleaved vertex/texcoord/normal array for maximum VA/VBO-friendliness:

struct Vertex
{
    float x, y, z;
    float u, v;
    float nx, ny, ny;
};

Generally you'll want sizeof(Vertex) to be a multiple of 32 bytes.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜