3D world -- triangles vs squares

Started by
8 comments, last by strongdrink 12 years, 4 months ago
Hello all,

I am creating a 3D game engine, and I am trying to decide if I should use triangles or squares to create the world
My idea was to create the whole world out of small triangles, but group them together into one bigger triangles whenever possible.

I am not sure if this is a good idea, but good article links would be appreciated :D

Thanks
Advertisement
Some years ago a professor told me that they worked with triangles because the graphic cards would split quads to triangles anyway. I dont know if that is still valid. I would go for triangles.
Alright, and would triangles be better for collision as well?
I think most physics libs expect triangles, so yes
Actually no.

There will be times when you need to work with triangles for collision, but your strategy should be to merge them into polygons as much as you can, as testing against an 8-sided convex polygon (for example) will typically be faster than testing against 8 triangles individually.

Quads are very good for collision detection as testing against them is almost as fast as testing against a triangle, so you basically double your speed.

And of course the best-case scenarios will allow you to replace all of those tests with a single primitive test. That is, you have no need to test a bunch of triangles when the object itself is spherical in shape. A single sphere test would eliminate 500 triangle tests.


L. Spiro

I restore Nintendo 64 video-game OST’s into HD! https://www.youtube.com/channel/UCCtX_wedtZ5BoyQBXEhnVZw/playlists?view=1&sort=lad&flow=grid

Ahh I see... What I was thinking about doing is just grouping triangles into bigger triangles, but I didn't think about other shapes... thanks for the tip!
Would it be a good idea to group the triangles into convex shapes (with unlimited points) when say, the map is saved?
I think it's important to note it's a good idea to separate your graphics representation from physics representation.
Take a look at how unreal engine 3 does it (scroll to end of page).
For collision, the more complex primitive you can use, the better but the question is murky at best. I am reasonably sure Bullet does not support "quads" at all, just as they don't support "triangles" explicitly (list of primitives).
When it comes to collision, don't even try using generic polygon soups for collisions, both performance and stability is way worse.

When it comes to graphics, I strongly suggest against anything else than the triangle. There is simply no reason to do more work than strictly necessary.

Previously "Krohm"

Alright, so I suppose bullet would be the best way to go eh?
Yes. the plan was to have physics and graphics all separate, and in the map editor, will be able to edit hitboxes on top of the graphics and such

EDIT:
err.. last question -- would squares be best for graphics? or triangles?

Alright, so I suppose bullet would be the best way to go eh?
Yes. the plan was to have physics and graphics all separate, and in the map editor, will be able to edit hitboxes on top of the graphics and such

EDIT:
err.. last question -- would squares be best for graphics? or triangles?


I would have to agree with the above (the one above yours) reply that triangles are better. Square = 2 right triangles. Also your question is a bit vague, what do you mean by graphics? Usually in computer graphics, graphics are the ins and outs of a pipeline that is responsible for rendering. Rending itself is usually separated into shading and compositing. Do you mean triangles are better for shading or compositing? Further more, even with a pipeline, there are three types "render-er" in general: OpenGL / DirectX, REYES and Ray-tracer. Which one you do you mean? Even with such diversity, triangle is probably your best bet since you really are doing minimal work. I do want to point out that, Ray-tracer usually have the entire scene there during rendering and thus making everything as triangles may not be as efficient. However, on OpenGL / DirectX, each polygons are rendered one at a time and thus triangles may offer the upper hand.

CXD
Youtube:
My Channel

Video Lessons:
Java Programming Lessons

Tutorials Written (Not-Active):
Introduction to A.I.

[quote name='strongdrink' timestamp='1323449749' post='4892240']
Alright, so I suppose bullet would be the best way to go eh?
Yes. the plan was to have physics and graphics all separate, and in the map editor, will be able to edit hitboxes on top of the graphics and such

EDIT:
err.. last question -- would squares be best for graphics? or triangles?


I would have to agree with the above (the one above yours) reply that triangles are better. Square = 2 right triangles. Also your question is a bit vague, what do you mean by graphics? Usually in computer graphics, graphics are the ins and outs of a pipeline that is responsible for rendering. Rending itself is usually separated into shading and compositing. Do you mean triangles are better for shading or compositing? Further more, even with a pipeline, there are three types "render-er" in general: OpenGL / DirectX, REYES and Ray-tracer. Which one you do you mean? Even with such diversity, triangle is probably your best bet since you really are doing minimal work. I do want to point out that, Ray-tracer usually have the entire scene there during rendering and thus making everything as triangles may not be as efficient. However, on OpenGL / DirectX, each polygons are rendered one at a time and thus triangles may offer the upper hand.

CXD
[/quote]

Yes, I meant which would be the best to render with. Alright, thanks everyone, I believe my questions have been answered

This topic is closed to new replies.

Advertisement