| [2942] | 1 | #ifndef _DYNAMIC_LINES_H_ |
|---|
| 2 | #define _DYNAMIC_LINES_H_ |
|---|
| 3 | |
|---|
| 4 | #include "DynamicRenderable.h" |
|---|
| 5 | #include <vector> |
|---|
| 6 | |
|---|
| 7 | |
|---|
| 8 | class DynamicLines : public DynamicRenderable |
|---|
| 9 | { |
|---|
| 10 | typedef Ogre::Vector3 Vector3; |
|---|
| 11 | typedef Ogre::Quaternion Quaternion; |
|---|
| 12 | typedef Ogre::Camera Camera; |
|---|
| 13 | typedef Ogre::Real Real; |
|---|
| 14 | typedef Ogre::RenderOperation::OperationType OperationType; |
|---|
| 15 | |
|---|
| 16 | public: |
|---|
| 17 | /// Constructor - see setOperationType() for description of argument. |
|---|
| 18 | DynamicLines(OperationType opType=Ogre::RenderOperation::OT_LINE_STRIP); |
|---|
| 19 | virtual ~DynamicLines(); |
|---|
| 20 | |
|---|
| 21 | /// Add a point to the point list |
|---|
| 22 | void addPoint(const Ogre::Vector3 &p); |
|---|
| 23 | /// Add a point to the point list |
|---|
| 24 | void addPoint(Real x, Real y, Real z); |
|---|
| 25 | |
|---|
| 26 | /// Change the location of an existing point in the point list |
|---|
| 27 | void setPoint(unsigned short index, const Vector3 &value); |
|---|
| 28 | |
|---|
| 29 | /// Return the location of an existing point in the point list |
|---|
| 30 | const Vector3& getPoint(unsigned short index) const; |
|---|
| 31 | |
|---|
| 32 | /// Return the total number of points in the point list |
|---|
| 33 | unsigned short getNumPoints(void) const; |
|---|
| 34 | |
|---|
| 35 | /// Remove all points from the point list |
|---|
| 36 | void clear(); |
|---|
| 37 | |
|---|
| 38 | /// Call this to update the hardware buffer after making changes. |
|---|
| 39 | void update(); |
|---|
| 40 | |
|---|
| 41 | /** Set the type of operation to draw with. |
|---|
| 42 | * @param opType Can be one of |
|---|
| 43 | * - RenderOperation::OT_LINE_STRIP |
|---|
| 44 | * - RenderOperation::OT_LINE_LIST |
|---|
| 45 | * - RenderOperation::OT_POINT_LIST |
|---|
| 46 | * - RenderOperation::OT_TRIANGLE_LIST |
|---|
| 47 | * - RenderOperation::OT_TRIANGLE_STRIP |
|---|
| 48 | * - RenderOperation::OT_TRIANGLE_FAN |
|---|
| 49 | * The default is OT_LINE_STRIP. |
|---|
| 50 | */ |
|---|
| 51 | void setOperationType(OperationType opType); |
|---|
| 52 | OperationType getOperationType() const; |
|---|
| 53 | |
|---|
| 54 | protected: |
|---|
| 55 | /// Implementation DynamicRenderable, creates a simple vertex-only decl |
|---|
| 56 | virtual void createVertexDeclaration(); |
|---|
| 57 | /// Implementation DynamicRenderable, pushes point list out to hardware memory |
|---|
| 58 | virtual void fillHardwareBuffers(); |
|---|
| 59 | |
|---|
| 60 | private: |
|---|
| 61 | std::vector<Vector3> mPoints; |
|---|
| 62 | bool mDirty; |
|---|
| 63 | }; |
|---|
| 64 | |
|---|
| 65 | |
|---|
| 66 | #endif |
|---|