Ogre::BillboardSet Class Reference

A collection of billboards (faces which are always facing the given direction) with the same (default) dimensions, material and which are fairly close proximity to each other. More...

#include <OgreBillboardSet.h>

Inheritance diagram for Ogre::BillboardSet:

Inheritance graph
[legend]

List of all members.

Public Types

typedef std::vector
< ShadowRenderable * > 
ShadowRenderableList
typedef
VectorIterator
< ShadowRenderableList
ShadowRenderableListIterator

Public Member Functions

 BillboardSet (const String &name, unsigned int poolSize=20, bool externalDataSource=false)
 Usual constructor - this is called by the SceneManager.
virtual ~BillboardSet ()
BillboardcreateBillboard (const Vector3 &position, const ColourValue &colour=ColourValue::White)
 Creates a new billboard and adds it to this set.
BillboardcreateBillboard (Real x, Real y, Real z, const ColourValue &colour=ColourValue::White)
 Creates a new billboard and adds it to this set.
virtual int getNumBillboards (void) const
 Returns the number of active billboards which currently make up this set.
virtual void setAutoextend (bool autoextend)
 Tells the set whether to allow automatic extension of the pool of billboards.
virtual bool getAutoextend (void) const
 Returns true if the billboard pool automatically extends.
virtual void setSortingEnabled (bool sortenable)
 Enables sorting for this BillboardSet.
virtual bool getSortingEnabled (void) const
 Returns true if sorting of billboards is enabled based on their distance from the camera.
virtual void setPoolSize (size_t size)
 Adjusts the size of the pool of billboards available in this set.
virtual unsigned int getPoolSize (void) const
 Returns the current size of the billboard pool.
virtual void clear ()
 Empties this set of all billboards.
virtual BillboardgetBillboard (unsigned int index) const
 Returns a pointer to the billboard at the supplied index.
virtual void removeBillboard (unsigned int index)
 Removes the billboard at the supplied index.
virtual void removeBillboard (Billboard *pBill)
 Removes a billboard from the set.
virtual void setBillboardOrigin (BillboardOrigin origin)
 Sets the point which acts as the origin point for all billboards in this set.
virtual BillboardOrigin getBillboardOrigin (void) const
 Gets the point which acts as the origin point for all billboards in this set.
virtual void setBillboardRotationType (BillboardRotationType rotationType)
 Sets billboard rotation type.
virtual
BillboardRotationType 
getBillboardRotationType (void) const
 Sets billboard rotation type.
virtual void setDefaultDimensions (Real width, Real height)
 Sets the default dimensions of the billboards in this set.
virtual void setDefaultWidth (Real width)
 See setDefaultDimensions - this sets 1 component individually.
virtual Real getDefaultWidth (void) const
 See setDefaultDimensions - this gets 1 component individually.
virtual void setDefaultHeight (Real height)
 See setDefaultDimensions - this sets 1 component individually.
virtual Real getDefaultHeight (void) const
 See setDefaultDimensions - this gets 1 component individually.
virtual void setMaterialName (const String &name)
 Sets the name of the material to be used for this billboard set.
virtual const StringgetMaterialName (void) const
 Sets the name of the material to be used for this billboard set.
virtual void _notifyCurrentCamera (Camera *cam)
 Overridden from MovableObject.
void beginBillboards (size_t numBillboards=0)
 Begin injection of billboard data; applicable when constructing the BillboardSet for external data use.
void injectBillboard (const Billboard &bb)
 Define a billboard.
void endBillboards (void)
 Finish defining billboards.
void setBounds (const AxisAlignedBox &box, Real radius)
 Set the bounds of the BillboardSet.
virtual const
AxisAlignedBox
getBoundingBox (void) const
 Overridden from MovableObject.
virtual Real getBoundingRadius (void) const
 Overridden from MovableObject.
virtual void _updateRenderQueue (RenderQueue *queue)
 Overridden from MovableObject.
virtual const
MaterialPtr
getMaterial (void) const
 Overridden from MovableObject.
virtual void getRenderOperation (RenderOperation &op)
 Overridden from MovableObject.
virtual void getWorldTransforms (Matrix4 *xform) const
 Overridden from MovableObject.
