CUGL
2.0
|
#include <cugl.h>
Public Member Functions | |
Revolute (int numSteps, GLfloat profile[][2]) | |
~Revolute () | |
void | setSlices (int slices) |
void | setEccentricity (double ecc) |
void | process () |
void | draw (bool showNormals=false) |
Private Member Functions | |
Revolute (const Revolute &) | |
const Revolute & | operator= (const Revolute &) |
Private Attributes | |
int | numSteps |
int | numSlices |
double | eccentricity |
bool | ready |
GLfloatArray * | coor |
GLfloat * | texCoor |
Point * | points |
Vector * | normals |
Vector * | faceNormals |
An instance is a surface of revolution represented by its profile.
The shape of the surface is determined by a 'profile'.
The profile is defined by an array. Each component of the array is a pair (h,r) in which h is measured along the axis of revolution and r is the distance from the axis. (If the axis is assumed to be vertical, then h suggests 'height' and r suggests 'radius'.) The surface is generated by rotating the profile about the Z-axis.
The function Revolute::draw()
generates vertex coordinates, normals, and texture coordinates for the surface.
It is up to the caller to set the OpenGL state for rendering: this includes setting material properties and defining rules for polygon shading, or binding an appropriate texture.
The normals generated by Revolute::process()
are obtained by averaging the normals of the polygons that meet at each vertex. Consequently, if GL_SMOOTH
shading is used and sufficient points and slices are specified, the object should look fairly smooth.
cugl::Revolute::Revolute | ( | int | numSteps, |
GLfloat | profile[][2] | ||
) |
Construct a surface of revolution.
numSteps | is the number of coordinates in the profile. |
profile | is the address of a 2D array giving the points of the profile. |
cugl::Revolute::~Revolute | ( | ) |
Delete a surface of revolution.
|
private |
The copy constructor is private and not implemented: instances cannot be copied implicitly.
void cugl::Revolute::draw | ( | bool | showNormals = false | ) |
Draw the surface of revolution.
showNormals | determines whether surface normals will be drawn. Note that surface normals are computed for lighting purposes anyway: showNormals is provided mainly as a debugging aid and should not normally be needed. |
The assignment operator is private and not implemented: instances cannot be assigned.
void cugl::Revolute::process | ( | ) |
Compute vertexes, normals, and texture coordinates for the surface of revolution. This function must be called before calling Revolute::draw()
.
void cugl::Revolute::setEccentricity | ( | double | ecc | ) |
Set the eccentricity of the surface. By default, the eccentricity is 0, giving a surface with a circular cross-section. Setting the eccentricity to a non-zero value gives a surface with an elliptical cross-section. As the eccentricity approaches 1, the major axis of the ellipse increases without limit as the cross-section approaches a parabola.
ecc | must be greater than or equal to zero and less than 1. |
Revolute::process()
again before calling Revolute::draw()
. void cugl::Revolute::setSlices | ( | int | slices | ) |
Set the number of "slices". The value determines the visual quality of the object. The number of slices should be an odd number greater than 2. If it is not, Revolute::process() will change it. By default, the number of slices is 45, corresponding to 8 degrees per slice.
Revolute::process()
again before calling Revolute::draw()
.