Jump to content

  • Log In with Google      Sign In   
  • Create Account


3D world -- triangles vs squares


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
9 replies to this topic

#1 strongdrink   Members   -  Reputation: 100

Like
0Likes
Like

Posted 30 November 2011 - 01:36 PM

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

Sponsor:

#2 rogerdv   Members   -  Reputation: 161

Like
1Likes
Like

Posted 30 November 2011 - 03:39 PM

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.

#3 strongdrink   Members   -  Reputation: 100

Like
0Likes
Like

Posted 30 November 2011 - 03:50 PM

Alright, and would triangles be better for collision as well?

#4 Triangles-PCT   Members   -  Reputation: 204

Like
0Likes
Like

Posted 30 November 2011 - 03:52 PM

I think most physics libs expect triangles, so yes

#5 L. Spiro   Crossbones+   -  Reputation: 13391

Like
3Likes
Like

Posted 30 November 2011 - 07:41 PM

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
It is amazing how often people try to be unique, and yet they are always trying to make others be like them. - L. Spiro 2011
I spent most of my life learning the courage it takes to go out and get what I want. Now that I have it, I am not sure exactly what it is that I want. - L. Spiro 2013
I went to my local Subway once to find some guy yelling at the staff. When someone finally came to take my order and asked, “May I help you?”, I replied, “Yeah, I’ll have one asshole to go.”
L. Spiro Engine: http://lspiroengine.com
L. Spiro Engine Forums: http://lspiroengine.com/forums

#6 strongdrink   Members   -  Reputation: 100

Like
0Likes
Like

Posted 30 November 2011 - 09:02 PM

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?

#7 Krohm   Crossbones+   -  Reputation: 3064

Like
2Likes
Like

Posted 01 December 2011 - 02:20 AM

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.

#8 strongdrink   Members   -  Reputation: 100

Like
0Likes
Like

Posted 09 December 2011 - 10:55 AM

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?

#9 ChaoSXDemon   Members   -  Reputation: 96

Like
0Likes
Like

Posted 11 December 2011 - 02:17 AM

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.

#10 strongdrink   Members   -  Reputation: 100

Like
0Likes
Like

Posted 11 December 2011 - 02:47 PM


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


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




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS