ASR::DynamicLines Class Reference

#include <DynamicLines.h>

Inheritance diagram for ASR::DynamicLines:

Inheritance graph
[legend]
Collaboration diagram for ASR::DynamicLines:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 DynamicLines (OperationType opType=Ogre::RenderOperation::OT_LINE_STRIP)
 Constructor - see setOperationType() for description of argument.
virtual ~DynamicLines ()
void addPoint (const Ogre::Vector3 &p)
 Add a point to the point list.
void addPoint (Real x, Real y, Real z)
 Add a point to the point list.
void setPoint (unsigned short index, const Vector3 &value)
 Change the location of an existing point in the point list.
const Vector3getPoint (unsigned short index) const
 Return the location of an existing point in the point list.
unsigned short getNumPoints (void) const
 Return the total number of points in the point list.
void clear ()
 Remove all points from the point list.
void update ()
 Call this to update the hardware buffer after making changes.
void setOperationType (OperationType opType)
 Set the type of operation to draw with.
OperationType getOperationType () const

Protected Member Functions

virtual void createVertexDeclaration ()
 Implementation DynamicRenderable, creates a simple vertex-only decl.
virtual void fillHardwareBuffers ()
 Implementation DynamicRenderable, pushes point list out to hardware memory.

Private Types

typedef Ogre::Vector3 Vector3
typedef Ogre::Quaternion Quaternion
typedef Ogre::Camera Camera
typedef Ogre::Real Real
typedef Ogre::RenderOperation::OperationType OperationType

Private Attributes

std::vector< Vector3mPoints
bool mDirty

Detailed Description

Definition at line 12 of file DynamicLines.h.


Member Typedef Documentation

typedef Ogre::Camera ASR::DynamicLines::Camera [private]

Definition at line 16 of file DynamicLines.h.

typedef Ogre::RenderOperation::OperationType ASR::DynamicLines::OperationType [private]

Definition at line 18 of file DynamicLines.h.

typedef Ogre::Quaternion ASR::DynamicLines::Quaternion [private]

Definition at line 15 of file DynamicLines.h.

typedef Ogre::Real ASR::DynamicLines::Real [private]

Definition at line 17 of file DynamicLines.h.

typedef Ogre::Vector3 ASR::DynamicLines::Vector3 [private]

Definition at line 14 of file DynamicLines.h.


Constructor & Destructor Documentation

ASR::DynamicLines::DynamicLines ( OperationType  opType = Ogre::RenderOperation::OT_LINE_STRIP  ) 

Constructor - see setOperationType() for description of argument.

Definition at line 16 of file DynamicLines.cpp.

References ASR::DynamicRenderable::initialize(), and mDirty.

00017         {
00018                 initialize(opType,false);
00019                 setMaterial("BaseWhiteNoLighting");
00020                 mDirty = true;
00021         }

ASR::DynamicLines::~DynamicLines (  )  [virtual]

Definition at line 23 of file DynamicLines.cpp.

00024         {
00025         }


Member Function Documentation

void ASR::DynamicLines::addPoint ( Real  x,
Real  y,
Real  z 
)

Add a point to the point list.

Definition at line 42 of file DynamicLines.cpp.

References mDirty, and mPoints.

00043         {
00044                 mPoints.push_back(Vector3(x,y,z));
00045                 mDirty = true;
00046         }

void ASR::DynamicLines::addPoint ( const Ogre::Vector3 &  p  ) 

Add a point to the point list.

void ASR::DynamicLines::clear (  ) 

Remove all points from the point list.

Definition at line 63 of file DynamicLines.cpp.

References mDirty, and mPoints.

00064         {
00065                 mPoints.clear();
00066                 mDirty = true;
00067         }

void ASR::DynamicLines::createVertexDeclaration (  )  [protected, virtual]

Implementation DynamicRenderable, creates a simple vertex-only decl.

Implements ASR::DynamicRenderable.

Definition at line 74 of file DynamicLines.cpp.

References ASR::POSITION_BINDING.

00075         {
00076                 VertexDeclaration *decl = mRenderOp.vertexData->vertexDeclaration;
00077                 decl->addElement(POSITION_BINDING, 0, VET_FLOAT3, VES_POSITION);
00078         }

void ASR::DynamicLines::fillHardwareBuffers (  )  [protected, virtual]

Implementation DynamicRenderable, pushes point list out to hardware memory.

Implements ASR::DynamicRenderable.

Definition at line 80 of file DynamicLines.cpp.

References mDirty, mPoints, and ASR::DynamicRenderable::prepareHardwareBuffers().

Referenced by update().

