Daniel K
Computer science MSc
DanielKahsu317@gmail.
com
Chapter 5
Representing 3D Objects
Contents
Representing 3D Objects
Modeling Using Polygons
Techniques for Creating Representational Polygon Meshes
Non-Polygonal representations
2
3D Object
Representation
3D object representation is divided into two categories:
1. Boundary Representations (B-reps)
It describes a 3D object as a set of surfaces that separates the object interior from
the environment.
2. Space–partitioning representations
It is used to describe interior properties, by partitioning the spatial region containing
an object into a set of small, non-overlapping, contiguous solids (usually cubes).
3
Modeling Using
Polygons
Polygon Surfaces
Objects are represented as a collection of surfaces.
The most commonly used boundary representation for a 3D graphics object is a
set of surface polygons that enclose the object interior.
Many graphics system use this method.
Set of polygons are stored for object description.
This simplifies and speeds up the surface rendering and display of object since
all surfaces can be described with linear equations.
The polygon surfaces are common in design and solid-modeling applications,
since their wireframe display can be done quickly to give general indication of
surface structure.
4
Cont'd
Then realistic scenes are produced by interpolating
shading patterns across polygon surface to illuminate.
Three ways to represent polygon surfaces:
1. Polygon Tables
2. Plane Equations
3. Polygon Meshes
5
Cont'd…
Returns GL_TRUE or GL_FALSE, depending on whether or not the
queried capability is currently activated.
6
Cont'd…
Polygon Tables
The object is store by using three
tables:
i. Vertex Table
ii. Edge Table
iii. Polygon-Surface Table
i.Vertex Table
It store x, y, and z coordinate
information of all the vertices as
v 1 : x 1 , y 1 , z1 .
7
Cont'd…
ii. Edge Table
The Edge table is used to store the edge information of
polygon.
In the following figure, edge E1 lies between vertex v1 and
v2 which is represented in the table as E1: v1, v2.
8
Cont'd…
iii. Polygon-Surface Table
Polygon surface table stores the number of surfaces present
in the polygon.
From the following figure, surface S1 is covered by edges E1,
E2 and E3 which can be represented in the polygon surface
table as S1: E1, E2, and E3.
9
Cont'd…
2. Plane Equations
The equation for plane surface can be expressed as:
Ax + By + Cz + D = 0
Where (x, y, z) is any point on the plane, and the coefficients A, B,
C, and D are constants describing the spatial properties of the
plane.
We can obtain the values of A, B, C, and D by solving a set of
three plane equations.
Let us assume that three vertices of the plane are (x1, y1, z1), (x2,
y2, z2) and (x3, y3, z3).
10
Cont'd…
Let us solve the following simultaneous equations for ratios A/D,
B/D, and C/D.
You get the values of A, B, C, and D.
(A/D) x1 + (B/D) y1 + (C/D) z1 = -1
(A/D) x2 + (B/D) y2 + (C/D) z2 = -1
(A/D) x3 + (B/D) y3 + (C/D) z3 = -1
To obtain the above equations in determinant form, apply
Cramer’s rule to the above equations.
11
Cont'd…
For any point x, y, z with parameters A, B, C, and D, we can say
that:
Ax + By + Cz + D ≠ 0 means the point is not on the plane.
Ax + By + Cz + D < 0 means the point is inside the surface.
Ax + By + Cz + D > 0 means the point is outside the surface.
3.Polygon Meshes
3D surfaces and solids can be approximated by a set of polygonal
and line elements.
Such surfaces are called polygonal meshes.
In polygon mesh, each edge is shared by at most two polygons.
The set of polygons or faces, together form the “skin” of the
object.
12
Cont'd…
This method can be used to represent a broad class of
solids/surfaces in graphics.
A polygonal mesh can be rendered using hidden surface
removal algorithms.
The polygon mesh can be represented by three ways:
Explicit representation
Pointers to a vertex list
Pointers to an edge list
13
Cont'd…
Advantages
It can be used to model almost any object.
They are easy to represent as a collection of vertices.
They are easy to transform.
They are easy to draw on computer screen.
Disadvantages
Curved surfaces can only be approximately described.
It is difficult to simulate some type of objects like hair or liquid.
14
Techniques for Creating Representational
Polygon Meshes
A polygonal mesh is a surface that is constructed out of a set of
polygons that are joined together by common edges.
A polygon mesh is a collection of vertices, edges and faces that
define the shape of a polyhedral object in 3D computer graphics and
solid modelling.
Polygon meshes may be represented in a variety of ways, using
different methods to store the vertex, edge and face data.
These include:
3. Winged-edge
1. Vertex-vertex meshes
meshes
2. Face-vertex meshes
4. Render dynamic
meshes
15
Cont'd
…
1. Vertex-vertex meshes(VV)
Represent an object as a set of vertices connected to other
vertices.
16
Cont'd
…
2. Face-vertex meshes
Represent an object as a set of faces and a set of vertices.
17
Cont'd…
3. Winged-edge meshes
Render Dynamic Mesh, which explicitly stores both the vertices of a face and
face of a vertex( like Face Vertices Meshes ) and the faces and vertices of an
edge.
Introduce by Baumgart 1975, winged-edge meshes explicitly represent the
vertices, faces, and edges of a mesh.
This representation is widely used in modeling programs to provide the greatest
flexibility in dynamically changing the mesh geometry, because split and merge
operations can be done quickly.
18
Cont'd…
The actual collection of pixels on the screen which are drawn for
various point widths depends on whether antialiasing is enabled.
Antialiasing is a technique for smoothing points and lines as they are
rendered.
If antialiasing is disabled (the default), fractional widths are rounded to
integer widths, and a screen−aligned square region of pixels is drawn.
Thus, if the width is 1.0,the square is 1 pixel by 1 pixel;
If the width is 2.0, the square is 2 pixels by 2 pixels, and so on.
With antialiasing enabled, a circular group of pixels is drawn, and the
pixels on the boundaries are typically drawn at less than full intensity
to give the edge a smoother appearance.
In this mode, non−integer widths aren’t rounded.
19
Cont'd…
Most OpenGL implementations support very large point sizes.
You can query the minimum and maximum sized for aliased points by
using glGetFloatv(GL_ALIASED_POINT_SIZE_RANGE, size)
Likewise, you can obtain the range of supported sizes for antialiased
points by passing GL_SMOOTH_POINT_SIZE_RANGE to glGetFloatv().
The sizes of supported antialiased points are evenly spaced
between the minimum and maximum sizes for the range.
Calling GetFloatv() with the parameter
GL_SMOOTH_POINT_SIZE_GRANULARITY
will return how accurately a given antialiased point size is
supported.
20
Cont'd…
For example, if you request glPointSize(2.37) and the
granularity returned is 0.1, then the point size is rounded to
2.4.
2.Line Details
With OpenGL, you can specify lines with different widths and
lines that are stippled in various ways:
dotted
dashed
drawn with alternating dots and dashes,
and so on.
21
Cont'd…
Wide Lines
void glLineWidth(GLfloat width);
Sets the width, in pixels, for rendered lines; width must be greater
than 0.0 and by default is 1.0.
The actual rendering of lines is affected if either antialiasing or
multisampling is enabled.
Without antialiasing, widths of 1, 2, and 3 draw lines 1, 2, and 3
pixels wide.
With antialiasing enabled, no-integer line widths are possible without
antialiasing, widths of 1, 2, and 3 draw lines 1, 2, and 3 pixels wide.
With antialiasing enabled, non-integer line widths are possible, and
pixels on the boundaries are typically drawn at less than full intensity.
22
Cont'd…
Similar to points you can obtain the range of supported aliased line
widths by using GL_ALIASED_LINE_WIDTH_RANGE with glGetFloatv().
To determine the supported minimum and maximum sizes of antialiased
line widths, and what granularity your implementation supports,
call glGetFloatv(),
with GL_SMOOTH_LINE_WIDTH_RANGE and
GL_SMOOTH_LINE_WIDTH_GRANULARITY.
Stippled Lines
To make stippled (dotted or dashed) lines, you use the
command glLineStipple() to define the stipple pattern,
and then you enable line stippling with
glEnable(GL_LINE_STIPPLE).
23
Cont'd…
To make stippled (dotted or dashed) lines, you use the command
glLineStipple() to define the stipple pattern, and then you enable
line stippling with glEnable(GL_LINE_STIPPLE).
void glLineStipple(GLint factor, GLushort pattern);
Sets the current stippling pattern for lines.
The pattern argument is a 16-bit series of 0s and 1s, and it’s repeated
as necessary to stipple a given line.
A 1 indicates that drawing occurs, and a 0 that it does not, on a pixel-
by-pixel basis, beginning with the low-order bit of the pattern.
The pattern can be stretched out by using factor.
24
Non-Polygonal Representations
1. Wireframe
A wireframe is a three-dimensional model that only includes
vertices and lines.
It does not contain surfaces, textures, or lighting like a 3D
mesh.
Instead, a wireframe model is a 3D image comprised of only
"wires" that represent three-dimensional shapes.
A wire-frame model is a visual presentation of a 3-
dimensional (3D) or physical object used in 3D computer
graphics.
25
Cont'd…
Wireframes provide the most basic representation of a three-
dimensional scene or object.
They are often used as the starting point in 3D modeling since they
create a "frame" for 3D structures.
For example, a 3D graphic designer can create a model from scratch
by simply defining points (vertices) and connecting them with lines
(paths).
Once the shape is created, surfaces or textures can be added to
make the model appear more realistic.
26
Cont'd…
3. Dereferencing and Rendering
In Step 3, contents of the arrays are obtained, sent to the server, and
then sent down the graphics processing pipeline for rendering.
Dereferencing a Single Array Element:
void glArrayElement(GLint ith)
Obtains the data of one (the ith) vertex for all currently enabled arrays.
For the vertex coordinate array, the corresponding command would be
glVertex[size][type]v(), where size is one of [2, 3, 4], and type is one of
[s,i,f,d] for GLshort, GLint, GLfloat, and GLdouble, respectively.
Both size and type were defined by glVertexPointer().
For other enabled arrays, glArrayElement() calls glEdgeFlagv(),
glTexCoord[size][type]v(), glColor[size][type]v(),
glSecondaryColor3[type]v(), glIndex[type]v(), glNormal3[type]v(), and
glFogCoord[type]v().
glArrayElement()
27
is usually called between glBegin() and glEnd().
Cont'd…
Example Using glArrayElement() to Define Colors and
Vertices:
glEnableClientState(GL_COLOR_ARRAY);
glEnableClientState(GL_VERTEX_ARRAY);
glColorPointer(3, GL_FLOAT, 0, colors);
glVertexPointer(2, GL_INT, 0, vertices);
glBegin(GL_TRIANGLES);
glArrayElement(2);
glArrayElement(3);
glArrayElement(5);
glEnd();
28
29