Miscellaneous functions


Functions

double cugl::radians (double angle)
double cugl::degrees (double angle)
void cugl::triStripNormals (Point points[], Vector normals[], int numPoints, bool neg=false)
void cugl::revolve (int numSteps, GLfloat coor[][2], int numSlices, bool drawNormals=false)
void cugl::lookAt (Point eye)
void cugl::lookAt (Point eye, Point model)
void cugl::lookAt (Point eye, Point model, Vector up)

Function Documentation

double cugl::degrees ( double  angle  )  [inline]

Convert radians to degrees.

Definition at line 2178 of file cugl.h.

References cugl::PI.

void cugl::lookAt ( Point  eye,
Point  model,
Vector  up 
) [inline]

Call gluLookAt().

Parameters:
eye is the position of the viewer's eye in model coordinates.
model is the point at the centre of the view in model coordinates.
up is a vector giving the upwards direction in the model.

Definition at line 2270 of file cugl.h.

void cugl::lookAt ( Point  eye,
Point  model 
) [inline]

Call gluLookAt() with 'up' vector (0,1,0).

Parameters:
eye is the position of the viewer's eye in model coordinates.
model is the point at the centre of the view in model coordinates.

Definition at line 2254 of file cugl.h.

void cugl::lookAt ( Point  eye  )  [inline]

Call gluLookAt() looking at the origin of the model (0,0,0) with 'up' vector (0,1,0).

Parameters:
eye is the position of the viewer's eye.

Definition at line 2239 of file cugl.h.

double cugl::radians ( double  angle  )  [inline]

Convert degrees to radians.

Definition at line 2170 of file cugl.h.

References cugl::PI.

void cugl::revolve ( int  numSteps,
GLfloat  coor[][2],
int  numSlices,
bool  drawNormals = false 
)

Constructs a surface of revolution. Constructs and renders a surface of revolution obtained by rotating a curve about the Y axis.

Parameters:
numSteps is the number of points in the array coor
coor is the 2D coordinates of points of the profile
numSlices is the number of pie-shaped slices used to render the surface.
drawNormals determines whether normals are generated. By default, normals are not generated.
For example, if numSlices = 20, points will be constructed at 360/20 = 18 degree intervals.

This function constructs an array of points in 3D space and then issues calls to glVertex(). If drawNormals is true, it also issues calls to glNormal(). The effect of these calls is to define a 3D mesh. It is up to the caller to set the OpenGL state for rendering: this includes setting material properties and defining rules for polygon shading.

The normals generated by revolve() are obtained by averaging the normals of the polygons that meet at each vertex. Consequently, if GL_SMOOTH shading is used and enough points are specified, the object should look fairly smooth.

Note:
This function has been replaced by class Revolute, which provides more functionality and is more efficient.

void cugl::triStripNormals ( Point  points[],
Vector  normals[],
int  numPoints,
bool  neg = false 
)

Construct normals for OpenGL triangle strips. Given a set of vertexes definining a triangle strip in OpenGL format, this functions constructs a normal corresponding to each vertex.

Parameters:
points is an array of points giving the vertex coordinates.
normals is an array of vectors in which the vertex normals will be stored.
numPoints is the number of vertexes provided and the number of normals that will be calculated.
neg specifies negated normals, if true. The default is false.
Note:
To avoid allocation and deallocation overhead, this function uses a a fixed amount of workspace that allows up to 100 vertexes to be processed. If numPoints > 100, the function will have no effect.

For efficiency, it is better to compute the normals during initialization rather than each time the model is displayed.


Generated on Wed Sep 12 14:31:41 2007 for CUGL by  doxygen 1.5.2