virtual void _notifyBillboardResized (void)
 Internal callback used by Billboards to notify their parent that they have been resized.
virtual void _notifyBillboardRotated (void)
 Internal callback used by Billboards to notify their parent that they have been rotated.
virtual bool getCullIndividually (void) const
 Returns whether or not billboards in this are tested individually for culling.
virtual void setCullIndividually (bool cullIndividual)
 Sets whether culling tests billboards in this individually as well as in a group.
virtual void setBillboardType (BillboardType bbt)
 Sets the type of billboard to render.
virtual BillboardType getBillboardType (void) const
 Returns the billboard type in use.
virtual void setCommonDirection (const Vector3 &vec)
 Use this to specify the common direction given to billboards of type BBT_ORIENTED_COMMON or BBT_PERPENDICULAR_COMMON.
virtual const Vector3getCommonDirection (void) const
 Gets the common direction for all billboards (BBT_ORIENTED_COMMON).
virtual void setCommonUpVector (const Vector3 &vec)
 Use this to specify the common up-vector given to billboards of type BBT_PERPENDICULAR_SELF or BBT_PERPENDICULAR_COMMON.
virtual const Vector3getCommonUpVector (void) const
 Gets the common up-vector for all billboards (BBT_PERPENDICULAR_SELF and BBT_PERPENDICULAR_COMMON).
virtual void setUseAccurateFacing (bool acc)
 Sets whether or not billboards should use an 'accurate' facing model based on the vector from each billboard to the camera, rather than an optimised version using just the camera direction.
virtual bool getUseAccurateFacing (void) const
 Gets whether or not billboards use an 'accurate' facing model based on the vector from each billboard to the camera, rather than an optimised version using just the camera direction.
virtual const StringgetMovableType (void) const
 Overridden from MovableObject.
Real getSquaredViewDepth (const Camera *cam) const
 Overridden, see Renderable.
virtual void _updateBounds (void)
 Update the bounds of the billboardset.
const LightListgetLights (void) const
 Gets a list of lights, ordered relative to how close they are to this renderable.

Remarks:
Directional lights, which have no position, will always be first on this list.

void visitRenderables (Renderable::Visitor *visitor, bool debugRenderables=false)
 Method to allow a caller to abstractly iterate over the Renderable instances that this MovableObject will add to the render queue when asked, if any.

Parameters:
visitor Pointer to a class implementing the Renderable::Visitor interface which will be called back for each Renderable which will be queued. Bear in mind that the state of the Renderable instances may not be finalised depending on when you call this.
debugRenderables If false, only regular renderables will be visited (those for normal display). If true, debug renderables will be included too.

virtual void _sortBillboards (Camera *cam)
 Sort the billboard set.
virtual SortMode _getSortMode (void) const
 Gets the sort mode of this billboard set.
virtual void setBillboardsInWorldSpace (bool ws)
 Sets whether billboards should be treated as being in world space.
virtual void setTextureCoords (Ogre::FloatRect const *coords, uint16 numCoords)
 BillboardSet can use custom texture coordinates for various billboards.
virtual void setTextureStacksAndSlices (uchar stacks, uchar slices)
 setTextureStacksAndSlices() will generate texture coordinate rects as if the texture for the billboard set contained 'stacks' rows of 'slices' images each, all equal size.
virtual
Ogre::FloatRect
const * 
getTextureCoords (uint16 *oNumCoords)
 getTextureCoords() returns the current texture coordinate rects in effect.
virtual void setPointRenderingEnabled (bool enabled)
 Set whether or not the BillboardSet will use point rendering rather than manually generated quads.
virtual bool isPointRenderingEnabled (void) const
 Returns whether point rendering is enabled.
uint32 getTypeFlags (void) const
 Override to return specific type flag.
virtual void _notifyCreator (MovableObjectFactory *fact)
 Notify the object of it's creator (internal use only).
virtual
MovableObjectFactory
_getCreator (void) const
 Get the creator of this object, if any (internal use only).
virtual void _notifyManager (SceneManager *man)
 Notify the object of it's manager (internal use only).
virtual SceneManager_getManager (void) const
 Get the manager of this object, if any (internal use only).
virtual const StringgetName (void) const
 Returns the name of this object.
virtual NodegetParentNode (void) const
 Returns the node to which this object is attached.
