HOME

TheInfoList



OR:

In
computer graphics Computer graphics deals with generating images with the aid of computers. Today, computer graphics is a core technology in digital photography, film, video games, cell phone and computer displays, and many specialized applications. A great deal ...
, a triangle strip is a subset of triangles in a
triangle mesh In computer graphics, a triangle mesh is a type of polygon mesh. It comprises a set of triangles (typically in three dimensions) that are connected by their common edges or vertices. Many graphics software packages and hardware devices can ...
with shared vertices, and is a more memory-efficient method of storing information about the mesh. They are more efficient than un-indexed lists of triangles, but usually equally fast or slower than indexed triangle lists. The primary reason to use triangle strips is to reduce the amount of data needed to create a series of triangles. The number of vertices stored in memory is reduced from to , where is the number of triangles to be drawn. This allows for less use of disk space, as well as making them faster to load into
RAM Ram, ram, or RAM may refer to: Animals * A male sheep * Ram cichlid, a freshwater tropical fish People * Ram (given name) * Ram (surname) * Ram (director) (Ramsubramaniam), an Indian Tamil film director * RAM (musician) (born 1974), Dutch ...
. For example, the four triangles in the diagram, without using triangle strips, would have to be stored and interpreted as four separate triangles: ABC, CBD, CDE, and EDF. However, using a triangle strip, they can be stored simply as a sequence of vertices ABCDEF. This sequence would be decoded as a set of triangles with vertices at ABC, BCD, CDE and DEF - although the exact order that the vertices are read will not be in left-to-right order as this would result in adjacent triangles facing alternating directions.


OpenGL implementation

OpenGL OpenGL (Open Graphics Library) is a cross-language, cross-platform application programming interface (API) for rendering 2D and 3D vector graphics. The API is typically used to interact with a graphics processing unit (GPU), to achieve ha ...
has built-in support for triangle strips. Fixed function OpenGL (deprecated in OpenGL 3.0) has support for triangle strips using immediate mode and the , , and functions. Newer versions support triangle strips using and . To draw a triangle strip using immediate mode OpenGL, must be passed the argument , which notifies OpenGL a triangle strip is about to be drawn. The family of functions specify the coordinates for each vertex in the triangle strip. For more information, consult The OpenGL Redbook. To draw the triangle strip in the diagram using immediate mode OpenGL, the code is as follows: //Vertices below are in Clockwise orientation //Default setting for glFrontFace is Counter-clockwise glFrontFace(GL_CW); glBegin(GL_TRIANGLE_STRIP); glVertex3f( 0.0f, 1.0f, 0.0f ); //vertex 1 glVertex3f( 0.0f, 0.0f, 0.0f ); //vertex 2 glVertex3f( 1.0f, 1.0f, 0.0f ); //vertex 3 glVertex3f( 1.5f, 0.0f, 0.0f ); //vertex 4 glEnd(); Note that only one additional vertex is needed to draw the second triangle. In OpenGL, the order in which the vertices are specified is important so that
surface normal In geometry, a normal is an object such as a line, ray, or vector that is perpendicular to a given object. For example, the normal line to a plane curve at a given point is the (infinite) line perpendicular to the tangent line to the curve ...
s are consistent. Quoting directly from the OpenGL Programming Guide:
GL_TRIANGLE_STRIPDraws a series of triangles (three-sided polygons) using vertices v0, v1, v2, then v2, v1, v3 (note the order), then v2, v3, v4, and so on. The ordering is to ensure that the triangles are all drawn with the same orientation so that the strip can correctly form part of a surface.
It's even clearer within the manual pages:
Draws a connected group of triangles. One triangle is defined for each vertex presented after the first two vertices. For odd , vertices , , and define triangle . For even , vertices , , and define triangle . triangles are drawn.
Note that starts at 1. The above code sample and diagram demonstrate triangles drawn in a clockwise orientation. For those to be considered front-facing, a preceding call to is necessary, which otherwise has an initial value of (meaning that triangles drawn counter-clockwise are front-facing by default). This is significant if and are already active ( by default), because back-facing triangles will be culled, so will not be drawn and will not appear on-screen at all.


