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 size_t getNumChainElements(size_t chainIndex) const; 00222 00224 virtual void clearChain(size_t chainIndex); 00226 virtual void clearAllChains(void); 00227 00229 virtual const String& getMaterialName(void) const { return mMaterialName; } 00231 virtual void setMaterialName(const String& name); 00232 00233 00234 // Overridden members follow 00235 void _notifyCurrentCamera(Camera* cam); 00236 Real getSquaredViewDepth(const Camera* cam) const; 00237 Real getBoundingRadius(void) const; 00238 const AxisAlignedBox& getBoundingBox(void) const; 00239 const MaterialPtr& getMaterial(void) const; 00240 const String& getMovableType(void) const; 00241 void _updateRenderQueue(RenderQueue *); 00242 void getRenderOperation(RenderOperation &); 00243 void getWorldTransforms(Matrix4 *) const; 00244 const LightList& getLights(void) const; 00246 void visitRenderables(Renderable::Visitor* visitor, 00247 bool debugRenderables = false); 00248 00249 00250 00251 protected: 00252 00254 size_t mMaxElementsPerChain; 00256 size_t mChainCount; 00258 bool mUseTexCoords; 00260 bool mUseVertexColour; 00262 bool mDynamic; 00264 VertexData* mVertexData; 00266 IndexData* mIndexData; 00268 bool mVertexDeclDirty; 00270 bool mBuffersNeedRecreating; 00272 mutable bool mBoundsDirty; 00274 bool mIndexContentDirty; 00276 mutable AxisAlignedBox mAABB; 00278 mutable Real mRadius; 00280 String mMaterialName; 00281 MaterialPtr mMaterial; 00283 TexCoordDirection mTexCoordDir; 00285 Real mOtherTexCoordRange[2]; 00286 00287 00289 ElementList mChainElementList; 00290 00298 struct ChainSegment 00299 { 00301 size_t start; 00303 size_t head; 00305 size_t tail; 00306 }; 00307 typedef std::vector<ChainSegment> ChainSegmentList; 00308 ChainSegmentList mChainSegmentList; 00309 00311 virtual void setupChainContainers(void); 00313 virtual void setupVertexDeclaration(void); 00314 // Setup buffers 00315 virtual void setupBuffers(void); 00317 virtual void updateVertexBuffer(Camera* cam); 00319 virtual void updateIndexBuffer(void); 00320 virtual void updateBoundingBox(void) const; 00321 00323 static const size_t SEGMENT_EMPTY; 00324 }; 00325 00326 00328 class _OgreExport BillboardChainFactory : public MovableObjectFactory 00329 { 00330 protected: 00331 MovableObject* createInstanceImpl( const String& name, const NameValuePairList* params); 00332 public: 00333 BillboardChainFactory() {} 00334 ~BillboardChainFactory() {} 00335 00336 static String FACTORY_TYPE_NAME; 00337 00338 const String& getType(void) const; 00339 void destroyInstance( MovableObject* obj); 00340 00341 }; 00342 00343 00344 } // namespace 00345 00346 #endif 00347
Copyright © 2008 Torus Knot Software Ltd
This work is licensed under a Creative Commons Attribution-ShareAlike 2.5 License.
Last modified Sun Sep 27 22:02:22 2009