Sign in to follow this  
Followers 0
strongdrink

3D world -- triangles vs squares

9 posts in this topic

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
0

Share this post


Link to post
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.
1

Share this post


Link to post
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
3

Share this post


Link to post
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?
0

Share this post


Link to post
Share on other sites
I think it's important to note it's a [b]good idea[/b] to separate your graphics representation from physics representation.
Take a look at [url="http://udn.epicgames.com/Three/CollisionReference.html"]how unreal engine 3 does it[/url] (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 ([url="http://bulletphysics.org/mediawiki-1.5.8/index.php/Collision_Shapes"]list of primitives[/url]).
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.
2

Share this post


Link to post
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?
0

Share this post


Link to post
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?
[/quote]

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
0

Share this post


Link to post
Share on other sites
[quote name='ChaoSXDemon' timestamp='1323591448' post='4892735']
[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?
[/quote]

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
0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0