OpenMW
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Classes | Public Member Functions | Private Types | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
MWRender::LocalMap Class Reference

Local map rendering. More...

#include <localmap.hpp>

Collaboration diagram for MWRender::LocalMap:

Classes

struct  MapSegment
 

Public Member Functions

 LocalMap (osg::Group *root)
 
 ~LocalMap ()
 
void clear ()
 
void requestMap (std::set< const MWWorld::CellStore * > cells)
 
void removeCell (MWWorld::CellStore *cell)
 
osg::ref_ptr< osg::Texture2D > getMapTexture (int x, int y)
 
osg::ref_ptr< osg::Texture2D > getFogOfWarTexture (int x, int y)
 
void removeCamera (osg::Camera *cam)
 
void markForRemoval (osg::Camera *cam)
 
void cleanupCameras ()
 
void updatePlayer (const osg::Vec3f &position, const osg::Quat &orientation, float &u, float &v, int &x, int &y, osg::Vec3f &direction)
 
void saveFogOfWar (MWWorld::CellStore *cell)
 
void worldToInteriorMapPosition (osg::Vec2f pos, float &nX, float &nY, int &x, int &y)
 
osg::Vec2f interiorMapToWorldPosition (float nX, float nY, int x, int y)
 
bool isPositionExplored (float nX, float nY, int x, int y)
 
osg::Group * getRoot ()
 

Private Types

typedef std::vector
< osg::ref_ptr< osg::Camera > > 
CameraVector
 
typedef std::map< std::pair
< int, int >, MapSegment
SegmentMap
 

Private Member Functions

const osg::Vec2f rotatePoint (const osg::Vec2f &point, const osg::Vec2f &center, const float angle)
 
void requestExteriorMap (const MWWorld::CellStore *cell)
 
void requestInteriorMap (const MWWorld::CellStore *cell)
 
osg::ref_ptr< osg::Camera > createOrthographicCamera (float left, float top, float width, float height, const osg::Vec3d &upVector, float zmin, float zmax)
 
void setupRenderToTexture (osg::ref_ptr< osg::Camera > camera, int x, int y)
 

Private Attributes

osg::ref_ptr< osg::Group > mRoot
 
osg::ref_ptr< osg::Node > mSceneRoot
 
CameraVector mActiveCameras
 
CameraVector mCamerasPendingRemoval
 
SegmentMap mSegments
 
int mMapResolution
 
float mMapWorldSize
 
int mCellDistance
 
float mAngle
 
bool mInterior
 
osg::BoundingBox mBounds
 

Static Private Attributes

static const int sFogOfWarResolution = 32
 

Detailed Description

Local map rendering.

Member Typedef Documentation

typedef std::vector< osg::ref_ptr<osg::Camera> > MWRender::LocalMap::CameraVector
private
typedef std::map<std::pair<int, int>, MapSegment> MWRender::LocalMap::SegmentMap
private

Constructor & Destructor Documentation

MWRender::LocalMap::LocalMap ( osg::Group *  root)
MWRender::LocalMap::~LocalMap ( )

Here is the call graph for this function:

Member Function Documentation

void MWRender::LocalMap::cleanupCameras ( )

Removes cameras that have already been rendered. Should be called every frame to ensure that we do not render the same map more than once. Note, this cleanup is difficult to implement in an automated fashion, since we can't alter the scene graph structure from within an update callback.

Here is the call graph for this function:

Here is the caller graph for this function:

void MWRender::LocalMap::clear ( )

Clear all savegame-specific data (i.e. fog of war textures)

Here is the caller graph for this function:

osg::ref_ptr< osg::Camera > MWRender::LocalMap::createOrthographicCamera ( float  left,
float  top,
float  width,
float  height,
const osg::Vec3d &  upVector,
float  zmin,
float  zmax 
)
private

Here is the caller graph for this function:

osg::ref_ptr< osg::Texture2D > MWRender::LocalMap::getFogOfWarTexture ( int  x,
int  y 
)

