3D Modeling: How are Meshes Rendered?

Started by irongiant, September 13, 2008, 16:39:02

Previous topic - Next topic

irongiant

In 3D modeling tools, meshes are often composed of both triangular and quadrangular faces. To render these I think of the following possibilities:

Immediate Mode - This approach could affect the performance for meshes with thousands of vertices;

Display Lists - Since we're talking about 3D modeling, the meshes must be dynamic. This is bad when we're adding, removing and messing with vertices;

VertexArrays (AR) and/or VBOs - They seem the right option.

The problem is that VAs and VBOs are rendered as, and only as, triangles or quads and meshes are often composed of both. Base on my (limited) knowledge, the only solution I come up with is for a mesh to have two VAs, one for triangles and the other for quads. The two VAs share common vertices when needed.

What are you thoughts on this? I would like to know if there are any better solutions, or at least some insight.

Alex

ndhb


bobjob

i think all the 3d modelling programs, can trianglulate a mesh(i know blender and max can), so do that be for exporting it.

try exporting to the ".obj" file type. then open it up in a text editor. its a very easy to understand model type. If your having trouble there are detailed pages on the net about how to read it.

you can use either display lists/vbo's or whatever it doesnt matter to much. If you want to use the models for games, then compile it into a display list/vbo. If you want to make your own model editing program, maybe just load it into a floatbuffer and draw from that.

irongiant

Yes, it's for a basic modeling tool I have to make.

Quote from: ndhb on September 13, 2008, 18:22:25
Split every quad into two triangles?

Perhaps meshes are internally represented as triangles, but using the edge flag, where needed, some faces appear as quads.

As for '.obj' files, I'm already comfortable with them; Blender triangulates models when exporting to that particular format. A simple cylinder model exported as '.obj' shows that some faces are triangular and others are quadrangular.

The final objective is to "ray trace" the models, so allowing quads will significantly reduce the computational time. On the other hand, triangles only reduces the complexity. I'll have to think a bit more about this.

Thank you, guys.

Alex

wolf_m

Quote from: irongiant on September 13, 2008, 20:17:33
Yes, it's for a basic modeling tool I have to make.

Quote from: ndhb on September 13, 2008, 18:22:25
Split every quad into two triangles?

Perhaps meshes are internally represented as triangles, but using the edge flag, where needed, some faces appear as quads.

As for '.obj' files, I'm already comfortable with them; Blender triangulates models when exporting to that particular format. A simple cylinder model exported as '.obj' shows that some faces are triangular and others are quadrangular.

The final objective is to "ray trace" the models, so allowing quads will significantly reduce the computational time. On the other hand, triangles only reduces the complexity. I'll have to think a bit more about this.

Thank you, guys.

Alex
Blender triangulates all selected faces in Edit Mode when you press Ctrl-T, if I recall correctly. So that's what you need to do in order to triangulate there, no matter what export format you have.

I'd say you would probably get the highest performance with a mix of all rendering methods you mention, for example IM for current dynamic faces, DLs or VBOs for everything else, then rearrange as you go. Although that leads to certain traps. Quite a difficult design problem, I suppose; plus, it's highly dependant on what you actually want to do.

If you want to design by feature, make a list of all modeling features you want to implement, then make schemes of rendering methods; finally, try to apply each scheme and list pros and cons. Theoretically, that will give you an objectively best scheme for your set of features.

Also note that there are OpenSource modeling tools out there, so you can gather information by inspecting other people's methods. As for Blender, they've got dev forums where you should be able to ask such details; they seem to have a quite fast and reliable method.