i’m tring to write a 3d tool myself, but i can’t figure out a good data structure for the mesh(polygon).
i’v found a structure called the winged-edge http://www.cs.mtu.edu/~shene/COURSES/cs3621/NOTES/model/winged-e.html , i think it’s great for editing the polygon but not good with subdivision, because it contain too much information that can’t be deal with easily when being subdivided.
so i decided to study the blender code and then figure out the proper data structure. could you please tell me in which file the mesh structer is defined and where i can find the subdivision function?
or is there any document on that?
thank you in advance.
uhh, I think blender has some crazy structure with edges and stuff refrenced from the more recent python api
but before more rambling, I have some questions for you… do you want to limit your meshes to triangles? triangles and quads? to a solid [‘manifold’ with no holes, edges have exactly two faces always]? no more than two faces per edge?
the winged edge structure is well suited to ngons, but tends to require a solid [manifold] mesh. Play with wings3d to see what I mean
regardless of the structure you use, the abstract version will be:
psuedocode:
faceType:
list verts
list edges
list of lists uv coords [per vert per material]
list of materials
... other face props...
vert:
float/double x,y,z
edge:
vert v1,v2 [end points]
list faces
the trick is being able to have a variable amount of verts per face, you might just decide not and go with similar to what blender has [it stores 4 verts, regardless if they are all used… or so it seems I haven’t messed with blender’s source]
it depends on the sizes of meshes you will work with.
for large meshes and low memory usage, just storing verts and faces is fine- but for tools that may want to know what connects to what its not so usefull.
I recomend looking into the “half edge” mesh datastructure…
For somthing like Wings3D (does that use HEMesh?)
Also Tuhopuu blender has a HEMesh mesh type in development.