dms::QuadricObject

Source Code

Class Specification

#include <dms/QuadricObject.h>

QuadricObject(void);
virtual ~QuadricObject(void);
virtual void draw(void);

void makeSphere(GLdouble radius=1.0,GLint slices=8,GLint stacks=8);
void makeCylinder(GLdouble baseRadius=1.0, GLdouble topRadius=1.0,
                  GLdouble height=1.0, GLint slices=8, GLint stacks=1,
                  int axis=DMS_Z);
void makeCone(GLdouble baseRadius=1.0, GLdouble height=1.0,
              GLint slices=8, GLint stacks=1, int axis=DMS_Z);
void makeDisk(GLdouble innerRadius=0.0, GLdouble outerRadius=1.0,
              GLint slices=8, GLint rings=1, int axis=DMS_Z);
void makePartialDisk(GLdouble innerRadius=0.0, GLdouble outerRadius=1.0,
                     GLint slices=8, GLint rings=1,
                     GLdouble startAngle=0.0, GLdouble sweep=180.0,
                     int axis=DMS_Z);

void setUseNormals(GLboolean state);
void setUseTexture(GLboolean state);
void setDrawStyle(GLenum style);

GLUquadric * quadric(void) const;
int quadricType(void) const;
GLboolean useNormals(void) const;
GLboolean useTexture(void) const;
GLenum drawStyle(void) const;

Description

QuadricObject(void)

The constructor will set the QuadricObject to be a unit-radius sphere, with normals but no texture coordinates, by default.

void draw(void)

Draws the quadric. This should normally be called by drawAll(), rather than directly, so that all the properties (material, etc) are applied.
Example:

QuadricObject sphere;
sphere.draw();
void makeSphere(GLdouble radius,GLint slices,GLint stacks)

Tells the QuadricObject to render a sphere, when draw() is called. The arguments are the same as those for gluSphere().
Example:

quadric.makeSphere(2.0, 32, 32);
void makeCylinder(GLdouble baseRadius, GLdouble topRadius,
                  GLdouble height, GLint slices, GLint stacks,
                  int axis)

Tells the QuadricObject to render a cylinder, when draw() is called. The arguments, except for axis, are the same as those for gluCylinder(). The axis argument defines which axis the cylinder should be aligned with; the allowed values are DMS_X, DMS_Y, or DMS_Z. By default, a cylinder is aligned with the Z axis.
Example:

quadric.makeCylinder(1.0, 1.0, 5.0, 32, 1, DMS_X);
void makeCone(GLdouble baseRadius, GLdouble height,
              GLint slices, GLint stacks, int axis)

Tells the QuadricObject to render a cone, when draw() is called. This is just a shortcut for calling makeCylinder() with a topRadius of 0.
Example:

quadric.makeCone(1.0, 5.0, 32, 1, DMS_X);
void makeDisk(GLdouble innerRadius, GLdouble outerRadius,
              GLint slices, GLint rings, int axis)

Tells the QuadricObject to render a disk, when draw() is called. The arguments, except for axis, are the same as those for gluDisk(). The axis argument defines which axis the disk should be drawn around; the allowed values are DMS_X, DMS_Y, or DMS_Z; the default is the Z axis.
Example:

quadric.makeDisk(0.0, 3.0, 12, 1, DMS_Y);
void makePartialDisk(GLdouble innerRadius, GLdouble outerRadius,
                     GLint slices, GLint rings, GLdouble startAngle,
                     GLdouble sweep, int axis)

Tells the QuadricObject to render a partial disk, when draw() is called. The arguments, except for axis, are the same as those for gluPartialDisk(). The axis argument defines which axis the disk should be drawn around; the allowed values are DMS_X, DMS_Y, or DMS_Z; the default is the Z axis.
Example:

quadric.makePartialDisk(0.0, 3.0, 12, 1, 90.0, 45.0);
void setUseNormals(GLboolean state)
GLboolean useNormals(void)

setUseNormals() defines whether normal vectors should be generated when the quadric is drawn. state can be either GL_TRUE or GL_FALSE. Normals are enabled by default.
useNormals() returns the current state of the normal-generation flag.
Example:

sphere.setUseNormals(GL_FALSE);
void setUseTexture(GLboolean state)
GLboolean useTexture(void)

setUseTexture() defines whether texture coordinates should be generated when the quadric is drawn. state can be either GL_TRUE or GL_FALSE. Texture coordinates are disabled by default.
useTexture() returns the current state of the texture-coordinate-generation flag.
Example:

sphere.setUseTexture(GL_TRUE);
void setDrawStyle(GLenum style)
GLenum drawStyle(void)

setDrawStyle() defines the drawing style to be used when the quadric is drawn. style can be one of GLU_FILL, GLU_LINE, GLU_SILHOUETTE, or GLU_POINT. The default is GLU_FILL.
drawStyle() returns the drawing style that is currently set.
Example:

sphere.setDrawStyle(GLU_SILHOUETTE);
GLUquadric * quadric(void)

Returns the pointer to the GLUquadric object that is used when drawing the quadric.

int quadricType(void)

Returns the type of quadric that the QuadricObject will draw. The return value is one of DMS_GLU_SPHERE, DMS_GLU_CYLINDER, DMS_GLU_DISK, or DMS_GLU_PARTIAL_DISK.