Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   Related Pages

# sglGeoSet Class Reference

#include <sglGeoSet.hpp>

Inheritance diagram for sglGeoSet::

List of all members.

enum  BindEnum {
eOFF,
eOVERALL,
ePER_PRIM,
ePER_VERTEX
}

## Public Methods

sglGeoSet ()
virtual ~sglGeoSet ()
virtual GLenum getGLPrimType () const=0
virtual unsigned int getPrimSize () const=0
unsigned int getNumPrims () const
void setNumPrims (unsigned int num)
void setCoordList (sglVec3f *alist)
void setCoordList (sglDataPtr *data, sglDataPtr::DataTypeEnum type=sglDataPtr::eFLOAT, int size=3, int offset=0, int stride=0)
void setNormalList (BindEnum bind, sglVec3f *alist)
void setNormalList (BindEnum bind, sglDataPtr *data, sglDataPtr::DataTypeEnum type=sglDataPtr::eFLOAT, int offset=0, int stride=0)
void setColorList (BindEnum bind, sglVec4f *alist)
void setColorList (BindEnum bind, sglDataPtr *data, sglDataPtr::DataTypeEnum type=sglDataPtr::eFLOAT, int size=4, int offset=0, int stride=0)
BindEnum getNormalBind () const
BindEnum getColorBind () const
sglDataPtrgetCoordList () const
sglDataPtrgetNormalList () const
sglDataPtrgetColorList () const
sglDataPtr::DataTypeEnum getCoordType () const
sglDataPtr::DataTypeEnum getNormalType () const
sglDataPtr::DataTypeEnum getColorType () const
int getCoordSize () const
int getColorSize () const
int getCoordOffset () const
int getNormalOffset () const
int getColorOffset () const
int getCoordStride () const
int getNormalStride () const
int getColorStride () const
virtual bool isValid () const
virtual void addStats (sglStats &stats) const
virtual void printInfo (ostream &ostrm, const char *indent_string) const

## Protected Types

enum  NormalEnum {
eNORMALS_NONE = 0x00000,
eNORMALS_OVERALL = 0x00001,
eNORMALS_PER_PRIM = 0x00002,
eNORMALS_PER_VERTEX = 0x00003
}
enum  ColorEnum {
eCOLORS_NONE = 0x00000,
eCOLORS_OVERALL = 0x00004,
eCOLORS_PER_PRIM = 0x00008,
eCOLORS_PER_VERTEX = 0x0000c
}
enum  ModeEnum {
eNORMALS = 0x00003,
eCOLORS = 0x0000c,
eMULTI_TEXTURE = 0x00010,
ePREFETCH = 0x00020
}
enum  TexCoordsEnum {
eTEXCOORDS_OVERALL = 0x01000,
eTEXCOORDS_PER_PRIM = 0x02000,
eTEXCOORDS_PER_VERTEX = 0x04000,
eTEXCOORDS = 0x07000
}
enum  BoundsEnum {
eNUMPRIMS = 0x01,
eLENGTHS = 0x02,
eVERTICES = 0x04,
eVINDICES = 0x08
}

## Protected Methods

virtual bool computeBounds ()
virtual void updateDrawFunc ()

## Protected Attributes

unsigned int m_mode
unsigned int m_num_prims
sglVertexPtr m_vertices
sglNormalPtr m_normals
sglColorPtr m_colors
unsigned int m_compute_bounds

## Friends

class  Initializer

## Detailed Description

This abstract class contains the vertex, normal, and color arrays for a single type of primitive (e.g. points, lines, triangles, etc.) that is determined when instantiating one of the concrete subclasses (e.g. sglPointSet, sglLineSet, sglTriangleSet, etc.). Every sglGeoSet must, at a minimum, have an array of vertices assigned using the setCoordList() member function, and the number of primitives set using the setNumPrims() member function. Optionally, normal and vertex color attributes can be also be defined. The first parameter to the setColorList() or setNormalList() member functions define the way that these arrays can be bound to the vertices as follows:

\begin{enumerate} \item sglGeoSet::ePER_VERTEX - like the coordinate vertex array, this array must have the same number of entries and each element is applied with a corresponding vertex.

\item sglGeoSet::ePER_PRIM - the array contains as many entries as the number of primitives, one for each.

\item sglGeoSet::eOVERALL - the array contains one element and applies to for all vertices in the coordinate list. \end{enumerate}

Passing in a NULL pointer for the attribute list has the effect of disabling that attribute. The getColorBind() and getNormalBind() functions return what mode the particular attribute is currently set to. If the attribute is unused (disabled) then the SGL_OFF token is returned.

{\bf Concrete subclasses: sglPointSet, sglLineSet, sglTriangleSet, sglQuadSet}

sglPointSet, sglLineSet, sglTriangleSet, and sglQuadSet are the only immediate concrete subclasses of sglGeoSet and allow the rendering of individual points, line segments, triangles, and quads. They imply that the primitive sizes are 1, 2, 3, and 4 respectively. The number of primitives, which is set by calling the sglGeoSet::setNumPrims() function, along with the classes' implied primitive size determine the required sizes of the geometry attributes. For example, an sglLineSet with the number of primitives set to 9, means that the vertex array must be at least 18 elements long. Note, no error checking is done by SGL so if the user makes a mistake, access out of array bounds can result in undefined behaviour.

{\bf Example:} \begin{verbatim} sglVec3f *vertex = new sglVec4f[6]; // vertices for two triangles vertex[0].set( 0.0f, 0.0f, 0.0f); vertex[1].set( 5.0f, 0.0f, 0.0f); vertex[2].set( 0.0f, 5.0f, 0.0f); vertex[3].set( 0.0f, 0.0f, 0.0f); vertex[4].set( 0.0f,-5.0f, 0.0f); vertex[5].set(-5.0f, 0.0f, 0.0f);

sglVec4f *color = new sglVec4f[2]; color[0].set(1.0f, 0.0f, 0.0f, 1.0f); // first triangle is red color[1].set(0.0f, 1.0f, 0.0f, 1.0f); // second triangle is green

sglVec3f *normal = new sglVec3f[1]; // one normal for all vertices normal[0].set(0.0f,0.0f,1.0f);

sglTriangleSet *tri_geom = new sglTriangleSet; tri_geom->setNumPrims(2); tri_geom->setCoorList(vertex); // sglGeoSet::ePER_VERTEX is implied tri_geom->setColorList(sglGeoSet::ePER_PRIM, color); tri_geom->setNormalList(sglGeoSet::eOVERALL, normal); \end{verbatim}

Definition at line 104 of file sglGeoSet.hpp.

## Constructor & Destructor Documentation

 sglGeoSet::sglGeoSet ( )
 default constructor.

 sglGeoSet::~sglGeoSet ( ) [virtual]
 virtual destructor.

## Member Function Documentation

 sglStats::PrimEnum sglGeoSet::getPrimType ( ) const [pure virtual]

 unsigned int sglGeoSet::getNumPrims ( ) const [inline]
 get/set the number of primitives in this geoset. Definition at line 127 of file sglGeoSet.hpp.

 void sglGeoSet::setCoordList ( sglVec3f * alist ) [inline]
 Set the array of vertices. Deprecated. Definition at line 132 of file sglGeoSet.hpp.

 void sglGeoSet::setCoordList ( sglDataPtr * data, sglDataPtr::DataTypeEnum type = sglDataPtr::eFLOAT, int size = 3, int offset = 0, int stride = 0 )

Set the array of vertices. This will increment the reference count on the given data pointer, and decrement the reference count of the previous data pointer. If the previous data pointer's refernce count goes to zero, it will be deleted.

Parameters:
 data Pointer to the list of vertices. type Data type of vertices [eSHORT, eINT, eFLOAT, eDOUBLE]. size Number of values per vertex [2,3,4]. offset Number of bytes in the array before the first vertex. stride Number of bytes from the start of one vertex to the start of the next vertex. If zero, the vertices are assumed to be tightly packed (i.e. stride == size * sizeof(type)). Stride must be non-negative.

 void sglGeoSet::setNormalList ( BindEnum bind, sglVec3f * alist ) [inline]
 Set the array of normals. Deprecated. Definition at line 155 of file sglGeoSet.hpp.

 void sglGeoSet::setNormalList ( BindEnum bind, sglDataPtr * data, sglDataPtr::DataTypeEnum type = sglDataPtr::eFLOAT, int offset = 0, int stride = 0 )

Set the array of normals. This will increment the reference count on the given data pointer, and decrement the reference count of the previous data pointer. If the previous data pointer's refernce count goes to zero, it will be deleted. Normals must have three values per normal.

Parameters:
 bind One of [eOVERALL, ePER_PRIM, ePER_VERTEX]. data Pointer to the list of normals. type Data type of normals [eBYTE, eSHORT, eINT, eFLOAT, eDOUBLE]. offset Number of bytes in the array before the first normal. stride Number of bytes from the start of one normal to the start of the next normal. If zero, the normals are assumed to be tightly packed (i.e. stride == 3 * sizeof(type)). Stride must be non-negative.

 void sglGeoSet::setColorList ( BindEnum bind, sglVec4f * alist ) [inline]
 Set the array of colors. Deprecated. Definition at line 179 of file sglGeoSet.hpp.

 void sglGeoSet::setColorList ( BindEnum bind, sglDataPtr * data, sglDataPtr::DataTypeEnum type = sglDataPtr::eFLOAT, int size = 4, int offset = 0, int stride = 0 )

Set the array of colors. This will increment the reference count on the given data pointer, and decrement the reference count of the previous data pointer. If the previous data pointer's refernce count goes to zero, it will be deleted.

Parameters:
 bind One of [eOVERALL, ePER_PRIM, ePER_VERTEX]. data Pointer to the list of colors. type Data type of colors (any). size Number of values per color [3,4]. offset Number of bytes in the array before the first color. stride Number of bytes from the start of one color to the start of the next color. If zero, the colors are assumed to be tightly packed (i.e. stride == size * sizeof(type)). Stride must be non-negative.

 BindEnum sglGeoSet::getNormalBind ( ) const
 get the current normal and color binding state.

 sglDataPtr * sglGeoSet::getCoordList ( ) const [inline]
 get the current vertex, normal, color attribute lists. Definition at line 209 of file sglGeoSet.hpp.

 sglDataPtr::DataTypeEnum sglGeoSet::getCoordType ( ) const [inline]
 get the current vertex, normal, color data types. Definition at line 216 of file sglGeoSet.hpp.

 int sglGeoSet::getCoordSize ( ) const [inline]
 get the number of values per vertex coordinate and color. Definition at line 226 of file sglGeoSet.hpp.

 int sglGeoSet::getCoordOffset ( ) const [inline]
 get the number of bytes in the array before the first coordinate value. Definition at line 231 of file sglGeoSet.hpp.

 int sglGeoSet::getCoordStride ( ) const [inline]
 get the number of bytes from the start of one vertex to the next. Definition at line 238 of file sglGeoSet.hpp.

 void sglGeoSet::addStats ( sglStats & stats ) const [virtual]
 Add this drawable's stats to the given debug_stats. Reimplemented from sglDrawable. Reimplemented in sglBezierSurfaceSet, sglGeoStripSet, sglIndexedGeoStripSet, and sglMonoIndexedGeoStripSet.

 virtual void sglGeoSet::printInfo ( ostream & ostrm, const char * indent_string ) const [virtual]

Output the state of this node to the specified ostream.

Parameters:
 ostrm the ostream to which the output is sent indent_string the string (usually spaces) that is output at the beginning of every line of output

Reimplemented from sglDrawable.

Reimplemented in sglCylinder.

 virtual bool sglGeoSet::computeBounds ( ) [protected, virtual]
 Compute the bounding box for this geometry and fill in the member variable, m_bbox, in this class. Returns: true if successful (all information is available for computing a bounding box), otherwise false. Reimplemented from sglDrawable.

The documentation for this class was generated from the following file:
Generated at Mon Jul 1 18:00:07 2002 for SGL by 1.2.6 written by Dimitri van Heesch, © 1997-2001