virtual SceneNodegetParentSceneNode (void) const
 Returns the scene node to which this object is attached.
virtual void _notifyAttached (Node *parent, bool isTagPoint=false)
 Internal method called to notify the object that it has been attached to a node.
virtual bool isAttached (void) const
 Returns true if this object is attached to a SceneNode or TagPoint.
virtual void detatchFromParent (void)
 Detaches an object from a parent SceneNode or TagPoint, if attached.
virtual bool isInScene (void) const
 Returns true if this object is attached to a SceneNode or TagPoint, and this SceneNode / TagPoint is currently in an active part of the scene graph.
virtual void _notifyMoved (void)
 Internal method called to notify the object that it has been moved.
virtual const
AxisAlignedBox
getWorldBoundingBox (bool derive=false) const
 Retrieves the axis-aligned bounding box for this object in world coordinates.
virtual const SpheregetWorldBoundingSphere (bool derive=false) const
 Retrieves the worldspace bounding sphere for this object.
virtual void setVisible (bool visible)
 Tells this object whether to be visible or not, if it has a renderable component.
virtual bool getVisible (void) const
 Gets this object whether to be visible or not, if it has a renderable component.
virtual bool isVisible (void) const
 Returns whether or not this object is supposed to be visible or not.
virtual void setRenderingDistance (Real dist)
 Sets the distance at which the object is no longer rendered.
virtual Real getRenderingDistance (void) const
 Gets the distance at which batches are no longer rendered.
virtual void setUserObject (UserDefinedObject *obj)
 Call this to associate your own custom user object instance with this MovableObject.
virtual
UserDefinedObject
getUserObject (void)
 Retrieves a pointer to a custom application object associated with this movable by an earlier call to setUserObject.
virtual void setUserAny (const Any &anything)
 Sets any kind of user value on this object.
virtual const AnygetUserAny (void) const
 Retrieves the custom user value associated with this object.
virtual void setRenderQueueGroup (uint8 queueID)
 Sets the render queue group this entity will be rendered through.
virtual uint8 getRenderQueueGroup (void) const
 Gets the queue group for this entity, see setRenderQueueGroup for full details.
virtual const Matrix4_getParentNodeFullTransform (void) const
 return the full transformation of the parent sceneNode or the attachingPoint node
virtual void setQueryFlags (uint32 flags)
 Sets the query flags for this object.
virtual void addQueryFlags (uint32 flags)
 As setQueryFlags, except the flags passed as parameters are appended to the existing flags on this object.
virtual void removeQueryFlags (unsigned long flags)
 As setQueryFlags, except the flags passed as parameters are removed from the existing flags on this object.
virtual uint32 getQueryFlags (void) const
 Returns the query flags relevant for this object.
virtual void setVisibilityFlags (uint32 flags)
 Sets the visiblity flags for this object.
virtual void addVisibilityFlags (uint32 flags)
 As setVisibilityFlags, except the flags passed as parameters are appended to the existing flags on this object.
virtual void removeVisibilityFlags (uint32 flags)
 As setVisibilityFlags, except the flags passed as parameters are removed from the existing flags on this object.
virtual uint32 getVisibilityFlags (void) const
 Returns the visibility flags relevant for this object.
virtual void setListener (Listener *listener)
 Sets a listener for this object.
virtual Listener * getListener (void) const
 Gets the current listener for this object.
virtual const LightListqueryLights (void) const
 Gets a list of lights, ordered relative to how close they are to this movable object.
virtual LightList_getLightList ()
 Returns a pointer to the current list of lights for this object.
EdgeDatagetEdgeList (void)
 Define a default implementation of method from ShadowCaster which implements no shadows.
bool hasEdgeList (void)
 Define a default implementation of method from ShadowCaster which implements no shadows.
ShadowRenderableListIterator getShadowVolumeRenderableIterator (ShadowTechnique shadowTechnique, const Light *light, HardwareIndexBufferSharedPtr *indexBuffer, bool extrudeVertices, Real extrusionDist, unsigned long flags=0)
 Define a default implementation of method from ShadowCaster which implements no shadows.
const AxisAlignedBoxgetLightCapBounds (void) const
 Overridden member from ShadowCaster.
