00001 /*------------------------------------------------------------------------- 00002 This source file is a part of OGRE 00003 (Object-oriented Graphics Rendering Engine) 00004 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 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 "OgreRenderable.h" 00039 #include "OgreDataChunk.h" 00040 #include "OgreBillboardSet.h" 00041 #include "OgreAnimationState.h" 00042 00043 namespace Ogre { 00044 00046 struct ViewPoint 00047 { 00048 Vector3 position; 00049 Quaternion orientation; 00050 }; 00051 00052 00068 class _OgreExport SceneManager 00069 { 00070 public: 00073 struct materialLess 00074 { 00075 _OgreExport bool operator()(const Material* x, const Material* y) const; 00076 }; 00077 protected: 00078 00080 RenderQueue mRenderQueue; 00081 00083 ColourValue mAmbientLight; 00084 00086 RenderSystem *mDestRenderSystem; 00087 00088 typedef std::map<std::string, Camera*, std::less<std::string> > CameraList; 00089 00092 CameraList mCameras; 00093 00094 typedef std::map<std::string, Light*, std::less<std::string> > LightList; 00095 00098 LightList mLights; 00099 00100 00101 typedef std::map<std::string, Entity*, std::less<std::string> > EntityList; 00102 00105 EntityList mEntities; 00106 00107 typedef std::map<std::string, BillboardSet*, std::less<std::string> > BillboardSetList; 00108 00111 BillboardSetList mBillboardSets; 00112 00113 typedef std::map<String, SceneNode*> SceneNodeList; 00114 00121 SceneNodeList mSceneNodes; 00122 00124 Camera* mCameraInProgress; 00125 00127 SceneNode* mSceneRoot; 00128 00129 // Sky params 00130 // Sky plane 00131 Entity* mSkyPlaneEntity; 00132 Entity* mSkyDomeEntity[5]; 00133 Entity* mSkyBoxEntity[6]; 00134 00135 SceneNode* mSkyPlaneNode; 00136 SceneNode* mSkyDomeNode; 00137 SceneNode* mSkyBoxNode; 00138 00139 bool mSkyPlaneEnabled; 00140 bool mSkyPlaneDrawFirst; 00141 Plane mSkyPlane; 00142 // Sky box 00143 bool mSkyBoxEnabled; 00144 bool mSkyBoxDrawFirst; 00145 Quaternion mSkyBoxOrientation; 00146 // Sky dome 00147 bool mSkyDomeEnabled; 00148 bool mSkyDomeDrawFirst; 00149 Quaternion mSkyDomeOrientation; 00150 // Fog 00151 FogMode mFogMode; 00152 ColourValue mFogColour; 00153 Real mFogStart; 00154 Real mFogEnd; 00155 Real mFogDensity; 00156 00175 int setMaterial(Material* mat, int numLayers); 00176 00177 enum BoxPlane 00178 { 00179 BP_FRONT = 0, 00180 BP_BACK = 1, 00181 BP_LEFT = 2, 00182 BP_RIGHT = 3, 00183 BP_UP = 4, 00184 BP_DOWN = 5 00185 }; 00186 00187 /* Internal utility method for creating the planes of a skybox. 00188 */ 00189 Mesh* createSkyboxPlane( 00190 BoxPlane bp, 00191 Real distance, 00192 const Quaternion& orientation); 00193 00194 /* Internal utility method for creating the planes of a skydome. 00195 */ 00196 Mesh* createSkydomePlane( 00197 BoxPlane bp, 00198 Real curvature, Real tiling, Real distance, 00199 const Quaternion& orientation); 00200 00201 // Flag indicating whether SceneNodes will be rendered as a set of 3 axes 00202 bool mDisplayNodes; 00203 00205 typedef std::map<String, Animation*> AnimationList; 00206 AnimationList mAnimationsList; 00207 AnimationStateSet mAnimationStates; 00208 00211 void useRenderableViewProjMode(Renderable* pRend); 00212 00214 bool mCamChanged; 00215 00216 typedef std::vector<RenderQueueListener*> RenderQueueListenerList; 00217 RenderQueueListenerList mRenderQueueListeners; 00218 00220 bool fireRenderQueueStarted(RenderQueueGroupID id); 00222 bool fireRenderQueueEnded(RenderQueueGroupID id); 00223 00225 virtual void setViewport(Viewport *vp); 00226 00228 bool mShowBoundingBoxes; 00229 00230 public: 00233 SceneManager(); 00234 00237 virtual ~SceneManager(); 00238 00246 virtual Camera* createCamera(const String& name); 00247 00250 virtual Camera* getCamera(const String& name); 00251 00260 virtual void removeCamera(Camera *cam); 00261 00267 virtual void removeCamera(const String& name); 00268 00271 virtual void removeAllCameras(void); 00272 00283 virtual Light* createLight(const String& name); 00284 00287 virtual Light* getLight(const String& name); 00288 00293 virtual void removeLight(const String& name); 00294 00299 virtual void removeLight(Light* light); 00302 virtual void removeAllLights(void); 00303 00306 virtual Material* createMaterial(const String& name); 00307 00335 virtual Material* getDefaultMaterialSettings(void); 00336 00344 virtual void addMaterial(const Material& mat); 00345 00348 virtual Material* getMaterial(const String& name); 00349 00356 virtual Material* getMaterial(int handle); 00357 00374 virtual SceneNode* createSceneNode(void); 00375 00390 virtual SceneNode* createSceneNode(const String& name); 00391 00398 virtual void destroySceneNode(const String& name); 00399 00415 virtual SceneNode* getRootSceneNode(void) const; 00416 00423 virtual SceneNode* getSceneNode(const String& name) const; 00424 00432 virtual Entity* createEntity(const String& entityName, const String& meshName); 00433 00440 enum PrefabType { 00441 PT_PLANE 00442 }; 00443 00450 virtual Entity* createEntity(const String& entityName, PrefabType ptype); 00452 virtual Entity* getEntity(const String& name); 00453 00462 virtual void removeEntity(Entity* ent); 00463 00472 virtual void removeEntity(const String& name); 00473 00483 virtual void removeAllEntities(void); 00484 00487 virtual void clearScene(void); 00488 00501 void setAmbientLight(ColourValue colour); 00502 00505 ColourValue getAmbientLight(void); 00506 00522 virtual void setWorldGeometry(const String& filename); 00523 00538 virtual ViewPoint getSuggestedViewpoint(bool random = false); 00539 00553 virtual bool setOption( const String& strKey, const void* pValue ) { return false; } 00554 00568 virtual bool getOption( const String& strKey, void* pDestValue ) { return false; } 00569 00579 virtual bool hasOption( const String& strKey ) { return false; } 00594 virtual bool getOptionValues( const String& strKey, std::list<SDDataChunk>& refValueList ) { return false; } 00595 00602 virtual bool getOptionKeys( std::list<String>& refKeys ) { return false; } 00603 00612 virtual void _updateSceneGraph(Camera* cam); 00613 00625 virtual void _findVisibleObjects(Camera* cam); 00626 00631 virtual void _applySceneAnimations(void); 00632 00635 virtual void _renderVisibleObjects(void); 00636 00650 virtual void _renderScene(Camera* camera, Viewport* vp, bool includeOverlays); 00651 00655 virtual void _queueSkiesForRendering(Camera* cam); 00656 00657 00664 virtual void _renderSubMesh(SubMesh* sm); 00665 00668 virtual void _updateDynamicLights(void); 00669 00678 virtual void _setDestinationRenderSystem(RenderSystem* sys); 00679 00726 virtual void setSkyPlane( 00727 bool enable, 00728 const Plane& plane, const String& materialName, Real scale = 1000, 00729 Real tiling = 10, bool drawFirst = true, Real bow = 0 ); 00730 00770 virtual void setSkyBox( 00771 bool enable, const String& materialName, Real distance = 5000, 00772 bool drawFirst = true, const Quaternion& orientation = Quaternion::IDENTITY ); 00773 00827 virtual void setSkyDome( 00828 bool enable, const String& materialName, Real curvature = 10, 00829 Real tiling = 8, Real distance = 4000, bool drawFirst = true, 00830 const Quaternion& orientation = Quaternion::IDENTITY); 00831 00856 void setFog( 00857 FogMode mode = FOG_NONE, ColourValue colour = ColourValue::White, 00858 Real expDensity = 0.001, Real linearStart = 0.0, Real linearEnd = 1.0); 00859 00862 virtual FogMode getFogMode(void) const; 00863 00866 virtual const ColourValue& getFogColour(void) const; 00867 00870 virtual Real getFogStart(void) const; 00871 00874 virtual Real getFogEnd(void) const; 00875 00878 virtual Real getFogDensity(void) const; 00879 00882 virtual void displaySplashScreen(Viewport* vp, const String& name ); 00883 00901 virtual BillboardSet* createBillboardSet(const String& name, unsigned int poolSize = 20); 00902 00905 virtual BillboardSet* getBillboardSet(const String& name); 00906 00913 virtual void removeBillboardSet(BillboardSet* set); 00914 00921 virtual void removeBillboardSet(const String& name); 00922 00930 virtual void setDisplaySceneNodes(bool display); 00931 00952 virtual Animation* createAnimation(const String& name, Real length); 00953 00955 virtual Animation* getAnimation(const String& name) const; 00956 00962 virtual void destroyAnimation(const String& name); 00963 00965 virtual void destroyAllAnimations(void); 00966 00990 virtual AnimationState* createAnimationState(const String& animName); 00991 00993 virtual AnimationState* getAnimationState(const String& animName); 00994 01000 virtual void destroyAnimationState(const String& name); 01001 01003 virtual void destroyAllAnimationStates(void); 01004 01030 virtual void manualRender(RenderOperation* rend, Material* mat, Viewport* vp, 01031 const Matrix4& worldMatrix, const Matrix4& viewMatrix, const Matrix4& projMatrix) ; 01032 01046 virtual Overlay* createOverlay(const String& name, ushort zorder = 100); 01047 01049 virtual Overlay* getOverlay(const String& name); 01050 01052 virtual void destroyOverlay(const String& name); 01053 01055 virtual void destroyAllOverlays(void); 01056 01060 virtual void addRenderQueueListener(RenderQueueListener* newListener); 01061 01063 virtual void removeRenderQueueListener(RenderQueueListener* delListener); 01064 01066 void showBoundingBoxes(bool bShow); 01067 01069 bool getShowBoundingBoxes(); 01070 01071 01072 01073 01074 01075 }; 01076 01077 01078 01079 } // Namespace 01080 01081 01082 01083 #endif 01084
Copyright © 2002 by The OGRE Team