00081         {
00082                 int size = mPoints.size();
00083 
00084                 prepareHardwareBuffers(size,0);
00085 
00086                 if (!size) { 
00087                         mBox.setExtents(Vector3::ZERO,Vector3::ZERO);
00088                         mDirty=false;
00089                         return;
00090                 }
00091 
00092                 Vector3 vaabMin = mPoints[0];
00093                 Vector3 vaabMax = mPoints[0];
00094 
00095                 HardwareVertexBufferSharedPtr vbuf =
00096                         mRenderOp.vertexData->vertexBufferBinding->getBuffer(0);
00097 
00098                 Real *prPos = static_cast<Real*>(vbuf->lock(HardwareBuffer::HBL_DISCARD));
00099                 {
00100                         for(int i = 0; i < size; i++)
00101                         {
00102                                 *prPos++ = mPoints[i].x;
00103                                 *prPos++ = mPoints[i].y;
00104                                 *prPos++ = mPoints[i].z;
00105 
00106                                 if(mPoints[i].x < vaabMin.x)
00107                                         vaabMin.x = mPoints[i].x;
00108                                 if(mPoints[i].y < vaabMin.y)
00109                                         vaabMin.y = mPoints[i].y;
00110                                 if(mPoints[i].z < vaabMin.z)
00111                                         vaabMin.z = mPoints[i].z;
00112 
00113                                 if(mPoints[i].x > vaabMax.x)
00114                                         vaabMax.x = mPoints[i].x;
00115                                 if(mPoints[i].y > vaabMax.y)
00116                                         vaabMax.y = mPoints[i].y;
00117                                 if(mPoints[i].z > vaabMax.z)
00118                                         vaabMax.z = mPoints[i].z;
00119                         }
00120                 }
00121                 vbuf->unlock();
00122 
00123                 mBox.setExtents(vaabMin, vaabMax);
00124 
00125                 mDirty = false;
00126         }

unsigned short ASR::DynamicLines::getNumPoints ( void   )  const

Return the total number of points in the point list.

Definition at line 52 of file DynamicLines.cpp.

References mPoints.

00053         {
00054                 return (unsigned short)mPoints.size();
00055         }

RenderOperation::OperationType ASR::DynamicLines::getOperationType (  )  const

Definition at line 32 of file DynamicLines.cpp.

00033         {
00034                 return mRenderOp.operationType;
00035         }

const Vector3 & ASR::DynamicLines::getPoint ( unsigned short  index  )  const

Return the location of an existing point in the point list.

Definition at line 47 of file DynamicLines.cpp.

References mPoints.

00048         {
00049                 assert(index < mPoints.size() && "Point index is out of bounds!!");
00050                 return mPoints[index];
00051         }

void ASR::DynamicLines::setOperationType ( OperationType  opType  ) 

Set the type of operation to draw with.

Parameters:
opType Can be one of
  • RenderOperation::OT_LINE_STRIP
  • RenderOperation::OT_LINE_LIST
  • RenderOperation::OT_POINT_LIST
  • RenderOperation::OT_TRIANGLE_LIST
  • RenderOperation::OT_TRIANGLE_STRIP
  • RenderOperation::OT_TRIANGLE_FAN The default is OT_LINE_STRIP.

Definition at line 27 of file DynamicLines.cpp.

00028         {
00029                 mRenderOp.operationType = opType;
00030         }

void ASR::DynamicLines::setPoint ( unsigned short  index,
const Vector3 value 
)

Change the location of an existing point in the point list.

Definition at line 56 of file DynamicLines.cpp.

References mDirty, and mPoints.

00057         {
00058                 assert(index < mPoints.size() && "Point index is out of bounds!!");
00059 
00060                 mPoints[index] = value;
00061                 mDirty = true;
00062         }

void ASR::DynamicLines::update (  ) 

Call this to update the hardware buffer after making changes.

Definition at line 69 of file DynamicLines.cpp.

References fillHardwareBuffers(), and mDirty.

00070         {
00071                 if (mDirty) fillHardwareBuffers();
00072         }


Member Data Documentation

bool ASR::DynamicLines::mDirty [private]

Definition at line 66 of file DynamicLines.h.

Referenced by addPoint(), clear(), DynamicLines(), fillHardwareBuffers(), setPoint(), and update().

std::vector<Vector3> ASR::DynamicLines::mPoints [private]

Definition at line 65 of file DynamicLines.h.

Referenced by addPoint(), clear(), fillHardwareBuffers(), getNumPoints(), getPoint(), and setPoint().


The documentation for this class was generated from the following files:
Generated on Sun Jun 25 19:23:43 2006 for Valors End by  doxygen 1.4.7