const AxisAlignedBoxgetDarkCapBounds (const Light &light, Real dirLightExtrusionDist) const
 Overridden member from ShadowCaster.
void setCastShadows (bool enabled)
 Sets whether or not this object will cast shadows.
bool getCastShadows (void) const
 Returns whether shadow casting is enabled for this object.
Real getPointExtrusionDistance (const Light *l) const
 Get the distance to extrude for a point/spot light.
virtual void setDebugDisplayEnabled (bool enabled)
 Sets whether or not the debug display of this object is enabled.
virtual bool isDebugDisplayEnabled (void) const
 Gets whether debug display of this object is enabled.
const StringVectorgetAnimableValueNames (void) const
 Gets a list of animable value names for this object.
virtual AnimableValuePtr createAnimableValue (const String &valueName)
 Create a reference-counted AnimableValuePtr for the named value.
void * operator new (size_t sz, const char *file, int line, const char *func)
 operator new, with debug line info
void * operator new (size_t sz)
void * operator new (size_t sz, void *ptr)
 placement operator new
void * operator new[] (size_t sz, const char *file, int line, const char *func)
 array operator new, with debug line info
void * operator new[] (size_t sz)
void operator delete (void *ptr)
void operator delete (void *ptr, const char *, int, const char *)
void operator delete[] (void *ptr)
void operator delete[] (void *ptr, const char *, int, const char *)
virtual TechniquegetTechnique (void) const
 Retrieves a pointer to the Material Technique this renderable object uses.
virtual bool preRender (SceneManager *sm, RenderSystem *rsys)
 Called just prior to the Renderable being rendered.
virtual void postRender (SceneManager *sm, RenderSystem *rsys)
 Called immediately after the Renderable has been rendered.
virtual unsigned short getNumWorldTransforms (void) const
 Returns the number of world transform matrices this renderable requires.
void setUseIdentityProjection (bool useIdentityProjection)
 Sets whether or not to use an 'identity' projection.
bool getUseIdentityProjection (void) const
 Returns whether or not to use an 'identity' projection.
void setUseIdentityView (bool useIdentityView)
 Sets whether or not to use an 'identity' view.
bool getUseIdentityView (void) const
 Returns whether or not to use an 'identity' view.
virtual bool getCastsShadows (void) const
 Method which reports whether this renderable would normally cast a shadow.
void setCustomParameter (size_t index, const Vector4 &value)
 Sets a custom parameter for this Renderable, which may be used to drive calculations for this specific Renderable, like GPU program parameters.
const Vector4getCustomParameter (size_t index) const
 Gets the custom value associated with this Renderable at the given index.
virtual void _updateCustomGpuParameter (const GpuProgramParameters::AutoConstantEntry &constantEntry, GpuProgramParameters *params) const
 Update a custom GpuProgramParameters constant which is derived from information only this Renderable knows.
virtual void setPolygonModeOverrideable (bool override)
 Sets whether this renderable's chosen detail level can be overridden (downgraded) by the camera setting.
virtual bool getPolygonModeOverrideable (void) const
 Gets whether this renderable's chosen detail level can be overridden (downgraded) by the camera setting.
virtual void setUserAny (const Any &anything)
 Sets any kind of user value on this object.
virtual const AnygetUserAny (void) const
 Retrieves the custom user value associated with this object.
virtual
RenderSystemData * 
getRenderSystemData () const
 Sets render system private data.
virtual void setRenderSystemData (RenderSystemData *val) const
 gets render system private data

Static Public Member Functions

static void setDefaultQueryFlags (uint32 flags)
 Set the default query flags for all future MovableObject instances.
static uint32 getDefaultQueryFlags ()
 Get the default query flags for all future MovableObject instances.
static void setDefaultVisibilityFlags (uint32 flags)
 Set the default visibility flags for all future MovableObject instances.
static uint32 getDefaultVisibilityFlags ()
 Get the default visibility flags for all future MovableObject instances.
static void extrudeVertices (const HardwareVertexBufferSharedPtr &vertexBuffer, size_t originalVertexCount, const Vector4 &lightPos, Real extrudeDist)
 Utility method for extruding vertices based on a light.

Protected Types

