📄 ogrepaginglandscapescenemanager.h
字号:
/***************************************************************************
OgrePagingLandScapeSceneManager.h - description
-------------------
begin : Mon May 12 2003
copyright : (C) 2003 by Jose A Milan
email : spoke2@supercable.es
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as *
* published by the Free Software Foundation; either version 2 of the *
* License, or (at your option) any later version. *
* *
***************************************************************************/
#ifndef PAGINGLANDSCAPESCENEMANAGER_H
#define PAGINGLANDSCAPESCENEMANAGER_H
#include <OgreSceneManager.h>
#include "OgrePagingLandScapeOptions.h"
#include "OgrePagingLandScapeTile.h"
#include "OgrePagingLandScapeTileManager.h"
#include "OgrePagingLandScapePage.h"
#include "OgrePagingLandScapeQueue.h"
#include "OgrePagingLandScapeRenderable.h"
#include "OgrePagingLandScapeRenderableManager.h"
namespace Ogre
{
class Image;
class PagingLandScapeIntersectionSceneQuery;
class PagingLandScapeRaySceneQuery;
typedef std::vector < PagingLandScapePage * > PagingLandScapePageRow;
typedef std::vector < PagingLandScapePageRow > PagingLandScapePages;
/** This is a basic SceneManager for organizing PagingLandScapeRenderables into a total landscape.
It loads a LandScape from a .cfg file that specifices what textures/scale/mipmaps/etc to use.
*/
class PagingLandScapeSceneManager : public SceneManager
{
friend class PagingLandScapeIntersectionSceneQuery;
friend class PagingLandScapeRaySceneQuery;
public:
PagingLandScapeSceneManager( );
~PagingLandScapeSceneManager( );
/** Loads the LandScape using parameters int he given config file.
*/
void setWorldGeometry( const String& filename );
/** Empties the entire scene, inluding all SceneNodes, Cameras, Entities and Lights etc.
*/
void clearScene(void);
/** Method for setting a specific option of the Scene Manager. These options are usually
specific for a certain implemntation of the Scene Manager class, and may (and probably
will) not exist across different implementations.
@param
strKey The name of the option to set
@param
pValue A pointer to the value - the size should be calculated by the scene manager
based on the key
@return
On success, true is returned.
@par
On failure, false is returned.
*/
bool setOption( const String& strKey, const void* pValue );
/** Method for getting the value of an implementation-specific Scene Manager option.
@param
strKey The name of the option
@param
pDestValue A pointer to a memory location where the value will
be copied. Currently, the memory will be allocated by the
scene manager, but this may change
@return
On success, true is returned and pDestValue points to the value of the given
option.
@par
On failure, false is returned and pDestValue is set to NULL.
*/
bool getOption( const String& strKey, void* pDestValue );
/** Method for verifying wether the scene manager has an implementation-specific
option.
@param
strKey The name of the option to check for.
@return
If the scene manager contains the given option, true is returned.
@remarks
If it does not, false is returned.
*/
bool hasOption( const String& strKey );
/** Method for getting all possible values for a specific option. When this list is too large
(i.e. the option expects, for example, a float), the return value will be true, but the
list will contain just one element whose size will be set to 0.
Otherwise, the list will be filled with all the possible values the option can
accept.
@param
strKey The name of the option to get the values for.
@param
refValueList A reference to a list that will be filled with the available values.
@return
On success (the option exists), true is returned.
@par
On failure, false is returned.
*/
bool getOptionValues( const String& strKey, std::list<SDDataChunk>& refValueList );
/** Method for getting all the implementation-specific options of the scene manager.
@param
refKeys A reference to a list that will be filled with all the available options.
@return
On success, true is returned. On failiure, false is returned.
*/
bool getOptionKeys( std::list<String>& refKeys );
/** Internal method for updating the scene graph ie the tree of SceneNode instances managed by this class.
@remarks
This must be done before issuing objects to the rendering pipeline, since derived transformations from
parent nodes are not updated until required. This SceneManager is a basic implementation which simply
updates all nodes from the root. This ensures the scene is up to date but requires all the nodes
to be updated even if they are not visible. Subclasses could trim this such that only potentially visible
nodes are updated.
*/
void _updateSceneGraph( Camera * cam );
/** Sends visible objects found in _findVisibleObjects to the rendering engine.
*/
void _renderVisibleObjects( void );
/** Internal method which parses the scene to find visible objects to render.
@remarks
If you're implementing a custom scene manager, this is the most important method to
override since it's here you can apply your custom world partitioning scheme. Once you
have added the appropriate objects to the render queue, you can let the default
SceneManager objects _renderVisibleObjects handle the actual rendering of the objects
you pick.
@par
Any visible objects will be added to a rendering queue, which is indexed by material in order
to ensure objects with the same material are rendered together to minimise render state changes.
*/
void _findVisibleObjects ( Camera * cam );
/** Creates a RaySceneQuery for this scene manager.
@remarks
This method creates a new instance of a query object for this scene manager,
looking for objects which fall along a ray. See SceneQuery and RaySceneQuery
for full details.
@par
The instance returned from this method must be destroyed by calling
SceneManager::destroyQuery when it is no longer required.
@param ray Details of the ray which describes the region for this query.
@param mask The query mask to apply to this query; can be used to filter out
certain objects; see SceneQuery for details.
*/
RaySceneQuery* createRayQuery(const Ray& ray, unsigned long mask = 0xFFFFFFFF);
/** Creates an IntersectionSceneQuery for this scene manager.
@remarks
This method creates a new instance of a query object for locating
intersecting objects. See SceneQuery and IntersectionSceneQuery
for full details.
@par
The instance returned from this method must be destroyed by calling
SceneManager::destroyQuery when it is no longer required.
@param mask The query mask to apply to this query; can be used to filter out
certain objects; see SceneQuery for details.
*/
IntersectionSceneQuery* createIntersectionQuery(unsigned long mask);
// JEFF
/** Get the Page indices from a world position vector
@remarks
Method is used to find the Page indices using a world position vector.
Beats having to iterate through the Page list to find a page at a particular
position in the world.
@param pos the world position vector. Only components x and z are used
@param x result placed in reference to the x index of the page
@param z result placed in reference to the z index of the page
*/
void getPageIndices(const Vector3& pos, int& x, int& z);
/** Get the real world height at a particular position
@remarks
Method is used to get the terrain height at a world position based on x and z.
This method just figures out what page the position is on and then asks the page node
to do the dirty work of getting the height.
@par
the float returned is the real world height based on the scale of the world. If the height could
not be determined then -1 is returned and this would only occur if the page was not preloaded or loaded
@param x x world position
@param z z world position
*/
float getRealWorldHeight(const float x, const float z);
protected:
void _ProcessLoading( void );
void _ProcessMergeSplit( const Vector3 & pos );
//void updateStats( const Vector3 & pos );
EntityList& getEntities() { return mEntities; }
/** All the plugin options are handle here.
*/
PagingLandScapeOptions mOptions;
/** LandScape tiles manager to avoid creating a deleting terrain tiles.
They are created at the plugin start and destroyed at the plugin unload.
*/
PagingLandScapeTileManager *mTileManager;
/** Queues to batch the process of loading and unloading Pages.
This avoid the plugin to load a lot of Pages in a single Frame, droping the FPS.
*/
PagingLandScapeQueue<PagingLandScapePage> mPageLoadQueue;
PagingLandScapeQueue<PagingLandScapePage> mPageUnloadQueue;
PagingLandScapeQueue<PagingLandScapePage> mPagePreloadQueue;
PagingLandScapeQueue<PagingLandScapePage> mPagePostunloadQueue;
/** LandScape Renderable manager to avoid creating a deleting renderables.
They are created at the plugin start and destroyed at the plugin unload.
*/
PagingLandScapeRenderableManager *mRenderableManager;
/** LandScape pages for the terrain.
*/
PagingLandScapePages mPages;
/** LandScapePage index where the camera is.
*/
uint mCurrentCameraPageX, mCurrentCameraPageZ;
/** The last estate for the camera.
*/
int mLastCameraPageState;
int mPause;
Vector3 mLastCameraPos;
bool mNeedOptionsUpdate;
//JEFF - flag to indicate if the world geometry was setup
bool mWorldGeomIsSetup;
};
}
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -