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

OgreSceneManager.h

Go to the documentation of this file.
00001 /*-------------------------------------------------------------------------
00002 This source file is a part of OGRE
00003 (Object-oriented Graphics Rendering Engine)
00004 
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 library is free software; you can redistribute it and/or modify it
00011 under the terms of the GNU Lesser General Public License (LGPL) as 
00012 published by the Free Software Foundation; either version 2.1 of the 
00013 License, or (at your option) any later version.
00014 
00015 This library is distributed in the hope that it will be useful, but 
00016 WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 
00017 or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public 
00018 License for more details.
00019 
00020 You should have received a copy of the GNU Lesser General Public License 
00021 along with this library; if not, write to the Free Software Foundation, 
00022 Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA or go to
00023 http://www.gnu.org/copyleft/lesser.txt
00024 -------------------------------------------------------------------------*/
00025 #ifndef __SceneManager_H__
00026 #define __SceneManager_H__
00027 
00028 // Precompiler options
00029 #include "OgrePrerequisites.h"
00030 
00031 #include "OgreString.h"
00032 #include "OgreSceneNode.h"
00033 #include "OgrePlane.h"
00034 #include "OgreQuaternion.h"
00035 #include "OgreColourValue.h"
00036 #include "OgreCommon.h"
00037 #include "OgreRenderQueue.h"
00038 #include "OgreDataChunk.h"
00039 #include "OgreAnimationState.h"
00040 #include "OgreSceneQuery.h"
00041 #include "OgreAutoParamDataSource.h"
00042 
00043 namespace Ogre {
00044 
00046     struct ViewPoint
00047     {
00048         Vector3 position;
00049         Quaternion orientation;
00050     };
00051 
00052     // Forward declarations
00053     class DefaultIntersectionSceneQuery;
00054     class DefaultRaySceneQuery;
00055     class DefaultSphereSceneQuery;
00056     class DefaultAxisAlignedBoxSceneQuery;
00057 
00073     class _OgreExport SceneManager
00074     {
00075         friend class DefaultIntersectionSceneQuery; 
00076         friend class DefaultRaySceneQuery;
00077         friend class DefaultSphereSceneQuery;
00078         friend class DefaultAxisAlignedBoxSceneQuery;
00079     public:
00082         struct materialLess
00083         {
00084             _OgreExport bool operator()(const Material* x, const Material* y) const;
00085         };
00087         struct lightLess
00088         {
00089             _OgreExport bool operator()(const Light* a, const Light* b) const;
00090         };
00091 
00092     protected:
00093 
00095         RenderQueue mRenderQueue;
00096 
00098         ColourValue mAmbientLight;
00099 
00101         RenderSystem *mDestRenderSystem;
00102 
00103         typedef std::map<std::string, Camera*, std::less<std::string> > CameraList;
00104 
00107         CameraList mCameras;
00108 
00109         typedef std::map<std::string, Light*, std::less<std::string> > SceneLightList;
00110 
00113         SceneLightList mLights;
00114 
00115 
00116         typedef std::map<std::string, Entity*, std::less<std::string> > EntityList;
00117 
00120         EntityList mEntities;
00121 
00122         typedef std::map<std::string, BillboardSet*, std::less<std::string> > BillboardSetList;
00123 
00126         BillboardSetList mBillboardSets;
00127 
00128         typedef std::map<String, SceneNode*> SceneNodeList;
00129 
00136         SceneNodeList mSceneNodes;
00137 
00139         Camera* mCameraInProgress;
00140 
00142         SceneNode* mSceneRoot;
00143 
00144         // Sky params
00145         // Sky plane
00146         Entity* mSkyPlaneEntity;
00147         Entity* mSkyDomeEntity[5];
00148         Entity* mSkyBoxEntity[6];
00149 
00150         SceneNode* mSkyPlaneNode;
00151         SceneNode* mSkyDomeNode;
00152         SceneNode* mSkyBoxNode;
00153 
00154         bool mSkyPlaneEnabled;
00155         bool mSkyPlaneDrawFirst;
00156         Plane mSkyPlane;
00157         // Sky box
00158         bool mSkyBoxEnabled;
00159         bool mSkyBoxDrawFirst;
00160         Quaternion mSkyBoxOrientation;
00161         // Sky dome
00162         bool mSkyDomeEnabled;
00163         bool mSkyDomeDrawFirst;
00164         Quaternion mSkyDomeOrientation;
00165         // Fog
00166         FogMode mFogMode;
00167         ColourValue mFogColour;
00168         Real mFogStart;
00169         Real mFogEnd;
00170         Real mFogDensity;
00171 
00176         void setPass(Pass* pass);
00177 
00178         enum BoxPlane
00179         {
00180             BP_FRONT = 0,
00181             BP_BACK = 1,
00182             BP_LEFT = 2,
00183             BP_RIGHT = 3,
00184             BP_UP = 4,
00185             BP_DOWN = 5
00186         };
00187 
00188         /* Internal utility method for creating the planes of a skybox.
00189         */
00190         Mesh* createSkyboxPlane(
00191             BoxPlane bp,
00192             Real distance,
00193             const Quaternion& orientation);
00194 
00195         /* Internal utility method for creating the planes of a skydome.
00196         */
00197         Mesh* createSkydomePlane(
00198             BoxPlane bp,
00199             Real curvature, Real tiling, Real distance,
00200             const Quaternion& orientation);
00201 
00202         // Flag indicating whether SceneNodes will be rendered as a set of 3 axes
00203         bool mDisplayNodes;
00204 
00206         typedef std::map<String, Animation*> AnimationList;
00207         AnimationList mAnimationsList;
00208         AnimationStateSet mAnimationStates;
00209 
00212         void useRenderableViewProjMode(Renderable* pRend);
00213 
00215         bool mCamChanged;
00216 
00217         typedef std::vector<RenderQueueListener*> RenderQueueListenerList;
00218         RenderQueueListenerList mRenderQueueListeners;
00219 
00221         bool fireRenderQueueStarted(RenderQueueGroupID id);
00223         bool fireRenderQueueEnded(RenderQueueGroupID id);
00224 
00226         virtual void setViewport(Viewport *vp);
00227 
00229         bool mShowBoundingBoxes;       
00230 
00235         virtual void renderSingleObject(Renderable* rend, Pass* pass);
00236 
00238         AutoParamDataSource mAutoParamDataSource;
00239 
00240     public:
00243         SceneManager();
00244 
00247         virtual ~SceneManager();
00248 
00256         virtual Camera* createCamera(const String& name);
00257 
00260         virtual Camera* getCamera(const String& name);
00261 
00270         virtual void removeCamera(Camera *cam);
00271 
00277         virtual void removeCamera(const String& name);
00278 
00281         virtual void removeAllCameras(void);
00282 
00293         virtual Light* createLight(const String& name);
00294 
00297         virtual Light* getLight(const String& name);
00298 
00303         virtual void removeLight(const String& name);
00304 
00309         virtual void removeLight(Light* light);
00312         virtual void removeAllLights(void);
00313 
00332         virtual void _populateLightList(const Vector3& position, LightList& destList);
00333 
00337         virtual Material* createMaterial(const String& name);
00338 
00369         virtual Material* getDefaultMaterialSettings(void);
00370 
00373         virtual Material* getMaterial(const String& name);
00374 
00381         virtual Material* getMaterial(int handle);
00382 
00399         virtual SceneNode* createSceneNode(void);
00400 
00415         virtual SceneNode* createSceneNode(const String& name);
00416 
00423         virtual void destroySceneNode(const String& name);
00424 
00440         virtual SceneNode* getRootSceneNode(void) const;
00441 
00448         virtual SceneNode* getSceneNode(const String& name) const;
00449 
00457         virtual Entity* createEntity(const String& entityName, const String& meshName);
00458 
00465         enum PrefabType {
00466             PT_PLANE
00467         };
00468 
00475         virtual Entity* createEntity(const String& entityName, PrefabType ptype);
00477         virtual Entity* getEntity(const String& name);
00478 
00487         virtual void removeEntity(Entity* ent);
00488 
00497         virtual void removeEntity(const String& name);
00498 
00508         virtual void removeAllEntities(void);
00509 
00512         virtual void clearScene(void);
00513 
00526         void setAmbientLight(const ColourValue& colour);
00527 
00530         const ColourValue& getAmbientLight(void) const;
00531 
00547         virtual void setWorldGeometry(const String& filename);
00548 
00563         virtual ViewPoint getSuggestedViewpoint(bool random = false);
00564 
00578         virtual bool setOption( const String& strKey, const void* pValue ) { return false; }
00579 
00593         virtual bool getOption( const String& strKey, void* pDestValue ) { return false; }
00594 
00604         virtual bool hasOption( const String& strKey ) const { return false; }
00619         virtual bool getOptionValues( const String& strKey, std::list<SDDataChunk>& refValueList ) { return false; }
00620 
00627         virtual bool getOptionKeys( std::list<String>& refKeys ) { return false; }
00628 
00637         virtual void _updateSceneGraph(Camera* cam);
00638 
00650         virtual void _findVisibleObjects(Camera* cam);
00651 
00656         virtual void _applySceneAnimations(void);
00657 
00660         virtual void _renderVisibleObjects(void);
00661 
00675         virtual void _renderScene(Camera* camera, Viewport* vp, bool includeOverlays);
00676 
00680         virtual void _queueSkiesForRendering(Camera* cam);
00681 
00682 
00683 
00692         virtual void _setDestinationRenderSystem(RenderSystem* sys);
00693 
00740         virtual void setSkyPlane(
00741             bool enable,
00742             const Plane& plane, const String& materialName, Real scale = 1000,
00743             Real tiling = 10, bool drawFirst = true, Real bow = 0 );
00744 
00784         virtual void setSkyBox(
00785             bool enable, const String& materialName, Real distance = 5000,
00786             bool drawFirst = true, const Quaternion& orientation = Quaternion::IDENTITY );
00787 
00841         virtual void setSkyDome(
00842             bool enable, const String& materialName, Real curvature = 10,
00843             Real tiling = 8, Real distance = 4000, bool drawFirst = true,
00844             const Quaternion& orientation = Quaternion::IDENTITY);
00845 
00870         void setFog(
00871             FogMode mode = FOG_NONE, const ColourValue& colour = ColourValue::White,
00872             Real expDensity = 0.001, Real linearStart = 0.0, Real linearEnd = 1.0);
00873 
00876         virtual FogMode getFogMode(void) const;
00877 
00880         virtual const ColourValue& getFogColour(void) const;
00881 
00884         virtual Real getFogStart(void) const;
00885 
00888         virtual Real getFogEnd(void) const;
00889 
00892         virtual Real getFogDensity(void) const;
00893 
00894 
00912         virtual BillboardSet* createBillboardSet(const String& name, unsigned int poolSize = 20);
00913 
00916         virtual BillboardSet* getBillboardSet(const String& name);
00917 
00924         virtual void removeBillboardSet(BillboardSet* set);
00925 
00932         virtual void removeBillboardSet(const String& name);
00933 
00941         virtual void setDisplaySceneNodes(bool display);
00942 
00963         virtual Animation* createAnimation(const String& name, Real length);
00964 
00966         virtual Animation* getAnimation(const String& name) const;
00967 
00973         virtual void destroyAnimation(const String& name);
00974 
00976         virtual void destroyAllAnimations(void);
00977 
01001         virtual AnimationState* createAnimationState(const String& animName);
01002 
01004         virtual AnimationState* getAnimationState(const String& animName);
01005 
01011         virtual void destroyAnimationState(const String& name);
01012 
01014         virtual void destroyAllAnimationStates(void);
01015 
01036         virtual void manualRender(RenderOperation* rend, Pass* pass, Viewport* vp, 
01037             const Matrix4& worldMatrix, const Matrix4& viewMatrix, const Matrix4& projMatrix) ;
01038 
01052         virtual Overlay* createOverlay(const String& name, ushort zorder = 100); 
01053 
01055         virtual Overlay* getOverlay(const String& name);
01056 
01058         virtual void destroyOverlay(const String& name);
01059         
01061         virtual void destroyAllOverlays(void);
01062 
01066         virtual void addRenderQueueListener(RenderQueueListener* newListener);
01067 
01069         virtual void removeRenderQueueListener(RenderQueueListener* delListener);
01070 
01072         void showBoundingBoxes(bool bShow);
01073 
01075         bool getShowBoundingBoxes() const;
01076 
01077         
01090         virtual AxisAlignedBoxSceneQuery* 
01091             createAABBQuery(const AxisAlignedBox& box, unsigned long mask = 0xFFFFFFFF);
01104         virtual SphereSceneQuery* 
01105             createSphereQuery(const Sphere& sphere, unsigned long mask = 0xFFFFFFFF);
01118         virtual RaySceneQuery* 
01119             createRayQuery(const Ray& ray, unsigned long mask = 0xFFFFFFFF);
01120         //PyramidSceneQuery* createPyramidQuery(const Pyramid& p, unsigned long mask = 0xFFFFFFFF);
01132         virtual IntersectionSceneQuery* 
01133             createIntersectionQuery(unsigned long mask = 0xFFFFFFFF);
01134 
01136         virtual void destroyQuery(SceneQuery* query);
01137 
01138         typedef MapIterator<SceneLightList> LightIterator;
01139         typedef MapIterator<EntityList> EntityIterator;
01140         typedef MapIterator<CameraList> CameraIterator;
01141         typedef MapIterator<BillboardSetList> BillboardSetIterator;
01142 
01144         LightIterator getLightIterator(void) {
01145             return LightIterator(mLights.begin(), mLights.end());
01146         }
01148         EntityIterator getEntityIterator(void) {
01149             return EntityIterator(mEntities.begin(), mEntities.end());
01150         }
01152         CameraIterator getCameraIterator(void) {
01153             return CameraIterator(mCameras.begin(), mCameras.end());
01154         }
01156         BillboardSetIterator getBillboardSetIterator(void) {
01157             return BillboardSetIterator(mBillboardSets.begin(), mBillboardSets.end());
01158         }
01159 
01160 
01161 
01162     };
01163 
01165     class _OgreExport DefaultIntersectionSceneQuery : 
01166         public IntersectionSceneQuery
01167     {
01168     public:
01169         DefaultIntersectionSceneQuery(SceneManager* creator);
01170         ~DefaultIntersectionSceneQuery();
01171 
01173         void execute(IntersectionSceneQueryListener* listener);
01174     };
01175 
01177     class _OgreExport DefaultRaySceneQuery : public RaySceneQuery
01178     {
01179     public:
01180         DefaultRaySceneQuery(SceneManager* creator);
01181         ~DefaultRaySceneQuery();
01182 
01184         void execute(RaySceneQueryListener* listener);
01185     };
01187     class _OgreExport DefaultSphereSceneQuery : public SphereSceneQuery
01188     {
01189     public:
01190         DefaultSphereSceneQuery(SceneManager* creator);
01191         ~DefaultSphereSceneQuery();
01192 
01194         void execute(SceneQueryListener* listener);
01195     };
01197     class _OgreExport DefaultAxisAlignedBoxSceneQuery : public AxisAlignedBoxSceneQuery
01198     {
01199     public:
01200         DefaultAxisAlignedBoxSceneQuery(SceneManager* creator);
01201         ~DefaultAxisAlignedBoxSceneQuery();
01202 
01204         void execute(SceneQueryListener* listener);
01205     };
01206     
01207 
01208 
01209 } // Namespace
01210 
01211 
01212 
01213 #endif
01214 

Copyright © 2002-2003 by The OGRE Team
Last modified Wed Jan 21 00:10:26 2004