typedef std::list
< Billboard * > 
ActiveBillboardList
typedef std::list
< Billboard * > 
FreeBillboardList
typedef std::vector
< Billboard * > 
BillboardPool
typedef std::vector
< Ogre::FloatRect
TextureCoordSets
typedef std::map
< String,
StringVector
AnimableDictionaryMap
typedef std::map
< size_t, Vector4
CustomParameterMap

Protected Member Functions

 BillboardSet ()
 Private constructor (instances cannot be created directly).
bool billboardVisible (Camera *cam, const Billboard &bill)
 Internal method for culling individual billboards.
virtual void increasePool (size_t size)
 Internal method for increasing pool size.
void genBillboardAxes (Vector3 *pX, Vector3 *pY, const Billboard *pBill=0)
 Internal method for generating billboard corners.
void getParametricOffsets (Real &left, Real &right, Real &top, Real &bottom)
 Internal method, generates parametric offsets based on origin.
void genVertices (const Vector3 *const offsets, const Billboard &pBillboard)
 Internal method for generating vertex data.
void genVertOffsets (Real inleft, Real inright, Real intop, Real inbottom, Real width, Real height, const Vector3 &x, const Vector3 &y, Vector3 *pDestVec)
 Internal method generates vertex offsets.
Real getExtrusionDistance (const Vector3 &objectPos, const Light *light) const
 Helper method for calculating extrusion distance.
virtual void updateEdgeListLightFacing (EdgeData *edgeData, const Vector4 &lightPos)
 Tells the caster to perform the tasks necessary to update the edge data's light listing.
virtual void generateShadowVolume (EdgeData *edgeData, const HardwareIndexBufferSharedPtr &indexBuffer, const Light *light, ShadowRenderableList &shadowRenderables, unsigned long flags)
 Generates the indexes required to render a shadow volume into the index buffer which is passed in, and updates shadow renderables to use it.
virtual void extrudeBounds (AxisAlignedBox &box, const Vector4 &lightPos, Real extrudeDist) const
 Utility method for extruding a bounding box.
virtual const StringgetAnimableDictionaryName (void) const
 Get the name of the animable dictionary for this class.
void createAnimableDictionary (void) const
 Internal method for creating a dictionary of animable value names for the class, if it does not already exist.
StringVector_getAnimableValueNames (void)
 Get an updateable reference to animable value list.
virtual void initialiseAnimableDictionary (StringVector &) const
 Internal method for initialising dictionary; should be implemented by subclasses wanting to expose animable parameters.

Protected Attributes

AxisAlignedBox mAABB
 Bounds of all billboards in this set.
Real mBoundingRadius
 Bounding radius.
BillboardOrigin mOriginType
 Origin of each billboard.
BillboardRotationType mRotationType
 Rotation type of each billboard.
Real mDefaultWidth
 Default width of each billboard.
Real mDefaultHeight
 Default height of each billboard.
String mMaterialName
 Name of the material to use.
MaterialPtr mpMaterial
 Pointer to the material to use.
bool mAllDefaultSize
 True if no billboards in this set have been resized - greater efficiency.
bool mAutoExtendPool
 Flag indicating whether to autoextend pool.
bool mSortingEnabled
 Flag indicating whether the billboards has to be sorted.
bool mAccurateFacing
bool mAllDefaultRotation
bool mWorldSpace
ActiveBillboardList mActiveBillboards
 Active billboard list.
FreeBillboardList mFreeBillboards
 Free billboard queue.
BillboardPool mBillboardPool
 Pool of billboard instances for use and reuse in the active billboard list.
VertexDatamVertexData
 The vertex position data for all billboards in this set.
HardwareVertexBufferSharedPtr mMainBuf
 Shortcut to main buffer (positions, colours, texture coords).
float * mLockPtr
 Locked pointer to buffer.
Vector3 mVOffset [4]
 Boundary offsets based on origin and camera orientation Vector3 vLeftOff, vRightOff, vTopOff, vBottomOff; Final vertex offsets, used where sizes all default to save calcs.
CameramCurrentCamera
 Current camera.
Real mLeftOff
Real mRightOff
Real mTopOff
Real mBottomOff
Vector3 mCamX
Vector3 mCamY
Vector3 mCamDir
Quaternion mCamQ
Vector3 mCamPos
IndexDatamIndexData
 The vertex index data for all billboards in this set (1 set only).
