OgreRibbonTrail.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.
-----------------------------------------------------------------------------
*/
#ifndef __RibbonTrail_H__
#define __RibbonTrail_H__
#include "OgrePrerequisites.h"
#include "OgreBillboardChain.h"
#include "OgreNode.h"
#include "OgreIteratorWrappers.h"
#include "OgreFrameListener.h"
#include "OgreControllerManager.h"
#include "OgreHeaderPrefix.h"
namespace Ogre {
class _OgreExport RibbonTrail : public BillboardChain, public Node::Listener
{
public:
RibbonTrail(const String& name, size_t maxElements = 20, size_t numberOfChains = 1,
bool useTextureCoords = true, bool useVertexColours = true);
virtual ~RibbonTrail();
typedef vector<Node*>::type NodeList;
typedef ConstVectorIterator<NodeList> NodeIterator;
virtual void addNode(Node* n);
virtual void removeNode(Node* n);
virtual NodeIterator getNodeIterator(void) const;
virtual size_t getChainIndexForNode(const Node* n);
virtual void setTrailLength(Real len);
virtual Real getTrailLength(void) const { return mTrailLength; }
void setMaxChainElements(size_t maxElements);
void setNumberOfChains(size_t numChains);
void clearChain(size_t chainIndex);
virtual void setInitialColour(size_t chainIndex, const ColourValue& col);
virtual void setInitialColour(size_t chainIndex, Real r, Real g, Real b, Real a = 1.0);
virtual const ColourValue& getInitialColour(size_t chainIndex) const;
virtual void setColourChange(size_t chainIndex, const ColourValue& valuePerSecond);
virtual void setInitialWidth(size_t chainIndex, Real width);
virtual Real getInitialWidth(size_t chainIndex) const;
virtual void setWidthChange(size_t chainIndex, Real widthDeltaPerSecond);
virtual Real getWidthChange(size_t chainIndex) const;
virtual void setColourChange(size_t chainIndex, Real r, Real g, Real b, Real a);
virtual const ColourValue& getColourChange(size_t chainIndex) const;
void nodeUpdated(const Node* node);
void nodeDestroyed(const Node* node);
virtual void _timeUpdate(Real time);
const String& getMovableType(void) const;
protected:
NodeList mNodeList;
typedef vector<size_t>::type IndexVector;
IndexVector mNodeToChainSegment;
// chains not in use
IndexVector mFreeChains;
// fast lookup node->chain index
// we use positional map too because that can be useful
typedef map<const Node*, size_t>::type NodeToChainSegmentMap;
NodeToChainSegmentMap mNodeToSegMap;
Real mTrailLength;
Real mElemLength;
Real mSquaredElemLength;
typedef vector<ColourValue>::type ColourValueList;
typedef vector<Real>::type RealList;
ColourValueList mInitialColour;
ColourValueList mDeltaColour;
RealList mInitialWidth;
RealList mDeltaWidth;
Controller<Real>* mFadeController;
ControllerValueRealPtr mTimeControllerValue;
virtual void manageController(void);
virtual void updateTrail(size_t index, const Node* node);
virtual void resetTrail(size_t index, const Node* node);
virtual void resetAllTrails(void);
};
class _OgreExport RibbonTrailFactory : public MovableObjectFactory
{
protected:
MovableObject* createInstanceImpl( const String& name, const NameValuePairList* params);
public:
RibbonTrailFactory() {}
~RibbonTrailFactory() {}
static String FACTORY_TYPE_NAME;
const String& getType(void) const;
void destroyInstance( MovableObject* obj);
};
}
#include "OgreHeaderSuffix.h"
#endif
Ogre::RibbonTrail::mFadeController
Controller< Real > * mFadeController
controller used to hook up frame time to fader
Definition: OgreRibbonTrail.h:210
Ogre::RibbonTrail::ColourValueList
vector< ColourValue >::type ColourValueList
Definition: OgreRibbonTrail.h:199
Ogre::RibbonTrail::getTrailLength
virtual Real getTrailLength(void) const
Get the length of the trail.
Definition: OgreRibbonTrail.h:110
Ogre::RibbonTrail::mTimeControllerValue
ControllerValueRealPtr mTimeControllerValue
controller value for hooking up frame time to fader
Definition: OgreRibbonTrail.h:212
_OgreExport
#define _OgreExport
Definition: OgrePlatform.h:257
Ogre::MovableObject
Abstract class defining a movable object in a scene.
Definition: OgreMovableObject.h:60
Ogre::RibbonTrailFactory::RibbonTrailFactory
RibbonTrailFactory()
Definition: OgreRibbonTrail.h:232
Ogre::RibbonTrail::mDeltaWidth
RealList mDeltaWidth
Delta width of the ribbon.
Definition: OgreRibbonTrail.h:208
Ogre::RibbonTrail::NodeToChainSegmentMap
map< const Node *, size_t >::type NodeToChainSegmentMap
Definition: OgreRibbonTrail.h:190
Ogre::ColourValue
Class representing colour.
Definition: OgreColourValue.h:57
Ogre::Real
float Real
Software floating point type.
Definition: OgrePrerequisites.h:70
Ogre::RibbonTrail::mElemLength
Real mElemLength
length of each element
Definition: OgreRibbonTrail.h:196
Ogre::RibbonTrail::mFreeChains
IndexVector mFreeChains
Definition: OgreRibbonTrail.h:186
Ogre::RibbonTrailFactory
Factory object for creating RibbonTrail instances.
Definition: OgreRibbonTrail.h:227
OgreFrameListener.h
Ogre::RibbonTrail
Subclass of BillboardChain which automatically leaves a trail behind one or more Node instances...
Definition: OgreRibbonTrail.h:71
Ogre::RibbonTrail::IndexVector
vector< size_t >::type IndexVector
Mapping of nodes to chain segments.
Definition: OgreRibbonTrail.h:182
Ogre::RibbonTrail::NodeIterator
ConstVectorIterator< NodeList > NodeIterator
Definition: OgreRibbonTrail.h:89
Ogre::Controller< Real >
Ogre::RibbonTrail::mTrailLength
Real mTrailLength
Total length of trail in world units.
Definition: OgreRibbonTrail.h:194
OgreNode.h
OgrePrerequisites.h
Ogre::Node
Class representing a general-purpose node an articulated scene graph.
Definition: OgreNode.h:64
Ogre::RibbonTrailFactory::FACTORY_TYPE_NAME
static String FACTORY_TYPE_NAME
Definition: OgreRibbonTrail.h:235
Ogre::RibbonTrail::RealList
vector< Real >::type RealList
Definition: OgreRibbonTrail.h:200
Ogre::NameValuePairList
map< String, String >::type NameValuePairList
Name / value parameter pair (first = name, second = value)
Definition: OgreCommon.h:550
Ogre::RibbonTrail::mNodeToChainSegment
IndexVector mNodeToChainSegment
Ordered like mNodeList, contains chain index.
Definition: OgreRibbonTrail.h:184
Ogre::RibbonTrailFactory::~RibbonTrailFactory
~RibbonTrailFactory()
Definition: OgreRibbonTrail.h:233
Ogre::String
_StringBase String
Definition: OgrePrerequisites.h:439
Ogre::RibbonTrail::mDeltaColour
ColourValueList mDeltaColour
fade amount per second
Definition: OgreRibbonTrail.h:204
Ogre::RibbonTrail::mInitialColour
ColourValueList mInitialColour
Initial colour of the ribbon.
Definition: OgreRibbonTrail.h:202
Ogre::RibbonTrail::mSquaredElemLength
Real mSquaredElemLength
Squared length of each element.
Definition: OgreRibbonTrail.h:198
Ogre::Node::Listener
Listener which gets called back on Node events.
Definition: OgreNode.h:84
OgreHeaderSuffix.h
OgreIteratorWrappers.h
Ogre
Definition: OgreAndroidLogListener.h:34
Ogre::RibbonTrail::mInitialWidth
RealList mInitialWidth
Initial width of the ribbon.
Definition: OgreRibbonTrail.h:206
Ogre::RibbonTrail::mNodeToSegMap
NodeToChainSegmentMap mNodeToSegMap
Definition: OgreRibbonTrail.h:191
Ogre::SharedPtr< ControllerValue< Real > >
OgreBillboardChain.h
Ogre::ConstVectorIterator
Concrete IteratorWrapper for const access to the underlying container.
Definition: OgreIteratorWrapper.h:217
Ogre::vector
Definition: OgrePrerequisites.h:491
OgreHeaderPrefix.h
Ogre::map
Definition: OgrePrerequisites.h:533
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::RibbonTrail::mNodeList
NodeList mNodeList
List of nodes being trailed.
Definition: OgreRibbonTrail.h:180
OgreControllerManager.h
Ogre::BillboardChain
Allows the rendering of a chain of connected billboards.
Definition: OgreBillboardChain.h:77
Ogre::RibbonTrail::NodeList
vector< Node * >::type NodeList
Definition: OgreRibbonTrail.h:88

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