Here is the caller graph for this function:

osg::ref_ptr< osg::Texture2D > MWRender::LocalMap::getMapTexture ( int  x,
int  y 
)

Here is the caller graph for this function:

osg::Group * MWRender::LocalMap::getRoot ( )
osg::Vec2f MWRender::LocalMap::interiorMapToWorldPosition ( float  nX,
float  nY,
int  x,
int  y 
)

Here is the call graph for this function:

Here is the caller graph for this function:

bool MWRender::LocalMap::isPositionExplored ( float  nX,
float  nY,
int  x,
int  y 
)

Check if a given position is explored by the player (i.e. not obscured by fog of war)

Here is the caller graph for this function:

void MWRender::LocalMap::markForRemoval ( osg::Camera *  cam)

Indicates a camera has been queued for rendering and can be cleaned up in the next frame. For internal use only.

void MWRender::LocalMap::removeCamera ( osg::Camera *  cam)

Here is the caller graph for this function:

void MWRender::LocalMap::removeCell ( MWWorld::CellStore cell)

Remove map and fog textures for the given cell.

Here is the call graph for this function:

Here is the caller graph for this function:

void MWRender::LocalMap::requestExteriorMap ( const MWWorld::CellStore cell)
private

Here is the call graph for this function:

Here is the caller graph for this function:

void MWRender::LocalMap::requestInteriorMap ( const MWWorld::CellStore cell)
private

Here is the call graph for this function:

Here is the caller graph for this function:

void MWRender::LocalMap::requestMap ( std::set< const MWWorld::CellStore * >  cells)

Request a map render for the given cells. Render textures will be immediately created and can be retrieved with the getMapTexture function.

Here is the call graph for this function:

Here is the caller graph for this function:

const osg::Vec2f MWRender::LocalMap::rotatePoint ( const osg::Vec2f &  point,
const osg::Vec2f &  center,
const float  angle 
)
private

Here is the caller graph for this function:

void MWRender::LocalMap::saveFogOfWar ( MWWorld::CellStore cell)

Save the fog of war for this cell to its CellStore.

Remarks
This should be called when unloading a cell, and for all active cells prior to saving the game.

Here is the call graph for this function:

Here is the caller graph for this function:

void MWRender::LocalMap::setupRenderToTexture ( osg::ref_ptr< osg::Camera >  camera,
int  x,
int  y 
)
private

Here is the caller graph for this function:

void MWRender::LocalMap::updatePlayer ( const osg::Vec3f &  position,
const osg::Quat &  orientation,
float &  u,
float &  v,
int x,
int y,
osg::Vec3f &  direction 
)

Set the position & direction of the player, and returns the position in map space through the reference parameters.

Remarks
This is used to draw a "fog of war" effect to hide areas on the map the player has not discovered yet.

Here is the call graph for this function:

Here is the caller graph for this function:

void MWRender::LocalMap::worldToInteriorMapPosition ( osg::Vec2f  pos,
float &  nX,
float &  nY,
int x,
int y 
)

Get the interior map texture index and normalized position on this texture, given a world position

Here is the call graph for this function:

Here is the caller graph for this function:

Member Data Documentation

CameraVector MWRender::LocalMap::mActiveCameras
private
float MWRender::LocalMap::mAngle
private
osg::BoundingBox MWRender::LocalMap::mBounds
private
CameraVector MWRender::LocalMap::mCamerasPendingRemoval
private
int MWRender::LocalMap::mCellDistance
private
bool MWRender::LocalMap::mInterior
private
int MWRender::LocalMap::mMapResolution
private
float MWRender::LocalMap::mMapWorldSize
private
osg::ref_ptr<osg::Group> MWRender::LocalMap::mRoot
private
osg::ref_ptr<osg::Node> MWRender::LocalMap::mSceneRoot
private
SegmentMap MWRender::LocalMap::mSegments
private
const int MWRender::LocalMap::sFogOfWarResolution = 32
staticprivate

The documentation for this class was generated from the following files: