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 © 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 "OgreStringInterface.h" 00034 00035 namespace Ogre { 00036 00042 enum BillboardOrigin 00043 { 00044 BBO_TOP_LEFT, 00045 BBO_TOP_CENTER, 00046 BBO_TOP_RIGHT, 00047 BBO_CENTER_LEFT, 00048 BBO_CENTER, 00049 BBO_CENTER_RIGHT, 00050 BBO_BOTTOM_LEFT, 00051 BBO_BOTTOM_CENTER, 00052 BBO_BOTTOM_RIGHT 00053 }; 00055 enum BillboardType 00056 { 00058 BBT_POINT, 00060 BBT_ORIENTED_COMMON, 00062 BBT_ORIENTED_SELF 00063 00064 }; 00065 00080 class _OgreExport BillboardSet : public StringInterface, public MovableObject, public Renderable 00081 { 00082 00083 protected: 00086 BillboardSet(); 00087 00089 String mName; 00090 00092 AxisAlignedBox mAABB; 00094 Real mBoundingRadius; 00095 00097 BillboardOrigin mOriginType; 00098 00100 Real mDefaultWidth; 00102 Real mDefaultHeight; 00103 00105 String mMaterialName; 00107 Material* mpMaterial; 00108 00110 bool mAllDefaultSize; 00111 00113 bool mAutoExtendPool; 00114 00115 bool mFixedTextureCoords; 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 VertexData* mVertexData; 00150 00152 //RGBA* mpColours; 00153 00155 //Real* mpTexCoords; 00156 00158 //unsigned short* mpIndexes; 00159 IndexData* mIndexData; 00160 00162 bool mCullIndividual; 00163 00165 BillboardType mBillboardType; 00166 00168 Vector3 mCommonDirection; 00169 00171 inline bool billboardVisible(Camera* cam, ActiveBillboardList::iterator bill); 00172 00173 // Number of visible billboards (will be == getNumBillboards if mCullIndividual == false) 00174 unsigned short mNumVisibleBillboards; 00175 00177 virtual void increasePool(unsigned int size); 00178 00179 00180 //----------------------------------------------------------------------- 00181 // The internal methods which follow are here to allow maximum flexibility as to 00182 // when various components of the calculation are done. Depending on whether the 00183 // billboards are of fixed size and whether they are point or oriented type will 00184 // determine how much calculation has to be done per-billboard. NOT a one-size fits all approach. 00185 //----------------------------------------------------------------------- 00190 virtual void genBillboardAxes(Camera& cam, Vector3* pX, Vector3 *pY, const Billboard* pBill = 0); 00191 00194 inline void getParametricOffsets(Real& left, Real& right, Real& top, Real& bottom); 00195 00203 inline void genVertices(Real **pPos, RGBA** pCol, Real **pTex, const Vector3* offsets, const Billboard* pBillboard); 00204 00212 inline void genVertOffsets(Real inleft, Real inright, Real intop, Real inbottom, 00213 Real width, Real height, 00214 const Vector3& x, const Vector3& y, Vector3* pDestVec); 00215 00217 static String msMovableType; 00218 00219 public: 00220 00232 BillboardSet( const String& name, unsigned int poolSize = 20); 00233 00234 virtual ~BillboardSet(); 00235 00253 Billboard* createBillboard( 00254 const Vector3& position, 00255 const ColourValue& colour = ColourValue::White ); 00256 00278 Billboard* createBillboard( 00279 Real x, Real y, Real z, 00280 const ColourValue& colour = ColourValue::White ); 00281 00284 virtual int getNumBillboards(void) const; 00285 00300 virtual void setAutoextend(bool autoextend); 00301 00306 virtual bool getAutoextend(void) const; 00307 00318 virtual void setPoolSize(unsigned int size); 00319 00326 virtual unsigned int getPoolSize(void) const; 00327 00328 00331 virtual void clear(); 00332 00344 virtual Billboard* getBillboard(unsigned int index) const; 00345 00350 virtual void removeBillboard(unsigned int index); 00351 00356 virtual void removeBillboard(Billboard* pBill); 00357 00369 virtual void setBillboardOrigin(BillboardOrigin origin); 00370 00375 virtual BillboardOrigin getBillboardOrigin(void) const; 00376 00387 virtual void setDefaultDimensions(Real width, Real height); 00388 00390 virtual void setDefaultWidth(Real width); 00392 virtual Real getDefaultWidth(void) const; 00394 virtual void setDefaultHeight(Real height); 00396 virtual Real getDefaultHeight(void) const; 00397 00402 virtual void setMaterialName(const String& name); 00403 00407 virtual const String& getMaterialName(void) const; 00408 00413 virtual void _notifyCurrentCamera(Camera* cam); 00414 00419 virtual const AxisAlignedBox& getBoundingBox(void) const; 00420 00425 virtual Real getBoundingRadius(void) const; 00430 virtual void _updateRenderQueue(RenderQueue* queue); 00431 00436 virtual Material* getMaterial(void) const; 00437 00442 virtual void getRenderOperation(RenderOperation& op); 00443 00448 virtual void getWorldTransforms(Matrix4* xform) const; 00449 00451 const Quaternion& getWorldOrientation(void) const; 00453 const Vector3& getWorldPosition(void) const; 00456 virtual void _notifyBillboardResized(void); 00457 00460 virtual void _notifyBillboardTextureCoordsModified(void) { 00461 mFixedTextureCoords = false; } 00462 00464 virtual bool getCullIndividually(void) const; 00485 virtual void setCullIndividually(bool cullIndividual); 00486 00497 virtual void setBillboardType(BillboardType bbt); 00498 00500 virtual BillboardType getBillboardType(void) const; 00501 00509 virtual void setCommonDirection(const Vector3& vec); 00510 00512 virtual const Vector3& getCommonDirection(void) const; 00513 00515 virtual const String& getName(void) const; 00516 00518 virtual const String& getMovableType(void) const; 00519 00521 Real getSquaredViewDepth(const Camera* cam) const; 00522 00524 virtual void _updateBounds(void); 00526 const LightList& getLights(void) const; 00527 00528 }; 00529 00530 } 00531 00532 00533 #endif
Copyright © 2002-2003 by The OGRE Team
Last modified Wed Jan 21 00:10:02 2004