# 3D world -- triangles vs squares

This topic is 2872 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

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

Thanks

##### Share on other sites
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.

##### Share on other sites
Alright, and would triangles be better for collision as well?

##### Share on other sites
I think most physics libs expect triangles, so yes

##### Share on other sites
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

##### Share on other sites
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?

##### Share on other sites
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.

##### Share on other sites
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?

##### Share on other sites

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

##### Share on other sites

[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

• ### Game Developer Survey

We are looking for qualified game developers to participate in a 10-minute online survey. Qualified participants will be offered a \$15 incentive for your time and insights. Click here to start!

• 9
• 11
• 15
• 21
• 26