This class implements an array of 3D points. More...
#include <CPointArray.h>
Public Member Functions | |
cPointArray (cVertexArrayPtr a_vertexArray) | |
~cPointArray () | |
void | clear () |
This method clears all points from the array. More... | |
virtual unsigned int | getNumVerticesPerElement () |
This method returns the number of vertices that compose a point. More... | |
cPointArrayPtr | copy () |
This method copies point data and return new point array. More... | |
void | compress () |
This method compresses the array by removing non used points. More... | |
int | newPoint (const unsigned int a_vertexIndex0) |
void | removePoint (const unsigned int a_pointIndex) |
void | setVertex (const unsigned int a_pointIndex, const unsigned int a_vertexIndex) |
unsigned int | getVertexIndex0 (const unsigned int a_pointIndex) const |
virtual unsigned int | getVertexIndex (const unsigned int a_elementIndex, const unsigned int a_vertexNumber) const |
cVector3d | getTexCoordAtPosition (const unsigned int a_pointIndex, const cVector3d &a_localPos) |
void | render () |
virtual bool | computeCollision (const unsigned int a_elementIndex, cGenericObject *a_object, cVector3d &a_segmentPointA, cVector3d &a_segmentPointB, cCollisionRecorder &a_recorder, cCollisionSettings &a_settings) const |
This method checks if a given line segment intersects a selected point from this array. More... | |
Public Member Functions inherited from chai3d::cGenericArray | |
cGenericArray (cVertexArrayPtr a_vertexArray) | |
~cGenericArray () | |
virtual unsigned int | getNumElements () |
This method returns the number of allocated elements. More... | |
void | compress () |
This method removes non used elements. This compresses the array. More... | |
bool | getAllocated (const unsigned int a_index) const |
cVector3d | getTexCoordAtPosition (const unsigned int a_elementIndex, const cVector3d &a_localPos) |
Static Public Member Functions | |
static cPointArrayPtr | create (cVertexArrayPtr a_vertexArray) |
Shared cPointArray allocator. More... | |
Static Public Member Functions inherited from chai3d::cGenericArray | |
static cGenericArrayPtr | create (cVertexArrayPtr a_vertexArray) |
Shared cGenericArray allocator. More... | |
Additional Inherited Members | |
Public Attributes inherited from chai3d::cGenericArray | |
cVertexArrayPtr | m_vertices |
Vertex array that contains all vertices used to describe the elements of this array. More... | |
std::vector< unsigned int > | m_indices |
Element indices to vertices. More... | |
std::vector< bool > | m_allocated |
Element allocation flags. More... | |
bool | m_flagMarkForUpdate |
If true then element data has been modified. More... | |
bool | m_flagMarkForResize |
If true then element array size has changed. More... | |
GLuint | m_elementBuffer |
OpenGL Buffer for storing elements. More... | |
Protected Attributes inherited from chai3d::cGenericArray | |
std::list< unsigned int > | m_freeElements |
List of free elements. More... | |
cPointArray defines an array of points, each composed of a single vertex.
A point array is created by first passing a reference to an array of vertices (cVertexArray) from which the points are composed.
For graphic rendering purposes and memory efficiency, points are stored in large arrays. The number of allocated points in an array can be retrieved by calling getNumElements().
New points can be added or removed by calling newPoint() and removePoint(). respectively.
When a point is removed from the array, its vertex index is set to zero and the point index number is added to a list of free points for future allocation.
To avoid accumulating large numbers of free points, it is possible to compress the array by calling compress(). This method removes all non used points from memory.
|
inline |
Constructor of cPointArray.
a_vertexArray | Array of vertices used to describe the points. |
|
inline |
Destructor of cPointArray.
|
inlinevirtual |
Reimplemented from chai3d::cGenericArray.
|
inlinestatic |
|
inlinevirtual |
Reimplemented from chai3d::cGenericArray.
cPointArrayPtr chai3d::cPointArray::copy | ( | ) |
This method creates a copy of all allocated points. Please note that this method does not copy points that were previously deallocated.
void chai3d::cPointArray::compress | ( | ) |
This method compress the point array by removing all non allocated points. If many points are unused, this method can effectively reduce the memory footprint allocated by the array.
IMPORTANT:
After calling this method, it is important to immediately update any collision detector as the collision tree may try to access points that no longer exist.
|
inline |
This method creates a new point.
a_vertexIndex0 | index of vertex 0. |
|
inline |
This method deallocates a selected point from the array. Its vertex index is set to zero, and the point is added to the free list for future allocation.
a_pointIndex | Index number of selected point. |
|
inline |
This method sets the vertex of a selected point by passing its index number.
a_pointIndex | Index of selected point. |
a_vertexIndex | Index of vertex. |
|
inline |
This method returns the index number of the vertex that describes a selected point.
a_pointIndex | Index of point. |
|
inlinevirtual |
This method reads the index number of the vertex of a selected point. In the case of a point a_vertexNumber
only takes value 0, as a point is only composed of a single vertex.
a_elementIndex | Index number of selected point. |
a_vertexNumber | Vertex number. |
Reimplemented from chai3d::cGenericArray.
|
inline |
This method returns the texture coordinate at the point. For points, a_localPos is meaningless and ignore. This value is used however for segments or triangles.
a_pointIndex | Index number of selected point. |
a_localPos | Value ignored. |
|
inlinevirtual |
This method renders the OpenGL vertex buffer object.
Reimplemented from chai3d::cGenericArray.
|
virtual |
This method checks if the given line point intersects a selected a point from this array.
If a collision occurs, the collision point is reported to the collision recorder.
a_elementIndex | Point index number. |
a_object | Pointer to the object on which collision detection is being performed. |
a_segmentPointA | Point from where collision ray starts (in local frame). |
a_segmentPointB | Direction vector of collision ray (in local frame). |
a_recorder | Stores collision events. |
a_settings | Collision detection settings. |
Reimplemented from chai3d::cGenericArray.