Viewing and Modeling Transformations
[ contents ]
Modeling Transformations / Graphic State Attributes

RenderMan

All camera/projection parameters are set between RiBegin() and RiWorldBegin(). Any geometric transformations after RiProjection() and before RiWorldBegin() effect the viewing matrix(camera). You must first clear the current matrix by calling RiIdentity(). After RiWorldBegin() all geometric transformations concern the world and object space.

OpenGL

Most camera/projection parameters are set in the reshape() function after a call to glMatrixMode(GL_PROJECTION) and before a call to glMatrixMode(GL_MODELVIEW). You must first clear the current matrix by calling glLoadIdentity(). After glMatrixMode(GL_MODELVIEW) geometric transformations effect the world and object space.


RiIdentity()

RiIdentity() clears the current transformation. It does not affect any saved transformations. RiIdentity() may be enclosed in a transformation block so that the block's RiTransformEnd() will restore to the pervious transformation. Effectively, it returns the local coordinate system to world space, if used after RiWorldBegin(), or to camera space if used before.

RdLookAt(camerapos, angle, direction)

RdLookAt() is a series of translations and rotations based on the camera's position, camera roll angle, and where the camera is pointing. It essentially translates and rotates the entire world coordinate system, moving the origin away from the virtual camera. angle is given in degrees camerpos and direction are RtPoint structures(three floats x,y,z). RdLookAt() is based on code in the Renderman Companion.

RtPoint position={4.0, 1.0, -3.5};
RtPoint direction={-4.0, -1.0, 3.5};
RtFloat roll = 0;

RdLookAt(camera, angle, direction);

RiTransformBegin()
RiTransformEnd()

RiTransformBegin() saves a copy of the current transformation matrix, and RiTransformEnd() restores it. Transform blocks may be nested.

RiAttributeBegin()
RiAttributeEnd()

RiAttributeBegin() saves the current state of all attributes including the current transformation, and RiAttributeEnd() restores the last set of attributes saved. Anything declared outside the Attribute block isn't effected by any transforms or attribute changes from within the block.

RiTranslate(x, y, z)

Is a geometric transformation specifying that all subsequent surfaces should be spatially transformed for viewing.

RiTranslate(2.0, 0.0, 4.0);

RiRotate(theta, x, y, z)

Is a geometric transformation causing subsequent surfaces to be rotated about a line in space. theta specifies the angle of rotation in degrees. x, y, and z, give a point is three dimensional space, the axis of rotation passes through this point and the coordinate origin. The rotation is left-handed.

RiRotate(45, 0, 0, 1);

RiScale(sx, sy, sz)

Is a geometric transformation causing subsequent surfaces to be scaled by s in the x, y, and z planes.

RiScale(2.0, 10.0, 4.0);

glLoadIdentity()

Sets the currently modifyable matrix to the 4x4 identity matrix. Typically, you call this command after gl_MatrixMode(GL_PROJECTION), before specifying projection or viewing transformations, or after gl_MatrixMode(GL_MODELVIEW) before specifying geometry. Effectively, it returns to transformation matrix to the default(origin).

gluLookAt(eyex, eyey, eyez, centerx, centery, centerz, upx, upy, upz)

Takes a set of arguments which specify the location of the viewpoint(eyex,y,z), define a reference point toward which the camera is aimed(centerx,y,z), and the cameras up direction(upx,y,z).

gluLookat(4.0, 1.0, 3.5, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0);

glPushMatrix()
glPopMatrix()

glPushMatrix() saves a copy of the current transformation matrix, and glPopMatrix() restores it. Push and Pop blocks may be nested.

glTranslate[dfv](x, y, z)

Is a geometric transformation specifying that all subsequent surfaces should be spatially transformed for viewing. The flags d, f, or v specify the type of the arguments passed to glTranslate().

glTranslatef(2.0, 0.0, 4.0);

GLfloat points[3] = {2.0, 0.0, 4.0};
glTranslatefv(points);

glRotate[dfv](theta, x, y, z)

Is a geometric transformation causing subsequent surfaces to be rotated about a line in space. theta specifies the angle of rotation in degrees. x, y, and z,give a point is three dimensional space, the axis of rotation passes through this point and the coordinate origin. The rotation is right-handed.

glRotatef(45, 0, 0, 1.0);

glScale[dfv](sx, sy, sz)

Is a geometric transformation causing subsequent surfaces to be scaled by s in the x, y, and z planes.

glScalef(2.0, 10.0, 4.0);