bool mCullIndividual
 Flag indicating whether each billboard should be culled separately (default: false).
TextureCoordSets mTextureCoords
BillboardType mBillboardType
 The type of billboard to render.
Vector3 mCommonDirection
 Common direction for billboards of type BBT_ORIENTED_COMMON and BBT_PERPENDICULAR_COMMON.
Vector3 mCommonUpVector
 Common up-vector for billboards of type BBT_PERPENDICULAR_SELF and BBT_PERPENDICULAR_COMMON.
unsigned short mNumVisibleBillboards
bool mPointRendering
 Use point rendering?
String mName
 Name of this object.
MovableObjectFactorymCreator
 Creator of this object (if created by a factory).
SceneManagermManager
 SceneManager holding this object (if applicable).
NodemParentNode
 node to which this object is attached
bool mParentIsTagPoint
bool mVisible
 Is this object visible?
bool mDebugDisplay
 Is debug display enabled?
Real mUpperDistance
 Upper distance to still render.
Real mSquaredUpperDistance
bool mBeyondFarDistance
 Hidden because of distance?
Any mUserAny
 User defined link to another object / value / whatever.
uint8 mRenderQueueID
 The render queue to use when rendering this object.
bool mRenderQueueIDSet
 Flags whether the RenderQueue's default should be used.
uint32 mQueryFlags
 Flags determining whether this object is included / excluded from scene queries.
uint32 mVisibilityFlags
 Flags determining whether this object is visible (compared to SceneManager mask).
AxisAlignedBox mWorldAABB
 Cached world AABB of this object.
Sphere mWorldBoundingSphere
AxisAlignedBox mWorldDarkCapBounds
 World space AABB of this object's dark cap.
bool mCastShadows
 Does this object cast shadows?
bool mRenderingDisabled
 Does rendering this object disabled by listener?
Listener * mListener
 MovableObject listener - only one allowed (no list) for size & performance reasons. */.
LightList mLightList
 List of lights for this object.
ulong mLightListUpdated
 The last frame that this light list was updated in.
CustomParameterMap mCustomParameters
bool mPolygonModeOverrideable
bool mUseIdentityProjection
bool mUseIdentityView
Any mUserAny
RenderSystemData * mRenderSystemData

Static Protected Attributes

static RadixSort
< ActiveBillboardList,
Billboard *, float > 
mRadixSorter
static uint32 msDefaultQueryFlags
 Default query flags.
static uint32 msDefaultVisibilityFlags
 Default visibility flags.
static
AnimableDictionaryMap 
msAnimableDictionary
 Static map of class name to list of animable value names.

Private Member Functions

void _createBuffers (void)
 Internal method creates vertex and index buffers.
void _destroyBuffers (void)
 Internal method destroys vertex and index buffers.

Private Attributes

bool mBuffersCreated
 Flag indicating whether the HW buffers have been created.
size_t mPoolSize
 The number of billboard in the pool.
bool mExternalData
 Is external billboard data in use?

Classes

struct  SortByDirectionFunctor
 Sort by direction functor. More...
struct  SortByDistanceFunctor
 Sort by distance functor. More...


Detailed Description

A collection of billboards (faces which are always facing the given direction) with the same (default) dimensions, material and which are fairly close proximity to each other.

Remarks:
Billboards are rectangles made up of 2 tris which are always facing the given direction. They are typically used for special effects like particles. This class collects together a set of billboards with the same (default) dimensions, material and relative locality in order to process them more efficiently. The entire set of billboards will be culled as a whole (by default, although this can be changed if you want a large set of billboards which are spread out and you want them culled individually), individual Billboards have locations which are relative to the set (which itself derives it's position from the SceneNode it is attached to since it is a MoveableObject), they will be rendered as a single rendering operation, and some calculations will be sped up by the fact that they use the same dimensions so some workings can be reused.
A BillboardSet can be created using the SceneManager::createBillboardSet method. They can also be used internally by other classes to create effects.
Note:
Billboard bounds are only automatically calculated when you create them. If you modify the position of a billboard you may need to call _updateBounds if the billboard moves outside the original bounds. Similarly, the bounds do no shrink when you remove a billboard, if you want them to call _updateBounds, but note this requires a potentially expensi