# 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-2009 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 // Thanks to Vincent Cantin (karmaGfa) for the original implementation of this
    00030 // class, although it has now been mostly rewritten
    00031
    00032 #ifndef _BillboardChain_H__
    00033 #define _BillboardChain_H__
    00034
    00035 #include "OgrePrerequisites.h"
    00036
    00037 #include "OgreMovableObject.h"
    00038 #include "OgreRenderable.h"
    00039 #include "OgreResourceGroupManager.h"
    00040
    00041 namespace Ogre {
    00042
    00076     class _OgreExport BillboardChain : public MovableObject, public Renderable
    00077     {
    00078
    00079     public:
    00080
    00083         class _OgreExport Element
    00084         {
    00085
    00086         public:
    00087
    00088             Element();
    00089
    00090             Element(Vector3 position,
    00091                 Real width,
    00092                 Real texCoord,
    00093                 ColourValue colour);
    00094
    00095             Vector3 position;
    00096             Real width;
    00098             Real texCoord;
    00099             ColourValue colour;
    00100
    00101         };
    00102         typedef vector<Element>::type ElementList;
    00103
    00112         BillboardChain(const String& name, size_t maxElements = 20, size_t numberOfChains = 1,
    00113             bool useTextureCoords = true, bool useColours = true, bool dynamic = true);
    00115         virtual ~BillboardChain();
    00116
    00119         virtual void setMaxChainElements(size_t maxElements);
    00122         virtual size_t getMaxChainElements(void) const { return mMaxElementsPerChain; }
    00126         virtual void setNumberOfChains(size_t numChains);
    00130         virtual size_t getNumberOfChains(void) const { return mChainCount; }
    00131
    00138         virtual void setUseTextureCoords(bool use);
    00142         virtual bool getUseTextureCoords(void) const { return mUseTexCoords; }
    00143
    00147         enum TexCoordDirection
    00148         {
    00150             TCD_U,
    00152             TCD_V
    00153         };
    00158         virtual void setTextureCoordDirection(TexCoordDirection dir);
    00162         virtual TexCoordDirection getTextureCoordDirection(void) { return mTexCoordDir; }
    00163
    00169         virtual void setOtherTextureCoordRange(Real start, Real end);
    00173         virtual const Real* getOtherTextureCoordRange(void) const { return mOtherTexCoordRange; }
    00174
    00181         virtual void setUseVertexColours(bool use);
    00185         virtual bool getUseVertexColours(void) const { return mUseVertexColour; }
    00186
    00190         virtual void setDynamic(bool dyn);
    00191
    00195         virtual bool getDynamic(void) const { return mDynamic; }
    00196
    00205         virtual void addChainElement(size_t chainIndex,
    00206             const Element& billboardChainElement);
    00210         virtual void removeChainElement(size_t chainIndex);
    00217         virtual void updateChainElement(size_t chainIndex, size_t elementIndex,
    00218             const Element& billboardChainElement);
    00224         virtual const Element& getChainElement(size_t chainIndex, size_t elementIndex) const;
    00225
    00227         virtual size_t getNumChainElements(size_t chainIndex) const;
    00228
    00230         virtual void clearChain(size_t chainIndex);
    00232         virtual void clearAllChains(void);
    00233
    00235         virtual const String& getMaterialName(void) const { return mMaterialName; }
    00237         virtual void setMaterialName( const String& name, const String& groupName = ResourceGroupManager::AUTODETECT_RESOURCE_GROUP_NAME );
    00238
    00239
    00240         // Overridden members follow
    00241         void _notifyCurrentCamera(Camera* cam);
    00242         Real getSquaredViewDepth(const Camera* cam) const;
    00243         Real getBoundingRadius(void) const;
    00244         const AxisAlignedBox& getBoundingBox(void) const;
    00245         const MaterialPtr& getMaterial(void) const;
    00246         const String& getMovableType(void) const;
    00247         void _updateRenderQueue(RenderQueue *);
    00248         void getRenderOperation(RenderOperation &);
    00249         void getWorldTransforms(Matrix4 *) const;
    00250         const LightList& getLights(void) const;
    00252         void visitRenderables(Renderable::Visitor* visitor,
    00253             bool debugRenderables = false);
    00254
    00255
    00256
    00257     protected:
    00258
    00260         size_t mMaxElementsPerChain;
    00262         size_t mChainCount;
    00264         bool mUseTexCoords;
    00266         bool mUseVertexColour;
    00268         bool mDynamic;
    00270         VertexData* mVertexData;
    00272         IndexData* mIndexData;
    00274         bool mVertexDeclDirty;
    00276         bool mBuffersNeedRecreating;
    00278         mutable bool mBoundsDirty;
    00280         bool mIndexContentDirty;
    00282         mutable AxisAlignedBox mAABB;
    00284         mutable Real mRadius;
    00286         String mMaterialName;
    00287         MaterialPtr mMaterial;
    00289         TexCoordDirection mTexCoordDir;
    00291         Real mOtherTexCoordRange[2];
    00292
    00293
    00295         ElementList mChainElementList;
    00296
    00304         struct ChainSegment
    00305         {
    00307             size_t start;
    00309             size_t head;
    00311             size_t tail;
    00312         };
    00313         typedef vector<ChainSegment>::type ChainSegmentList;
    00314         ChainSegmentList mChainSegmentList;
    00315
    00317         virtual void setupChainContainers(void);
    00319         virtual void setupVertexDeclaration(void);
    00320         // Setup buffers
    00321         virtual void setupBuffers(void);
    00323         virtual void updateVertexBuffer(Camera* cam);
    00325         virtual void updateIndexBuffer(void);
    00326         virtual void updateBoundingBox(void) const;
    00327
    00329         static const size_t SEGMENT_EMPTY;
    00330     };
    00331
    00332
    00334     class _OgreExport BillboardChainFactory : public MovableObjectFactory
    00335     {
    00336     protected:
    00337         MovableObject* createInstanceImpl( const String& name, const NameValuePairList* params);
    00338     public:
    00339         BillboardChainFactory() {}
    00340         ~BillboardChainFactory() {}
    00341
    00342         static String FACTORY_TYPE_NAME;
    00343
    00344         const String& getType(void) const;
    00345         void destroyInstance( MovableObject* obj);
    00346
    00347     };
    00348
    00352 } // namespace
    00353
    00354 #endif
    00355
    00356

Copyright © 2008 Torus Knot Software Ltd
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
Last modified Sun May 8 2011 20:28:08