Properties and construction

It follows from definition that a subsequence of vertices of a triangle strip also represents a triangle strip. However, if this substrip starts at an even (with 1-based counting) vertex, then the resulting triangles will change their orientation. For example a substrip BCDEF would represent triangles: BCD,CED,DEF. Similarly, reversal of strips’ vertices will result in the same set of triangles if the strip has an even number of vertices. (e.g. strip FEDCBA will represent the same triangles FED,ECD,DCB,CAB as the original strip). However, if a strip has an odd number of vertices then the reversed strip will represent triangles with opposite orientation. For example, reversal of a strip ABCDE will result in strip EDCBA which represents triangles EDC, DBC, CBA). Converting a general
polygon mesh In 3D computer graphics and solid modeling, a polygon mesh is a collection of , s and s that defines the shape of a polyhedral object. The faces usually consist of triangles ( triangle mesh), quadrilaterals (quads), or other simple convex ...
to a single long strip was until recently generally not possible. Usually the triangle strips are analogous to a set of edge loops, and poles on the model are represented by
triangle fan frame, Set of connected triangles described by vertices A through F. A triangle fan is a primitive in 3D computer graphics that saves on storage and processing time. It describes a set of connected triangles that share one central vertex (unlike ...
s. Tools such as
Stripe Stripe, striped, or stripes may refer to: Decorations * Stripe (pattern), a line or band that differs in colour or tone from an adjacent surface * Racing stripe, a vehicle decoration * Service stripe, a decoration of the U.S. military Entertainme ...
or FTSG represent the model as several strips. Optimally grouping a set of triangles into sequential strips has been proven
NP-complete In computational complexity theory, a problem is NP-complete when: # it is a problem for which the correctness of each solution can be verified quickly (namely, in polynomial time) and a brute-force search algorithm can find a solution by tryin ...
.Regina Estkowski, Joseph S. B. Mitchell, Xinyu Xiang. Optimal decomposition of polygonal models into triangle strips. In Proceedings of Symposium on Computational Geometry'2002. pp.254~263 url=http://www.ams.sunysb.edu/~jsbm/papers/p151-mitchell.pdf url=http://portal.acm.org/citation.cfm?id=513431 Alternatively, a complete object can be described as a degenerate strip, which contains zero-area triangles that the processing software or hardware will discard. The degenerate triangles effectively introduce discontinuities or "jumps" to the strip. For example, the mesh in the diagram could also be represented as ABCDDFFEDC, which would be interpreted as triangles ABC CBD ''CDD DDF DFF FFE'' FED DEC (degenerate triangles marked with italics). Notice how this strip first builds two triangles from the left, then restarts and builds the remaining two from the right. While discontinuities in triangle strips can always be implemented by resending vertices, APIs sometimes explicitly support this feature. IRIS GL supported Swaps (flipping two subsequent vertices in a strip), a feature relied on by early algorithms such as the SGI algorithm. Recently OpenGL/DirectX can render multiple triangle strips without degenerated triangles using Primitive Restart feature.


References

{{Reflist


See also

*
Triangle A triangle is a polygon with three edges and three vertices. It is one of the basic shapes in geometry. A triangle with vertices ''A'', ''B'', and ''C'' is denoted \triangle ABC. In Euclidean geometry, any three points, when non- colli ...
*
Triangle fan frame, Set of connected triangles described by vertices A through F. A triangle fan is a primitive in 3D computer graphics that saves on storage and processing time. It describes a set of connected triangles that share one central vertex (unlike ...
*
Computer graphics Computer graphics deals with generating images with the aid of computers. Today, computer graphics is a core technology in digital photography, film, video games, cell phone and computer displays, and many specialized applications. A great deal ...
*
Graphics cards A graphics card (also called a video card, display card, graphics adapter, VGA card/VGA, video adapter, display adapter, or mistakenly GPU) is an expansion card which generates a feed of output images to a display device, such as a computer mon ...
*
Optimization (computer science) In computer science, program optimization, code optimization, or software optimization, is the process of modifying a software system to make some aspect of it work more efficiently or use fewer resources. In general, a computer program may be o ...
Computer graphics Triangle geometry