# 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;
    00215
    00217         virtual void clearChain(size_t chainIndex);
    00219         virtual void clearAllChains(void);
    00220
    00222         virtual const String& getMaterialName(void) const { return mMaterialName; }
    00224         virtual void setMaterialName(const String& name);
    00225
    00226
    00227         // Overridden members follow
    00228         void _notifyCurrentCamera(Camera* cam);
    00229         Real getSquaredViewDepth(const Camera* cam) const;
    00230         Real getBoundingRadius(void) const;
    00231         const AxisAlignedBox& getBoundingBox(void) const;
    00232         const MaterialPtr& getMaterial(void) const;
    00233         const String& getMovableType(void) const;
    00234         void _updateRenderQueue(RenderQueue *);
    00235         void getRenderOperation(RenderOperation &);
    00236         void getWorldTransforms(Matrix4 *) const;
    00237         const Quaternion& getWorldOrientation(void) const;
    00238         const Vector3& getWorldPosition(void) const;
    00239         const LightList& getLights(void) const;
    00240
    00241
    00242
    00243     protected:
    00244
    00246         size_t mMaxElementsPerChain;
    00248         size_t mChainCount;
    00250         bool mUseTexCoords;
    00252         bool mUseVertexColour;
    00254         bool mDynamic;
    00256         VertexData* mVertexData;
    00258         IndexData* mIndexData;
    00260         bool mVertexDeclDirty;
    00262         bool mBuffersNeedRecreating;
    00264         mutable bool mBoundsDirty;
    00266         bool mIndexContentDirty;
    00268         mutable AxisAlignedBox mAABB;
    00270         mutable Real mRadius;
    00272         String mMaterialName;
    00273         MaterialPtr mMaterial;
    00275         TexCoordDirection mTexCoordDir;
    00277         Real mOtherTexCoordRange[2];
    00278
    00279
    00281         ElementList mChainElementList;
    00282
    00290         struct ChainSegment
    00291         {
    00293             size_t start;
    00295             size_t head;
    00297             size_t tail;
    00298         };
    00299         typedef std::vector<ChainSegment> ChainSegmentList;
    00300         ChainSegmentList mChainSegmentList;
    00301
    00303         virtual void setupChainContainers(void);
    00305         virtual void setupVertexDeclaration(void);
    00306         // Setup buffers
    00307         virtual void setupBuffers(void);
    00309         virtual void updateVertexBuffer(Camera* cam);
    00311         virtual void updateIndexBuffer(void);
    00312         virtual void updateBoundingBox(void) const;
    00313
    00315         static const size_t SEGMENT_EMPTY;
    00316     };
    00317
    00318
    00320     class _OgreExport BillboardChainFactory : public MovableObjectFactory
    00321     {
    00322     protected:
    00323         MovableObject* createInstanceImpl( const String& name, const NameValuePairList* params);
    00324     public:
    00325         BillboardChainFactory() {}
    00326         ~BillboardChainFactory() {}
    00327
    00328         static String FACTORY_TYPE_NAME;
    00329
    00330         const String& getType(void) const;
    00331         void destroyInstance( MovableObject* obj);
    00332
    00333     };
    00334
    00335
    00336 } // namespace
    00337
    00338 #endif
    00339

Copyright © 2000-2005 by The OGRE Team
This work is licensed under a Creative Commons Attribution-ShareAlike 2.5 License.
Last modified Sun Sep 17 15:39:07 2006