Crazy Eddie's GUI System  0.8.7
RendererModules/Ogre/GeometryBuffer.h
1 /***********************************************************************
2  created: Tue Feb 17 2009
3  author: Paul D Turner
4 *************************************************************************/
5 /***************************************************************************
6  * Copyright (C) 2004 - 2011 Paul D Turner & The CEGUI Development Team
7  *
8  * Permission is hereby granted, free of charge, to any person obtaining
9  * a copy of this software and associated documentation files (the
10  * "Software"), to deal in the Software without restriction, including
11  * without limitation the rights to use, copy, modify, merge, publish,
12  * distribute, sublicense, and/or sell copies of the Software, and to
13  * permit persons to whom the Software is furnished to do so, subject to
14  * the following conditions:
15  *
16  * The above copyright notice and this permission notice shall be
17  * included in all copies or substantial portions of the Software.
18  *
19  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
22  * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
23  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
24  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
25  * OTHER DEALINGS IN THE SOFTWARE.
26  ***************************************************************************/
27 #ifndef _CEGUIOgreGeometryBuffer_h_
28 #define _CEGUIOgreGeometryBuffer_h_
29 
30 #include "CEGUI/GeometryBuffer.h"
31 #include "CEGUI/RendererModules/Ogre/Renderer.h"
32 #include "CEGUI/Rect.h"
33 #include "CEGUI/Quaternion.h"
34 
35 #include <OgreMatrix4.h>
36 #include <OgreColourValue.h>
37 #include <OgreRenderOperation.h>
38 #include <OgreTexture.h>
39 
40 #include <utility>
41 #include <vector>
42 
43 #ifdef CEGUI_USE_OGRE_HLMS
44 #include <OgreRenderable.h>
45 #endif
46 
47 // Ogre forward refs
48 namespace Ogre
49 {
50 class RenderSystem;
51 }
52 
53 // Start of CEGUI namespace section
54 namespace CEGUI
55 {
57 class OGRE_GUIRENDERER_API OgreGeometryBuffer : public GeometryBuffer
58 {
59 public:
61  OgreGeometryBuffer(OgreRenderer& owner, Ogre::RenderSystem& rs);
64 
66  const Ogre::Matrix4& getMatrix() const;
67 
68  // implement CEGUI::GeometryBuffer interface.
69  virtual void draw() const;
70  virtual void setTranslation(const Vector3f& v);
71  virtual void setRotation(const Quaternion& r);
72  virtual void setPivot(const Vector3f& p);
73  virtual void setClippingRegion(const Rectf& region);
74  virtual void appendVertex(const Vertex& vertex);
75  virtual void appendGeometry(const Vertex* const vbuff, uint vertex_count);
76  virtual void setActiveTexture(Texture* texture);
77  virtual void reset();
78  virtual Texture* getActiveTexture() const;
79  virtual uint getVertexCount() const;
80  virtual uint getBatchCount() const;
81  virtual void setRenderEffect(RenderEffect* effect);
83  void setClippingActive(const bool active);
84  bool isClippingActive() const;
85 
86 protected:
88  Ogre::RGBA colourToOgre(const Colour& col) const;
90  void updateMatrix() const;
92  void syncHardwareBuffer() const;
95 
97  struct OgreVertex
98  {
99  float x, y, z;
100  Ogre::RGBA diffuse;
101  float u, v;
102  };
103 
105  struct BatchInfo
106  {
107  Ogre::TexturePtr texture;
108  uint vertexCount;
109  bool clip;
110  };
111 
115  Ogre::RenderSystem& d_renderSystem;
133  mutable Ogre::Matrix4 d_matrix;
135  mutable bool d_matrixValid;
136 #ifdef CEGUI_USE_OGRE_HLMS
137  mutable Ogre::v1::RenderOperation d_renderOp;
140  mutable Ogre::v1::HardwareVertexBufferSharedPtr d_hwBuffer;
141 #else
142  mutable Ogre::RenderOperation d_renderOp;
145  mutable Ogre::HardwareVertexBufferSharedPtr d_hwBuffer;
146 #endif
147  mutable bool d_sync;
150  typedef std::vector<BatchInfo> BatchList;
154  typedef std::vector<OgreVertex> VertexList;
157 };
158 
159 
160 } // End of CEGUI namespace section
161 
162 #endif // end of guard _CEGUIOgreGeometryBuffer_h_
CEGUI::GeometryBuffer
Abstract class defining the interface for objects that buffer geometry for later rendering.
Definition: GeometryBuffer.h:44
CEGUI::OgreGeometryBuffer::getMatrix
const Ogre::Matrix4 & getMatrix() const
return the transformation matrix used for this buffer.
CEGUI::OgreGeometryBuffer::setRenderEffect
virtual void setRenderEffect(RenderEffect *effect)
Set the RenderEffect to be used by this GeometryBuffer.
CEGUI::OgreGeometryBuffer::d_clippingActive
bool d_clippingActive
whether clipping will be active for the current batch
Definition: RendererModules/Ogre/GeometryBuffer.h:121
CEGUI::OgreGeometryBuffer::draw
virtual void draw() const
Draw the geometry buffered within this GeometryBuffer object.
CEGUI::OgreGeometryBuffer::syncHardwareBuffer
void syncHardwareBuffer() const
Synchronise data in the hardware buffer with what's been added.
CEGUI::OgreGeometryBuffer::setClippingRegion
virtual void setClippingRegion(const Rectf &region)
Set the clipping region to be used when rendering this buffer.
CEGUI::OgreRenderer
CEGUI::Renderer implementation for the Ogre engine.
Definition: RendererModules/Ogre/Renderer.h:92
CEGUI::OgreGeometryBuffer::OgreVertex
vertex structure used internally and also by Ogre.
Definition: RendererModules/Ogre/GeometryBuffer.h:98
CEGUI::OgreGeometryBuffer::getBatchCount
virtual uint getBatchCount() const
Return the number of batches of geometry that this GeometryBuffer has split the vertices into.
CEGUI::OgreGeometryBuffer::BatchList
std::vector< BatchInfo > BatchList
type of container that tracks BatchInfos.
Definition: RendererModules/Ogre/GeometryBuffer.h:150
CEGUI::OgreGeometryBuffer::d_activeTexture
OgreTexture * d_activeTexture
Texture that is set as active.
Definition: RendererModules/Ogre/GeometryBuffer.h:117
CEGUI
Main namespace for Crazy Eddie's GUI Library.
Definition: arch_overview.dox:1
CEGUI::Quaternion
Class to represent rotation, avoids Gimbal lock.
Definition: Quaternion.h:69
CEGUI::OgreGeometryBuffer::initialiseTextureStates
void initialiseTextureStates() const
set up texture related states
CEGUI::OgreGeometryBuffer::appendGeometry
virtual void appendGeometry(const Vertex *const vbuff, uint vertex_count)
Append a number of vertices from an array to the GeometryBuffer.
CEGUI::OgreGeometryBuffer::setClippingActive
void setClippingActive(const bool active)
Set whether clipping will be active for subsequently added vertices.
CEGUI::OgreGeometryBuffer::getActiveTexture
virtual Texture * getActiveTexture() const
Return a pointer to the currently active Texture object. This may return 0 if no texture is set.
CEGUI::OgreGeometryBuffer::BatchInfo
type to track info for per-texture sub batches of geometry
Definition: RendererModules/Ogre/GeometryBuffer.h:106
CEGUI::OgreGeometryBuffer::updateMatrix
void updateMatrix() const
update cached matrix
CEGUI::Vector2< float >
CEGUI::OgreGeometryBuffer::d_matrix
Ogre::Matrix4 d_matrix
model matrix cache
Definition: RendererModules/Ogre/GeometryBuffer.h:133
CEGUI::OgreGeometryBuffer::getVertexCount
virtual uint getVertexCount() const
Return the total number of vertices currently held by this GeometryBuffer object.
CEGUI::OgreGeometryBuffer::d_vertices
VertexList d_vertices
container where added geometry is stored.
Definition: RendererModules/Ogre/GeometryBuffer.h:156
CEGUI::Vertex
structure that is used to hold details of a single vertex in 3D space.
Definition: Vertex.h:42
CEGUI::OgreGeometryBuffer::setPivot
virtual void setPivot(const Vector3f &p)
Set the pivot point to be used when applying the rotations.
CEGUI::Vector3< float >
CEGUI::OgreGeometryBuffer::d_effect
RenderEffect * d_effect
RenderEffect that will be used by the GeometryBuffer.
Definition: RendererModules/Ogre/GeometryBuffer.h:129
CEGUI::OgreGeometryBuffer::setActiveTexture
virtual void setActiveTexture(Texture *texture)
Set the active texture to be used with all subsequently added vertices.
CEGUI::Texture
Abstract base class specifying the required interface for Texture objects.
Definition: Texture.h:54
CEGUI::OgreGeometryBuffer::d_clipRect
Rectf d_clipRect
rectangular clip region
Definition: RendererModules/Ogre/GeometryBuffer.h:119
CEGUI::OgreGeometryBuffer::~OgreGeometryBuffer
virtual ~OgreGeometryBuffer()
Destructor.
CEGUI::OgreGeometryBuffer::reset
virtual void reset()
Clear all buffered data and reset the GeometryBuffer to the default state.
CEGUI::OgreGeometryBuffer::VertexList
std::vector< OgreVertex > VertexList
type of container used to queue the geometry
Definition: RendererModules/Ogre/GeometryBuffer.h:154
CEGUI::OgreGeometryBuffer::d_batches
BatchList d_batches
list of texture batches added to the geometry buffer
Definition: RendererModules/Ogre/GeometryBuffer.h:152
CEGUI::OgreGeometryBuffer::setRotation
virtual void setRotation(const Quaternion &r)
Set the rotations to be applied to the geometry in the buffer when it is subsequently rendered.
CEGUI::OgreGeometryBuffer::d_renderSystem
Ogre::RenderSystem & d_renderSystem
Ogre render system we're to use.
Definition: RendererModules/Ogre/GeometryBuffer.h:115
CEGUI::OgreGeometryBuffer::d_texelOffset
Vector2f d_texelOffset
offset to be applied to all geometry
Definition: RendererModules/Ogre/GeometryBuffer.h:131
CEGUI::OgreGeometryBuffer::getRenderEffect
virtual RenderEffect * getRenderEffect()
Return the RenderEffect object that is assigned to this GeometryBuffer or 0 if none.
CEGUI::OgreGeometryBuffer::d_owner
OgreRenderer & d_owner
Renderer object that owns this GeometryBuffer.
Definition: RendererModules/Ogre/GeometryBuffer.h:113
CEGUI::OgreGeometryBuffer::OgreGeometryBuffer
OgreGeometryBuffer(OgreRenderer &owner, Ogre::RenderSystem &rs)
Constructor.
CEGUI::OgreGeometryBuffer::d_rotation
Quaternion d_rotation
rotation quaternion
Definition: RendererModules/Ogre/GeometryBuffer.h:125
CEGUI::OgreGeometryBuffer::d_translation
Vector3f d_translation
translation vector
Definition: RendererModules/Ogre/GeometryBuffer.h:123
CEGUI::OgreGeometryBuffer::d_pivot
Vector3f d_pivot
pivot point for rotation
Definition: RendererModules/Ogre/GeometryBuffer.h:127
CEGUI::Colour
Class representing colour values within the system.
Definition: Colour.h:46
CEGUI::Rect< float >
CEGUI::OgreGeometryBuffer::appendVertex
virtual void appendVertex(const Vertex &vertex)
Append a single vertex to the buffer.
CEGUI::OgreGeometryBuffer::d_matrixValid
bool d_matrixValid
true when d_matrix is valid and up to date
Definition: RendererModules/Ogre/GeometryBuffer.h:135
CEGUI::RenderEffect
Interface for objects that hook into RenderingWindow to affect the rendering process,...
Definition: RenderEffect.h:42
CEGUI::OgreGeometryBuffer::colourToOgre
Ogre::RGBA colourToOgre(const Colour &col) const
convert CEGUI::colour into something Ogre can use
CEGUI::OgreGeometryBuffer::setTranslation
virtual void setTranslation(const Vector3f &v)
Set the translation to be applied to the geometry in the buffer when it is subsequently rendered.
CEGUI::OgreGeometryBuffer
Implementation of CEGUI::GeometryBuffer for the Ogre engine.
Definition: RendererModules/Ogre/GeometryBuffer.h:58
CEGUI::OgreTexture
Implementation of the CEGUI::Texture class for the Ogre engine.
Definition: RendererModules/Ogre/Texture.h:39
CEGUI::OgreGeometryBuffer::d_hwBuffer
Ogre::HardwareVertexBufferSharedPtr d_hwBuffer
H/W buffer where the vertices are rendered from.
Definition: RendererModules/Ogre/GeometryBuffer.h:145