Docsity

3D Modeling - Computer Graphics - Lecture Slides, Slides of Computer Graphics

Partial preview of the text

Download 3D Modeling - Computer Graphics - Lecture Slides and more Slides Computer Graphics in PDF only on Docsity!

Computer Graphics Introduction to 3D Modeling

3D Modeling

n Overview of OpenGL modeling (Hill 5.6)

n Modeling: create 3D model of scene/objects

n OpenGL commands

n Coordinate systems (left hand, right hand, openGL-way) n Basic shapes (cone, cylinder, etc) n Transformations/Matrices n Lighting/Materials n Synthetic camera basics n View volume n Projection

n GLUT models (wireframe/solid)

n Scene Description Language (SDL): 3D file format

Rotation Direction

n Which way is +ve rotation

n Look in –ve direction (into +ve arrow) n CCW is +ve rotation

x

y

z

3D Modeling: GLUT Models

n Two main categories:

n Wireframe Models n Solid Models

n Basic Shapes

n Cylinder: glutWireCylinder( ), glutSolidCylinder( ) n Cone: glutWireCone( ), glutSolidCone( ) n Sphere: glutWireSphere( ), glutSolidSphere( ) n Cube: glutWireCube( ), glutSolidCube( )

n More advanced shapes:

n Newell Teapot: (symbolic) n Dodecahedron, Torus

3D Modeling: GLUT Models

n Glut functions actually

n generate sequence of points that define corresponding shape n centered at 0.

n Without GLUT models:

n Use generating functions n More work!!

n What does it look like?

n Generates a list of points and polygons for simple shapes n Spheres/Cubes/Sphere

Cylinder Algorithm

glBegin(GL_QUADS) For each A = Angles{ glVertex3f(Rcos(A), Rsin(A), 0); glVertex3f(Rcos(A+DA), Rsin(A+DA), 0) glVertex3f(Rcos(A+DA), Rsin(A+DA), H) glVertex3f(Rcos(A), Rsin(a), H) }

// Make Polygon of Top/Bottom of cylinder

OpenGL Matrices

Graphics pipeline: vertices goes through series of operations

OpenGL Matrices/Pipeline

n OpenGL uses 3 matrices (simplified) for geometry:

n Modelview matrix: n Projection matrix: n Viewport matrix:

n Modelview matrix:

n combination of modeling matrix M and Camera transforms V

n Other OpenGL matrices include texture and color matrices

n glMatrixMode command selects matrix mode

n May initialize matrices with glLoadIdentity( )

n glMatrixMode parameters: GL_MODELVIEW,

GL_PROJECTION, GL_TEXTURE, etc

n OpenGL matrix operations are 4x4 matrices

n Graphics card: fast 4x4 multiplier -> tremendous speedup

Projection

n Different types of projections?

n Different view volume shapes n Different visual effects

n Example projections

n Parallel n Perspective

n Parallel is simple

n Will use for this intro, expand later

OpenGL Matrices/Pipeline

n Projection matrix:

n Scales and shifts each vertex in a particular way. n View volume lies inside cube of –1 to 1 n Reverses sense of z: increasing z = increasing depth n Effectively squishes view volume down to cube centered at 1

n Clipping: (in 3D) then eliminates portions outside view volume

n Viewport matrix:

n Maps surviving portion of block (cube) into a 3D viewport n Retains a measure of the depth of a point

Synthetic Camera

n Define:

n Eye position n LookAt point n Up vector (if spinning: confusing)

n Programmer knows scene, chooses:

n eye n lookAt

n Up direction usually set to (0,1,0)

n OpenGL:

n gluLookAt (eye.x, eye.y, eye.z, look.x, look.y, look.z, up.x, up.y, up.z)

Synthetic Camera

Hierarchical Transforms Using OpenGL

n Object dependency description using tree structure

Base

Lower arm

Upper arm

Hammer

Root node

Leaf node

Object position and orientation can be affected by its parent, grand-parent, grand-grand-parent … nodes

Hierarchical representation

is known as Scene Graph

Transformations

n Two ways to specify transformations:

n (1) Absolute transformation: each part of the object is transformed independently relative to the origin

Translate the base by (5,0,0); Translate the lower arm by (5,00); Translate the upper arm by (5,00); …

x z

y