CUGL  2.0
Classes | Typedefs | Enumerations | Functions | Variables
cugl Namespace Reference

Classes

class  Point
 
class  Line
 
class  Plane
 
class  Vector
 
class  Matrix
 
class  Quaternion
 
class  BaseCamera
 
class  Camera
 
class  Interpolator
 
class  PixelMap
 
class  Revolute
 

Typedefs

typedef GLfloat GL_Matrix[4][4]
 
typedef GLfloat * GLfloatArray
 

Enumerations

enum  CUGLErrorType {
  NO_ERROR = 0 , BAD_INDEX , BAD_MATRIX_MODE , BAD_ROTATION_MATRIX ,
  SINGULAR_MATRIX , ZERO_DIVISOR , ZERO_NORM , BAD_INTERPOLATOR_ARG ,
  OPEN_FAILED , NOT_BMP_FILE , NOT_24_BITS , COMPRESSED_BMP_FILE ,
  NOT_ENOUGH_MEMORY , NO_PIX_MAP , BAD_PLANE , BAD_LINE ,
  TOO_MANY_MATERIALS , TOO_MANY_POINTS
}
 
enum  MATERIAL {
  BLACK , WHITE , RED , GREEN ,
  BLUE , METAL , GLASS , BRASS ,
  BRONZE , POLISHED_BRONZE , CHROME , COPPER ,
  POLISHED_COPPER , GOLD , POLISHED_GOLD , PEWTER ,
  SILVER , POLISHED_SILVER , EMERALD , JADE ,
  OBSIDIAN , PEARL , RUBY , TURQUOISE ,
  BLACK_PLASTIC , BLACK_RUBBER , LAST_VALUE
}
 

Functions

CUGLErrorType getError ()
 
const char * getErrorString (CUGLErrorType err)
 
void checkCUGLStatus ()
 
void checkOpenGLStatus ()
 
const Vector I (1, 0, 0)
 
const Vector J (0, 1, 0)
 
const Vector K (0, 0, 1)
 
double radians (double angle)
 
double degrees (double angle)
 
double sqr (double x)
 
unsigned int randInt (unsigned int max)
 
int randSym (unsigned int max)
 
double randReal ()
 
void triStripNormals (Point points[], Vector normals[], int numPoints, bool neg=false)
 
void revolve (int numSteps, GLfloat coor[][2], int numSlices, bool drawNormals=false)
 
void lookAt (Point eye)
 
void lookAt (Point eye, Point model)
 
void lookAt (Point eye, Point model, Vector up)
 
void axes (GLfloat size=1)
 
void buildPlane (bool shadow=false)
 
GLuint makePlaneList (bool shadow=false)
 
void setMaterial (const int m, GLenum face=GL_FRONT)
 
int addMaterial (GLfloat ambR, GLfloat ambG, GLfloat ambB, GLfloat ambA, GLfloat difR, GLfloat difG, GLfloat difB, GLfloat difA, GLfloat speR, GLfloat speG, GLfloat speB, GLfloat speA, GLfloat shine)
 
int addMaterial (GLfloat params[])
 
Point operator+ (const Point &p, const Vector &v)
 
Point operator+ (const Vector &v, const Point &p)
 
Point operator* (const Point &p, GLfloat s)
 
Point operator* (GLfloat s, const Point &p)
 
bool operator== (const Point &p, const Point &q)
 
bool operator!= (const Point &p, const Point &q)
 
GLfloat dist (const Point &p, const Plane &s)
 
GLfloat dist (const Plane &s, const Point &p)
 
bool operator== (const Line &m, const Line &n)
 
bool operator!= (const Line &m, const Line &n)
 
bool operator== (const Plane &p, const Plane &q)
 
bool operator!= (const Plane &p, const Plane &q)
 
Vector operator- (const Point &p, const Point &q)
 
Vector operator+ (const Vector &u, const Vector &v)
 
Vector operator- (const Vector &u, const Vector &v)
 
Vector operator* (const Vector &v, GLfloat s)
 
Vector operator* (GLfloat s, const Vector &v)
 
Vector cross (const Vector &u, const Vector &v)
 
Vector operator* (const Vector &u, const Vector &v)
 
GLfloat dot (const Vector &u, const Vector &v)
 
bool operator== (const Vector &u, const Vector &v)
 
bool operator!= (const Vector &u, const Vector &v)
 
