00001 /* 00002 ----------------------------------------------------------------------------- 00003 This source file is part of OGRE 00004 (Object-oriented Graphics Rendering Engine) 00005 For the latest info, see http://ogre.sourceforge.net/ 00006 00007 Copyright © 2000-2002 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 #ifndef __BillboardSet_H__ 00027 #define __BillboardSet_H__ 00028 00029 #include "OgrePrerequisites.h" 00030 00031 #include "OgreMovableObject.h" 00032 #include "OgreRenderable.h" 00033 #include "OgreAxisAlignedBox.h" 00034 #include "OgreBillboard.h" 00035 #include "OgreString.h" 00036 #include "OgreColourValue.h" 00037 #include "OgreStringInterface.h" 00038 00039 namespace Ogre { 00040 00046 enum BillboardOrigin 00047 { 00048 BBO_TOP_LEFT, 00049 BBO_TOP_CENTER, 00050 BBO_TOP_RIGHT, 00051 BBO_CENTER_LEFT, 00052 BBO_CENTER, 00053 BBO_CENTER_RIGHT, 00054 BBO_BOTTOM_LEFT, 00055 BBO_BOTTOM_CENTER, 00056 BBO_BOTTOM_RIGHT 00057 }; 00059 enum BillboardType 00060 { 00062 BBT_POINT, 00064 BBT_ORIENTED_COMMON, 00066 BBT_ORIENTED_SELF 00067 00068 }; 00069 00084 class _OgreExport BillboardSet : public StringInterface, public MovableObject, public Renderable 00085 { 00086 00087 protected: 00090 BillboardSet(); 00091 00093 String mName; 00094 00096 AxisAlignedBox mAABB; 00097 00099 BillboardOrigin mOriginType; 00100 00102 Real mDefaultWidth; 00104 Real mDefaultHeight; 00105 00107 String mMaterialName; 00109 Material* mpMaterial; 00110 00112 bool mAllDefaultSize; 00113 00115 bool mAutoExtendPool; 00116 00117 typedef std::list<Billboard*> ActiveBillboardList; 00118 typedef std::deque<Billboard*> FreeBillboardQueue; 00119 typedef std::vector<Billboard*> BillboardPool; 00120 00129 ActiveBillboardList mActiveBillboards; 00130 00138 FreeBillboardQueue mFreeBillboards; 00139 00144 BillboardPool mBillboardPool; 00145 00146 00148 Real* mpPositions; 00149 00151 RGBA* mpColours; 00152 00154 Real* mpTexCoords; 00155 00157 unsigned short* mpIndexes; 00158 00160 bool mCullIndividual; 00161 00163 BillboardType mBillboardType; 00164 00166 Vector3 mCommonDirection; 00167 00169 inline bool billboardVisible(Camera* cam, ActiveBillboardList::iterator bill); 00170 00171 // Number of visible billboards (will be == getNumBillboards if mCullIndividual == false) 00172 unsigned short mNumVisibleBillboards; 00173 00175 virtual void increasePool(unsigned int size); 00176 00177 00178 //----------------------------------------------------------------------- 00179 // The internal methods which follow are here to allow maximum flexibility as to 00180 // when various components of the calculation are done. Depending on whether the 00181 // billboards are of fixed size and whether they are point or oriented type will 00182 // determine how much calculation has to be done per-billboard. NOT a one-size fits all approach. 00183 //----------------------------------------------------------------------- 00188 virtual void genBillboardAxes(Camera& cam, Vector3* pX, Vector3 *pY, const Billboard* pBill = 0); 00189 00192 inline void getParametricOffsets(Real& left, Real& right, Real& top, Real& bottom); 00193 00201 inline void genVertices(Real **pPos, RGBA** pCol, const Vector3* offsets, const Billboard* pBillboard); 00202 00210 inline void genVertOffsets(Real inleft, Real inright, Real intop, Real inbottom, 00211 Real width, Real height, 00212 const Vector3& x, const Vector3& y, Vector3* pDestVec); 00213 00215 static String msMovableType; 00216 00217 public: 00218 00230 BillboardSet( const String& name, unsigned int poolSize = 20); 00231 00232 virtual ~BillboardSet(); 00233 00251 Billboard* createBillboard( 00252 const Vector3& position, 00253 const ColourValue& colour = ColourValue::White ); 00254 00276 Billboard* createBillboard( 00277 Real x, Real y, Real z, 00278 const ColourValue& colour = ColourValue::White ); 00279 00282 virtual int getNumBillboards(void) const; 00283 00298 virtual void setAutoextend(bool autoextend); 00299 00304 virtual bool getAutoextend(void) const; 00305 00316 virtual void setPoolSize(unsigned int size); 00317 00324 virtual unsigned int getPoolSize(void) const; 00325 00326 00329 virtual void clear(); 00330 00342 virtual Billboard* getBillboard(unsigned int index) const; 00343 00348 virtual void removeBillboard(unsigned int index); 00349 00354 virtual void removeBillboard(Billboard* pBill); 00355 00367 virtual void setBillboardOrigin(BillboardOrigin origin); 00368 00373 virtual BillboardOrigin getBillboardOrigin(void) const; 00374 00385 virtual void setDefaultDimensions(Real width, Real height); 00386 00388 virtual void setDefaultWidth(Real width); 00390 virtual Real getDefaultWidth(void); 00392 virtual void setDefaultHeight(Real height); 00394 virtual Real getDefaultHeight(void); 00395 00400 virtual void setMaterialName(const String& name); 00401 00405 virtual const String& getMaterialName(void) const; 00406 00411 virtual void _notifyCurrentCamera(Camera* cam); 00412 00417 virtual const AxisAlignedBox& getBoundingBox(void) const; 00418 00423 virtual void _updateRenderQueue(RenderQueue* queue); 00424 00429 virtual Material* getMaterial(void) const; 00430 00435 virtual void getRenderOperation(RenderOperation& rend); 00436 00441 virtual void getWorldTransforms(Matrix4* xform); 00442 00445 virtual void _notifyBillboardResized(void); 00446 00448 virtual bool getCullIndividually(void); 00469 virtual void setCullIndividually(bool cullIndividual); 00470 00481 virtual void setBillboardType(BillboardType bbt); 00482 00484 virtual BillboardType getBillboardType(void); 00485 00493 virtual void setCommonDirection(const Vector3& vec); 00494 00496 virtual Vector3 getCommonDirection(void); 00497 00499 virtual const String& getName(void) const; 00500 00502 virtual const String getMovableType(void) const; 00503 00505 Real getSquaredViewDepth(const Camera* cam) const; 00506 00508 virtual void _updateBounds(void); 00509 00510 }; 00511 00512 } 00513 00514 00515 #endif
Copyright © 2002 by The OGRE Team