Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

OgreBillboardSet.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 © 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     protected:
00085         BillboardSet();
00086 
00088         String mName;
00089 
00091         AxisAlignedBox mAABB;
00093         Real mBoundingRadius;
00094 
00096         BillboardOrigin mOriginType;
00097 
00099         Real mDefaultWidth;
00101         Real mDefaultHeight;
00102 
00104         String mMaterialName;
00106         Material* mpMaterial;
00107 
00109         bool mAllDefaultSize;
00110 
00112         bool mAutoExtendPool;
00113 
00114         bool mFixedTextureCoords;
00115 
00116         typedef std::list<Billboard*> ActiveBillboardList;
00117         typedef std::deque<Billboard*> FreeBillboardQueue;
00118         typedef std::vector<Billboard*> BillboardPool;
00119 
00128         ActiveBillboardList mActiveBillboards;
00129 
00137         FreeBillboardQueue mFreeBillboards;
00138 
00143         BillboardPool mBillboardPool;
00144 
00145 
00147         //Real* mpPositions;
00148         VertexData* mVertexData;
00149 
00151         //RGBA* mpColours;
00152 
00154         //Real* mpTexCoords;
00155 
00157         //unsigned short* mpIndexes;
00158         IndexData* mIndexData;
00159 
00161         bool mCullIndividual;
00162 
00164         BillboardType mBillboardType;
00165 
00167         Vector3 mCommonDirection;
00168 
00170         inline bool billboardVisible(Camera* cam, ActiveBillboardList::iterator bill);
00171 
00172         // Number of visible billboards (will be == getNumBillboards if mCullIndividual == false)
00173         unsigned short mNumVisibleBillboards;
00174 
00176         virtual void increasePool(unsigned int size);
00177 
00178 
00179         //-----------------------------------------------------------------------
00180         // The internal methods which follow are here to allow maximum flexibility as to 
00181         //  when various components of the calculation are done. Depending on whether the
00182         //  billboards are of fixed size and whether they are point or oriented type will
00183         //  determine how much calculation has to be done per-billboard. NOT a one-size fits all approach.
00184         //-----------------------------------------------------------------------
00189         virtual void genBillboardAxes(const Camera& cam, Vector3* pX, Vector3 *pY, const Billboard* pBill = 0);
00190 
00193         void getParametricOffsets(Real& left, Real& right, Real& top, Real& bottom);
00194 
00202         void genVertices(Real **pPos, RGBA** pCol, Real **pTex, const Vector3* const offsets, const Billboard* const pBillboard);
00203 
00211         void genVertOffsets(Real inleft, Real inright, Real intop, Real inbottom,
00212             Real width, Real height,
00213             const Vector3& x, const Vector3& y, Vector3* pDestVec);
00214 
00216         static String msMovableType;
00217 
00218     private:
00220         bool mBuffersCreated;
00222         unsigned int mPoolSize;
00223 
00226         void _createBuffers(void);
00227 
00228     public:
00229 
00241         BillboardSet( const String& name, unsigned int poolSize = 20);
00242 
00243         virtual ~BillboardSet();
00244 
00262         Billboard* createBillboard(
00263             const Vector3& position,
00264             const ColourValue& colour = ColourValue::White );
00265 
00287         Billboard* createBillboard(
00288             Real x, Real y, Real z,
00289             const ColourValue& colour = ColourValue::White );
00290 
00293         virtual int getNumBillboards(void) const;
00294 
00309         virtual void setAutoextend(bool autoextend);
00310 
00315         virtual bool getAutoextend(void) const;
00316 
00327         virtual void setPoolSize(unsigned int size);
00328 
00335         virtual unsigned int getPoolSize(void) const;
00336 
00337 
00340         virtual void clear();
00341 
00353         virtual Billboard* getBillboard(unsigned int index) const;
00354 
00359         virtual void removeBillboard(unsigned int index);
00360 
00365         virtual void removeBillboard(Billboard* pBill);
00366 
00378         virtual void setBillboardOrigin(BillboardOrigin origin);
00379 
00384         virtual BillboardOrigin getBillboardOrigin(void) const;
00385 
00396         virtual void setDefaultDimensions(Real width, Real height);
00397 
00399         virtual void setDefaultWidth(Real width);
00401         virtual Real getDefaultWidth(void) const;
00403         virtual void setDefaultHeight(Real height);
00405         virtual Real getDefaultHeight(void) const;
00406 
00411         virtual void setMaterialName(const String& name);
00412 
00416         virtual const String& getMaterialName(void) const;
00417 
00422         virtual void _notifyCurrentCamera(Camera* cam);
00423 
00428         virtual const AxisAlignedBox& getBoundingBox(void) const;
00429 
00434         virtual Real getBoundingRadius(void) const;
00439         virtual void _updateRenderQueue(RenderQueue* queue);
00440 
00445         virtual Material* getMaterial(void) const;
00446 
00451         virtual void getRenderOperation(RenderOperation& op);
00452 
00457         virtual void getWorldTransforms(Matrix4* xform) const;
00458 
00460         const Quaternion& getWorldOrientation(void) const;
00462         const Vector3& getWorldPosition(void) const;
00465         virtual void _notifyBillboardResized(void);
00466 
00469         virtual void _notifyBillboardTextureCoordsModified(void) {
00470             mFixedTextureCoords = false; }
00471 
00473         virtual bool getCullIndividually(void) const;
00494         virtual void setCullIndividually(bool cullIndividual);
00495 
00506         virtual void setBillboardType(BillboardType bbt);
00507 
00509         virtual BillboardType getBillboardType(void) const;
00510 
00518         virtual void setCommonDirection(const Vector3& vec);
00519 
00521         virtual const Vector3& getCommonDirection(void) const;
00522 
00524         virtual const String& getName(void) const;
00525 
00527         virtual const String& getMovableType(void) const;
00528 
00530         Real getSquaredViewDepth(const Camera* cam) const;
00531 
00533         virtual void _updateBounds(void);
00535         const LightList& getLights(void) const;
00536 
00537     };
00538 
00539 }
00540 
00541 
00542 #endif

Copyright © 2002-2003 by The OGRE Team
Last modified Sun Nov 28 19:48:15 2004