OgreRibbonTrail.h

Go to the documentation of this file.
00001 /*
00002 -----------------------------------------------------------------------------
00003 This source file is part of OGRE
00004 (Object-oriented Graphics Rendering Engine)
00005 For the latest info, see http://www.ogre3d.org/
00006 
00007 Copyright (c) 2000-2006 Torus Knot Software Ltd
00008 Also see acknowledgements in Readme.html
00009 
00010 This program is free software; you can redistribute it and/or modify it under
00011 the terms of the GNU Lesser General Public License as published by the Free Software
00012 Foundation; either version 2 of the License, or (at your option) any later
00013 version.
00014 
00015 This program is distributed in the hope that it will be useful, but WITHOUT
00016 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00017 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
00018 
00019 You should have received a copy of the GNU Lesser General Public License along with
00020 this program; if not, write to the Free Software Foundation, Inc., 59 Temple
00021 Place - Suite 330, Boston, MA 02111-1307, USA, or go to
00022 http://www.gnu.org/copyleft/lesser.txt.
00023 
00024 You may alternatively use this source under the terms of a specific version of
00025 the OGRE Unrestricted License provided you have obtained such a license from
00026 Torus Knot Software Ltd.
00027 -----------------------------------------------------------------------------
00028 */
00029 
00030 #ifndef __RibbonTrail_H__
00031 #define __RibbonTrail_H__
00032 
00033 #include "OgrePrerequisites.h"
00034 
00035 #include "OgreBillboardChain.h"
00036 #include "OgreNode.h"
00037 #include "OgreIteratorWrappers.h"
00038 #include "OgreFrameListener.h"
00039 #include "OgreControllerManager.h"
00040 
00041 namespace Ogre {
00042 
00065     class _OgreExport RibbonTrail : public BillboardChain, public Node::Listener
00066     {
00067     public:
00077         RibbonTrail(const String& name, size_t maxElements = 20, size_t numberOfChains = 1, 
00078             bool useTextureCoords = true, bool useColours = true);
00080         virtual ~RibbonTrail();
00081 
00082         typedef std::vector<Node*> NodeList;
00083         typedef ConstVectorIterator<NodeList> NodeIterator;
00084 
00088         virtual void addNode(Node* n);
00090         virtual void removeNode(Node* n);
00092         virtual NodeIterator getNodeIterator(void) const;
00094         virtual size_t getChainIndexForNode(const Node* n);
00095 
00102         virtual void setTrailLength(Real len);
00104         virtual Real getTrailLength(void) const { return mTrailLength; }
00105 
00107         void setMaxChainElements(size_t maxElements);
00109         void setNumberOfChains(size_t numChains);
00111         void clearChain(size_t chainIndex);
00112 
00119         virtual void setInitialColour(size_t chainIndex, const ColourValue& col);
00126         virtual void setInitialColour(size_t chainIndex, Real r, Real g, Real b, Real a = 1.0);
00128         virtual const ColourValue& getInitialColour(size_t chainIndex) const;
00129 
00134         virtual void setColourChange(size_t chainIndex, const ColourValue& valuePerSecond);
00135 
00140         virtual void setInitialWidth(size_t chainIndex, Real width);
00142         virtual Real getInitialWidth(size_t chainIndex) const;
00143         
00148         virtual void setWidthChange(size_t chainIndex, Real widthDeltaPerSecond);
00150         virtual Real getWidthChange(size_t chainIndex) const;
00151 
00156         virtual void setColourChange(size_t chainIndex, Real r, Real g, Real b, Real a);
00157 
00159         virtual const ColourValue& getColourChange(size_t chainIndex) const;
00160 
00162         void nodeUpdated(const Node* node);
00164         void nodeDestroyed(const Node* node);
00165 
00167         virtual void _timeUpdate(Real time);
00168 
00170         const String& getMovableType(void) const;
00171 
00172     protected:
00174         NodeList mNodeList;
00176         typedef std::vector<size_t> IndexVector;
00178         IndexVector mNodeToChainSegment;
00179         // chains not in use
00180         IndexVector mFreeChains;
00181 
00182         // fast lookup node->chain index
00183         // we use positional map too because that can be useful
00184         typedef std::map<const Node*, size_t> NodeToChainSegmentMap;
00185         NodeToChainSegmentMap mNodeToSegMap;
00186 
00188         Real mTrailLength;
00190         Real mElemLength;
00192         Real mSquaredElemLength;
00193         typedef std::vector<ColourValue> ColourValueList;
00194         typedef std::vector<Real> RealList;
00196         ColourValueList mInitialColour;
00198         ColourValueList mDeltaColour;
00200         RealList mInitialWidth;
00202         RealList mDeltaWidth;
00204         Controller<Real>* mFadeController;
00206         ControllerValueRealPtr mTimeControllerValue;
00207 
00209         virtual void manageController(void);
00211         virtual void updateTrail(size_t index, const Node* node);
00213         virtual void resetTrail(size_t index, const Node* node);
00215         virtual void resetAllTrails(void);
00216 
00217     };
00218 
00219 
00221     class _OgreExport RibbonTrailFactory : public MovableObjectFactory
00222     {
00223     protected:
00224         MovableObject* createInstanceImpl( const String& name, const NameValuePairList* params);
00225     public:
00226         RibbonTrailFactory() {}
00227         ~RibbonTrailFactory() {}
00228 
00229         static String FACTORY_TYPE_NAME;
00230 
00231         const String& getType(void) const;
00232         void destroyInstance( MovableObject* obj);  
00233 
00234     };
00235 
00236 }
00237 
00238 #endif

Copyright © 2008 Torus Knot Software Ltd
Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 2.5 License.
Last modified Sun Sep 27 22:02:25 2009