0% found this document useful (0 votes)
23 views13 pages

Computer Graphics - Lecture 3

Computer Graphics

Uploaded by

alcinialbob1234
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views13 pages

Computer Graphics - Lecture 3

Computer Graphics

Uploaded by

alcinialbob1234
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 13

Chapter III

Modeling

All class materials including this PowerPoint file are available at


https://github.com/medialab-ku/openGLESbook

Introduction to Computer Graphics with OpenGL ES (J. Han)


Polygon Mesh
▪ Implicit representation vs. explicit representation (in polygon mesh)

▪ The polygon mesh representation is preferred in real-time applications because


the GPU is optimized for processing polygons.
▪ Note that the mesh’s vertices are the points that sample the smooth surface and
therefore the polygon mesh is not an accurate representation but an
approximate one.

Introduction to Computer Graphics with OpenGL ES (J. Han) 3-2


Polygon Mesh (cont’d)
▪ A triangle is the simplest polygon and the triangle mesh is most popularly used.
▪ In a typical closed mesh, the number of triangles is approximately twice the
number of vertices, e.g., given 100 vertices, we have about 200 triangles.

▪ Even though the triangle mesh is far more popular in general, the quad mesh is
often preferred especially for modeling step.

triangle mesh quad mesh

▪ A straightforward method to convert a quad mesh into a triangle mesh is to


split each quad into two triangles.

Introduction to Computer Graphics with OpenGL ES (J. Han) 3-3


Polygon Mesh (cont’d)
▪ The vertex count of a polygon mesh is described as a resolution or level of
detail (LOD).
▪ Tradeoff between accuracy and efficiency: As the resolution increases, the
shape of the mesh becomes closer to the original smooth surface, but the time
needed for processing the mesh also increases.

refinement

simplification

Introduction to Computer Graphics with OpenGL ES (J. Han) 3-4


Polygon Mesh – Non-indexed Representation
▪ The vertices are enumerated in a memory space, named vertex array.
▪ Three vertices are read in linear order to make up a triangle.

▪ It is inefficient because the vertex array contains redundant data.

Introduction to Computer Graphics with OpenGL ES (J. Han) 3-5


Polygon Mesh – Indexed Representation
▪ A better method is using a separate index array.
▪ A vertex appears “only once” in the vertex array.
▪ Three indices per triangle are stored in the index array.

▪ The data stored in the vertex array are not restricted to vertex positions but
include a lot of additional information. (All of these data will be presented one
by one throughout this class.) Therefore, the vertex array storage saved by
removing the duplicate data outweighs the additional storage needed for the
index array.

Introduction to Computer Graphics with OpenGL ES (J. Han) 3-6


Surface Normals
▪ Surface normals play a key role in computer graphics.
▪ Given triangle p1, p2, p3, let v1 denote the vector connecting the first vertex (p1)
and the second (p2). Similarly, the vector connecting the first vertex (p1) and
the third (p3) is denoted by v2. Then, the triangle normal can be computed
using the cross product based on the right-hand rule.

▪ Every normal vector is made to be a unit vector by default.


▪ Note that p1, p2, and p3 are ordered counter-clockwise (CCW).

Introduction to Computer Graphics with OpenGL ES (J. Han) 3-7


Surface Normals (cont’d)
▪ What if the vertices are ordered clockwise (CW), i.e., p1, p3, p2?
▪ The vector connecting the first vertex (p1) and the second (p3) and that
connecting the first vertex (p1) and the third (p2) define the triangle normal.

▪ The normal is in the opposite direction!


▪ The normal direction depends on the vertex order, i.e., whether p1, p2, p3 or
p1, p3, p2.
▪ In computer graphics, surface normals are supposed to point out of the
polyhedron. For this, we need CCW ordering of the vertices, i.e., p1, p2, p3,
instead of p1, p3, p2.

Introduction to Computer Graphics with OpenGL ES (J. Han) 3-8


Surface Normals (cont’d)
▪ In the index array, the vertices are ordered CCW.

Introduction to Computer Graphics with OpenGL ES (J. Han) 3-9


Surface Normals (cont’d)
▪ We have discussed the triangle normals, but more important are the vertex
normals. A normal can be assigned to a vertex such that the vertex normal
approximates the normal of the smooth surface’s point that the vertex samples.

▪ A vertex normal can be defined by averaging the normals of all the triangles
sharing the vertex.

▪ Modeling packages such as 3ds Max do compute vertex normals.


▪ Vertex normals are an indispensable component of the vertex array.

Introduction to Computer Graphics with OpenGL ES (J. Han) 3-10


Export and Import
▪ Polygon meshes and related data created using off-line graphics packages are
stored in files and passed to the run-time 3D application program.
▪ The process of outputting the data in a format suitable for other
applications is called export.
▪ On the other hand, taking such exported data is called import.

export import
application 1 file application 2

▪ For exporting and importing, simple scripts or programs are used. For example,
3ds Max provides MAXScript and an exporter can be written using MAXScript.
▪ In 3ds Max, a lot of file formats are supported for export. Among the popular
is .obj file.

Introduction to Computer Graphics with OpenGL ES (J. Han) 3-11


Export and Import (cont’d)
▪ Consider a low-resolution mesh of a unit sphere.
▪ The sphere surface is uniformly sampled at every 45 degrees such that the
mesh is composed of 26 vertices and 48 triangles.
▪ Shown below are some snippets of the .obj file for the mesh.

Introduction to Computer Graphics with OpenGL ES (J. Han) 3-12


Export and Import (cont’d)
▪ The triangle mesh stored in a file is imported into the vertex and index arrays of
the 3D application.
▪ As the mesh is composed of 48 triangles, the index array has 144 (48 times 3)
elements.

Introduction to Computer Graphics with OpenGL ES (J. Han) 3-13

You might also like