Triangles vs pyramids...

I'm a really RAW recruit into the gaming world. I'm by profession a VB6/Oracle/ programmer and haven't ever looked further than that until now. I'm teaching myself C# using the excellent Microsoft Visual C# .Net Express Edition and have started on the 101 webcasts for 2d games, and it's slow heavy going for my non-oo, database-centric brain to get hold of, but I'll get there .. in the end ...

So, my question, or rather observation, regards something probably a little more low level than DirectX. But if you're here you're probably the right type of people to discuss it with.

In my limited understanding of 3d rendering nowadays everything is done with triangles. So, I'm guessing, every triangle is created by three sets of coordinates:

PointA [x,y,z]
PointB [x,y,z]
PointC [x,y,z]

And that lets you render a texture on it's face.

Would it not be better and more efficient to provide 4 sets of coordinates Thus creating a tringular pyramid.

Using the "triangle theory" you would have to provide 3 or 4 seperate triangles to create a pyramid (the fourth face would be implicit .. ie, the hole .. although you may actually have to provide the triangle coordinates to render a texture onto it). By providing 4 points you could, (surely!) cut down on a lot of processing.

An added bonus would be that if all four coordinates fell on the same plane... ie creating a 2d triangle with one point in the middle you would have the means of rendering 3 triangles (it's damned hard to explain this without a picture!!!!) within a triangle with, possibly 3 different textures .. again saving processor power....

These may just be the ravings of an ignorant, uninformed newbie .... and probably are! But it's been bugging me since I started out!

Thanks for listening! Elton Hurrell




Answer this question

Triangles vs pyramids...

  • Andreas H

    What you describe (generally) is the well-understood concept of shared vertices.
    Just about any book aimed at beginning level programming (Frank Luna's book, my book, etc) will give you a simple introduction to this concept. You might also want to look for introductory articles on GameDev.net


  • Hadi Eskandari

    Thanks all (especially Beric)..

  • Paul Vacarescu

    The reason behind using triangles is because most of the processing power is required to handle the surfaces, not store the vertex information. While drawing the pyramid in your example the rendering engine (in this case DirectX) would still actually need to render 3 or 4 triangles (depending on whether you were rendering the base). Plus the depth calculations (to see which triangle is obscured by other surfaces etc) would still need to be done per triangle. There would also potentially be additional processing for faces of the pyramid which were facing away from the camera. There are also a bunch of other issues.

    Triangles are actually very well suited for building more complex shapes if the vertex buffer is built as a triangle list or triangle fan. For example if you want a flat square, you can actually describe it in a triangle strip with only 4 verticies (which creates two triangles).

    In the pyramid example it is actually fairly complex mathematics to determine if all four verticies lie on the same plane.

    I hope that description works. (I often understand things in my head, but my mouth sometimes has difficulty :-)



  • Kishore M N

    what he said... look up 'index buffers' in DirectX for how it is implemented in practise.

  • Triangles vs pyramids...