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 #include "OgreHeaderPrefix.h"
41 
42 namespace Ogre {
43 
78  {
79 
80  public:
81 
85  {
86 
87  public:
88 
90 
91  Element(const Vector3 &position,
92  Real width,
93  Real texCoord,
94  const ColourValue &colour,
95  const Quaternion &orientation);
96 
102 
105  };
107 
116  BillboardChain(const String& name, size_t maxElements = 20, size_t numberOfChains = 1,
117  bool useTextureCoords = true, bool useColours = true, bool dynamic = true);
119  virtual ~BillboardChain();
120 
123  virtual void setMaxChainElements(size_t maxElements);
126  virtual size_t getMaxChainElements(void) const { return mMaxElementsPerChain; }
130  virtual void setNumberOfChains(size_t numChains);
134  virtual size_t getNumberOfChains(void) const { return mChainCount; }
135 
142  virtual void setUseTextureCoords(bool use);
146  virtual bool getUseTextureCoords(void) const { return mUseTexCoords; }
147 
152  {
156  TCD_V
157  };
166  virtual TexCoordDirection getTextureCoordDirection(void) { return mTexCoordDir; }
167 
173  virtual void setOtherTextureCoordRange(Real start, Real end);
177  virtual const Real* getOtherTextureCoordRange(void) const { return mOtherTexCoordRange; }
178 
185  virtual void setUseVertexColours(bool use);
189  virtual bool getUseVertexColours(void) const { return mUseVertexColour; }
190 
194  virtual void setDynamic(bool dyn);
195 
199  virtual bool getDynamic(void) const { return mDynamic; }
200 
209  virtual void addChainElement(size_t chainIndex,
210  const Element& billboardChainElement);
214  virtual void removeChainElement(size_t chainIndex);
221  virtual void updateChainElement(size_t chainIndex, size_t elementIndex,
222  const Element& billboardChainElement);
228  virtual const Element& getChainElement(size_t chainIndex, size_t elementIndex) const;
229 
231  virtual size_t getNumChainElements(size_t chainIndex) const;
232 
234  virtual void clearChain(size_t chainIndex);
236  virtual void clearAllChains(void);
237 
254  void setFaceCamera( bool faceCamera, const Vector3 &normalVector=Vector3::UNIT_X );
255 
257  virtual const String& getMaterialName(void) const { return mMaterialName; }
260 
261 
262  // Overridden members follow
263  Real getSquaredViewDepth(const Camera* cam) const;
264  Real getBoundingRadius(void) const;
265  const AxisAlignedBox& getBoundingBox(void) const;
266  const MaterialPtr& getMaterial(void) const;
267  const String& getMovableType(void) const;
270  virtual bool preRender(SceneManager* sm, RenderSystem* rsys);
272  const LightList& getLights(void) const;
275  bool debugRenderables = false);
276 
277 
278 
279  protected:
280 
284  size_t mChainCount;
290  bool mDynamic;
300  mutable bool mBoundsDirty;
308  mutable Real mRadius;
315  Real mOtherTexCoordRange[2];
324 
325 
328 
337  {
339  size_t start;
341  size_t head;
343  size_t tail;
344  };
347 
349  virtual void setupChainContainers(void);
351  virtual void setupVertexDeclaration(void);
353  virtual void setupBuffers(void);
355  virtual void updateVertexBuffer(Camera* cam);
357  virtual void updateIndexBuffer(void);
358  virtual void updateBoundingBox(void) const;
359 
361  static const size_t SEGMENT_EMPTY;
362  };
363 
364 
367  {
368  protected:
370  public:
373 
375 
376  const String& getType(void) const;
378 
379  };
380 
384 } // namespace
385 
386 #include "OgreHeaderSuffix.h"
387 
388 #endif
389 
390 
OgreHeaderSuffix.h
Ogre::HashedVector< Light * >
Ogre::BillboardChain::getBoundingRadius
Real getBoundingRadius(void) const
Retrieves the radius of the origin-centered bounding sphere for this object.
Ogre::BillboardChain::mChainElementList
ElementList mChainElementList
The list holding the chain elements.
Definition: OgreBillboardChain.h:327
Ogre::BillboardChain::getMovableType
const String & getMovableType(void) const
Returns the type name of this object.
Ogre::BillboardChain::getRenderOperation
void getRenderOperation(RenderOperation &)
Gets the render operation required to send this object to the frame buffer.
Ogre::BillboardChain::mChainCount
size_t mChainCount
Number of chains.
Definition: OgreBillboardChain.h:284
Ogre::RenderSystem
Defines the functionality of a 3D API.
Definition: OgreRenderSystem.h:126
Ogre::BillboardChain::setUseTextureCoords
virtual void setUseTextureCoords(bool use)
Sets whether texture coordinate information should be included in the final buffers generated.
Ogre::BillboardChain::mFaceCamera
bool mFaceCamera
When true, the billboards always face the camera.
Definition: OgreBillboardChain.h:319
Ogre::BillboardChain::ElementList
vector< Element >::type ElementList
Definition: OgreBillboardChain.h:106
Ogre
Definition: OgreAndroidLogListener.h:35
Ogre::BillboardChain::updateVertexBuffer
virtual void updateVertexBuffer(Camera *cam)
Update the contents of the vertex buffer.
Ogre::BillboardChain::mMaterial
MaterialPtr mMaterial
Definition: OgreBillboardChain.h:311
Ogre::Camera
A viewpoint from which the scene will be rendered.
Definition: OgreCamera.h:87
Ogre::BillboardChain::mUseVertexColour
bool mUseVertexColour
Use vertex colour?
Definition: OgreBillboardChain.h:288
Ogre::BillboardChain::getBoundingBox
const AxisAlignedBox & getBoundingBox(void) const
Retrieves the local axis-aligned bounding box for this object.
Ogre::BillboardChain::TexCoordDirection
TexCoordDirection
The direction in which texture coordinates from elements of the chain are used.
Definition: OgreBillboardChain.h:152
Ogre::BillboardChain::setDynamic
virtual void setDynamic(bool dyn)
Sets whether or not the buffers created for this object are suitable for dynamic alteration.
Ogre::BillboardChain::ChainSegment::start
size_t start
The start of this chains subset of the buffer.
Definition: OgreBillboardChain.h:339
Ogre::BillboardChain::addChainElement
virtual void addChainElement(size_t chainIndex, const Element &billboardChainElement)
Add an element to the 'head' of a chain.
Ogre::BillboardChain::getMaterial
const MaterialPtr & getMaterial(void) const
Retrieves a weak reference to the material this renderable object uses.
Ogre::BillboardChain::mBoundsDirty
bool mBoundsDirty
Do the bounds need redefining?
Definition: OgreBillboardChain.h:300
Ogre::BillboardChain::mIndexData
IndexData * mIndexData
Index data (to allow multiple unconnected chains)
Definition: OgreBillboardChain.h:294
Ogre::BillboardChain::ChainSegment
Simple struct defining a chain segment by referencing a subset of the preallocated buffer (which will...
Definition: OgreBillboardChain.h:337
Ogre::BillboardChain::ChainSegment::head
size_t head
The 'head' of the chain, relative to start.
Definition: OgreBillboardChain.h:341
Ogre::BillboardChain::Element::colour
ColourValue colour
Definition: OgreBillboardChain.h:101
Ogre::BillboardChain::clearChain
virtual void clearChain(size_t chainIndex)
Remove all elements of a given chain (but leave the chain intact).
Ogre::BillboardChain::getChainElement
virtual const Element & getChainElement(size_t chainIndex, size_t elementIndex) const
Get the detail of a chain element.
Ogre::MovableObject
Abstract class defining a movable object in a scene.
Definition: OgreMovableObject.h:61
Ogre::ResourceGroupManager::AUTODETECT_RESOURCE_GROUP_NAME
static String AUTODETECT_RESOURCE_GROUP_NAME
Special resource group name which causes resource group to be automatically determined based on searc...
Definition: OgreResourceGroupManager.h:270
Ogre::BillboardChain::mBuffersNeedRecreating
bool mBuffersNeedRecreating
Do the buffers need recreating?
Definition: OgreBillboardChain.h:298
Ogre::BillboardChain::mVertexData
VertexData * mVertexData
Vertex data.
Definition: OgreBillboardChain.h:292
Ogre::BillboardChain::Element::Element
Element()
Ogre::BillboardChain::Element::position
Vector3 position
Definition: OgreBillboardChain.h:97
Ogre::String
_StringBase String
Definition: OgrePrerequisites.h:439
Ogre::MovableObjectFactory
Interface definition for a factory class which produces a certain kind of MovableObject,...
Definition: OgreMovableObject.h:579
Ogre::BillboardChain::mMaxElementsPerChain
size_t mMaxElementsPerChain
Maximum length of each chain.
Definition: OgreBillboardChain.h:282
Ogre::Vector3::UNIT_X
static const Vector3 UNIT_X
Definition: OgreVector3.h:801
OgreResourceGroupManager.h
Ogre::BillboardChain::getNumChainElements
virtual size_t getNumChainElements(size_t chainIndex) const
Returns the number of chain elements.
Ogre::BillboardChain::getDynamic
virtual bool getDynamic(void) const
Gets whether or not the buffers created for this object are suitable for dynamic alteration.
Definition: OgreBillboardChain.h:199
Ogre::NameValuePairList
map< String, String >::type NameValuePairList
Name / value parameter pair (first = name, second = value)
Definition: OgreCommon.h:550
Ogre::BillboardChain::setOtherTextureCoordRange
virtual void setOtherTextureCoordRange(Real start, Real end)
Set the range of the texture coordinates generated across the width of the chain elements.
Ogre::VertexData
Summary class collecting together vertex source information.
Definition: OgreVertexIndexData.h:50
Ogre::BillboardChain::mVertexDeclDirty
bool mVertexDeclDirty
Is the vertex declaration dirty?
Definition: OgreBillboardChain.h:296
Ogre::Quaternion
Implementation of a Quaternion, i.e.
Definition: OgreQuaternion.h:58
Ogre::BillboardChain::setNumberOfChains
virtual void setNumberOfChains(size_t numChains)
Set the number of chain segments (this class can render multiple chains at once using the same materi...
Ogre::BillboardChain::clearAllChains
virtual void clearAllChains(void)
Remove all elements from all chains (but leave the chains themselves intact).
OgreHeaderPrefix.h
Ogre::BillboardChainFactory::destroyInstance
void destroyInstance(MovableObject *obj)
Destroy an instance of the object.
Ogre::Matrix4
Class encapsulating a standard 4x4 homogeneous matrix.
Definition: OgreMatrix4.h:79
Ogre::SceneManager
Manages the organisation and rendering of a 'scene' i.e.
Definition: OgreSceneManager.h:144
OgrePrerequisites.h
Ogre::BillboardChain::mNormalBase
Vector3 mNormalBase
Used when mFaceCamera == false; determines the billboard's "normal".
Definition: OgreBillboardChain.h:323
Ogre::BillboardChain::mUseTexCoords
bool mUseTexCoords
Use texture coords?
Definition: OgreBillboardChain.h:286
Ogre::BillboardChain::setUseVertexColours
virtual void setUseVertexColours(bool use)
Sets whether vertex colour information should be included in the final buffers generated.
Ogre::BillboardChainFactory::createInstanceImpl
MovableObject * createInstanceImpl(const String &name, const NameValuePairList *params)
Internal implementation of create method - must be overridden.
Ogre::BillboardChain::Element::orientation
Quaternion orientation
Only used when mFaceCamera == false.
Definition: OgreBillboardChain.h:104
Ogre::AxisAlignedBox
A 3D box aligned with the x/y/z axes.
Definition: OgreAxisAlignedBox.h:55
_OgreExport
#define _OgreExport
Definition: OgrePlatform.h:257
Ogre::BillboardChain::mRadius
Real mRadius
Bounding radius.
Definition: OgreBillboardChain.h:308
Ogre::BillboardChain::~BillboardChain
virtual ~BillboardChain()
Destructor.
Ogre::BillboardChain::Element
Contains the data of an element of the BillboardChain.
Definition: OgreBillboardChain.h:85
Ogre::BillboardChain::mVertexContentDirty
bool mVertexContentDirty
Is the vertex buffer dirty?
Definition: OgreBillboardChain.h:304
Ogre::BillboardChainFactory::getType
const String & getType(void) const
Get the type of the object to be created.
Ogre::BillboardChain::setTextureCoordDirection
virtual void setTextureCoordDirection(TexCoordDirection dir)
Sets the direction in which texture coords specified on each element are deemed to run along the leng...
Ogre::BillboardChainFactory::BillboardChainFactory
BillboardChainFactory()
Definition: OgreBillboardChain.h:371
Ogre::BillboardChain::setMaxChainElements
virtual void setMaxChainElements(size_t maxElements)
Set the maximum number of chain elements per chain.
Ogre::BillboardChain::SEGMENT_EMPTY
static const size_t SEGMENT_EMPTY
Chain segment has no elements.
Definition: OgreBillboardChain.h:361
Ogre::BillboardChain::mChainSegmentList
ChainSegmentList mChainSegmentList
Definition: OgreBillboardChain.h:346
Ogre::SharedPtr< Material >
OgreRenderable.h
OgreMovableObject.h
Ogre::BillboardChain::getLights
const LightList & getLights(void) const
Gets a list of lights, ordered relative to how close they are to this renderable.
Ogre::BillboardChainFactory
Factory object for creating BillboardChain instances.
Definition: OgreBillboardChain.h:367
Ogre::BillboardChain::getWorldTransforms
void getWorldTransforms(Matrix4 *) const
Gets the world transform matrix / matrices for this renderable object.
Ogre::BillboardChain::BillboardChain
BillboardChain(const String &name, size_t maxElements=20, size_t numberOfChains=1, bool useTextureCoords=true, bool useColours=true, bool dynamic=true)
Constructor (don't use directly, use factory)
Ogre::BillboardChain::getUseTextureCoords
virtual bool getUseTextureCoords(void) const
Gets whether texture coordinate information should be included in the final buffers generated.
Definition: OgreBillboardChain.h:146
Ogre::BillboardChain::updateBoundingBox
virtual void updateBoundingBox(void) const
Ogre::ColourValue
Class representing colour.
Definition: OgreColourValue.h:58
Ogre::BillboardChain::Element::Element
Element(const Vector3 &position, Real width, Real texCoord, const ColourValue &colour, const Quaternion &orientation)
Ogre::BillboardChain::setMaterialName
virtual void setMaterialName(const String &name, const String &groupName=ResourceGroupManager::AUTODETECT_RESOURCE_GROUP_NAME)
Set the material name to use for rendering.
Ogre::BillboardChain::visitRenderables
void visitRenderables(Renderable::Visitor *visitor, bool debugRenderables=false)
Method to allow a caller to abstractly iterate over the Renderable instances that this MovableObject ...
Ogre::BillboardChain::preRender
virtual bool preRender(SceneManager *sm, RenderSystem *rsys)
Called just prior to the Renderable being rendered.
Ogre::Renderable::Visitor
Visitor object that can be used to iterate over a collection of Renderable instances abstractly.
Definition: OgreRenderable.h:378
Ogre::BillboardChain::ChainSegmentList
vector< ChainSegment >::type ChainSegmentList
Definition: OgreBillboardChain.h:345
Ogre::BillboardChain::mDynamic
bool mDynamic
Dynamic use?
Definition: OgreBillboardChain.h:290
Ogre::BillboardChain::_updateRenderQueue
void _updateRenderQueue(RenderQueue *)
Internal method by which the movable object must add Renderable subclass instances to the rendering q...
Ogre::BillboardChain::setFaceCamera
void setFaceCamera(bool faceCamera, const Vector3 &normalVector=Vector3::UNIT_X)
Sets whether the billboard should always be facing the camera or a custom direction set by each point...
Ogre::BillboardChain::Element::texCoord
Real texCoord
U or V texture coord depending on options.
Definition: OgreBillboardChain.h:100
Ogre::Renderable
Abstract class defining the interface all renderable objects must implement.
Definition: OgreRenderable.h:64
Ogre::BillboardChain::mMaterialName
String mMaterialName
Material.
Definition: OgreBillboardChain.h:310
Ogre::BillboardChain::ChainSegment::tail
size_t tail
The 'tail' of the chain, relative to start.
Definition: OgreBillboardChain.h:343
Ogre::BillboardChain::mAABB
AxisAlignedBox mAABB
AABB.
Definition: OgreBillboardChain.h:306
Ogre::Real
float Real
Software floating point type.
Definition: OgrePrerequisites.h:70
Ogre::BillboardChain::setupChainContainers
virtual void setupChainContainers(void)
Setup the STL collections.
Ogre::BillboardChain::mTexCoordDir
TexCoordDirection mTexCoordDir
Texture coord direction.
Definition: OgreBillboardChain.h:313
Ogre::BillboardChain
Allows the rendering of a chain of connected billboards.
Definition: OgreBillboardChain.h:78
Ogre::BillboardChain::setupBuffers
virtual void setupBuffers(void)
Setup buffers.
Ogre::BillboardChain::getUseVertexColours
virtual bool getUseVertexColours(void) const
Gets whether vertex colour information should be included in the final buffers generated.
Definition: OgreBillboardChain.h:189
Ogre::BillboardChain::TCD_U
@ TCD_U
Tex coord in elements is treated as the 'u' texture coordinate.
Definition: OgreBillboardChain.h:154
Ogre::vector
Definition: OgrePrerequisites.h:492
Ogre::BillboardChain::getNumberOfChains
virtual size_t getNumberOfChains(void) const
Get the number of chain segments (this class can render multiple chains at once using the same materi...
Definition: OgreBillboardChain.h:134
Ogre::BillboardChain::getMaxChainElements
virtual size_t getMaxChainElements(void) const
Get the maximum number of chain elements per chain.
Definition: OgreBillboardChain.h:126
Ogre::BillboardChain::getSquaredViewDepth
Real getSquaredViewDepth(const Camera *cam) const
Returns the camera-relative squared depth of this renderable.
Ogre::BillboardChain::updateChainElement
virtual void updateChainElement(size_t chainIndex, size_t elementIndex, const Element &billboardChainElement)
Update the details of an existing chain element.
Ogre::BillboardChain::setupVertexDeclaration
virtual void setupVertexDeclaration(void)
Setup vertex declaration.
Ogre::IndexData
Summary class collecting together index data source information.
Definition: OgreVertexIndexData.h:243
Ogre::Vector3
Standard 3-dimensional vector.
Definition: OgreVector3.h:52
Ogre::BillboardChainFactory::~BillboardChainFactory
~BillboardChainFactory()
Definition: OgreBillboardChain.h:372
Ogre::RenderOperation
'New' rendering operation using vertex buffers.
Definition: OgreRenderOperation.h:45
Ogre::BillboardChain::getMaterialName
virtual const String & getMaterialName(void) const
Get the material name in use.
Definition: OgreBillboardChain.h:257
Ogre::BillboardChainFactory::FACTORY_TYPE_NAME
static String FACTORY_TYPE_NAME
Definition: OgreBillboardChain.h:374
Ogre::BillboardChain::mIndexContentDirty
bool mIndexContentDirty
Is the index buffer dirty?
Definition: OgreBillboardChain.h:302
Ogre::BillboardChain::updateIndexBuffer
virtual void updateIndexBuffer(void)
Update the contents of the index buffer.
Ogre::BillboardChain::removeChainElement
virtual void removeChainElement(size_t chainIndex)
Remove an element from the 'tail' of a chain.
Ogre::RenderQueue
Class to manage the scene object rendering queue.
Definition: OgreRenderQueue.h:93
Ogre::BillboardChain::mVertexCameraUsed
Camera * mVertexCameraUsed
Camera last used to build the vertex buffer.
Definition: OgreBillboardChain.h:317
Ogre::BillboardChain::getOtherTextureCoordRange
virtual const Real * getOtherTextureCoordRange(void) const
Get the range of the texture coordinates generated across the width of the chain elements.
Definition: OgreBillboardChain.h:177
Ogre::BillboardChain::getTextureCoordDirection
virtual TexCoordDirection getTextureCoordDirection(void)
Gets the direction in which texture coords specified on each element are deemed to run.
Definition: OgreBillboardChain.h:166
Ogre::BillboardChain::Element::width
Real width
Definition: OgreBillboardChain.h:98

Copyright © 2012 Torus Knot Software Ltd
Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.