Projection Transformations (virtual camera)
[ contents ]
Projection Transformations / Graphic State Options

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.


RiFormat(xres, yres, pixelaspectratio)

This sets the total image resolution to xres wide and yres tall in pixels. pixelaspectratio is the aspect ratio of a screen pixel.

RiFormat(640, 480, 1);

RiProjection(type, ...)

This call sets the projection model, it can either be perspective or orthogonal. If perspective is the type, the call looks like this, where fov is the field of view, in degrees.

RiProjection("perspective", RI_FOV, 45, RI_NULL);

RiFrameAspectRatio(frameratio)

This call enforces an aspect ratio for the output frame, independent of the computer display. frameratio is a floating point argument.

RiFrameAspectRatio(1.33);

RiScreenWindow(left, right, bottom, top)

RiScreenWindow() defines a screen window, the boundaries of an image on the image plane. Only what falls inside this crop is rendered. Where left, right, bottom and top are numerical arguments in screen space.

RiScreenWindow(-1, 1, -1, 1);

glViewPort(x, y, (GLsizei)width, (GLsizei)height)

Defines a pixel window into which the final image is mapped. Where x and yare the lower left corner of the viewport, and width and height are the size of the viewport. By default width and height are the actual size of the window.

glViewport(0, 0, 640, 480);

glFrustrum(left, right, bottom, top, near, far)

Creates a matrix for a perspective-view frustrum and multiplies the current matrix by it. The frustrum's viewing volume is defined by the parameters: (left, bottom, -near) and (right, top, -near). near and far give the distances from the viewpoint to the near and far clipping planes. (they should always be positive).

glFrustrum(-2.0, 2.0, 1.5, -1.5, 1.0, 60.0);

*NOTE - glFrustrum is very tricky to master, and you might feel more comfortable using the Utility Library routine gluPerspective().

gluPerspective(fovy, aspectratio, near, far)

Creates a matrix for a symmetric perspective-view frustrum and multiplies the current matrix by it. fovy is the angle of the field of view in the x-z plane in degrees (between 0.0 and 180.0). aspectratio is the aspect ratio of the frame. near and far are the distances between the viewpoint and the clipping planes along the negative Z-axis (they should always be positive).

gluPerspective(45, 1.33, 1.0, 60.0);