Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/map/src/orxonox/tools/DynamicRenderable.h @ 2977

Last change on this file since 2977 was 2942, checked in by Naaduun, 16 years ago

=added dynamic libs to orxonox/tools. changed humancontroller to use mouseview

File size: 2.7 KB
Line 
1#ifndef DYNAMIC_RENDERABLE_H
2#define DYNAMIC_RENDERABLE_H
3
4#include <OgreSimpleRenderable.h>
5
6/// Abstract base class providing mechanisms for dynamically growing hardware buffers.
7class DynamicRenderable : public Ogre::SimpleRenderable
8{
9public:
10  /// Constructor
11  DynamicRenderable();
12  /// Virtual destructor
13  virtual ~DynamicRenderable();
14
15  /** Initializes the dynamic renderable.
16   @remarks
17      This function should only be called once. It initializes the
18      render operation, and calls the abstract function
19      createVertexDeclaration().
20   @param operationType The type of render operation to perform.
21   @param useIndices Specifies whether to use indices to determine the
22          vertices to use as input. */
23  void initialize(Ogre::RenderOperation::OperationType operationType,
24                  bool useIndices);
25
26  /// Implementation of Ogre::SimpleRenderable
27  virtual Ogre::Real getBoundingRadius(void) const;
28  /// Implementation of Ogre::SimpleRenderable
29  virtual Ogre::Real getSquaredViewDepth(const Ogre::Camera* cam) const;
30
31protected:
32  /// Maximum capacity of the currently allocated vertex buffer.
33  size_t mVertexBufferCapacity;
34  /// Maximum capacity of the currently allocated index buffer.
35  size_t mIndexBufferCapacity;
36
37  /** Creates the vertex declaration.
38   @remarks
39      Override and set mRenderOp.vertexData->vertexDeclaration here.
40      mRenderOp.vertexData will be created for you before this method
41      is called. */
42  virtual void createVertexDeclaration() = 0;
43
44  /** Prepares the hardware buffers for the requested vertex and index counts.
45   @remarks
46      This function must be called before locking the buffers in
47      fillHardwareBuffers(). It guarantees that the hardware buffers
48      are large enough to hold at least the requested number of
49      vertices and indices (if using indices). The buffers are
50      possibly reallocated to achieve this.
51   @par
52      The vertex and index count in the render operation are set to
53      the values of vertexCount and indexCount respectively.
54   @param vertexCount The number of vertices the buffer must hold.
55
56   @param indexCount The number of indices the buffer must hold. This
57          parameter is ignored if not using indices. */
58  void prepareHardwareBuffers(size_t vertexCount, size_t indexCount);
59
60  /** Fills the hardware vertex and index buffers with data.
61   @remarks
62      This function must call prepareHardwareBuffers() before locking
63      the buffers to ensure the they are large enough for the data to
64      be written. Afterwards the vertex and index buffers (if using
65      indices) can be locked, and data can be written to them. */
66  virtual void fillHardwareBuffers() = 0;
67};
68
69#endif // DYNAMIC_RENDERABLE_H
Note: See TracBrowser for help on using the repository browser.