CUGL  2.0
Public Member Functions | Private Member Functions | Private Attributes | List of all members
cugl::Revolute Class Reference

#include <cugl.h>

Collaboration diagram for cugl::Revolute:
Collaboration graph
[legend]

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 Revoluteoperator= (const Revolute &)
 

Private Attributes

int numSteps
 
int numSlices
 
double eccentricity
 
bool ready
 
GLfloatArraycoor
 
GLfloat * texCoor
 
Pointpoints
 
Vectornormals
 
VectorfaceNormals
 

Detailed Description

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.

Definition at line 2204 of file cugl.h.

Constructor & Destructor Documentation

cugl::Revolute::Revolute ( int  numSteps,
GLfloat  profile[][2] 
)

Construct a surface of revolution.

Parameters
numStepsis the number of coordinates in the profile.
profileis the address of a 2D array giving the points of the profile.
cugl::Revolute::~Revolute ( )

Delete a surface of revolution.

cugl::Revolute::Revolute ( const Revolute )
private

The copy constructor is private and not implemented: instances cannot be copied implicitly.

Member Function Documentation

void cugl::Revolute::draw ( bool  showNormals = false)

Draw the surface of revolution.

Parameters
showNormalsdetermines 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.
Note
Revolute::process() must be called before this function.
const Revolute& cugl::Revolute::operator= ( const Revolute )
private

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.

Parameters
eccmust be greater than or equal to zero and less than 1.
Note
After changing the eccentricity, you must call 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.

Note
After changing the number of slices, you must call Revolute::process() again before calling Revolute::draw().

The documentation for this class was generated from the following file: