VertexArrayObject Class Reference

Object that uses vertex arrays. More...

#include <VertexArrayObject.h>

Inheritance diagram for VertexArrayObject:

RawObject Cube2 LandPatch Torus2 List of all members.

Public Member Functions

 VertexArrayObject ()
 ~VertexArrayObject ()
virtual void Draw ()
double GetBoundingRadius ()
BoundingBox GetBoundingBox ()
void PrintToConsole ()
void ComputeNormals (bool clock_wise)
void ComputeSphericalTextureCoordinates (GLuint texture_id)

Static Public Attributes

static bool show_normals = false
static float normal_length = 3.0f

Protected Member Functions

void SetVertexData (float *data, int num_vertices)
void SetVertexIndices (GLuint *indices, int num_faces)
void SetTextureCoordinates (float *data, GLuint texture_id)

Private Member Functions

void Draw_Normals ()
void ComputeBoundingVolumes ()

Private Attributes

float * vertex_pointer
int num_vertices
GLuint * index_pointer
int num_faces
float * normal_pointer
float * texture_pointer
GLuint texture_id
bool bounding_volumes_computed
BoundingBox bounding_box
double bounding_radius

Detailed Description

Object that uses vertex arrays.

A VertexArrayObject is a specialized form of a RawObjects that supports vertex arrays to display itself. Additional functionality includes the automated calculation of the bounding box as well as the bounding sphere of the object from the vertex data, the computation of the normals of the object from the vertex and index data of the object anf finally a spherical texture coordinate generation routine.

Definition at line 21 of file VertexArrayObject.h.


Constructor & Destructor Documentation

VertexArrayObject::VertexArrayObject  ) 
 

Constructor: Brings the object into a consistent state.

Definition at line 4 of file VertexArrayObject.cpp.

VertexArrayObject::~VertexArrayObject  ) 
 

Destructor.

Definition at line 17 of file VertexArrayObject.cpp.


Member Function Documentation

void VertexArrayObject::ComputeBoundingVolumes  )  [private]
 

Computes the bounding box and bounding radius from the vertex data.

Definition at line 207 of file VertexArrayObject.cpp.

void VertexArrayObject::ComputeNormals bool  clock_wise  ) 
 

Computes the normals of the object from the vertex and index data. Normals are built by averaging for each point the normals of all the faces that use that point. These normals are additionally weighted by the width of the angle of the respecive faces.

Parameters:
clock_wise States wheather the faces are indexed clockwise or not.

Definition at line 112 of file VertexArrayObject.cpp.

void VertexArrayObject::ComputeSphericalTextureCoordinates GLuint  texture_id  ) 
 

Computes spherical texture coordinates (and the normal data if necessary) for the object.

Parameters:
texture_id OpenGL texture name which identifies the texture with which the generated coordinates shall be used.

Definition at line 189 of file VertexArrayObject.cpp.

void VertexArrayObject::Draw  )  [virtual]
 

Draws the vertex array object.

Reimplemented from RawObject.

Definition at line 60 of file VertexArrayObject.cpp.

void VertexArrayObject::Draw_Normals  )  [private]
 

Draws the normals of the object.

Definition at line 93 of file VertexArrayObject.cpp.

BoundingBox VertexArrayObject::GetBoundingBox  )  [virtual]
 

Implementation of the GetBoundingBox routine. Iterates over the vertex data and computes the minimal and maximal distance along each axis.

Reimplemented from RawObject.

Reimplemented in Torus2.

Definition at line 52 of file VertexArrayObject.cpp.

double VertexArrayObject::GetBoundingRadius  )  [virtual]
 

Implementation of the GetBoundingRadius routine. Iterates over the vertex data and returns the maximal distance from the origin.

Reimplemented from RawObject.

Reimplemented in Torus2.

Definition at line 44 of file VertexArrayObject.cpp.

void VertexArrayObject::PrintToConsole  ) 
 

Prints information about this object to the console.

Definition at line 244 of file VertexArrayObject.cpp.

void VertexArrayObject::SetTextureCoordinates float *  data,
GLuint  texture_id
[protected]
 

Sets the texture coordinates for the vertex data. One texture coordinate must consist of exaclty 2 consecutive floating point values (u, v).

Parameters:
data Pointer to an array which contains the values of the texture coordinates. Since the values are not copied, the data to which the pointer points must stay valid.
texture_id OpenGL texture name that uniquely identifies the texture that shall be used with the texture coordinates.

Definition at line 38 of file VertexArrayObject.cpp.

void VertexArrayObject::SetVertexData float *  data,
int  num_vertices
[protected]
 

Sets the vertex data. One vertex must consist of 3 consecutive floating point values (x, y, z).

Parameters:
data Pointer to an array which contains the values for the vertices. Since the values are not copied, the data to which the pointer points must stay valid.
num_vertices Number of vertices contained within the array. This means that the array must contain at least 3 * num_vertices elements.

Definition at line 25 of file VertexArrayObject.cpp.

void VertexArrayObject::SetVertexIndices GLuint *  indices,
int  num_faces
[protected]
 

Sets the indices for the vertex data that define the polygon faces.

Parameters:
indices Pointer to an array which contains indices into the vertex data array. Since the values are not copied, the data to which the pointer points must stay valid.
num_faces Number of faces contained within the array with the indices. Since one face is defined by 3 consecutive indices, that array must contain at least 3 * num_faces elements.

Definition at line 32 of file VertexArrayObject.cpp.


Member Data Documentation

BoundingBox VertexArrayObject::bounding_box [private]
 

Internal, precomputed bounding box.

Definition at line 142 of file VertexArrayObject.h.

double VertexArrayObject::bounding_radius [private]
 

Internal, precomputed bounding radius.

Definition at line 145 of file VertexArrayObject.h.

bool VertexArrayObject::bounding_volumes_computed [private]
 

Internal flag indicating wheather the bounding volumes have already been computed or not.

Definition at line 139 of file VertexArrayObject.h.

GLuint* VertexArrayObject::index_pointer [private]
 

Internal pointer to the index data.

Definition at line 124 of file VertexArrayObject.h.

float VertexArrayObject::normal_length = 3.0f [static]
 

Lenght of the normals to be drawn.

Definition at line 77 of file VertexArrayObject.h.

float* VertexArrayObject::normal_pointer [private]
 

Internal pointer to the normal data.

Definition at line 130 of file VertexArrayObject.h.

int VertexArrayObject::num_faces [private]
 

Number of faces contained within the index data.

Definition at line 127 of file VertexArrayObject.h.

int VertexArrayObject::num_vertices [private]
 

Number of vertices contained within the vertex data.

Definition at line 121 of file VertexArrayObject.h.

bool VertexArrayObject::show_normals = false [static]
 

If set to 'true', the normals of the VertexArrayObjects will be drawn whenever such an object is drawn.

Definition at line 74 of file VertexArrayObject.h.

GLuint VertexArrayObject::texture_id [private]
 

Internal storage of the OpenGL texture name which shall be used along the texture coordinates.

Definition at line 136 of file VertexArrayObject.h.

float* VertexArrayObject::texture_pointer [private]
 

Internal pointer to the texture coordinate data.

Definition at line 133 of file VertexArrayObject.h.

float* VertexArrayObject::vertex_pointer [private]
 

Internal pointer to the vertex data.

Definition at line 118 of file VertexArrayObject.h.


Generated on Sun Jul 2 13:20:41 2006 for Demo by  doxygen 1.4.6-NO