|
![](/i/fill.gif) |
stm31415 wrote:
>
> I suppose I should ask, do you (either of you) use mesh2 or
> mesh?
I write out the final mesh in mesh2 format, but I switch around between
storing the triangles in array formats similar to both.
// similar to "mesh"
#local aMesh = array[1][3] { { <0,0,0>, <1,1,0>, <1,0,1> } }
// similar to "mesh2"
#local aMeshV = array[3] { <0,0,0>, <1,1,0>, <1,0,1> }
#local aMeshI = array[1][3] { 0, 1, 2 }
> I can't see how you can get your SDL to keep track of which
> points belong to which edge of which face. It looks like I'll
> be in low-chart mode for a while...
I'm a bad example. I do it differently almost every time. What you can
do is use an array of arrays. For example, here's a tetrahedron where
every vertex "knows" its edges and faces:
#local aTet = array[4] { // one 3D array per vertex
array[3] { // D1=Location D2=Edges D3=Faces
array[1] { <0,0,0> } // the vertex
array[3][2] { // the vertex' three edges
{ <0,0,0>, <1,0,1> },
{ <0,0,0>, <1,1,0> },
{ <0,0,0>, <0,1,1> }
}
array[3][3] { // the vertex' three faces
{ <0,0,0>, <1,0,1>, <1,1,0> },
{ <0,0,0>, <1,1,0>, <0,1,1> },
{ <0,0,0>, <0,1,1>, <1,0,1> }
}
} // end firse vertex
array[3] ... // second vertex
array[3] ... // third vertex
array[3] ... // fourth vertex
} // end of tetrahedron
Lot of redundancy, but it's just an example. In practice, you'd probably
just put the four vertices in their own array and then fill this larger
array with indices of the vertex list array. You can just keep adding
arrays of arrays of arrays until you get all of the information you need
for whatever you're doing. This is one way I've done it. This is cool in
a way and how I did the temple, but I'll probably go back to dozens of
small arrays in the future. Dozens of smaller arrays makes for cleaner
looking code IMO.
Something like:
#local aTetVertLocations = array[4] ...
#local aTetVertEdges = array[4][2] ...
#local aTetVertFaces = array[4][3] ...
-Shay
Post a reply to this message
|
![](/i/fill.gif) |