Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

OgreBillboardChain.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-2005 The OGRE Team
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 */
00025 
00026 // Thanks to Vincent Cantin (karmaGfa) for the original implementation of this
00027 // class, although it has now been mostly rewritten
00028 
00029 #ifndef _BillboardChain_H__
00030 #define _BillboardChain_H__
00031 
00032 #include "OgrePrerequisites.h"
00033 
00034 #include "OgreMovableObject.h"
00035 #include "OgreRenderable.h"
00036 
00037 namespace Ogre {
00038 
00039 
00066     class _OgreExport BillboardChain : public MovableObject, public Renderable
00067     {
00068 
00069     public:
00070 
00073         class _OgreExport Element
00074         {
00075 
00076         public:
00077 
00078             Element();
00079 
00080             Element(Vector3 position,
00081                 Real width,
00082                 Real texCoord,
00083                 ColourValue colour);
00084 
00085             Vector3 position;
00086             Real width;
00088             Real texCoord;
00089             ColourValue colour;
00090 
00091         };
00092         typedef std::vector<Element> ElementList;
00093 
00102         BillboardChain(const String& name, size_t maxElements = 20, size_t numberOfChains = 1, 
00103             bool useTextureCoords = true, bool useColours = true, bool dynamic = true);
00105         virtual ~BillboardChain();
00106 
00109         virtual void setMaxChainElements(size_t maxElements);
00112         virtual size_t getMaxChainElements(void) const { return mMaxElementsPerChain; }
00116         virtual void setNumberOfChains(size_t numChains);
00120         virtual size_t getNumberOfChains(void) const { return mChainCount; }
00121 
00128         virtual void setUseTextureCoords(bool use);
00132         virtual bool getUseTextureCoords(void) const { return mUseTexCoords; }
00133 
00137         enum TexCoordDirection
00138         {
00140             TCD_U,
00142             TCD_V,
00143         };
00148         virtual void setTextureCoordDirection(TexCoordDirection dir);
00152         virtual TexCoordDirection getTextureCoordDirection(void) { return mTexCoordDir; }
00153 
00159         virtual void setOtherTextureCoordRange(Real start, Real end);
00163         virtual const Real* getOtherTextureCoordRange(void) const { return mOtherTexCoordRange; }
00164 
00171         virtual void setUseVertexColours(bool use);
00175         virtual bool getUseVertexColours(void) const { return mUseVertexColour; }
00176 
00180         virtual void setDynamic(bool dyn);
00181 
00185         virtual bool getDynamic(void) const { return mDynamic; }
00186         
00195         virtual void addChainElement(size_t chainIndex, 
00196             const Element& billboardChainElement);
00200         virtual void removeChainElement(size_t chainIndex);
00207         virtual void updateChainElement(size_t chainIndex, size_t elementIndex, 
00208             const Element& billboardChainElement);
00214         virtual const Element& getChainElement(size_t chainIndex, size_t elementIndex) const;
00216         virtual const String& getMaterialName(void) const { return mMaterialName; }
00218         virtual void setMaterialName(const String& name);
00219 
00220 
00221         // Overridden members follow
00222         void _notifyCurrentCamera(Camera* cam);
00223         Real getSquaredViewDepth(const Camera* cam) const;
00224         Real getBoundingRadius(void) const;
00225         const AxisAlignedBox& getBoundingBox(void) const;
00226         const MaterialPtr& getMaterial(void) const;
00227         const String& getMovableType(void) const;
00228         void _updateRenderQueue(RenderQueue *);
00229         void getRenderOperation(RenderOperation &);
00230         void getWorldTransforms(Matrix4 *) const;
00231         const Quaternion& getWorldOrientation(void) const;
00232         const Vector3& getWorldPosition(void) const;
00233         const LightList& getLights(void) const;
00234 
00235 
00236 
00237     protected:
00238 
00240         size_t mMaxElementsPerChain;
00242         size_t mChainCount;
00244         bool mUseTexCoords;
00246         bool mUseVertexColour;
00248         bool mDynamic;
00250         VertexData* mVertexData;
00252         IndexData* mIndexData;
00254         bool mVertexDeclDirty;
00256         bool mBuffersNeedRecreating;
00258         mutable bool mBoundsDirty;
00260         bool mIndexContentDirty;
00262         mutable AxisAlignedBox mAABB;
00264         mutable Real mRadius;
00266         String mMaterialName;
00267         MaterialPtr mMaterial;
00269         TexCoordDirection mTexCoordDir;
00271         Real mOtherTexCoordRange[2];
00272 
00273 
00275         ElementList mChainElementList;
00276 
00284         struct ChainSegment
00285         {
00287             size_t start;
00289             size_t head;
00291             size_t tail;
00292         };
00293         typedef std::vector<ChainSegment> ChainSegmentList;
00294         ChainSegmentList mChainSegmentList;
00295 
00297         virtual void setupChainContainers(void);
00299         virtual void setupVertexDeclaration(void);
00300         // Setup buffers
00301         virtual void setupBuffers(void);
00303         virtual void updateVertexBuffer(Camera* cam);
00305         virtual void updateIndexBuffer(void);
00306         virtual void updateBoundingBox(void) const;
00307 
00309         static const size_t SEGMENT_EMPTY;
00310     };
00311 
00312 
00314     class _OgreExport BillboardChainFactory : public MovableObjectFactory
00315     {
00316     protected:
00317         MovableObject* createInstanceImpl( const String& name, const NameValuePairList* params);
00318     public:
00319         BillboardChainFactory() {}
00320         ~BillboardChainFactory() {}
00321 
00322         static String FACTORY_TYPE_NAME;
00323 
00324         const String& getType(void) const;
00325         void destroyInstance( MovableObject* obj);  
00326 
00327     };
00328 
00329 
00330 } // namespace
00331 
00332 #endif
00333 

Copyright © 2000-2005 by The OGRE Team
Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 2.5 License.
Last modified Sun Mar 12 14:37:37 2006