Matrix operator+ (const Matrix &m, const Matrix &n)
 
Matrix operator- (const Matrix &m, const Matrix &n)
 
Matrix operator* (const Matrix &m, const Matrix &n)
 
bool operator== (const Matrix &m, const Matrix &n)
 
bool operator!= (const Matrix &m, const Matrix &n)
 
Matrix operator* (GLfloat s, const Matrix &m)
 
Matrix operator* (const Matrix &m, GLfloat s)
 
Matrix operator/ (const Matrix &m, GLfloat s)
 
GLfloat dot (const Quaternion &q, const Quaternion &r)
 
Quaternion operator+ (const Quaternion &q, const Quaternion &r)
 
Quaternion operator- (const Quaternion &q, const Quaternion &r)
 
Quaternion operator* (const Quaternion &q, const Quaternion &r)
 
Quaternion operator* (const Vector &v, const Quaternion &q)
 
Quaternion operator* (const Quaternion &q, const Vector &v)
 
Quaternion operator* (const Quaternion &q, GLfloat a)
 
Quaternion operator* (GLfloat a, const Quaternion &q)
 
bool operator== (const Quaternion &q, const Quaternion &r)
 
bool operator!= (const Quaternion &q, const Quaternion &r)
 

Variables

const char version [] = "CUGL V2 2009.11.24"
 
const double PI = 4 * atan(1.0)
 

Detailed Description

Extensions

Todo:

Quaternion += and -=

Matrix operator*=(Matrix) - done

bool isVisible(Point) - harder than it looks

Typedef Documentation

◆ GL_Matrix

typedef GLfloat cugl::GL_Matrix[4][4]

The type of OpenGL projection and model view matrices. It is tempting to write CUGL as a template llibrary, but the fixed type of OpenGL matrices makes this difficult to do effectively.

Definition at line 74 of file cugl.h.

◆ GLfloatArray

typedef GLfloat* cugl::GLfloatArray

The type of an array of GLfloats.

Definition at line 2188 of file cugl.h.

Enumeration Type Documentation

◆ CUGLErrorType

Enumeration values for CUGL function errors.

Enumerator
NO_ERROR 

No error has occurred since the error flag was reset.

BAD_INDEX 

Encountered an invalid array index.

BAD_MATRIX_MODE 

The matrix mode was not GL_PROJECTION or GL_MODELVIEW.

BAD_ROTATION_MATRIX 

The given matrix was not a rotation matrix.

SINGULAR_MATRIX 

The matrix is singular.

ZERO_DIVISOR 

An attempt was made to divide by zero.

ZERO_NORM 

An attempt was made to normalize a null vector.

BAD_INTERPOLATOR_ARG 

The angle between the rotations of the interpolator is zero.

OPEN_FAILED 

The program failed to open a BMP file.

NOT_BMP_FILE 

The file opened was not a BMP file.

NOT_24_BITS 

The BMP file was not in 24-bit format.

COMPRESSED_BMP_FILE 

The BMP file was in compressed form.

NOT_ENOUGH_MEMORY 

There is not enough memory to store the pixel map.

NO_PIX_MAP 

There is no pixel map to draw.

BAD_PLANE 

Parameters do not define a plane.

BAD_LINE 

The line lies in the plane.

TOO_MANY_MATERIALS 

Too many materials.

TOO_MANY_POINTS 

Too many points.

Definition at line 81 of file cugl.h.

◆ MATERIAL

Enumeration for materials.

Enumerator
BLACK 

Black.

WHITE 

White.

RED 

Red.

GREEN 

Green.

BLUE 

Blue.

METAL 

General metallic colour.

GLASS 

General transparent marterial.

BRASS 

Brass.

BRONZE 

Matt bronze.

POLISHED_BRONZE 

Polished bronze.

CHROME 

Chrome.

COPPER 

Matt copper.

POLISHED_COPPER 

Polished copper.

GOLD 

Matt gold.

POLISHED_GOLD 

Polished gold.

PEWTER 

Pewter.

SILVER 

Matt silver.

POLISHED_SILVER 

Polished silver.

EMERALD 

Emerald.

JADE 

Jade.

OBSIDIAN 

Obsidian.

PEARL 

Pearl.

RUBY 

Ruby.

TURQUOISE 

Turquoise.

BLACK_PLASTIC 

Black plastic.

BLACK_RUBBER 

Black rubber.

