OpenMW
|
00001 #ifndef _GAME_RENDER_LOCALMAP_H 00002 #define _GAME_RENDER_LOCALMAP_H 00003 00004 #include <openengine/ogre/renderer.hpp> 00005 00006 #include <OgreAxisAlignedBox.h> 00007 #include <OgreColourValue.h> 00008 00009 namespace MWWorld 00010 { 00011 class CellStore; 00012 } 00013 00014 namespace MWRender 00015 { 00016 class RenderingManager; 00017 00021 class LocalMap 00022 { 00023 public: 00024 LocalMap(OEngine::Render::OgreRenderer*, MWRender::RenderingManager* rendering); 00025 ~LocalMap(); 00026 00035 void requestMap (MWWorld::CellStore* cell, float zMin, float zMax); 00036 00044 void requestMap (MWWorld::CellStore* cell, 00045 Ogre::AxisAlignedBox bounds); 00046 00054 void updatePlayer (const Ogre::Vector3& position, const Ogre::Quaternion& orientation); 00055 00062 void saveFogOfWar(MWWorld::CellStore* cell); 00063 00068 void getInteriorMapPosition (Ogre::Vector2 pos, float& nX, float& nY, int& x, int& y); 00069 00073 bool isPositionExplored (float nX, float nY, int x, int y, bool interior); 00074 00075 private: 00076 OEngine::Render::OgreRenderer* mRendering; 00077 MWRender::RenderingManager* mRenderingManager; 00078 00079 // 1024*1024 pixels for a cell 00080 static const int sMapResolution = 512; 00081 00082 // the dynamic texture is a bottleneck, so don't set this too high 00083 static const int sFogOfWarResolution = 32; 00084 00085 // frames to skip before rendering fog of war 00086 static const int sFogOfWarSkip = 2; 00087 00088 // size of a map segment (for exteriors, 1 cell) 00089 static const int sSize = 8192; 00090 00091 Ogre::Camera* mCellCamera; 00092 Ogre::SceneNode* mCameraNode; 00093 Ogre::SceneNode* mCameraPosNode; 00094 Ogre::SceneNode* mCameraRotNode; 00095 00096 // directional light from a fixed angle 00097 Ogre::Light* mLight; 00098 00099 float mAngle; 00100 const Ogre::Vector2 rotatePoint(const Ogre::Vector2& p, const Ogre::Vector2& c, const float angle); 00101 00102 void render(const float x, const float y, 00103 const float zlow, const float zhigh, 00104 const float xw, const float yw, 00105 const std::string& texture); 00106 00107 void saveTexture(const std::string& texname, const std::string& filename); 00108 00109 std::string coordStr(const int x, const int y); 00110 00111 // a buffer for the "fog of war" texture of the current cell. 00112 // interior cells could be divided into multiple textures, 00113 // so we store in a map. 00114 std::map <std::string, std::vector<Ogre::uint32> > mBuffers; 00115 00116 void deleteBuffers(); 00117 00118 bool mInterior; 00119 int mCellX, mCellY; 00120 Ogre::AxisAlignedBox mBounds; 00121 std::string mInteriorName; 00122 }; 00123 00124 } 00125 #endif