Lecture #6: Complex 3D Modeling With Polygon Mesh
Lecture #6: Complex 3D Modeling With Polygon Mesh
Lecture #6: Complex 3D Modeling With Polygon Mesh
Computer Graphics
Lecture #6: Complex 3D Modeling with Polygon Mesh
faces.
Meshes in Modeling
Can be used to create the skin of a solid
object.
Cube Example
Not a solid.... Solid! [Note] some meshes can represent solid or non solid shapes depending on which polygons are shaded in
Simple solids are really just polygon meshes as their faces are polygons (with the exception of real sphere or cone). have created a solid.
Traverse a face counterclockwise as seen from the outside of the object. your left.
Calculating Normals
Why do we need the normals?
Normal tells us which is the outside of the face. The normal is used for calculating how much light falls on the outside surface. The normal determines how smoothly textures are rendered on the surfaces.
Finding Normals #1
Find the cross product using 3 points on the
surface:
However: If the vectors are almost parallel .. the cross product will be small and inaccuracies will occur! The polygon may not be a perfect planar.
n
Finding Normals #2
Using (Martin) Newells method:
mx = !N1 (yi ynext i )(zi + znexti ) i=0 my = !N1 (zi znext i )(xi + xnexti ) i=0
N1 mz = !i=0 (xi xnext i )(yi + ynexti )
Example:
Consider the polygon with vertices Find the normal to this polygon with
Newells method
vertex, and is the index of the next vertex around the face.
OpenGL uses the normals to determine where the outside face of the mesh is, and how to light it.
With Normals
glBegin(GL_QUADS); // Start Drawing Quads // Front Face // Normal pointing towards viewer glNormal3f( 0.0f, 0.0f, 1.0f); glVertex3f(-1.0f, -1.0f, 1.0f); glVertex3f( 1.0f, -1.0f, 1.0f); glVertex3f( 1.0f, 1.0f, 1.0f); glVertex3f(-1.0f, 1.0f, 1.0f); // Back Face // Normal pointing glNormal3f( 0.0f, glVertex3f(-1.0f, glVertex3f(-1.0f, glVertex3f( 1.0f, glVertex3f( 1.0f, glEnd(); away from viewer 0.0f,-1.0f); -1.0f, -1.0f); 1.0f, -1.0f); 1.0f, -1.0f); -1.0f, -1.0f);
Properties of Meshes
Solidity
Connectedness
connected if an unbroken path along polygon edges exists (if nor connected it is more than one object)
Properties of Meshes
Simplicity Planarity
simple, if it is a solid with no holes planar if every face of the object represent a plane: the vertices of each face then lie in a single plane.
Convexity
convex and concave. The mesh represents a convex object if the line connecting any two points within the object lies wholly inside the object.
Drawing Mesh
Polyhedra
A polyhedra is a connected mesh of simple
planar polygons enclosing a nite amount of space.
Simple Polyhedra
A simple polyhedra satises Eulers equation
V E +F = 2
Complex Polyhedra
Eulers formala for complex equation with
holes
V E + F H = 2(C G)
V=24 E=36 F=15 H=3 (number of holes in faces C=1 (number of parts) G=1 (number of through holes)
Schlegel Diagram
A 2D diagram of a 3D polyhedra as seen in
perspective
A Polyhedra Model
A Model is the unfolded representation of a
solid
A prism is a polyhedra that embodies certain symmetries and therefore is quite simple to describe. A prism is dened as a sweep or extrusion of a polygon along a straight line.
Extruded Shapes
Creating Prisms
We take a basic polygon and use it for the top. Then extrude the vertices in some direction for some length.
Example: Arrow
Both the front and back are the same polygon. However, their normals will be in opposite directions.
Example: Tube
A tube can be created by extruding a
polyhedra along a spine.
Tube
But each time the sphere moves, the old sphere is left in the image...
Tubes
By varying the x, y, and z values for the center of the sphere along spiral formulae, we can come up with all kinds of interesting shapes.
Swept surfaces
A swept surface take a simple or complex
2D polygon and rotates it.
Smooth Surfaces
A polygon mesh can also be used to create
smooth surfaces
(Mesh[0][0][0], Mesh[0][0][1],Mesh[0][0][2])
Mesh[i][j][2] = pow(x,2) + pow(y,2); // for x and y between -1 and 1 Mesh[i][j][2] = (sin(3.14*x)/3.14*x + sin(3.14*y)/3.14*y);
200x200 mesh
200x200 bitmap
Step 1:
Applying the bitmap to the mesh:
glBegin(GL_QUADS); glNormal3f(Normals[i][j].x, Normals[i][j].y, Normals[i][j].z); glTexCoord2f(j/(float)Width,i/(float)Height); glVertex3f(Mesh[i][j][0],Mesh[i][j][1],Mesh[i][j][2]);
Step 2:
Shape the table cloth.
ripple: y = cos(z)
Step 3:
Flatten the top
if (Mesh[i][j][1] > 0.5) Mesh[i][j][1] = 0.5; else Mesh[i][j][1] = Mesh[i][j][1];
Step 4:
Add teapot :-)
Remaining Topics
Curves and Surfaces Fractals Terrain Particle System Ray Tracing
Homework:
[self] try reading BMP les with rgbpixmap.h
library
http://www.cs.su.ac.th/~rawitat/classes/graphics/code/rgbpixmap.h
Homework
Penny Follow todays handouts (bycurtainsBaillie-de Byl) and create mesh-based and table-cloth into your scene from previous homework.
create some objects and map the BMP texture onto it.
Tuesday
Assignment #2 :-(
Use your imagination. What can you do with your current ability? Modeling a house on a hill, ... We can walk in, and see some nice dining
table and bed? (and probably replace?) person to 3rd person with a key!