In 3d modeling, there is some "triangle count" which determines complexity. I am not sure but I think cubes have 12 triangles or somethong.But I see NONE They have squares, no triangles! Can someone please help me understand what a triangle is?
To expand on @Makogan and @lightxbulb's answers/comments:
There are several reasons for using triangles as the basic primitive.
- (Non-degenerate) triangles are guaranteed to be planar. This means that an individual single triangle cannot obscure itself (in terms of hidden surface removal) and thus cannot form an internal silhouette edge (when being rendered) nor, say, cast a shadow on itself.
This is also means that when scan converting a triangle, for each pixel, each attribute (e.g. depth, texture coordinate, shading) can only take a 'single' value.
They are guaranteed to be convex. Scan converting/filling convex polygons is far simpler than a general polygon filling algorithm
An arbitrary polygonal mesh can always be easily decomposed into triangles
[Update: As @joojaa pointed out, you could still use quads by either
a) Noting that any triangle can be represented as 3 quads by the addition of four more vertices - one at the centre of the triangle and one on each edge). You need to be careful, though, not to introduce T-Junctions. or
b) Using a degenerate quad to create a triangle - i.e. either collapse an edge by repeating a vertex or (but this may have other problems due to precision) making 3 of the vertices collinear Neither seems, to me at least, as particularly attractive].
If you are concerned about the 'cost' in vertices of supplying two triangles to represent your quad, remember that APIs (and HW) have triangle strips/fans/indexed representations which will, in most cases, eliminate the additional vertex overheads. There is thus little point in adding additional hardware to support 'fast' quad rendering as (a) it wouldn't get used much and (b) is extremely unlikely to be the bottleneck in rendering!
Having said all this, the original Series 1 PowerVR graphics chips (eg PCX1 and PCX2) used a lower-level primitive (the half plane) from which N-sided convex polygons (or in fact N-sided polyhedra - e.g a entire cube was, at most, 6 half-planes) could be constructed. IIRC the driver tried to detect if two consecutive triangles actually formed a planar quad and then replaced them with a more efficient representation. Further, for a quad to be "planar" not only was it geometrically flat but the texture coordinates also had to be 'flat'.