here is a milkshape3d model, it is drawn using triangles (NOT triangle strips or some variant) but yet somehow the number of vertices is LESS than the number of triangles when it should be more. Am I missing something? Cuz this doesn't make sense.
This is a discussion on can someone explain how this is possible within the Game Programming forums, part of the General Programming Boards category; here is a milkshape3d model, it is drawn using triangles (NOT triangle strips or some variant) but yet somehow the ...
here is a milkshape3d model, it is drawn using triangles (NOT triangle strips or some variant) but yet somehow the number of vertices is LESS than the number of triangles when it should be more. Am I missing something? Cuz this doesn't make sense.
That looks correct to me. Lets take a simple cube for example. This cube has 8 vertices. Each side of the cube has 2 face ( or triangles ). So the 6 sides * 2 faces per side yields 12 triangles. So this is more triangles then vertices too. You are re-using vertices for different faces. Maybe this clears it up.
If you draw the planes inside the cube too, you end up with 12 more triangles, yielding a total of 24 triangles with 8 vertices.
Last edited by Sang-drax : Tomorrow at 02:21 AM. Reason: Time travelling
Yes, but I was strictly speaking of a "simple" model.Originally posted by Sang-drax
If you draw the planes inside the cube too, you end up with 12 more triangles, yielding a total of 24 triangles with 8 vertices.
"...the results are undefined, and we all know what "undefined" means: it means it works during development, it works during testing, and it blows up in your most important customers' faces." --Scott Meyers
That has to be what it is, but what is confusing me is what I said in my first post that has to do with the fact that the application doesn't seem to 'reuse' triangles (which would mean drawing a TRIANGLE_STRIP). Instead it draws straight triangles and I'm re examining how it does it, but i'm sure what you guys said is still somehow correct.That looks correct to me. Lets take a simple cube for example. This cube has 8 vertices. Each side of the cube has 2 face ( or triangles ). So the 6 sides * 2 faces per side yields 12 triangles. So this is more triangles then vertices too. You are re-using vertices for different faces. Maybe this clears it up.
EDIT:
The application draws like this:
loop through all the meshes
loop through each triangle
draw 3 vertices
the only explanation I can see is there is a lot of redraw going on, because it actually draws (numtris * 3) vertices but yet there are only 40 different ones.
Last edited by Shadow12345; 12-26-2002 at 06:19 PM.
well chucky....er i mean shadow, it DOES seem impossible. lol.
Hrm, I use to use MilkShape3D at one time, but I never saw that it doesn't use triangle strips.
Im not sure how you determined the drawing process, perhaps you followed a some methods around till you found a drawVertex method?
It seems very possible and very likely that perhaps the vertex methods checks the vertex list for vertexs that are the same as the one being plotted, and if it is found, then the triangle strip is altered to to use the found vertex already in the buffer, and if not, plots a new and alters the triangle strip.
I would guess he has a pretty complicated method that rearranges triangle strips on the fly (that most likely took a while to write, but very worth the time).
c++->visualc++->directx->opengl->c++;
(it should be realized my posts are all in a light hearted manner. And should not be taken offense to.)
Shadow, it doesn't use strips or fans but it does reuse vertices in memory. While it is true that each vertex has to be passed again for every triangle, the vertex is only stored once in memory and is refered to by a pointer by each face that uses it. That's the whole point of the "weld" function in Milkshape 3D -- if you make 2 different vertices that are in the same location, they are stored as two different vertices, but once you weld them, they become the same vertex.
It doesn't use strips or fans because that would require the program to be re-optimized whenever you added a face, etc. and it would make deleting faces more taxing. Most modeling environments don't optimize with strips or fans -- those are things that are optimized when you export it to another format to be used in a realtime application. Otherwise it makes things much too slow for the program to work with.
EDIT: Just noting that Milkshape 3D 1.6.5 came out at the beginning of December -- might wanna update!
Last edited by Polymorphic OOP; 12-29-2002 at 07:06 AM.
It sounds to me like its using vertex arrays to me, the most efficient means of drawing when the data to be drawn might change.
I highly doubt that is the case -- that would require each vertex to be stored separately for as many times as it is used (this is straight up triangles, remember, no strips or fans). Also, what would happen if you deleted a face in the middle? It would require you to shift everything after it back in the array, which isn't ideal for a real-time modeling application.It sounds to me like its using vertex arrays to me, the most efficient means of drawing when the data to be drawn might change.
EDIT: Not only that, but it would also require the storage of vertex pointers as well to keep track of which vertices are the same and which are just in the same spot, and then, every time you moved a vertex, you'd have to change the values of the coordinates for every single instance of that vertex in the array. It just isn't efficient here to use vertex arrays.
Last edited by Polymorphic OOP; 12-29-2002 at 09:55 AM.