CUGL
2.0
|
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) |
Extensions
Quaternion += and -=
Matrix operator*=(Matrix) - done
bool isVisible(Point) - harder than it looks
typedef GLfloat cugl::GL_Matrix[4][4] |
typedef GLfloat* cugl::GLfloatArray |
enum cugl::CUGLErrorType |
Enumeration values for CUGL function errors.
enum cugl::MATERIAL |
Enumeration for materials.
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:
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.
params | specifies:
|
void cugl::axes | ( | GLfloat | size = 1 | ) |
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.
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.
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.
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.
|
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.
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.
|
inline |
CUGLErrorType cugl::getError | ( | ) |
Set code to NO_ERROR
and return last error code.
const char* cugl::getErrorString | ( | CUGLErrorType | err | ) |
Map error codes to descriptive strings.
err | is an error code obtained from getError() . |
const Vector cugl::I | ( | 1 | , |
0 | , | ||
0 | |||
) |
Unit vector parallel to X axis.
const Vector cugl::J | ( | 0 | , |
1 | , | ||
0 | |||
) |
Unit vector parallel to Y axis.
const Vector cugl::K | ( | 0 | , |
0 | , | ||
1 | |||
) |
Unit vector parallel to Z axis.
|
inline |
GLuint cugl::makePlaneList | ( | bool | shadow = false | ) |
Construct a GL call list for the aircraft and return its index.
|
inline |
|
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.
|
inline |
|
inline |
Return the quaternion a*q, where a is a scalar. a is a scalar and a*(s,v) = (a*s, a*v).
|
inline |
|
inline |
Return the quaternion a*q, where a is a scalar. a is a scalar and a*(s,v) = (a*s, a*v).
|
inline |
Return the quaternion q+r.
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.
|
inline |
Return the quaternion q-r.
|
inline |
|
inline |
|
inline |
Return a random integer in [0, max).
Definition at line 2347 of file cugl.h.
Referenced by randReal(), and randSym().
|
inline |
|
inline |
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.
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.
Revolute
, which provides more functionality and is more efficient. void cugl::setMaterial | ( | const int | m, |
GLenum | face = GL_FRONT |
||
) |
Set material values from the enumeration.
m | is chosen from the enumeration MATERIAL |
face | should be one of GL_FRONT (the default), GL_BACK , or GL_FRONT_AND_BACK . |
|
inline |
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.
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. |
const double cugl::PI = 4 * atan(1.0) |