Definition at line 2515 of file cugl.h.

Function Documentation

◆ addMaterial() [1/2]

int cugl::addMaterial ( GLfloat  ambR,
GLfloat  ambG,
GLfloat  ambB,
GLfloat  ambA,
GLfloat  difR,
GLfloat  difG,
GLfloat  difB,
GLfloat  difA,
GLfloat  speR,
GLfloat  speG,
GLfloat  speB,
GLfloat  speA,
GLfloat  shine 
)

Add a material to the set of built-in materials. The array of material has a fixed size of 100. An attempt to create more than 100 materials will fail. The parameters specify:

  • RGBA values for ambient light
  • RGBA values for diffuse light
  • RGBA values for specular light
  • Value for shininess exponent
    Returns
    the index of the new material.

◆ addMaterial() [2/2]

int cugl::addMaterial ( GLfloat  params[])

Add a material to the set of built-in materials. The array of material has a fixed size of 100. An attempt to create more than 100 materials will fail.

Parameters
paramsspecifies:
  • RGBA values for ambient light
  • RGBA values for diffuse light
  • RGBA values for specular light
  • Value for shininess exponent
Returns
the index of the new material.

◆ axes()

void cugl::axes ( GLfloat  size = 1)
Todo:
Models should probably be put into a separate file.

Draw coordinate axes. This function draws the three principal axes in the current position, using size to determine the length of each axis. The axes are colour-coded: X = red, Y = green, Z = blue.

◆ buildPlane()

void cugl::buildPlane ( bool  shadow = false)

Draw an aircraft. The argument determines whether the plane is drawn with a metallic colour (shadow = false, the default) or black, to act as a shadow (shadow = true). The aircraft is built using Bezier surfaces. If you use glScalef to change its size, you must enable GL_NORMALIZE to correct the normals. Otherwise, the lighting will be wrong.

◆ checkCUGLStatus()

void cugl::checkCUGLStatus ( )

Display a message if an CUGL error has occurred. This function checks the CUGL error status. If no error has occurred, it has no effect. If CUGL has reported an error, this function writes the CUGL error code and the corresponding message to the stream cerr.

Since getError() clears the CUGL error flag, after calling this function CUGL shows no errors.

This function is intended mainly for development and should not normally be included in a production program.

◆ checkOpenGLStatus()

void cugl::checkOpenGLStatus ( )

Display a message if an OpenGL error has occurred. This function checks the OpenGL error status. If no error has occurred, it has no effect. If OpenGL has reported an error, this function writes the OpenGL error code and the corresponding message to the stream cerr.

Since glGetError() clears the OpenGL error flag, after calling this function OpenGL shows no errors.

This function is intended mainly for development and should not normally be included in a production program.

◆ cross()

Vector cugl::cross ( const Vector u,
const Vector v 
)
inline

Return cross product of vectors u and v.

Definition at line 2871 of file cugl.h.

◆ degrees()

double cugl::degrees ( double  angle)
inline

Convert radians to degrees.

Definition at line 2335 of file cugl.h.

References PI.

◆ dist() [1/2]

GLfloat cugl::dist ( const Plane s,
const Point p 
)
inline

Return the distance between a Point and a Plane. The result has the correct magnitude only if the Point and the Plane are both in normal form. In particular, the result is incorrect if the Point is at infinity. However, the sign of the result is correct in all cases, and so it is not necessary to provide normalized arguments if only the sign is important.

Definition at line 2690 of file cugl.h.

◆ dist() [2/2]

GLfloat cugl::dist ( const Point p,
const Plane s 
)
inline

Return the distance between a Point and a Plane. The result has the correct magnitude only if the Point and the Plane are both in normal form. In particular, the result is incorrect if the Point is at infinity. However, the sign of the result is correct in all cases, and so it is not necessary to provide normalized arguments if only the sign is important.

Definition at line 2685 of file cugl.h.

◆ dot() [1/2]

GLfloat cugl::dot ( const Quaternion q,
const Quaternion r 
)
inline

Return the dot product of quaternions q and r. The dot product of (s,u) and (t,v) is st+dot(u,v) where dot(u,v) denotes the vector dot product of u and v.

Returns
the dot product of quaternions q and r.

Definition at line 3231 of file cugl.h.

◆ dot() [2/2]

GLfloat cugl::dot ( const Vector u,
const Vector v 
)
inline

Return dot product of vectors u and v.

