Thread: can someone explain how this is possible

  1. #1
    Shadow12345
    Guest

    can someone explain how this is possible

    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.

  2. #2
    Registered User
    Join Date
    Apr 2002
    Posts
    1,571
    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.

  3. #3
    S Sang-drax's Avatar
    Join Date
    May 2002
    Location
    Göteborg, Sweden
    Posts
    2,072
    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

  4. #4
    Registered User
    Join Date
    Apr 2002
    Posts
    1,571
    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.
    Yes, but I was strictly speaking of a "simple" model.
    "...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

  5. #5
    Shadow12345
    Guest
    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.
    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.

    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 07:19 PM.

  6. #6
    Unregistered Leeman_s's Avatar
    Join Date
    Oct 2001
    Posts
    753
    well chucky....er i mean shadow, it DOES seem impossible. lol.

  7. #7
    mov.w #$1337,D0 Jeremy G's Avatar
    Join Date
    Nov 2001
    Posts
    704
    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.)

  8. #8
    Programming Sex-God Polymorphic OOP's Avatar
    Join Date
    Nov 2002
    Posts
    1,078
    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 08:06 AM.

  9. #9
    Registered User
    Join Date
    Aug 2001
    Posts
    411
    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.

  10. #10
    Programming Sex-God Polymorphic OOP's Avatar
    Join Date
    Nov 2002
    Posts
    1,078

    Thumbs down

    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.

    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 10:55 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Can you explain these bitwise operations?
    By 6tr6tr in forum C++ Programming
    Replies: 6
    Last Post: 10-29-2008, 01:19 PM
  2. Please explain?
    By neo_phyte in forum C Programming
    Replies: 3
    Last Post: 08-25-2006, 05:23 AM
  3. Can someone explain to me what this code means
    By Shadow12345 in forum C++ Programming
    Replies: 3
    Last Post: 12-22-2002, 12:36 PM
  4. Replies: 4
    Last Post: 11-19-2002, 09:18 PM
  5. Can someone explain "extern" to me?
    By valar_king in forum C++ Programming
    Replies: 3
    Last Post: 09-16-2001, 12:22 AM