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-2012 Torus Knot Software Ltd
    00008
    00009 Permission is hereby granted, free of charge, to any person obtaining a copy
    00010 of this software and associated documentation files (the "Software"), to deal
    00011 in the Software without restriction, including without limitation the rights
    00012 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    00013 copies of the Software, and to permit persons to whom the Software is
    00014 furnished to do so, subject to the following conditions:
    00015
    00016 The above copyright notice and this permission notice shall be included in
    00017 all copies or substantial portions of the Software.
    00018
    00019 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    00020 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    00021 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    00022 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    00023 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    00024 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
    00025 THE SOFTWARE.
    00026 -----------------------------------------------------------------------------
    00027 */
    00028
    00029 #ifndef __RibbonTrail_H__
    00030 #define __RibbonTrail_H__
    00031
    00032 #include "OgrePrerequisites.h"
    00033
    00034 #include "OgreBillboardChain.h"
    00035 #include "OgreNode.h"
    00036 #include "OgreIteratorWrappers.h"
    00037 #include "OgreFrameListener.h"
    00038 #include "OgreControllerManager.h"
    00039
    00040 namespace Ogre {
    00041
    00070     class _OgreExport RibbonTrail : public BillboardChain, public Node::Listener
    00071     {
    00072     public:
    00082         RibbonTrail(const String& name, size_t maxElements = 20, size_t numberOfChains = 1,
    00083             bool useTextureCoords = true, bool useColours = true);
    00085         virtual ~RibbonTrail();
    00086
    00087         typedef vector<Node*>::type NodeList;
    00088         typedef ConstVectorIterator<NodeList> NodeIterator;
    00089
    00093         virtual void addNode(Node* n);
    00095         virtual void removeNode(Node* n);
    00097         virtual NodeIterator getNodeIterator(void) const;
    00099         virtual size_t getChainIndexForNode(const Node* n);
    00100
    00107         virtual void setTrailLength(Real len);
    00109         virtual Real getTrailLength(void) const { return mTrailLength; }
    00110
    00112         void setMaxChainElements(size_t maxElements);
    00114         void setNumberOfChains(size_t numChains);
    00116         void clearChain(size_t chainIndex);
    00117
    00124         virtual void setInitialColour(size_t chainIndex, const ColourValue& col);
    00131         virtual void setInitialColour(size_t chainIndex, Real r, Real g, Real b, Real a = 1.0);
    00133         virtual const ColourValue& getInitialColour(size_t chainIndex) const;
    00134
    00139         virtual void setColourChange(size_t chainIndex, const ColourValue& valuePerSecond);
    00140
    00145         virtual void setInitialWidth(size_t chainIndex, Real width);
    00147         virtual Real getInitialWidth(size_t chainIndex) const;
    00148
    00153         virtual void setWidthChange(size_t chainIndex, Real widthDeltaPerSecond);
    00155         virtual Real getWidthChange(size_t chainIndex) const;
    00156
    00161         virtual void setColourChange(size_t chainIndex, Real r, Real g, Real b, Real a);
    00162
    00164         virtual const ColourValue& getColourChange(size_t chainIndex) const;
    00165
    00167         void nodeUpdated(const Node* node);
    00169         void nodeDestroyed(const Node* node);
    00170
    00172         virtual void _timeUpdate(Real time);
    00173
    00175         const String& getMovableType(void) const;
    00176
    00177     protected:
    00179         NodeList mNodeList;
    00181         typedef vector<size_t>::type IndexVector;
    00183         IndexVector mNodeToChainSegment;
    00184         // chains not in use
    00185         IndexVector mFreeChains;
    00186
    00187         // fast lookup node->chain index
    00188         // we use positional map too because that can be useful
    00189         typedef map<const Node*, size_t>::type NodeToChainSegmentMap;
    00190         NodeToChainSegmentMap mNodeToSegMap;
    00191
    00193         Real mTrailLength;
    00195         Real mElemLength;
    00197         Real mSquaredElemLength;
    00198         typedef vector<ColourValue>::type ColourValueList;
    00199         typedef vector<Real>::type RealList;
    00201         ColourValueList mInitialColour;
    00203         ColourValueList mDeltaColour;
    00205         RealList mInitialWidth;
    00207         RealList mDeltaWidth;
    00209         Controller<Real>* mFadeController;
    00211         ControllerValueRealPtr mTimeControllerValue;
    00212
    00214         virtual void manageController(void);
    00216         virtual void updateTrail(size_t index, const Node* node);
    00218         virtual void resetTrail(size_t index, const Node* node);
    00220         virtual void resetAllTrails(void);
    00221
    00222     };
    00223
    00224
    00226     class _OgreExport RibbonTrailFactory : public MovableObjectFactory
    00227     {
    00228     protected:
    00229         MovableObject* createInstanceImpl( const String& name, const NameValuePairList* params);
    00230     public:
    00231         RibbonTrailFactory() {}
    00232         ~RibbonTrailFactory() {}
    00233
    00234         static String FACTORY_TYPE_NAME;
    00235
    00236         const String& getType(void) const;
    00237         void destroyInstance( MovableObject* obj);
    00238
    00239     };
    00243 }
    00244
    00245 #endif

Copyright © 2012 Torus Knot Software Ltd
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
Last modified Sun Sep 2 2012 07:27:23