1 #pragma once
2 #include <OgreRenderOperation.h>
3 #include <OgreSimpleRenderable.h>
4 #include <vector>
5 
6 
7 //----------------------------------------------------------------------------------------------
8 
9 class DynamicRenderable : public Ogre::SimpleRenderable
10 {
11 public:
12 	DynamicRenderable();
13 	virtual ~DynamicRenderable();
14 
15 	void initialize(Ogre::RenderOperation::OperationType operationType, bool useIndices);
16 
17 	virtual Ogre::Real getBoundingRadius(void) const;
18 	virtual Ogre::Real getSquaredViewDepth(const Ogre::Camera* cam) const;
19 
20 protected:
21 	size_t mVertexBufferCapacity;
22 	size_t mIndexBufferCapacity;
23 
24 	virtual void createVertexDeclaration() = 0;
25 	void prepareHardwareBuffers(size_t vertexCount, size_t indexCount);
26 	virtual void fillHardwareBuffers() = 0;
27 };
28 
29 
30 //----------------------------------------------------------------------------------------------
31 
32 class DynamicLines : public DynamicRenderable
33 {
34    int iBufferSize;
35 private:
36    std::vector<Ogre::Vector3> mPoints;
37    std::vector<Ogre::ColourValue> mColors;
38    bool mDirty;
39 
40 public:
41    DynamicLines(Ogre::RenderOperation::OperationType opType = Ogre::RenderOperation::OT_LINE_STRIP);
42    virtual ~DynamicLines();
43 
44    void addLine(const Ogre::Vector3 &vectStart, const Ogre::Vector3 &vectEnd, const Ogre::ColourValue &colStart, const Ogre::ColourValue &colEnd);
45    void addLine(const Ogre::Vector3 &vectStart, const Ogre::Vector3 &vectEnd, const Ogre::ColourValue &col);
46    void clear();
47    void update();  //  Call this to update the hardware buffer after making changes.
48 
49    void setOperationType(Ogre::RenderOperation::OperationType opType);
50    Ogre::RenderOperation::OperationType getOperationType() const;
51 
52 protected:
53    virtual void createVertexDeclaration();
54    virtual void fillHardwareBuffers();
55 };
56