Definition at line 2887 of file cugl.h.

◆ getError()

CUGLErrorType cugl::getError ( )

Set code to NO_ERROR and return last error code.

Returns
the most recent error code.

◆ getErrorString()

const char* cugl::getErrorString ( CUGLErrorType  err)

Map error codes to descriptive strings.

Parameters
erris an error code obtained from getError().
Returns
A string describing the eeror.

◆ I()

const Vector cugl::I ( ,
,
 
)

Unit vector parallel to X axis.

◆ J()

const Vector cugl::J ( ,
,
 
)

Unit vector parallel to Y axis.

◆ K()

const Vector cugl::K ( ,
,
 
)

Unit vector parallel to Z axis.

◆ lookAt() [1/3]

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
eyeis the position of the viewer's eye.

Definition at line 2430 of file cugl.h.

◆ lookAt() [2/3]

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

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

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

Definition at line 2445 of file cugl.h.

◆ lookAt() [3/3]

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

Call gluLookAt().

Parameters
eyeis the position of the viewer's eye in model coordinates.
modelis the point at the centre of the view in model coordinates.
upis a vector giving the upwards direction in the model.

Definition at line 2461 of file cugl.h.

◆ makePlaneList()

GLuint cugl::makePlaneList ( bool  shadow = false)

Construct a GL call list for the aircraft and return its index.

◆ operator!=() [1/6]

bool cugl::operator!= ( const Line m,
const Line n 
)
inline

Compare two lines. This function returns false only if corresponding components are exactly equal. Values that are theoretically equal but computed in different ways are likely to be unequal according to this function.

Definition at line 2713 of file cugl.h.

◆ operator!=() [2/6]

bool cugl::operator!= ( const Matrix m,
const Matrix n 
)
inline

Compare two matrices. This function returns false only if corresponding components are exactly equal. Values that are theoretically equal but computed in different ways are likely to be unequal according to this function.

Definition at line 3100 of file cugl.h.

◆ operator!=() [3/6]

bool cugl::operator!= ( const Plane p,
const Plane q 
)
inline

Compare two planes. This function returns false only if corresponding components are exactly equal. Values that are theoretically equal but computed in different ways are likely to be unequal according to this function.

Definition at line 2734 of file cugl.h.

◆ operator!=() [4/6]

bool cugl::operator!= ( const Point p,
const Point q 
)
inline

Compare two points. This function returns false only if corresponding components are exactly equal. Values that are theoretically equal but computed in different ways are likely to be unequal according to this function.

Definition at line 2680 of file cugl.h.

◆ operator!=() [5/6]

bool cugl::operator!= ( const Quaternion q,
const Quaternion r 
)
inline

Compare two quaternions. This function returns false only if corresponding components are exactly equal. Values that are theoretically equal but computed in different ways are likely to be unequal according to this function.

Definition at line 3308 of file cugl.h.

◆ operator!=() [6/6]

bool cugl::operator!= ( const Vector u,
const Vector v 
)
inline

Compare two vectors. This function returns false only if corresponding components are exactly equal. Values that are theoretically equal but computed in different ways are likely to be unequal according to this function.

Definition at line 2897 of file cugl.h.

◆ operator*() [1/13]

Matrix cugl::operator* ( const Matrix m,
const Matrix n 
)
inline

Multiply two matrices.

Definition at line 3069 of file cugl.h.

◆ operator*() [2/13]

Matrix cugl::operator* ( const Matrix m,
GLfloat  s 
)
inline

Multiply matrix and scalar.

Definition at line 3118 of file cugl.h.

◆ operator*() [3/13]

Point cugl::operator* ( const Point p,
GLfloat  s 
)
inline

Scale a point.

Returns
Point at (p.x + p.w*v.x, p.y + p.w*v.y, p.z + p.w*v.z).

Definition at line 2665 of file cugl.h.

◆ operator*() [4/13]

Quaternion cugl::operator* ( const Quaternion q,
const Quaternion r 
)
inline

Return the quaternion product q*r. If q and r represent rotations, then q*r represents the rotation q followed by the rotation r.

Note
Quaternion multiplication is not commutative: q*r is not equal to r*q.
Returns
the Quaternion product q*r.

Definition at line 3246 of file cugl.h.

◆ operator*() [5/13]

Quaternion cugl::operator* ( const Quaternion q,
const Vector v 
)
inline

