Crazy Eddie's GUI System  0.8.7
RendererModules/Irrlicht/GeometryBuffer.h
1 /***********************************************************************
2  created: Tue Mar 3 2009
3  author: Paul D Turner (parts based on original code by Thomas Suter)
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 _CEGUIIrrlichtGeometryBuffer_h_
28 #define _CEGUIIrrlichtGeometryBuffer_h_
29 
30 #include "CEGUI/RendererModules/Irrlicht/RendererDef.h"
31 #include "CEGUI/GeometryBuffer.h"
32 #include "CEGUI/Rect.h"
33 #include "CEGUI/Vector.h"
34 #include <irrlicht.h>
35 #include <vector>
36 
37 #if defined(_MSC_VER)
38 # pragma warning(push)
39 # pragma warning(disable : 4251)
40 #endif
41 
42 // Start of CEGUI namespace section
43 namespace CEGUI
44 {
45 class IrrlichtTexture;
46 
48 class IRR_GUIRENDERER_API IrrlichtGeometryBuffer : public GeometryBuffer
49 {
50 public:
52  IrrlichtGeometryBuffer(irr::video::IVideoDriver& driver);
53 
55  const irr::core::matrix4& getMatrix() const;
56 
58  irr::video::SMaterial& getMaterial();
60  const irr::video::SMaterial& getMaterial() const;
61 
62 
63  // implement GeometryBuffer interface
64  void draw() const;
65  void setTranslation(const Vector3f& v);
66  void setRotation(const Quaternion& r);
67  void setPivot(const Vector3f& p);
68  void setClippingRegion(const Rectf& region);
69  void appendVertex(const Vertex& vertex);
70  void appendGeometry(const Vertex* const vbuff, uint vertex_count);
71  void setActiveTexture(Texture* texture);
72  void reset();
74  uint getVertexCount() const;
75  uint getBatchCount() const;
78  void setClippingActive(const bool active);
79  bool isClippingActive() const;
80  // overrides of GeometryBuffer base functions.
81  void setBlendMode(const BlendMode mode);
82 
83 protected:
85  void updateMatrix() const;
86  void setupClipping() const;
87  void cleanupClipping() const;
88 
90  struct BatchInfo
91  {
92  irr::video::ITexture* texture;
93  uint vertexCount;
94  bool clip;
95  };
96 
98  irr::video::IVideoDriver& d_driver;
102  mutable irr::video::SMaterial d_material;
108  irr::core::vector3d<irr::f32> d_translation;
110  irr::core::quaternion d_rotation;
112  irr::core::vector3d<irr::f32> d_pivot;
116  mutable irr::core::matrix4 d_matrix;
118  mutable bool d_matrixValid;
120  typedef std::vector<BatchInfo> BatchList;
122  typedef std::vector<irr::video::S3DVertex> VertexList;
124  typedef std::vector<irr::u16> IndexList;
132  const float d_xViewDir;
134  const float d_texelOffset;
136  mutable irr::core::rect<irr::s32> d_savedViewport;
138  mutable irr::core::matrix4 d_savedProjection;
139 };
140 
141 
142 } // End of CEGUI namespace section
143 
144 #if defined(_MSC_VER)
145 # pragma warning(pop)
146 #endif
147 
148 #endif // end of guard _CEGUIIrrlichtGeometryBuffer_h_
CEGUI::GeometryBuffer
Abstract class defining the interface for objects that buffer geometry for later rendering.
Definition: GeometryBuffer.h:44
CEGUI::IrrlichtGeometryBuffer::appendGeometry
void appendGeometry(const Vertex *const vbuff, uint vertex_count)
Append a number of vertices from an array to the GeometryBuffer.
CEGUI::IrrlichtGeometryBuffer::d_activeTexture
IrrlichtTexture * d_activeTexture
Texture that is set as active.
Definition: RendererModules/Irrlicht/GeometryBuffer.h:100
CEGUI::IrrlichtGeometryBuffer::d_indices
IndexList d_indices
container where added geometry indices are stored.
Definition: RendererModules/Irrlicht/GeometryBuffer.h:130
CEGUI::IrrlichtGeometryBuffer::d_translation
irr::core::vector3d< irr::f32 > d_translation
translation vector
Definition: RendererModules/Irrlicht/GeometryBuffer.h:108
CEGUI::IrrlichtGeometryBuffer::BatchInfo
type to track info for per-texture sub batches of geometry
Definition: RendererModules/Irrlicht/GeometryBuffer.h:91
CEGUI::IrrlichtGeometryBuffer::setPivot
void setPivot(const Vector3f &p)
Set the pivot point to be used when applying the rotations.
CEGUI::IrrlichtGeometryBuffer::getMatrix
const irr::core::matrix4 & getMatrix() const
return the transformation matrix used for this buffer.
CEGUI::IrrlichtGeometryBuffer::getActiveTexture
Texture * getActiveTexture() const
Return a pointer to the currently active Texture object. This may return 0 if no texture is set.
CEGUI::IrrlichtGeometryBuffer::d_xViewDir
const float d_xViewDir
a coefficient used to handle OpenGL / D3D projection variations.
Definition: RendererModules/Irrlicht/GeometryBuffer.h:132
CEGUI::IrrlichtGeometryBuffer::reset
void reset()
Clear all buffered data and reset the GeometryBuffer to the default state.
CEGUI::IrrlichtGeometryBuffer::d_matrix
irr::core::matrix4 d_matrix
model matrix cache
Definition: RendererModules/Irrlicht/GeometryBuffer.h:116
CEGUI::IrrlichtGeometryBuffer::getRenderEffect
RenderEffect * getRenderEffect()
Return the RenderEffect object that is assigned to this GeometryBuffer or 0 if none.
CEGUI::IrrlichtGeometryBuffer::d_vertices
VertexList d_vertices
container where added geometry vertices are stored.
Definition: RendererModules/Irrlicht/GeometryBuffer.h:128
CEGUI::IrrlichtGeometryBuffer::d_savedViewport
irr::core::rect< irr::s32 > d_savedViewport
viewport that was set prior to us initialising clipping
Definition: RendererModules/Irrlicht/GeometryBuffer.h:136
CEGUI::IrrlichtGeometryBuffer::updateMatrix
void updateMatrix() const
update cached matrix
CEGUI::IrrlichtGeometryBuffer::d_batches
BatchList d_batches
list of texture batches added to the geometry buffer
Definition: RendererModules/Irrlicht/GeometryBuffer.h:126
CEGUI::IrrlichtGeometryBuffer::setBlendMode
void setBlendMode(const BlendMode mode)
Set the blend mode option to use when rendering this GeometryBuffer.
CEGUI::IrrlichtGeometryBuffer::d_material
irr::video::SMaterial d_material
material used with the texture for rendering.
Definition: RendererModules/Irrlicht/GeometryBuffer.h:102
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::IrrlichtGeometryBuffer::setClippingActive
void setClippingActive(const bool active)
Set whether clipping will be active for subsequently added vertices.
CEGUI::IrrlichtGeometryBuffer::IrrlichtGeometryBuffer
IrrlichtGeometryBuffer(irr::video::IVideoDriver &driver)
constructor
CEGUI::IrrlichtGeometryBuffer::setClippingRegion
void setClippingRegion(const Rectf &region)
Set the clipping region to be used when rendering this buffer.
CEGUI::IrrlichtGeometryBuffer::VertexList
std::vector< irr::video::S3DVertex > VertexList
type of container used to queue the geometry
Definition: RendererModules/Irrlicht/GeometryBuffer.h:122
CEGUI::IrrlichtGeometryBuffer::getVertexCount
uint getVertexCount() const
Return the total number of vertices currently held by this GeometryBuffer object.
CEGUI::IrrlichtGeometryBuffer::d_savedProjection
irr::core::matrix4 d_savedProjection
projection transform that was set priot to us initialising clipping
Definition: RendererModules/Irrlicht/GeometryBuffer.h:138
CEGUI::IrrlichtGeometryBuffer::getMaterial
const irr::video::SMaterial & getMaterial() const
return reference to the Irrlicht material used with this GeometryBuffer.
CEGUI::IrrlichtGeometryBuffer::draw
void draw() const
Draw the geometry buffered within this GeometryBuffer object.
CEGUI::IrrlichtGeometryBuffer::appendVertex
void appendVertex(const Vertex &vertex)
Append a single vertex to the buffer.
CEGUI::Vertex
structure that is used to hold details of a single vertex in 3D space.
Definition: Vertex.h:42
CEGUI::IrrlichtGeometryBuffer::d_texelOffset
const float d_texelOffset
an offset applied to geometry to get correct texel to pixel mapping.
Definition: RendererModules/Irrlicht/GeometryBuffer.h:134
CEGUI::Vector3< float >
CEGUI::IrrlichtGeometryBuffer::d_driver
irr::video::IVideoDriver & d_driver
Irrlicht video driver we're to use.
Definition: RendererModules/Irrlicht/GeometryBuffer.h:98
CEGUI::IrrlichtGeometryBuffer::getBatchCount
uint getBatchCount() const
Return the number of batches of geometry that this GeometryBuffer has split the vertices into.
CEGUI::IrrlichtGeometryBuffer::d_clipRect
Rectf d_clipRect
rectangular clip region
Definition: RendererModules/Irrlicht/GeometryBuffer.h:104
CEGUI::IrrlichtGeometryBuffer::BatchList
std::vector< BatchInfo > BatchList
type of container that tracks BatchInfos.
Definition: RendererModules/Irrlicht/GeometryBuffer.h:120
CEGUI::Texture
Abstract base class specifying the required interface for Texture objects.
Definition: Texture.h:54
CEGUI::IrrlichtGeometryBuffer::IndexList
std::vector< irr::u16 > IndexList
type of container used for indexes
Definition: RendererModules/Irrlicht/GeometryBuffer.h:124
CEGUI::BlendMode
BlendMode
Enumerated type that contains the valid options that specify the type of blending that is to be perfo...
Definition: Renderer.h:62
CEGUI::IrrlichtGeometryBuffer::d_matrixValid
bool d_matrixValid
true when d_matrix is valid and up to date
Definition: RendererModules/Irrlicht/GeometryBuffer.h:118
CEGUI::IrrlichtGeometryBuffer::d_clippingActive
bool d_clippingActive
whether clipping will be active for the current batch
Definition: RendererModules/Irrlicht/GeometryBuffer.h:106
CEGUI::IrrlichtGeometryBuffer::setActiveTexture
void setActiveTexture(Texture *texture)
Set the active texture to be used with all subsequently added vertices.
CEGUI::IrrlichtTexture
Implementation of the CEGUI::Texture class for the Irrlicht engine.
Definition: RendererModules/Irrlicht/Texture.h:50
CEGUI::IrrlichtGeometryBuffer::getMaterial
irr::video::SMaterial & getMaterial()
return reference to the Irrlicht material used with this GeometryBuffer.
CEGUI::IrrlichtGeometryBuffer::setRenderEffect
void setRenderEffect(RenderEffect *effect)
Set the RenderEffect to be used by this GeometryBuffer.
CEGUI::IrrlichtGeometryBuffer
GeometryBuffer implementation for the Irrlicht engine.
Definition: RendererModules/Irrlicht/GeometryBuffer.h:49
CEGUI::Rect< float >
CEGUI::IrrlichtGeometryBuffer::setTranslation
void setTranslation(const Vector3f &v)
Set the translation to be applied to the geometry in the buffer when it is subsequently rendered.
CEGUI::IrrlichtGeometryBuffer::d_effect
RenderEffect * d_effect
RenderEffect that will be used by the GeometryBuffer.
Definition: RendererModules/Irrlicht/GeometryBuffer.h:114
CEGUI::RenderEffect
Interface for objects that hook into RenderingWindow to affect the rendering process,...
Definition: RenderEffect.h:42
CEGUI::IrrlichtGeometryBuffer::setRotation
void setRotation(const Quaternion &r)
Set the rotations to be applied to the geometry in the buffer when it is subsequently rendered.
CEGUI::IrrlichtGeometryBuffer::d_rotation
irr::core::quaternion d_rotation
rotation quaternion
Definition: RendererModules/Irrlicht/GeometryBuffer.h:110
CEGUI::IrrlichtGeometryBuffer::d_pivot
irr::core::vector3d< irr::f32 > d_pivot
pivot point for rotation
Definition: RendererModules/Irrlicht/GeometryBuffer.h:112