181 const unsigned int a_vertexIndex1)
191 setVertices(index, a_vertexIndex0, a_vertexIndex1);
254 const unsigned int a_vertexIndex0,
255 const unsigned int a_vertexIndex1)
257 m_indices[2*a_segmentIndex+0] = a_vertexIndex0;
258 m_indices[2*a_segmentIndex+1] = a_vertexIndex1;
307 const unsigned int a_vertexNumber)
const
309 switch (a_vertexNumber)
311 case 0:
return (
m_indices[2*a_elementIndex+0]);
312 case 1:
return (
m_indices[2*a_elementIndex+1]);
342 double distance01 =
cDistance(vertex0, vertex1);
350 double distanceP0 =
cDistance(vertex0, point);
351 c1 = distanceP0 / distance01;
364 texCoord =
cAdd(
cMul(c0, texCoord0),
cMul(c1, texCoord1));
368 texCoord.
set(0.0, 0.0, 0.0);
398 glBufferData(GL_ELEMENT_ARRAY_BUFFER, 2 * numSegments *
sizeof(
unsigned int), &(
m_indices[0]), GL_STATIC_DRAW);
406 glBufferSubData(GL_ELEMENT_ARRAY_BUFFER, 0, 2 * numSegments *
sizeof(
unsigned int), &(
m_indices[0]));
414 glEnableClientState(GL_VERTEX_ARRAY);
416 glDrawElements( GL_LINES, 2 * numSegments, GL_UNSIGNED_INT, (
void*)0);
417 glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
Implements an abstract class for describing elements composed of vertices.
This class implements a collision detection recorder that stores all collision events that are report...
Definition CCollisionBasics.h:186
This class implements an abstract class for describing geometrical elements composed of vertices.
Definition CGenericArray.h:91
GLuint m_elementBuffer
OpenGL Buffer for storing elements.
Definition CGenericArray.h:249
cVertexArrayPtr m_vertices
Vertex array that contains all vertices used to describe the elements of this array.
Definition CGenericArray.h:227
std::list< unsigned int > m_freeElements
List of free elements.
Definition CGenericArray.h:259
bool m_flagMarkForResize
If true then element array size has changed.
Definition CGenericArray.h:239
bool m_flagMarkForUpdate
If true then element data has been modified.
Definition CGenericArray.h:236
virtual unsigned int getNumElements()
This method returns the number of allocated elements.
Definition CGenericArray.h:145
std::vector< unsigned int > m_indices
Element indices to vertices.
Definition CGenericArray.h:230
std::vector< bool > m_allocated
Element allocation flags.
Definition CGenericArray.h:233
This class implements a base class for all 2D or 3D objects in CHAI3D.
Definition CGenericObject.h:113
This class implements an array of 3D segments.
Definition CSegmentArray.h:104
virtual unsigned int getNumVerticesPerElement()
This method returns the number of vertices that compose a segment.
Definition CSegmentArray.h:161
cSegmentArrayPtr copy()
This method create a copy of all segment data and returns a new segment array.
Definition CSegmentArray.cpp:259
unsigned int getVertexIndex0(const unsigned int a_segmentIndex) const
Definition CSegmentArray.h:274
void removeSegment(const unsigned int a_segmentIndex)
Definition CSegmentArray.h:223
void setVertices(const unsigned int a_segmentIndex, const unsigned int a_vertexIndex0, const unsigned int a_vertexIndex1)
Definition CSegmentArray.h:253
cSegmentArray(cVertexArrayPtr a_vertexArray)
Definition CSegmentArray.h:118
unsigned int getVertexIndex1(const unsigned int a_segmentIndex) const
Definition CSegmentArray.h:289
void clear()
This method clears all segments from array.
Definition CSegmentArray.h:140
virtual unsigned int getVertexIndex(const unsigned int a_elementIndex, const unsigned int a_vertexNumber) const
Definition CSegmentArray.h:306
cVector3d getTexCoordAtPosition(const unsigned int a_segmentIndex, const cVector3d &a_localPos)
Definition CSegmentArray.h:329
void render()
Definition CSegmentArray.h:381
void compress()
This method compresses the array by removing non used segments.
Definition CSegmentArray.cpp:296
int newSegment(const unsigned int a_vertexIndex0, const unsigned int a_vertexIndex1)
Definition CSegmentArray.h:180
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 the given line segment intersects a selected segment from this array.
Definition CSegmentArray.cpp:73
virtual ~cSegmentArray()
Definition CSegmentArray.h:136
static cSegmentArrayPtr create(cVertexArrayPtr a_vertexArray)
Shared cSegmentArray allocator.
Definition CSegmentArray.h:151
Definition CAudioBuffer.cpp:57
cVector3d cAdd(const cVector3d &a_vector1, const cVector3d &a_vector2)
This function computes the addition of two vectors.
Definition CMaths.h:771
std::shared_ptr< cSegmentArray > cSegmentArrayPtr
Definition CSegmentArray.h:66
const double C_SMALL
Small value near zero.
Definition CConstants.h:103
cVector3d cMul(const double &a_value, const cVector3d &a_vector)
This function computes the multiplication of a vector by a scalar.
Definition CMaths.h:887
double cDistance(const cVector3d &a_point1, const cVector3d &a_point2)
This function computes the Euclidean distance between two points.
Definition CMaths.h:1016
std::shared_ptr< cVertexArray > cVertexArrayPtr
Definition CVertexArray.h:108
cVector3d cProjectPointOnSegment(const cVector3d &a_point, const cVector3d &a_segmentPointA, const cVector3d &a_segmentPointB)
This function computes the projection of a point onto a segment.
Definition CGeometry.h:299
This structure stores the collision settings that are passed to a collision detector when querying fo...
Definition CCollisionBasics.h:243
This class implements a 3D vector.
Definition CVector3d.h:89
void set(const double &a_x, const double &a_y, const double &a_z)
This method initializes this vector with components x, y, and z passed as arguments.
Definition CVector3d.h:278