OGRE: OgreBillboardChain.h Source File - OGRE Documentation

Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | 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-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 // Thanks to Vincent Cantin (karmaGfa) for the original implementation of this
    00031 // class, although it has now been mostly rewritten
    00032
    00033 #ifndef _BillboardChain_H__
    00034 #define _BillboardChain_H__
    00035
    00036 #include "OgrePrerequisites.h"
    00037
    00038 #include "OgreMovableObject.h"
    00039 #include "OgreRenderable.h"
    00040
    00041 namespace Ogre {
    00042
    00043
    00070     class _OgreExport BillboardChain : public MovableObject, public Renderable
    00071     {
    00072
    00073     public:
    00074
    00077         class _OgreExport Element
    00078         {
    00079
    00080         public:
    00081
    00082             Element();
    00083
    00084             Element(Vector3 position,
    00085                 Real width,
    00086                 Real texCoord,
    00087                 ColourValue colour);
    00088
    00089             Vector3 position;
    00090             Real width;
    00092             Real texCoord;
    00093             ColourValue colour;
    00094
    00095         };
    00096         typedef std::vector<Element> ElementList;
    00097
    00106         BillboardChain(const String& name, size_t maxElements = 20, size_t numberOfChains = 1,
    00107             bool useTextureCoords = true, bool useColours = true, bool dynamic = true);
    00109         virtual ~BillboardChain();
    00110
    00113         virtual void setMaxChainElements(size_t maxElements);
    00116         virtual size_t getMaxChainElements(void) const { return mMaxElementsPerChain; }
    00120         virtual void setNumberOfChains(size_t numChains);
    00124         virtual size_t getNumberOfChains(void) const { return mChainCount; }
    00125
    00132         virtual void setUseTextureCoords(bool use);
    00136         virtual bool getUseTextureCoords(void) const { return mUseTexCoords; }
    00137
    00141         enum TexCoordDirection
    00142         {
    00144             TCD_U,
    00146             TCD_V
    00147         };
    00152         virtual void setTextureCoordDirection(TexCoordDirection dir);
    00156         virtual TexCoordDirection getTextureCoordDirection(void) { return mTexCoordDir; }
    00157
    00163         virtual void setOtherTextureCoordRange(Real start, Real end);
    00167         virtual const Real* getOtherTextureCoordRange(void) const { return mOtherTexCoordRange; }
    00168
    00175         virtual void setUseVertexColours(bool use);
    00179         virtual bool getUseVertexColours(void) const { return mUseVertexColour; }
    00180
    00184         virtual void setDynamic(bool dyn);
    00185
    00189         virtual bool getDynamic(void) const { return mDynamic; }
    00190
    00199         virtual void addChainElement(size_t chainIndex,
    00200             const Element& billboardChainElement);
    00204         virtual void removeChainElement(size_t chainIndex);
    00211         virtual void updateChainElement(size_t chainIndex, size_t elementIndex,
    00212             const Element& billboardChainElement);
    00218         virtual const Element& getChainElement(size_t chainIndex, size_t elementIndex) const;
    00219
    00221         virtual void clearChain(size_t chainIndex);
    00223         virtual void clearAllChains(void);
    00224
    00226         virtual const String& getMaterialName(void) const { return mMaterialName; }
    00228         virtual void setMaterialName(const String& name);
    00229
    00230
    00231         // Overridden members follow
    00232         void _notifyCurrentCamera(Camera* cam);
    00233         Real getSquaredViewDepth(const Camera* cam) const;
    00234         Real getBoundingRadius(void) const;
    00235         const AxisAlignedBox& getBoundingBox(void) const;
    00236         const MaterialPtr& getMaterial(void) const;
    00237         const String& getMovableType(void) const;
    00238         void _updateRenderQueue(RenderQueue *);
    00239         void getRenderOperation(RenderOperation &);
    00240         void getWorldTransforms(Matrix4 *) const;
    00241         const Quaternion& getWorldOrientation(void) const;
    00242         const Vector3& getWorldPosition(void) const;
    00243         const LightList& getLights(void) const;
    00244
    00245
    00246
    00247     protected:
    00248
    00250         size_t mMaxElementsPerChain;
    00252         size_t mChainCount;
    00254         bool mUseTexCoords;
    00256         bool mUseVertexColour;
    00258         bool mDynamic;
    00260         VertexData* mVertexData;
    00262         IndexData* mIndexData;
    00264         bool mVertexDeclDirty;
    00266         bool mBuffersNeedRecreating;
    00268         mutable bool mBoundsDirty;
    00270         bool mIndexContentDirty;
    00272         mutable AxisAlignedBox mAABB;
    00274         mutable Real mRadius;
    00276         String mMaterialName;
    00277         MaterialPtr mMaterial;
    00279         TexCoordDirection mTexCoordDir;
    00281         Real mOtherTexCoordRange[2];
    00282
    00283
    00285         ElementList mChainElementList;
    00286
    00294         struct ChainSegment
    00295         {
    00297             size_t start;
    00299             size_t head;
    00301             size_t tail;
    00302         };
    00303         typedef std::vector<ChainSegment> ChainSegmentList;
    00304         ChainSegmentList mChainSegmentList;
    00305
    00307         virtual void setupChainContainers(void);
    00309         virtual void setupVertexDeclaration(void);
    00310         // Setup buffers
    00311         virtual void setupBuffers(void);
    00313         virtual void updateVertexBuffer(Camera* cam);
    00315         virtual void updateIndexBuffer(void);
    00316         virtual void updateBoundingBox(void) const;
    00317
    00319         static const size_t SEGMENT_EMPTY;
    00320     };
    00321
    00322
    00324     class _OgreExport BillboardChainFactory : public MovableObjectFactory
    00325     {
    00326     protected:
    00327         MovableObject* createInstanceImpl( const String& name, const NameValuePairList* params);
    00328     public:
    00329         BillboardChainFactory() {}
    00330         ~BillboardChainFactory() {}
    00331
    00332         static String FACTORY_TYPE_NAME;
    00333
    00334         const String& getType(void) const;
    00335         void destroyInstance( MovableObject* obj);
    00336
    00337     };
    00338
    00339
    00340 } // namespace
    00341
    00342 #endif
    00343

Copyright © 2000-2005 by The OGRE Team
This work is licensed under a Creative Commons Attribution-ShareAlike 2.5 License.
Last modified Thu Mar 6 09:46:25 2008