The simplest method of modelling objects is to use primitives such as lines and polygons. In the following, M is the desired transformation matrix which transforms points (2D or 3D) to pixel coordinates. for each vertex i new_vertex_list[i] = M * vertex_list[i] scanconvert( new_vertex_list )Here is the equivalent in OpenGL:. glBegin(GL_POLYGON); for each vertex i glVertex3fv( vertex_list[i] ); glEnd();There are several things to note:
glMatrixMode( GL_MODELVIEW ); glLoadIdentity(); glTranslatef(2.0, 1.0, 0.0); glRotatef( -3.14/2.0, 0.0, 0.0, 1.0); glScalef(2.0, 2.0, 2.0); ...which produces the matrix M = trans(2,1,0) rot(z,-90) scale(2,2,2) .... Another way of loading M is to use: glMatrixMode( GL_MODELVIEW ); glLoadMatrixf( M ); Transformation HierarchiesConsider building the following model of a hand with one finger::
Now consider draw a hand with three identical fingers. We can create
a more complex scene graph which uses multiple instances of a finger scene
graph, as shown below. Because each of the fingers is defined relative
to the hand coordinate system, a way is needed to restore the hand coordinate
system before beginning to draw each finger. This is done through the pushMatrix()
and popMatrix() function calls.
|
Hosted by Graphics & Media Lab
http://graphics.cs.msu.su |
mailto: Laboratory |