OgreBillboardChain.h
Go to the documentation of this file.
/*
-----------------------------------------------------------------------------
This source file is part of OGRE
(Object-oriented Graphics Rendering Engine)
For the latest info, see http://www.ogre3d.org/
Copyright (c) 2000-2013 Torus Knot Software Ltd
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
-----------------------------------------------------------------------------
*/
// Thanks to Vincent Cantin (karmaGfa) for the original implementation of this
// class, although it has now been mostly rewritten
#ifndef _BillboardChain_H__
#define _BillboardChain_H__
#include "OgrePrerequisites.h"
#include "OgreMovableObject.h"
#include "OgreRenderable.h"
#include "OgreResourceGroupManager.h"
#include "OgreHeaderPrefix.h"
namespace Ogre {
class _OgreExport BillboardChain : public MovableObject, public Renderable
{
public:
class _OgreExport Element
{
public:
Element();
Element(const Vector3 &position,
Real width,
Real texCoord,
const ColourValue &colour,
const Quaternion &orientation);
Vector3 position;
Real width;
Real texCoord;
ColourValue colour;
Quaternion orientation;
};
typedef vector<Element>::type ElementList;
BillboardChain(const String& name, size_t maxElements = 20, size_t numberOfChains = 1,
bool useTextureCoords = true, bool useColours = true, bool dynamic = true);
virtual ~BillboardChain();
virtual void setMaxChainElements(size_t maxElements);
virtual size_t getMaxChainElements(void) const { return mMaxElementsPerChain; }
virtual void setNumberOfChains(size_t numChains);
virtual size_t getNumberOfChains(void) const { return mChainCount; }
virtual void setUseTextureCoords(bool use);
virtual bool getUseTextureCoords(void) const { return mUseTexCoords; }
enum TexCoordDirection
{
TCD_U,
TCD_V
};
virtual void setTextureCoordDirection(TexCoordDirection dir);
virtual TexCoordDirection getTextureCoordDirection(void) { return mTexCoordDir; }
virtual void setOtherTextureCoordRange(Real start, Real end);
virtual const Real* getOtherTextureCoordRange(void) const { return mOtherTexCoordRange; }
virtual void setUseVertexColours(bool use);
virtual bool getUseVertexColours(void) const { return mUseVertexColour; }
virtual void setDynamic(bool dyn);
virtual bool getDynamic(void) const { return mDynamic; }
virtual void addChainElement(size_t chainIndex,
const Element& billboardChainElement);
virtual void removeChainElement(size_t chainIndex);
virtual void updateChainElement(size_t chainIndex, size_t elementIndex,
const Element& billboardChainElement);
virtual const Element& getChainElement(size_t chainIndex, size_t elementIndex) const;
virtual size_t getNumChainElements(size_t chainIndex) const;
virtual void clearChain(size_t chainIndex);
virtual void clearAllChains(void);
void setFaceCamera( bool faceCamera, const Vector3 &normalVector=Vector3::UNIT_X );
virtual const String& getMaterialName(void) const { return mMaterialName; }
virtual void setMaterialName( const String& name, const String& groupName = ResourceGroupManager::AUTODETECT_RESOURCE_GROUP_NAME );
// Overridden members follow
Real getSquaredViewDepth(const Camera* cam) const;
Real getBoundingRadius(void) const;
const AxisAlignedBox& getBoundingBox(void) const;
const MaterialPtr& getMaterial(void) const;
const String& getMovableType(void) const;
void _updateRenderQueue(RenderQueue *);
void getRenderOperation(RenderOperation &);
virtual bool preRender(SceneManager* sm, RenderSystem* rsys);
void getWorldTransforms(Matrix4 *) const;
const LightList& getLights(void) const;
void visitRenderables(Renderable::Visitor* visitor,
bool debugRenderables = false);
protected:
size_t mMaxElementsPerChain;
size_t mChainCount;
bool mUseTexCoords;
bool mUseVertexColour;
bool mDynamic;
VertexData* mVertexData;
IndexData* mIndexData;
bool mVertexDeclDirty;
bool mBuffersNeedRecreating;
mutable bool mBoundsDirty;
bool mIndexContentDirty;
bool mVertexContentDirty;
mutable AxisAlignedBox mAABB;
mutable Real mRadius;
String mMaterialName;
MaterialPtr mMaterial;
TexCoordDirection mTexCoordDir;
Real mOtherTexCoordRange[2];
Camera *mVertexCameraUsed;
bool mFaceCamera;
Vector3 mNormalBase;
ElementList mChainElementList;
struct ChainSegment
{
size_t start;
size_t head;
size_t tail;
};
typedef vector<ChainSegment>::type ChainSegmentList;
ChainSegmentList mChainSegmentList;
virtual void setupChainContainers(void);
virtual void setupVertexDeclaration(void);
virtual void setupBuffers(void);
virtual void updateVertexBuffer(Camera* cam);
virtual void updateIndexBuffer(void);
virtual void updateBoundingBox(void) const;
static const size_t SEGMENT_EMPTY;
};
class _OgreExport BillboardChainFactory : public MovableObjectFactory
{
protected:
MovableObject* createInstanceImpl( const String& name, const NameValuePairList* params);
public:
BillboardChainFactory() {}
~BillboardChainFactory() {}
static String FACTORY_TYPE_NAME;
const String& getType(void) const;
void destroyInstance( MovableObject* obj);
};
} // namespace
#include "OgreHeaderSuffix.h"
#endif
Ogre::BillboardChain::mRadius
Real mRadius
Bounding radius.
Definition: OgreBillboardChain.h:308
Ogre::BillboardChain::ChainSegment::tail
size_t tail
The &#39;tail&#39; of the chain, relative to start.
Definition: OgreBillboardChain.h:343
Ogre::Renderable
Abstract class defining the interface all renderable objects must implement.
Definition: OgreRenderable.h:63
Ogre::BillboardChain::mUseTexCoords
bool mUseTexCoords
Use texture coords?
Definition: OgreBillboardChain.h:286
_OgreExport
#define _OgreExport
Definition: OgrePlatform.h:257
Ogre::BillboardChain::SEGMENT_EMPTY
static const size_t SEGMENT_EMPTY
Chain segment has no elements.
Definition: OgreBillboardChain.h:361
Ogre::BillboardChainFactory::~BillboardChainFactory
~BillboardChainFactory()
Definition: OgreBillboardChain.h:372
Ogre::BillboardChain::mChainSegmentList
ChainSegmentList mChainSegmentList
Definition: OgreBillboardChain.h:346
Ogre::MovableObject
Abstract class defining a movable object in a scene.
Definition: OgreMovableObject.h:60
Ogre::BillboardChainFactory::FACTORY_TYPE_NAME
static String FACTORY_TYPE_NAME
Definition: OgreBillboardChain.h:374
OgreRenderable.h
OgreMovableObject.h
Ogre::VertexData
Summary class collecting together vertex source information.
Definition: OgreVertexIndexData.h:49
Ogre::Quaternion
Implementation of a Quaternion, i.e.
Definition: OgreQuaternion.h:57
Ogre::BillboardChain::mVertexContentDirty
bool mVertexContentDirty
Is the vertex buffer dirty?
Definition: OgreBillboardChain.h:304
Ogre::BillboardChain::TCD_U
Tex coord in elements is treated as the &#39;u&#39; texture coordinate.
Definition: OgreBillboardChain.h:154
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::ChainSegment
Simple struct defining a chain segment by referencing a subset of the preallocated buffer (which will...
Definition: OgreBillboardChain.h:336
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::ColourValue
Class representing colour.
Definition: OgreColourValue.h:57
Ogre::Real
float Real
Software floating point type.
Definition: OgrePrerequisites.h:70
Ogre::Vector3::UNIT_X
static const Vector3 UNIT_X
Definition: OgreVector3.h:801
Ogre::RenderQueue
Class to manage the scene object rendering queue.
Definition: OgreRenderQueue.h:92
Ogre::IndexData
Summary class collecting together index data source information.
Definition: OgreVertexIndexData.h:242
Ogre::BillboardChain::mDynamic
bool mDynamic
Dynamic use?
Definition: OgreBillboardChain.h:290
Ogre::BillboardChain::mAABB
AxisAlignedBox mAABB
AABB.
Definition: OgreBillboardChain.h:306
Ogre::BillboardChain::mTexCoordDir
TexCoordDirection mTexCoordDir
Texture coord direction.
Definition: OgreBillboardChain.h:313
Ogre::BillboardChain::mMaterialName
String mMaterialName
Material.
Definition: OgreBillboardChain.h:310
Ogre::BillboardChain::ChainSegmentList
vector< ChainSegment >::type ChainSegmentList
Definition: OgreBillboardChain.h:345
Ogre::BillboardChain::getMaxChainElements
virtual size_t getMaxChainElements(void) const
Get the maximum number of chain elements per chain.
Definition: OgreBillboardChain.h:126
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::Element::position
Vector3 position
Definition: OgreBillboardChain.h:97
Ogre::BillboardChain::getMaterialName
virtual const String & getMaterialName(void) const
Get the material name in use.
Definition: OgreBillboardChain.h:257
Ogre::Matrix4
Class encapsulating a standard 4x4 homogeneous matrix.
Definition: OgreMatrix4.h:78
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::Vector3
Standard 3-dimensional vector.
Definition: OgreVector3.h:51
Ogre::BillboardChain::mVertexCameraUsed
Camera * mVertexCameraUsed
Camera last used to build the vertex buffer.
Definition: OgreBillboardChain.h:317
OgrePrerequisites.h
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::mChainElementList
ElementList mChainElementList
The list holding the chain elements.
Definition: OgreBillboardChain.h:327
Ogre::BillboardChain::Element::texCoord
Real texCoord
U or V texture coord depending on options.
Definition: OgreBillboardChain.h:100
Ogre::HashedVector
A hashed vector.
Definition: OgreCommon.h:332
Ogre::Renderable::Visitor
Visitor object that can be used to iterate over a collection of Renderable instances abstractly...
Definition: OgreRenderable.h:377
Ogre::BillboardChain::Element::colour
ColourValue colour
Definition: OgreBillboardChain.h:101
Ogre::BillboardChain::mIndexContentDirty
bool mIndexContentDirty
Is the index buffer dirty?
Definition: OgreBillboardChain.h:302
Ogre::BillboardChain::ElementList
vector< Element >::type ElementList
Definition: OgreBillboardChain.h:106
Ogre::RenderSystem
Defines the functionality of a 3D API.
Definition: OgreRenderSystem.h:125
Ogre::NameValuePairList
map< String, String >::type NameValuePairList
Name / value parameter pair (first = name, second = value)
Definition: OgreCommon.h:550
Ogre::BillboardChain::mMaterial
MaterialPtr mMaterial
Definition: OgreBillboardChain.h:311
Ogre::String
_StringBase String
Definition: OgrePrerequisites.h:439
Ogre::BillboardChain::mChainCount
size_t mChainCount
Number of chains.
Definition: OgreBillboardChain.h:284
Ogre::BillboardChain::TexCoordDirection
TexCoordDirection
The direction in which texture coordinates from elements of the chain are used.
Definition: OgreBillboardChain.h:151
Ogre::BillboardChain::mFaceCamera
bool mFaceCamera
When true, the billboards always face the camera.
Definition: OgreBillboardChain.h:319
Ogre::BillboardChain::ChainSegment::head
size_t head
The &#39;head&#39; of the chain, relative to start.
Definition: OgreBillboardChain.h:341
Ogre::BillboardChain::Element::width
Real width
Definition: OgreBillboardChain.h:98
Ogre::Camera
A viewpoint from which the scene will be rendered.
Definition: OgreCamera.h:86
OgreHeaderSuffix.h
Ogre::BillboardChain::mUseVertexColour
bool mUseVertexColour
Use vertex colour?
Definition: OgreBillboardChain.h:288
Ogre::BillboardChain::mIndexData
IndexData * mIndexData
Index data (to allow multiple unconnected chains)
Definition: OgreBillboardChain.h:294
Ogre
Definition: OgreAndroidLogListener.h:34
Ogre::BillboardChain::mBoundsDirty
bool mBoundsDirty
Do the bounds need redefining?
Definition: OgreBillboardChain.h:300
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::BillboardChainFactory::BillboardChainFactory
BillboardChainFactory()
Definition: OgreBillboardChain.h:371
Ogre::SharedPtr< Material >
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::vector
Definition: OgrePrerequisites.h:491
OgreHeaderPrefix.h
Ogre::BillboardChain::mMaxElementsPerChain
size_t mMaxElementsPerChain
Maximum length of each chain.
Definition: OgreBillboardChain.h:282
Ogre::BillboardChain::ChainSegment::start
size_t start
The start of this chains subset of the buffer.
Definition: OgreBillboardChain.h:339
Ogre::RenderOperation
&#39;New&#39; rendering operation using vertex buffers.
Definition: OgreRenderOperation.h:45
Ogre::BillboardChain::Element::orientation
Quaternion orientation
Only used when mFaceCamera == false.
Definition: OgreBillboardChain.h:104
OgreResourceGroupManager.h
Ogre::MovableObjectFactory
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.
Definition: OgreMovableObject.h:578
Ogre::BillboardChain::Element
Contains the data of an element of the BillboardChain.
Definition: OgreBillboardChain.h:84
Ogre::AxisAlignedBox
A 3D box aligned with the x/y/z axes.
Definition: OgreAxisAlignedBox.h:54
Ogre::SceneManager
Manages the organisation and rendering of a &#39;scene&#39; i.e.
Definition: OgreSceneManager.h:143
Ogre::BillboardChain::mNormalBase
Vector3 mNormalBase
Used when mFaceCamera == false; determines the billboard&#39;s "normal".
Definition: OgreBillboardChain.h:323
Ogre::BillboardChain::mVertexDeclDirty
bool mVertexDeclDirty
Is the vertex declaration dirty?
Definition: OgreBillboardChain.h:296
Ogre::BillboardChain
Allows the rendering of a chain of connected billboards.
Definition: OgreBillboardChain.h:77
Ogre::BillboardChainFactory
Factory object for creating BillboardChain instances.
Definition: OgreBillboardChain.h:366

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