Promote the vector v to a quaternion qv and return the quaternion product q*qv.

Definition at line 3268 of file cugl.h.

◆ operator*() [6/13]

Quaternion cugl::operator* ( const Quaternion q,
GLfloat  a 
)
inline

Return the quaternion a*q, where a is a scalar. a is a scalar and a*(s,v) = (a*s, a*v).

Returns
the Quaternion a*q.

Definition at line 3293 of file cugl.h.

◆ operator*() [7/13]

Vector cugl::operator* ( const Vector u,
const Vector v 
)
inline

Return cross product of vectors u and v.

Definition at line 2879 of file cugl.h.

◆ operator*() [8/13]

Quaternion cugl::operator* ( const Vector v,
const Quaternion q 
)
inline

Promote the vector v to a quaternion qv and return the quaternion product qv*q.

Definition at line 3257 of file cugl.h.

◆ operator*() [9/13]

Vector cugl::operator* ( const Vector v,
GLfloat  s 
)
inline

Return Vector s*v.

Definition at line 2861 of file cugl.h.

◆ operator*() [10/13]

Quaternion cugl::operator* ( GLfloat  a,
const Quaternion q 
)
inline

Return the quaternion a*q, where a is a scalar. a is a scalar and a*(s,v) = (a*s, a*v).

Returns
the Quaternion a*q.

Definition at line 3298 of file cugl.h.

◆ operator*() [11/13]

Matrix cugl::operator* ( GLfloat  s,
const Matrix m 
)
inline

Multiply scalar and matrix.

Definition at line 3109 of file cugl.h.

◆ operator*() [12/13]

Point cugl::operator* ( GLfloat  s,
const Point p 
)
inline

