OgreRibbonTrail.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 #ifndef __RibbonTrail_H__
30 #define __RibbonTrail_H__
31 
32 #include "OgrePrerequisites.h"
33 
34 #include "OgreBillboardChain.h"
35 #include "OgreNode.h"
36 #include "OgreIteratorWrappers.h"
37 #include "OgreFrameListener.h"
38 #include "OgreControllerManager.h"
39 #include "OgreHeaderPrefix.h"
40 
41 namespace Ogre {
42 
72  {
73  public:
83  RibbonTrail(const String& name, size_t maxElements = 20, size_t numberOfChains = 1,
84  bool useTextureCoords = true, bool useVertexColours = true);
86  virtual ~RibbonTrail();
87 
90 
94  virtual void addNode(Node* n);
96  virtual void removeNode(Node* n);
98  virtual NodeIterator getNodeIterator(void) const;
100  virtual size_t getChainIndexForNode(const Node* n);
101 
108  virtual void setTrailLength(Real len);
110  virtual Real getTrailLength(void) const { return mTrailLength; }
111 
113  void setMaxChainElements(size_t maxElements);
115  void setNumberOfChains(size_t numChains);
117  void clearChain(size_t chainIndex);
118 
125  virtual void setInitialColour(size_t chainIndex, const ColourValue& col);
132  virtual void setInitialColour(size_t chainIndex, Real r, Real g, Real b, Real a = 1.0);
134  virtual const ColourValue& getInitialColour(size_t chainIndex) const;
135 
140  virtual void setColourChange(size_t chainIndex, const ColourValue& valuePerSecond);
141 
146  virtual void setInitialWidth(size_t chainIndex, Real width);
148  virtual Real getInitialWidth(size_t chainIndex) const;
149 
154  virtual void setWidthChange(size_t chainIndex, Real widthDeltaPerSecond);
156  virtual Real getWidthChange(size_t chainIndex) const;
157 
162  virtual void setColourChange(size_t chainIndex, Real r, Real g, Real b, Real a);
163 
165  virtual const ColourValue& getColourChange(size_t chainIndex) const;
166 
168  void nodeUpdated(const Node* node);
170  void nodeDestroyed(const Node* node);
171 
173  virtual void _timeUpdate(Real time);
174 
176  const String& getMovableType(void) const;
177 
178  protected:
185  // chains not in use
187 
188  // fast lookup node->chain index
189  // we use positional map too because that can be useful
192 
213 
215  virtual void manageController(void);
217  virtual void updateTrail(size_t index, const Node* node);
219  virtual void resetTrail(size_t index, const Node* node);
221  virtual void resetAllTrails(void);
222 
223  };
224 
225 
228  {
229  protected:
231  public:
234 
236 
237  const String& getType(void) const;
239 
240  };
244 }
245 
246 #include "OgreHeaderSuffix.h"
247 
248 #endif
OgreHeaderSuffix.h
Ogre::RibbonTrail::setNumberOfChains
void setNumberOfChains(size_t numChains)
Set the number of chain segments (this class can render multiple chains at once using the same materi...
Ogre::RibbonTrail::addNode
virtual void addNode(Node *n)
Add a node to be tracked.
Ogre
Definition: OgreAndroidLogListener.h:35
Ogre::map
Definition: OgrePrerequisites.h:534
Ogre::RibbonTrail::NodeIterator
ConstVectorIterator< NodeList > NodeIterator
Definition: OgreRibbonTrail.h:89
Ogre::RibbonTrail::setColourChange
virtual void setColourChange(size_t chainIndex, Real r, Real g, Real b, Real a)
Enables / disables fading the trail using colour.
Ogre::RibbonTrail::mNodeToSegMap
NodeToChainSegmentMap mNodeToSegMap
Definition: OgreRibbonTrail.h:191
Ogre::RibbonTrail::clearChain
void clearChain(size_t chainIndex)
Remove all elements of a given chain (but leave the chain intact).
Ogre::RibbonTrail::nodeDestroyed
void nodeDestroyed(const Node *node)
Ogre::RibbonTrail::NodeToChainSegmentMap
map< const Node *, size_t >::type NodeToChainSegmentMap
Definition: OgreRibbonTrail.h:190
Ogre::RibbonTrail::setTrailLength
virtual void setTrailLength(Real len)
Set the length of the trail.
Ogre::RibbonTrail::RibbonTrail
RibbonTrail(const String &name, size_t maxElements=20, size_t numberOfChains=1, bool useTextureCoords=true, bool useVertexColours=true)
Constructor (don't use directly, use factory)
Ogre::RibbonTrail::setMaxChainElements
void setMaxChainElements(size_t maxElements)
Set the maximum number of chain elements per chain.
Ogre::MovableObject
Abstract class defining a movable object in a scene.
Definition: OgreMovableObject.h:61
Ogre::RibbonTrail::mFadeController
Controller< Real > * mFadeController
controller used to hook up frame time to fader
Definition: OgreRibbonTrail.h:210
Ogre::RibbonTrail::getColourChange
virtual const ColourValue & getColourChange(size_t chainIndex) const
Get the per-second fading amount.
Ogre::RibbonTrail::mFreeChains
IndexVector mFreeChains
Definition: OgreRibbonTrail.h:186
Ogre::String
_StringBase String
Definition: OgrePrerequisites.h:439
Ogre::RibbonTrail::getInitialColour
virtual const ColourValue & getInitialColour(size_t chainIndex) const
Get the starting ribbon colour.
Ogre::MovableObjectFactory
Interface definition for a factory class which produces a certain kind of MovableObject,...
Definition: OgreMovableObject.h:579
OgreBillboardChain.h
Ogre::NameValuePairList
map< String, String >::type NameValuePairList
Name / value parameter pair (first = name, second = value)
Definition: OgreCommon.h:550
Ogre::RibbonTrailFactory::destroyInstance
void destroyInstance(MovableObject *obj)
Destroy an instance of the object.
Ogre::RibbonTrail::mTimeControllerValue
ControllerValueRealPtr mTimeControllerValue
controller value for hooking up frame time to fader
Definition: OgreRibbonTrail.h:212
Ogre::RibbonTrail::mNodeToChainSegment
IndexVector mNodeToChainSegment
Ordered like mNodeList, contains chain index.
Definition: OgreRibbonTrail.h:184
Ogre::RibbonTrail
Subclass of BillboardChain which automatically leaves a trail behind one or more Node instances.
Definition: OgreRibbonTrail.h:72
Ogre::RibbonTrail::getInitialWidth
virtual Real getInitialWidth(size_t chainIndex) const
Get the starting ribbon width in world units.
Ogre::RibbonTrail::mElemLength
Real mElemLength
length of each element
Definition: OgreRibbonTrail.h:196
Ogre::Controller< Real >
OgreHeaderPrefix.h
Ogre::Node::Listener
Listener which gets called back on Node events.
Definition: OgreNode.h:85
OgreFrameListener.h
Ogre::RibbonTrail::mInitialWidth
RealList mInitialWidth
Initial width of the ribbon.
Definition: OgreRibbonTrail.h:206
OgrePrerequisites.h
Ogre::RibbonTrail::IndexVector
vector< size_t >::type IndexVector
Mapping of nodes to chain segments.
Definition: OgreRibbonTrail.h:182
Ogre::RibbonTrail::NodeList
vector< Node * >::type NodeList
Definition: OgreRibbonTrail.h:88
Ogre::RibbonTrail::resetAllTrails
virtual void resetAllTrails(void)
Reset all tracked chains to initial state.
OgreControllerManager.h
_OgreExport
#define _OgreExport
Definition: OgrePlatform.h:257
Ogre::RibbonTrail::mDeltaColour
ColourValueList mDeltaColour
fade amount per second
Definition: OgreRibbonTrail.h:204
Ogre::RibbonTrail::setInitialColour
virtual void setInitialColour(size_t chainIndex, Real r, Real g, Real b, Real a=1.0)
Set the starting ribbon colour.
Ogre::RibbonTrail::resetTrail
virtual void resetTrail(size_t index, const Node *node)
Reset the tracked chain to initial state.
Ogre::RibbonTrail::mNodeList
NodeList mNodeList
List of nodes being trailed.
Definition: OgreRibbonTrail.h:180
Ogre::RibbonTrail::getTrailLength
virtual Real getTrailLength(void) const
Get the length of the trail.
Definition: OgreRibbonTrail.h:110
Ogre::RibbonTrail::mSquaredElemLength
Real mSquaredElemLength
Squared length of each element.
Definition: OgreRibbonTrail.h:198
Ogre::SharedPtr< ControllerValue< Real > >
Ogre::RibbonTrailFactory::createInstanceImpl
MovableObject * createInstanceImpl(const String &name, const NameValuePairList *params)
Internal implementation of create method - must be overridden.
Ogre::RibbonTrailFactory::~RibbonTrailFactory
~RibbonTrailFactory()
Definition: OgreRibbonTrail.h:233
OgreNode.h
OgreIteratorWrappers.h
Ogre::RibbonTrail::setInitialWidth
virtual void setInitialWidth(size_t chainIndex, Real width)
Set the starting ribbon width in world units.
Ogre::RibbonTrail::getWidthChange
virtual Real getWidthChange(size_t chainIndex) const
Get the change in ribbon width per second.
Ogre::ColourValue
Class representing colour.
Definition: OgreColourValue.h:58
Ogre::RibbonTrail::manageController
virtual void manageController(void)
Manage updates to the time controller.
Ogre::RibbonTrail::setInitialColour
virtual void setInitialColour(size_t chainIndex, const ColourValue &col)
Set the starting ribbon colour for a given segment.
Ogre::RibbonTrail::getNodeIterator
virtual NodeIterator getNodeIterator(void) const
Get an iterator over the nodes which are being tracked.
Ogre::RibbonTrail::ColourValueList
vector< ColourValue >::type ColourValueList
Definition: OgreRibbonTrail.h:199
Ogre::RibbonTrail::setColourChange
virtual void setColourChange(size_t chainIndex, const ColourValue &valuePerSecond)
Enables / disables fading the trail using colour.
Ogre::RibbonTrail::~RibbonTrail
virtual ~RibbonTrail()
destructor
Ogre::RibbonTrailFactory::FACTORY_TYPE_NAME
static String FACTORY_TYPE_NAME
Definition: OgreRibbonTrail.h:235
Ogre::RibbonTrailFactory::getType
const String & getType(void) const
Get the type of the object to be created.
Ogre::RibbonTrail::RealList
vector< Real >::type RealList
Definition: OgreRibbonTrail.h:200
Ogre::RibbonTrail::removeNode
virtual void removeNode(Node *n)
Remove tracking on a given node.
Ogre::Real
float Real
Software floating point type.
Definition: OgrePrerequisites.h:70
Ogre::RibbonTrail::_timeUpdate
virtual void _timeUpdate(Real time)
Perform any fading / width delta required; internal method.
Ogre::RibbonTrail::mDeltaWidth
RealList mDeltaWidth
Delta width of the ribbon.
Definition: OgreRibbonTrail.h:208
Ogre::BillboardChain
Allows the rendering of a chain of connected billboards.
Definition: OgreBillboardChain.h:78
Ogre::RibbonTrail::mInitialColour
ColourValueList mInitialColour
Initial colour of the ribbon.
Definition: OgreRibbonTrail.h:202
Ogre::RibbonTrail::updateTrail
virtual void updateTrail(size_t index, const Node *node)
Node has changed position, update.
Ogre::Node
Class representing a general-purpose node an articulated scene graph.
Definition: OgreNode.h:65
Ogre::vector
Definition: OgrePrerequisites.h:492
Ogre::RibbonTrail::getMovableType
const String & getMovableType(void) const
Overridden from MovableObject.
Ogre::RibbonTrail::getChainIndexForNode
virtual size_t getChainIndexForNode(const Node *n)
Get the chain index for a given Node being tracked.
Ogre::RibbonTrailFactory
Factory object for creating RibbonTrail instances.
Definition: OgreRibbonTrail.h:228
Ogre::RibbonTrail::nodeUpdated
void nodeUpdated(const Node *node)
Ogre::RibbonTrail::setWidthChange
virtual void setWidthChange(size_t chainIndex, Real widthDeltaPerSecond)
Set the change in ribbon width per second.
Ogre::ConstVectorIterator
Concrete IteratorWrapper for const access to the underlying container.
Definition: OgreIteratorWrapper.h:217
Ogre::RibbonTrailFactory::RibbonTrailFactory
RibbonTrailFactory()
Definition: OgreRibbonTrail.h:232
Ogre::RibbonTrail::mTrailLength
Real mTrailLength
Total length of trail in world units.
Definition: OgreRibbonTrail.h:194

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