OGRE  1.8
Object-Oriented Graphics Rendering Engine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
OgreBillboardChain.h
Go to the documentation of this file.
1 /*
2 -----------------------------------------------------------------------------
3 This source file is part of OGRE
4 (Object-oriented Graphics Rendering Engine)
5 For the latest info, see http://www.ogre3d.org/
6 
7 Copyright (c) 2000-2013 Torus Knot Software Ltd
8 
9 Permission is hereby granted, free of charge, to any person obtaining a copy
10 of this software and associated documentation files (the "Software"), to deal
11 in the Software without restriction, including without limitation the rights
12 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 copies of the Software, and to permit persons to whom the Software is
14 furnished to do so, subject to the following conditions:
15 
16 The above copyright notice and this permission notice shall be included in
17 all copies or substantial portions of the Software.
18 
19 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 THE SOFTWARE.
26 -----------------------------------------------------------------------------
27 */
28 
29 // Thanks to Vincent Cantin (karmaGfa) for the original implementation of this
30 // class, although it has now been mostly rewritten
31 
32 #ifndef _BillboardChain_H__
33 #define _BillboardChain_H__
34 
35 #include "OgrePrerequisites.h"
36 
37 #include "OgreMovableObject.h"
38 #include "OgreRenderable.h"
40 
41 namespace Ogre {
42 
77  {
78 
79  public:
80 
84  {
85 
86  public:
87 
88  Element();
89 
90  Element(const Vector3 &position,
91  Real width,
92  Real texCoord,
93  const ColourValue &colour,
94  const Quaternion &orientation);
95 
101 
102  //Only used when mFaceCamera == false
104  };
106 
115  BillboardChain(const String& name, size_t maxElements = 20, size_t numberOfChains = 1,
116  bool useTextureCoords = true, bool useColours = true, bool dynamic = true);
118  virtual ~BillboardChain();
119 
122  virtual void setMaxChainElements(size_t maxElements);
125  virtual size_t getMaxChainElements(void) const { return mMaxElementsPerChain; }
129  virtual void setNumberOfChains(size_t numChains);
133  virtual size_t getNumberOfChains(void) const { return mChainCount; }
134 
141  virtual void setUseTextureCoords(bool use);
145  virtual bool getUseTextureCoords(void) const { return mUseTexCoords; }
146 
151  {
155  TCD_V
156  };
161  virtual void setTextureCoordDirection(TexCoordDirection dir);
165  virtual TexCoordDirection getTextureCoordDirection(void) { return mTexCoordDir; }
166 
172  virtual void setOtherTextureCoordRange(Real start, Real end);
176  virtual const Real* getOtherTextureCoordRange(void) const { return mOtherTexCoordRange; }
177 
184  virtual void setUseVertexColours(bool use);
188  virtual bool getUseVertexColours(void) const { return mUseVertexColour; }
189 
193  virtual void setDynamic(bool dyn);
194 
198  virtual bool getDynamic(void) const { return mDynamic; }
199 
208  virtual void addChainElement(size_t chainIndex,
209  const Element& billboardChainElement);
213  virtual void removeChainElement(size_t chainIndex);
220  virtual void updateChainElement(size_t chainIndex, size_t elementIndex,
221  const Element& billboardChainElement);
227  virtual const Element& getChainElement(size_t chainIndex, size_t elementIndex) const;
228 
230  virtual size_t getNumChainElements(size_t chainIndex) const;
231 
233  virtual void clearChain(size_t chainIndex);
235  virtual void clearAllChains(void);
236 
253  void setFaceCamera( bool faceCamera, const Vector3 &normalVector=Vector3::UNIT_X );
254 
256  virtual const String& getMaterialName(void) const { return mMaterialName; }
258  virtual void setMaterialName( const String& name, const String& groupName = ResourceGroupManager::AUTODETECT_RESOURCE_GROUP_NAME );
259 
260 
261  // Overridden members follow
262  Real getSquaredViewDepth(const Camera* cam) const;
263  Real getBoundingRadius(void) const;
264  const AxisAlignedBox& getBoundingBox(void) const;
265  const MaterialPtr& getMaterial(void) const;
266  const String& getMovableType(void) const;
267  void _updateRenderQueue(RenderQueue *);
268  void getRenderOperation(RenderOperation &);
269  virtual bool preRender(SceneManager* sm, RenderSystem* rsys);
270  void getWorldTransforms(Matrix4 *) const;
271  const LightList& getLights(void) const;
273  void visitRenderables(Renderable::Visitor* visitor,
274  bool debugRenderables = false);
275 
276 
277 
278  protected:
279 
283  size_t mChainCount;
289  bool mDynamic;
299  mutable bool mBoundsDirty;
307  mutable Real mRadius;
314  Real mOtherTexCoordRange[2];
323 
324 
327 
336  {
338  size_t start;
340  size_t head;
342  size_t tail;
343  };
346 
348  virtual void setupChainContainers(void);
350  virtual void setupVertexDeclaration(void);
351  // Setup buffers
352  virtual void setupBuffers(void);
354  virtual void updateVertexBuffer(Camera* cam);
356  virtual void updateIndexBuffer(void);
357  virtual void updateBoundingBox(void) const;
358 
360  static const size_t SEGMENT_EMPTY;
361  };
362 
363 
366  {
367  protected:
368  MovableObject* createInstanceImpl( const String& name, const NameValuePairList* params);
369  public:
372 
374 
375  const String& getType(void) const;
376  void destroyInstance( MovableObject* obj);
377 
378  };
379 
383 } // namespace
384 
385 #endif
386 
387 
size_t mMaxElementsPerChain
Maximum length of each chain.
A viewpoint from which the scene will be rendered.
Definition: OgreCamera.h:86
Class encapsulating a standard 4x4 homogeneous matrix.
Definition: OgreMatrix4.h:78
VertexData * mVertexData
Vertex data.
float Real
Software floating point type.
bool mIndexContentDirty
Is the index buffer dirty?
#define _OgreExport
Definition: OgrePlatform.h:233
size_t start
The start of this chains subset of the buffer.
map< String, String >::type NameValuePairList
Name / value parameter pair (first = name, second = value)
Definition: OgreCommon.h:553
String mMaterialName
Material.
Vector3 mNormalBase
Used when mFaceCamera == false; determines the billboard's "normal".
Contains the data of an element of the BillboardChain.
Class representing colour.
vector< ChainSegment >::type ChainSegmentList
Manages the organisation and rendering of a 'scene' i.e.
static String AUTODETECT_RESOURCE_GROUP_NAME
Special resource group name which causes resource group to be automatically determined based on searc...
virtual const Real * getOtherTextureCoordRange(void) const
Get the range of the texture coordinates generated across the width of the chain elements.
A 3D box aligned with the x/y/z axes.
IndexData * mIndexData
Index data (to allow multiple unconnected chains)
Real texCoord
U or V texture coord depending on options.
ChainSegmentList mChainSegmentList
virtual bool getUseVertexColours(void) const
Gets whether vertex colour information should be included in the final buffers generated.
Interface definition for a factory class which produces a certain kind of MovableObject, and can be registered with Root in order to allow all clients to produce new instances of this object, integrated with the standard Ogre processing.
virtual size_t getMaxChainElements(void) const
Get the maximum number of chain elements per chain.
Abstract class defining a movable object in a scene.
virtual const String & getMaterialName(void) const
Get the material name in use.
Camera * mVertexCameraUsed
Camera last used to build the vertex buffer.
bool mVertexContentDirty
Is the vertex buffer dirty?
Abstract class defining the interface all renderable objects must implement.
Implementation of a Quaternion, i.e.
virtual size_t getNumberOfChains(void) const
Get the number of chain segments (this class can render multiple chains at once using the same materi...
Allows the rendering of a chain of connected billboards.
size_t mChainCount
Number of chains.
size_t tail
The 'tail' of the chain, relative to start.
ElementList mChainElementList
The list holding the chain elements.
TexCoordDirection
The direction in which texture coordinates from elements of the chain are used.
AxisAlignedBox mAABB
AABB.
Real mRadius
Bounding radius.
vector< Element >::type ElementList
bool mBoundsDirty
Do the bounds need redefining?
Summary class collecting together index data source information.
Visitor object that can be used to iterate over a collection of Renderable instances abstractly...
Tex coord in elements is treated as the 'u' texture coordinate.
size_t head
The 'head' of the chain, relative to start.
bool mDynamic
Dynamic use?
Standard 3-dimensional vector.
Definition: OgreVector3.h:51
bool mUseTexCoords
Use texture coords?
bool mVertexDeclDirty
Is the vertex declaration dirty?
Summary class collecting together vertex source information.
'New' rendering operation using vertex buffers.
static const Vector3 UNIT_X
Definition: OgreVector3.h:797
Class to manage the scene object rendering queue.
bool mBuffersNeedRecreating
Do the buffers need recreating?
TexCoordDirection mTexCoordDir
Texture coord direction.
Factory object for creating BillboardChain instances.
_StringBase String
Specialisation of SharedPtr to allow SharedPtr to be assigned to MaterialPtr.
Definition: OgreMaterial.h:688
static const size_t SEGMENT_EMPTY
Chain segment has no elements.
Defines the functionality of a 3D API.
bool mFaceCamera
When true, the billboards always face the camera.
virtual bool getUseTextureCoords(void) const
Gets whether texture coordinate information should be included in the final buffers generated...
virtual TexCoordDirection getTextureCoordDirection(void)
Gets the direction in which texture coords specified on each element are deemed to run...
Simple struct defining a chain segment by referencing a subset of the preallocated buffer (which will...
virtual bool getDynamic(void) const
Gets whether or not the buffers created for this object are suitable for dynamic alteration.
bool mUseVertexColour
Use vertex colour?