Hierarchy Hand
Hierarchy Hand
Hierarchy Hand
Hierarchical Modeling
GLUT 3D Models
• Two main categories
– Wireframe Models
– Solid Models
• Basic Shapes
– Cube: glutWireCube( ), glutSolidCube( )
– Cone: glutWireCone( ), glutSolidCone( )
– Sphere, Torus, Tetrahedron
• More advanced shapes
– Octahedron, Dodecahedron, Icosahedron
– Teapot (symbolic)
Basic 3D GLUT Objects
glutWireCube(1.0);
glutWireSphere(0.5,10,10);
glutWireTorus(0.5,1.5,10,10)
glutWireTetrahedron(); glutWireDodecahedron();
glutWireOctahedron(); glutWireIcosahedron();
GLUT Object (Symbolic)
glutWireTeapot(1.0);
GLU Models
• GLUT does not provide a Cylinder object
• GLU provides so called Quadrics objects:
partial disk
disk sphere cylinder
Quadrics
• Algebraic surface
– f(x,y,z) is the sum of polynomials in x, y, z
• Quadric surface
– Algebraic surfaces with a degree up to 2
– Examples: x, y, xy, z², but not xy²
• Quadrics:
– Spheres, disks, cones
– At most 2 intersections with lines
– Approximate quadrics surface by polygons
gluCylinder
Three steps to create a cylinder: sphere, cylinder,
1. Create a GLU quadric object disk, partial disk
GLUquadricObj *p = gluNewQuadric();
2. Set to wire frame mode
gluQuadricDrawStyle(GLU__LINE);
3. Derive a cylinder object from p
gluCylinder(p, base, top, height, slice, stacks);
M=TRS
In OpenGL
• Appropriate transformation set up from the model frame
(frame of symbols) to the world frame
• Apply it to the MODELVIEW matrix BEFORE EXECUTING
the code
Model Æ World
glMatrixMode(GL_MODELVIEW); /* M = T R S */
glLoadIdentity ( );
glTranslatef (....);
glRotatef (...);
glScalef(..);
gluCylinder (.....) /* or other symbol */
Hierarchical Models
Articulated Models
• Rigid parts connected by joints
• [Demo 3D Robot]
a=c
a b c
A B A
a
A
a
A B
A
a
A
B B
A
a a c
b
a=c
A
Making an Arm, step 4
A
AB B
a c a c
A
B A
B
a c
a c
A b
B
a c
a=c
A
a=c
B
b A
a=c
B
a=c
A
Hierarchical Transforms
b
TSR‐βT‐b a=c
Upper arm B A
Lower Arm A
glPushMatrix();
Lower Arm A
__________________
__________________
• Down edges: __________________
• Push, transform, draw __________________
• Up edges: glPopMatrix();
• Pop. glPopMatrix();
20
60
40
5
20
60
Step 2 5
40
body
(transform brake Handle Back Front
w.r.t. default
handle) Wheel Wheel handle
Lower Upper
wheel
Brake Brake
lll
rll
Step 1
• Write functions that draw parts in default location
Step 3
• Code it up: glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glTranslatef(x, y);
torso();
Hands‐on Session
• Download robotSkeleton.cpp from class website
• Complete Steps 1, 2, 3 to draw the robot
• Add Keyboard events to make robot move and
increase/decrease joint angles
• Add a menu that allows selection of individual
joints and manipulation of joint angles (+, ‐)
• Add Idle or Timer events to make robot dance
Summary
• GLUT 3D Models
– Cube, sphere, cone, torus, teapot
– Tetr/oct/dodec/icos ‐‐ ahedron
• GLU Models
– Cylinder, sphere, disk, partial disk
• Hierarchical Modeling
– Transform each object relative to its parent
– Transformation applies to parent and ALL children
– Convenient for static models
– Vital for animations