Scale a point. Multiply each of the components of the Point by s. In homogeneous coordinates, this operation does not change the `‘position’' of the Point. However, it may be used, for example, to normalize a Point.

Returns
The scaled Point.

Definition at line 2670 of file cugl.h.

◆ operator*() [13/13]

Vector cugl::operator* ( GLfloat  s,
const Vector v 
)
inline

Return Vector s*v.

Definition at line 2866 of file cugl.h.

◆ operator+() [1/5]

Matrix cugl::operator+ ( const Matrix m,
const Matrix n 
)
inline

Add two matrices.

Definition at line 3041 of file cugl.h.

◆ operator+() [2/5]

Point cugl::operator+ ( const Point p,
const Vector v 
)
inline

Displace a Point with a Vector. The components of the Vector are added to the corresponding components of the Point. If the Point is not in normal form, the Vector is implicitly scaled.

Returns
Point at (p.x+p.w*v.x, p.y+p.w*v.y, p.z+p.w*v.z, p.w).

Definition at line 2655 of file cugl.h.

◆ operator+() [3/5]

Quaternion cugl::operator+ ( const Quaternion q,
const Quaternion r 
)
inline

Return the quaternion q+r.

Note
The sum of two unit quaternions is not in general a unit quaternion. However, it occasionally appears in expressions such as k q1 + (1 - k) q2, which does yield a unit quaternion.
Returns
the Quaternion q+r.

Definition at line 3236 of file cugl.h.

◆ operator+() [4/5]

Vector cugl::operator+ ( const Vector u,
const Vector v 
)
inline

Return Vector u+v.

Definition at line 2851 of file cugl.h.

◆ operator+() [5/5]

Point cugl::operator+ ( const Vector v,
const Point p 
)
inline

Displace a Point with a Vector. The components of the Vector are added to the corresponding components of the Point. If the Point is not in normal form, the Vector is implicitly scaled.

Returns
Point at (p.x+p.w*v.x, p.y+p.w*v.y, p.z+p.w*v.z, p.w).

Definition at line 2660 of file cugl.h.

◆ operator-() [1/4]

Matrix cugl::operator- ( const Matrix m,
const Matrix n 
)
inline

Subtract two matrices.

Definition at line 3056 of file cugl.h.

◆ operator-() [2/4]

Vector cugl::operator- ( const Point p,
const Point q 
)
inline

Return the vector corresponding to the displacement between the two points. This is the vector (p.x/p.w - q.x/q.w, p.y/p.w - q.y/q.w, p.z/p.w - q.z/q.w). If p or q is a point at infinity, return the zero vector.

Returns
the Vector corresponding to the displacement between the two points.

Definition at line 2843 of file cugl.h.

◆ operator-() [3/4]

Quaternion cugl::operator- ( const Quaternion q,
const Quaternion r 
)
inline

Return the quaternion q-r.

Note
The difference of two unit quaternions is not in general a unit quaternion.
Returns
the Quaternion q-r.

Definition at line 3241 of file cugl.h.

◆ operator-() [4/4]

Vector cugl::operator- ( const Vector u,
const Vector v 
)
inline

Return Vector u-v.

Definition at line 2856 of file cugl.h.

◆ operator/()

Matrix cugl::operator/ ( const Matrix m,
GLfloat  s 
)
inline

Divide by scalar.

Definition at line 3127 of file cugl.h.

◆ operator==() [1/6]

bool cugl::operator== ( const Line m,
const Line n 
)
inline

Compare two lines. This function returns true only if corresponding components are exactly equal. Values that are theoretically equal but computed in different ways are likely to be unequal according to this function.

Definition at line 2708 of file cugl.h.

◆ operator==() [2/6]

bool cugl::operator== ( const Matrix m,
const Matrix n 
)
inline

Compare two matrices. This function returns true only if corresponding components are exactly equal. Values that are theoretically equal but computed in different ways are likely to be unequal according to this function.

Definition at line 3091 of file cugl.h.

◆ operator==() [3/6]

bool cugl::operator== ( const Plane p,
const Plane q 
)
inline

Compare two planes. This function returns true only if corresponding components are exactly equal. Values that are theoretically equal but computed in different ways are likely to be unequal according to this function.

Definition at line 2729 of file cugl.h.

◆ operator==() [4/6]

bool cugl::operator== ( const Point p,
const Point q 
)
inline

Compare two points. This function returns true only if corresponding components are exactly equal. Values that are theoretically equal but computed in different ways are likely to be unequal according to this function.

Definition at line 2675 of file cugl.h.

◆ operator==() [5/6]

bool cugl::operator== ( const Quaternion q,
const Quaternion r 
)
inline

Compare two quaternions. This function returns true only if corresponding components are exactly equal. Values that are theoretically equal but computed in different ways are likely to be unequal according to this function.

Definition at line 3303 of file cugl.h.

◆ operator==() [6/6]

bool cugl::operator== ( const Vector u,
const Vector v 
)
inline

Compare two vectors. This function returns true only if corresponding components are exactly equal. Values that are theoretically equal but computed in different ways are likely to be unequal according to this function.

Definition at line 2892 of file cugl.h.

◆ radians()

double cugl::radians ( double  angle)
inline

Convert degrees to radians.

Definition at line 2327 of file cugl.h.

References PI.

◆ randInt()

unsigned int cugl::randInt ( unsigned int  max)
inline

Return a random integer in [0, max).

Definition at line 2347 of file cugl.h.

Referenced by randReal(), and randSym().

◆ randReal()

double cugl::randReal ( )
inline

Return a random double in [0, 1).

Definition at line 2368 of file cugl.h.

References randInt().

◆ randSym()

int cugl::randSym ( unsigned int  max)
inline

Return a random integer in [-max, max].

Definition at line 2362 of file cugl.h.

References randInt().

◆ revolve()

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
numStepsis the number of points in the array coor
cooris the 2D coordinates of points of the profile
numSlicesis the number of pie-shaped slices used to render the surface.
drawNormalsdetermines 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.

◆ setMaterial()

void cugl::setMaterial ( const int  m,
GLenum  face = GL_FRONT 
)

Set material values from the enumeration.

Parameters
mis chosen from the enumeration MATERIAL
faceshould be one of GL_FRONT (the default), GL_BACK, or GL_FRONT_AND_BACK.

◆ sqr()

double cugl::sqr ( double  x)
inline

Return the square of the argument.

Definition at line 2341 of file cugl.h.

◆ triStripNormals()

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
pointsis an array of points giving the vertex coordinates.
normalsis an array of vectors in which the vertex normals will be stored.
numPointsis the number of vertexes provided and the number of normals that will be calculated.
negspecifies 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.

Variable Documentation

◆ PI

const double cugl::PI = 4 * atan(1.0)

A well-known mathematical constant.

Definition at line 66 of file cugl.h.

Referenced by degrees(), and radians().

◆ version

const char cugl::version[] = "CUGL V2 2009.11.24"

A string giving the version of CUGL and the most recent build date.

Definition at line 63 of file cugl.h.