Merge branch 'master' into water

actorid
scrawl 13 years ago
commit d393f2dd4b

@ -278,6 +278,7 @@ LocalMapBase::LocalMapBase()
: mCurX(0) : mCurX(0)
, mCurY(0) , mCurY(0)
, mInterior(false) , mInterior(false)
, mFogOfWar(true)
, mLocalMap(NULL) , mLocalMap(NULL)
, mPrefix() , mPrefix()
, mChanged(true) , mChanged(true)
@ -297,6 +298,32 @@ void LocalMapBase::setCellPrefix(const std::string& prefix)
mChanged = true; mChanged = true;
} }
void LocalMapBase::toggleFogOfWar()
{
mFogOfWar = !mFogOfWar;
applyFogOfWar();
}
void LocalMapBase::applyFogOfWar()
{
for (int mx=0; mx<3; ++mx)
{
for (int my=0; my<3; ++my)
{
std::string name = "Map_" + boost::lexical_cast<std::string>(mx) + "_"
+ boost::lexical_cast<std::string>(my);
std::string image = mPrefix+"_"+ boost::lexical_cast<std::string>(mCurX + (mx-1)) + "_"
+ boost::lexical_cast<std::string>(mCurY + (mInterior ? (my-1) : -1*(my-1)));
MyGUI::ImageBox* fog;
mLayout->getWidget(fog, name+"_fog");
fog->setImageTexture(mFogOfWar ?
((MyGUI::RenderManager::getInstance().getTexture(image+"_fog") != 0) ? image+"_fog"
: "black.png" )
: "");
}
}
}
void LocalMapBase::setActiveCell(const int x, const int y, bool interior) void LocalMapBase::setActiveCell(const int x, const int y, bool interior)
{ {
if (x==mCurX && y==mCurY && mInterior==interior && !mChanged) return; // don't do anything if we're still in the same cell if (x==mCurX && y==mCurY && mInterior==interior && !mChanged) return; // don't do anything if we're still in the same cell
@ -312,23 +339,17 @@ void LocalMapBase::setActiveCell(const int x, const int y, bool interior)
MyGUI::ImageBox* box; MyGUI::ImageBox* box;
mLayout->getWidget(box, name); mLayout->getWidget(box, name);
MyGUI::ImageBox* fog;
mLayout->getWidget(fog, name+"_fog");
if (MyGUI::RenderManager::getInstance().getTexture(image) != 0) if (MyGUI::RenderManager::getInstance().getTexture(image) != 0)
box->setImageTexture(image); box->setImageTexture(image);
else else
box->setImageTexture("black.png"); box->setImageTexture("black.png");
if (MyGUI::RenderManager::getInstance().getTexture(image+"_fog") != 0)
fog->setImageTexture(image+"_fog");
else
fog->setImageTexture("black.png");
} }
} }
mInterior = interior; mInterior = interior;
mCurX = x; mCurX = x;
mCurY = y; mCurY = y;
mChanged = false; mChanged = false;
applyFogOfWar();
} }

@ -40,12 +40,17 @@ namespace MWGui
void setCellPrefix(const std::string& prefix); void setCellPrefix(const std::string& prefix);
void setActiveCell(const int x, const int y, bool interior=false); void setActiveCell(const int x, const int y, bool interior=false);
void toggleFogOfWar();
protected: protected:
int mCurX, mCurY; int mCurX, mCurY;
bool mInterior; bool mInterior;
MyGUI::ScrollView* mLocalMap; MyGUI::ScrollView* mLocalMap;
std::string mPrefix; std::string mPrefix;
bool mChanged; bool mChanged;
bool mFogOfWar;
void applyFogOfWar();
OEngine::GUI::Layout* mLayout; OEngine::GUI::Layout* mLayout;
}; };

@ -455,3 +455,9 @@ void WindowManager::setPlayerDir(const float x, const float y)
map->setPlayerDir(x,y); map->setPlayerDir(x,y);
hud->setPlayerDir(x,y); hud->setPlayerDir(x,y);
} }
void WindowManager::toggleFogOfWar()
{
map->toggleFogOfWar();
hud->toggleFogOfWar();
}

@ -156,6 +156,8 @@ namespace MWGui
void changeCell(MWWorld::Ptr::CellStore* cell); ///< change the active cell void changeCell(MWWorld::Ptr::CellStore* cell); ///< change the active cell
void setPlayerPos(const float x, const float y); ///< set player position in map space void setPlayerPos(const float x, const float y); ///< set player position in map space
void setPlayerDir(const float x, const float y); ///< set player view direction in map space void setPlayerDir(const float x, const float y); ///< set player view direction in map space
void toggleFogOfWar();
void setInteriorMapTexture(const int x, const int y); void setInteriorMapTexture(const int x, const int y);
///< set the index of the map texture that should be used (for interiors) ///< set the index of the map texture that should be used (for interiors)

@ -2,6 +2,7 @@
#include "renderingmanager.hpp" #include "renderingmanager.hpp"
#include "../mwworld/environment.hpp" #include "../mwworld/environment.hpp"
#include "../mwworld/world.hpp"
#include "../mwgui/window_manager.hpp" #include "../mwgui/window_manager.hpp"
#include <OgreOverlayManager.h> #include <OgreOverlayManager.h>
@ -10,16 +11,24 @@
using namespace MWRender; using namespace MWRender;
using namespace Ogre; using namespace Ogre;
LocalMap::LocalMap(OEngine::Render::OgreRenderer* rend, MWWorld::Environment* env) LocalMap::LocalMap(OEngine::Render::OgreRenderer* rend, MWRender::RenderingManager* rendering, MWWorld::Environment* env) :
mInterior(false), mCellX(0), mCellY(0)
{ {
mRendering = rend; mRendering = rend;
mRenderingManager = rendering;
mEnvironment = env; mEnvironment = env;
mCameraPosNode = mRendering->getScene()->getRootSceneNode()->createChildSceneNode();
mCameraRotNode = mCameraPosNode->createChildSceneNode();
mCameraNode = mCameraRotNode->createChildSceneNode();
mCellCamera = mRendering->getScene()->createCamera("CellCamera"); mCellCamera = mRendering->getScene()->createCamera("CellCamera");
mCellCamera->setProjectionType(PT_ORTHOGRAPHIC); mCellCamera->setProjectionType(PT_ORTHOGRAPHIC);
// look down -y // look down -y
const float sqrt0pt5 = 0.707106781; const float sqrt0pt5 = 0.707106781;
mCellCamera->setOrientation(Quaternion(sqrt0pt5, -sqrt0pt5, 0, 0)); mCellCamera->setOrientation(Quaternion(sqrt0pt5, -sqrt0pt5, 0, 0));
mCameraNode->attachObject(mCellCamera);
} }
LocalMap::~LocalMap() LocalMap::~LocalMap()
@ -27,6 +36,12 @@ LocalMap::~LocalMap()
deleteBuffers(); deleteBuffers();
} }
const Ogre::Vector2 LocalMap::rotatePoint(const Ogre::Vector2& p, const Ogre::Vector2& c, const float angle)
{
return Vector2( Math::Cos(angle) * (p.x - c.x) - Math::Sin(angle) * (p.y - c.y) + c.x,
Math::Sin(angle) * (p.x - c.x) + Math::Cos(angle) * (p.y - c.y) + c.y);
}
void LocalMap::deleteBuffers() void LocalMap::deleteBuffers()
{ {
mBuffers.clear(); mBuffers.clear();
@ -65,9 +80,6 @@ void LocalMap::saveFogOfWar(MWWorld::Ptr::CellStore* cell)
{ {
Vector2 min(mBounds.getMinimum().x, mBounds.getMinimum().z); Vector2 min(mBounds.getMinimum().x, mBounds.getMinimum().z);
Vector2 max(mBounds.getMaximum().x, mBounds.getMaximum().z); Vector2 max(mBounds.getMaximum().x, mBounds.getMaximum().z);
/// \todo why is this workaround needed?
min *= 1.3;
max *= 1.3;
Vector2 length = max-min; Vector2 length = max-min;
// divide into segments // divide into segments
@ -90,11 +102,15 @@ void LocalMap::requestMap(MWWorld::Ptr::CellStore* cell)
{ {
mInterior = false; mInterior = false;
mCameraRotNode->setOrientation(Quaternion::IDENTITY);
std::string name = "Cell_"+coordStr(cell->cell->data.gridX, cell->cell->data.gridY); std::string name = "Cell_"+coordStr(cell->cell->data.gridX, cell->cell->data.gridY);
int x = cell->cell->data.gridX; int x = cell->cell->data.gridX;
int y = cell->cell->data.gridY; int y = cell->cell->data.gridY;
mCameraPosNode->setPosition(Vector3(0,0,0));
render((x+0.5)*sSize, (-y-0.5)*sSize, -10000, 10000, sSize, sSize, name); render((x+0.5)*sSize, (-y-0.5)*sSize, -10000, 10000, sSize, sSize, name);
} }
@ -103,17 +119,29 @@ void LocalMap::requestMap(MWWorld::Ptr::CellStore* cell,
{ {
mInterior = true; mInterior = true;
mBounds = bounds; mBounds = bounds;
Vector2 z(bounds.getMaximum().y, bounds.getMinimum().y);
Vector2 min(bounds.getMinimum().x, bounds.getMinimum().z);
Vector2 max(bounds.getMaximum().x, bounds.getMaximum().z);
/// \todo why is this workaround needed? Vector2 z(mBounds.getMaximum().y, mBounds.getMinimum().y);
min *= 1.3;
max *= 1.3; const Vector2& north = mEnvironment->mWorld->getNorthVector(cell);
Radian angle(std::atan2(-north.x, -north.y));
mAngle = angle.valueRadians();
mCameraRotNode->setOrientation(Quaternion(Math::Cos(angle/2.f), 0, Math::Sin(angle/2.f), 0));
mBounds.merge(mCameraRotNode->convertWorldToLocalPosition(bounds.getCorner(AxisAlignedBox::NEAR_LEFT_BOTTOM)));
mBounds.merge(mCameraRotNode->convertWorldToLocalPosition(bounds.getCorner(AxisAlignedBox::FAR_LEFT_BOTTOM)));
mBounds.merge(mCameraRotNode->convertWorldToLocalPosition(bounds.getCorner(AxisAlignedBox::NEAR_RIGHT_BOTTOM)));
mBounds.merge(mCameraRotNode->convertWorldToLocalPosition(bounds.getCorner(AxisAlignedBox::FAR_RIGHT_BOTTOM)));
mBounds.scale(Vector3(2,2,2));
Vector2 center(mBounds.getCenter().x, mBounds.getCenter().z);
Vector2 min(mBounds.getMinimum().x, mBounds.getMinimum().z);
Vector2 max(mBounds.getMaximum().x, mBounds.getMaximum().z);
Vector2 length = max-min; Vector2 length = max-min;
Vector2 center(bounds.getCenter().x, bounds.getCenter().z);
mCameraPosNode->setPosition(Vector3(center.x, 0, center.y));
// divide into segments // divide into segments
const int segsX = std::ceil( length.x / sSize ); const int segsX = std::ceil( length.x / sSize );
@ -128,7 +156,7 @@ void LocalMap::requestMap(MWWorld::Ptr::CellStore* cell,
Vector2 start = min + Vector2(sSize*x,sSize*y); Vector2 start = min + Vector2(sSize*x,sSize*y);
Vector2 newcenter = start + 4096; Vector2 newcenter = start + 4096;
render(newcenter.x, newcenter.y, z.y, z.x, sSize, sSize, render(newcenter.x - center.x, newcenter.y - center.y, z.y, z.x, sSize, sSize,
cell->cell->name + "_" + coordStr(x,y)); cell->cell->name + "_" + coordStr(x,y));
} }
} }
@ -147,8 +175,9 @@ void LocalMap::render(const float x, const float y,
// make everything visible // make everything visible
mRendering->getScene()->setAmbientLight(ColourValue(1,1,1)); mRendering->getScene()->setAmbientLight(ColourValue(1,1,1));
mRenderingManager->disableLights();
mCellCamera->setPosition(Vector3(x, zhigh+100000, y)); mCameraNode->setPosition(Vector3(x, zhigh+100000, y));
//mCellCamera->setFarClipDistance( (zhigh-zlow) * 1.1 ); //mCellCamera->setFarClipDistance( (zhigh-zlow) * 1.1 );
mCellCamera->setFarClipDistance(0); // infinite mCellCamera->setFarClipDistance(0); // infinite
@ -215,13 +244,14 @@ void LocalMap::render(const float x, const float y,
//rtt->writeContentsToFile("./" + texture + ".jpg"); //rtt->writeContentsToFile("./" + texture + ".jpg");
} }
} }
mRenderingManager->enableLights();
// re-enable fog // re-enable fog
mRendering->getScene()->setFog(FOG_LINEAR, clr, 0, fStart, fEnd); mRendering->getScene()->setFog(FOG_LINEAR, clr, 0, fStart, fEnd);
} }
void LocalMap::updatePlayer (const Ogre::Vector3& position, const Ogre::Vector3& direction) void LocalMap::updatePlayer (const Ogre::Vector3& position, const Ogre::Quaternion& orientation)
{ {
if (sFogOfWarSkip != 0) if (sFogOfWarSkip != 0)
{ {
@ -232,7 +262,19 @@ void LocalMap::updatePlayer (const Ogre::Vector3& position, const Ogre::Vector3&
// retrieve the x,y grid coordinates the player is in // retrieve the x,y grid coordinates the player is in
int x,y; int x,y;
Vector2 pos(position.x, position.z); Vector3 _pos(position.x, 0, position.z);
Vector2 pos(_pos.x, _pos.z);
if (mInterior)
{
pos = rotatePoint(pos, Vector2(mBounds.getCenter().x, mBounds.getCenter().z), mAngle);
}
Vector3 playerdirection = -mCameraRotNode->convertWorldToLocalOrientation(orientation).zAxis();
Vector2 min(mBounds.getMinimum().x, mBounds.getMinimum().z);
if (!mInterior) if (!mInterior)
{ {
x = std::ceil(pos.x / sSize)-1; x = std::ceil(pos.x / sSize)-1;
@ -242,9 +284,6 @@ void LocalMap::updatePlayer (const Ogre::Vector3& position, const Ogre::Vector3&
} }
else else
{ {
Vector2 min(mBounds.getMinimum().x, mBounds.getMinimum().z);
min *= 1.3;
x = std::ceil((pos.x - min.x)/sSize)-1; x = std::ceil((pos.x - min.x)/sSize)-1;
y = std::ceil((pos.y - min.y)/sSize)-1; y = std::ceil((pos.y - min.y)/sSize)-1;
@ -259,20 +298,17 @@ void LocalMap::updatePlayer (const Ogre::Vector3& position, const Ogre::Vector3&
u = std::abs((pos.x - (sSize*x))/sSize); u = std::abs((pos.x - (sSize*x))/sSize);
v = 1-std::abs((pos.y + (sSize*y))/sSize); v = 1-std::abs((pos.y + (sSize*y))/sSize);
texName = "Cell_"+coordStr(x,y); texName = "Cell_"+coordStr(x,y);
} }
else else
{ {
Vector2 min(mBounds.getMinimum().x, mBounds.getMinimum().z);
min *= 1.3;
u = (pos.x - min.x - sSize*x)/sSize; u = (pos.x - min.x - sSize*x)/sSize;
v = (pos.y - min.y - sSize*y)/sSize; v = (pos.y - min.y - sSize*y)/sSize;
texName = mInteriorName + "_" + coordStr(x,y); texName = mInteriorName + "_" + coordStr(x,y);
} }
mEnvironment->mWindowManager->setPlayerPos(u, v); mEnvironment->mWindowManager->setPlayerPos(u, v);
mEnvironment->mWindowManager->setPlayerDir(direction.x, -direction.z); mEnvironment->mWindowManager->setPlayerDir(playerdirection.x, -playerdirection.z);
// explore radius (squared) // explore radius (squared)
const float sqrExploreRadius = 0.01 * sFogOfWarResolution*sFogOfWarResolution; const float sqrExploreRadius = 0.01 * sFogOfWarResolution*sFogOfWarResolution;

@ -12,13 +12,15 @@ namespace MWWorld
namespace MWRender namespace MWRender
{ {
class RenderingManager;
/// ///
/// \brief Local map rendering /// \brief Local map rendering
/// ///
class LocalMap class LocalMap
{ {
public: public:
LocalMap(OEngine::Render::OgreRenderer*, MWWorld::Environment* env); LocalMap(OEngine::Render::OgreRenderer*, MWRender::RenderingManager* rendering, MWWorld::Environment* env);
~LocalMap(); ~LocalMap();
/** /**
@ -44,9 +46,9 @@ namespace MWRender
* @remarks This is used to draw a "fog of war" effect * @remarks This is used to draw a "fog of war" effect
* to hide areas on the map the player has not discovered yet. * to hide areas on the map the player has not discovered yet.
* @param position (OGRE coordinates) * @param position (OGRE coordinates)
* @param view direction (OGRE coordinates) * @param camera orientation (OGRE coordinates)
*/ */
void updatePlayer (const Ogre::Vector3& position, const Ogre::Vector3& direction); void updatePlayer (const Ogre::Vector3& position, const Ogre::Quaternion& orientation);
/** /**
* Save the fog of war for the current cell to disk. * Save the fog of war for the current cell to disk.
@ -58,6 +60,7 @@ namespace MWRender
private: private:
OEngine::Render::OgreRenderer* mRendering; OEngine::Render::OgreRenderer* mRendering;
MWRender::RenderingManager* mRenderingManager;
MWWorld::Environment* mEnvironment; MWWorld::Environment* mEnvironment;
// 1024*1024 pixels for a cell // 1024*1024 pixels for a cell
@ -73,6 +76,12 @@ namespace MWRender
static const int sSize = 8192; static const int sSize = 8192;
Ogre::Camera* mCellCamera; Ogre::Camera* mCellCamera;
Ogre::SceneNode* mCameraNode;
Ogre::SceneNode* mCameraPosNode;
Ogre::SceneNode* mCameraRotNode;
float mAngle;
const Ogre::Vector2 rotatePoint(const Ogre::Vector2& p, const Ogre::Vector2& c, const float angle);
void render(const float x, const float y, void render(const float x, const float y,
const float zlow, const float zhigh, const float zlow, const float zhigh,

@ -168,6 +168,7 @@ void Objects::insertLight (const MWWorld::Ptr& ptr, float r, float g, float b, f
assert(insert); assert(insert);
Ogre::Light *light = mRenderer.getScene()->createLight(); Ogre::Light *light = mRenderer.getScene()->createLight();
light->setDiffuseColour (r, g, b); light->setDiffuseColour (r, g, b);
mLights.push_back(light->getName());
float cval=0.0f, lval=0.0f, qval=0.0f; float cval=0.0f, lval=0.0f, qval=0.0f;
@ -273,3 +274,34 @@ Ogre::AxisAlignedBox Objects::getDimensions(MWWorld::Ptr::CellStore* cell)
{ {
return mBounds[cell]; return mBounds[cell];
} }
void Objects::enableLights()
{
std::vector<std::string>::iterator it = mLights.begin();
while (it != mLights.end())
{
if (mMwRoot->getCreator()->hasLight(*it))
{
mMwRoot->getCreator()->getLight(*it)->setVisible(true);
++it;
}
else
it = mLights.erase(it);
}
}
void Objects::disableLights()
{
std::vector<std::string>::iterator it = mLights.begin();
while (it != mLights.end())
{
if (mMwRoot->getCreator()->hasLight(*it))
{
mMwRoot->getCreator()->getLight(*it)->setVisible(false);
++it;
}
else
it = mLights.erase(it);
}
}

@ -16,6 +16,7 @@ class Objects{
std::map<MWWorld::Ptr::CellStore *, Ogre::StaticGeometry*> mStaticGeometry; std::map<MWWorld::Ptr::CellStore *, Ogre::StaticGeometry*> mStaticGeometry;
std::map<MWWorld::Ptr::CellStore *, Ogre::StaticGeometry*> mStaticGeometrySmall; std::map<MWWorld::Ptr::CellStore *, Ogre::StaticGeometry*> mStaticGeometrySmall;
std::map<MWWorld::Ptr::CellStore *, Ogre::AxisAlignedBox> mBounds; std::map<MWWorld::Ptr::CellStore *, Ogre::AxisAlignedBox> mBounds;
std::vector<std::string> mLights;
Ogre::SceneNode* mMwRoot; Ogre::SceneNode* mMwRoot;
bool mIsStatic; bool mIsStatic;
static int uniqueID; static int uniqueID;
@ -44,6 +45,9 @@ public:
void insertMesh (const MWWorld::Ptr& ptr, const std::string& mesh); void insertMesh (const MWWorld::Ptr& ptr, const std::string& mesh);
void insertLight (const MWWorld::Ptr& ptr, float r, float g, float b, float radius); void insertLight (const MWWorld::Ptr& ptr, float r, float g, float b, float radius);
void enableLights();
void disableLights();
Ogre::AxisAlignedBox getDimensions(MWWorld::Ptr::CellStore*); Ogre::AxisAlignedBox getDimensions(MWWorld::Ptr::CellStore*);
///< get a bounding box that encloses all objects in the specified cell ///< get a bounding box that encloses all objects in the specified cell

@ -65,7 +65,7 @@ RenderingManager::RenderingManager (OEngine::Render::OgreRenderer& _rend, const
mSun = 0; mSun = 0;
mDebugging = new Debugging(mMwRoot, environment, engine); mDebugging = new Debugging(mMwRoot, environment, engine);
mLocalMap = new MWRender::LocalMap(&mRendering, &environment); mLocalMap = new MWRender::LocalMap(&mRendering, this, &environment);
} }
RenderingManager::~RenderingManager () RenderingManager::~RenderingManager ()
@ -178,7 +178,7 @@ void RenderingManager::update (float duration){
mRendering.update(duration); mRendering.update(duration);
mLocalMap->updatePlayer( mRendering.getCamera()->getRealPosition(), mRendering.getCamera()->getRealDirection() ); mLocalMap->updatePlayer( mRendering.getCamera()->getRealPosition(), mRendering.getCamera()->getRealOrientation() );
checkUnderwater(); checkUnderwater();
} }
@ -408,4 +408,14 @@ void RenderingManager::preCellChange(MWWorld::Ptr::CellStore* cell)
mLocalMap->saveFogOfWar(cell); mLocalMap->saveFogOfWar(cell);
} }
void RenderingManager::disableLights()
{
mObjects.disableLights();
}
void RenderingManager::enableLights()
{
mObjects.enableLights();
}
} // namespace } // namespace

@ -106,6 +106,9 @@ class RenderingManager: private RenderingInterface {
void sunEnable(); void sunEnable();
void sunDisable(); void sunDisable();
void disableLights();
void enableLights();
bool occlusionQuerySupported() { return mOcclusionQuery->supported(); }; bool occlusionQuerySupported() { return mOcclusionQuery->supported(); };
OcclusionQuery* getOcclusionQuery() { return mOcclusionQuery; }; OcclusionQuery* getOcclusionQuery() { return mOcclusionQuery; };

@ -746,6 +746,7 @@ void SkyManager::setGlare(const float glare)
Vector3 SkyManager::getRealSunPos() Vector3 SkyManager::getRealSunPos()
{ {
if (!mCreated) return Vector3(0,0,0);
return mSun->getNode()->_getDerivedPosition(); return mSun->getNode()->_getDerivedPosition();
} }

@ -127,5 +127,6 @@ op 0x2000141: GetWaterLevel
op 0x2000142: SetWaterLevel op 0x2000142: SetWaterLevel
op 0x2000143: ModWaterLevel op 0x2000143: ModWaterLevel
op 0x2000144: ToggleWater, twa op 0x2000144: ToggleWater, twa
op 0x2000145: TogglePathgrid op 0x2000145: ToggleFogOfWar (tfow)
opcodes 0x2000146-0x3ffffff unused op 0x2000146: TogglePathgrid
opcodes 0x2000147-0x3ffffff unused

@ -67,6 +67,19 @@ namespace MWScript
} }
}; };
class OpToggleFogOfWar : public Interpreter::Opcode0
{
public:
virtual void execute (Interpreter::Runtime& runtime)
{
InterpreterContext& context =
static_cast<InterpreterContext&> (runtime.getContext());
context.getEnvironment().mWindowManager->toggleFogOfWar();
}
};
const int opcodeEnableBirthMenu = 0x200000e; const int opcodeEnableBirthMenu = 0x200000e;
const int opcodeEnableClassMenu = 0x200000f; const int opcodeEnableClassMenu = 0x200000f;
const int opcodeEnableNameMenu = 0x2000010; const int opcodeEnableNameMenu = 0x2000010;
@ -79,6 +92,7 @@ namespace MWScript
const int opcodeEnableRest = 0x2000017; const int opcodeEnableRest = 0x2000017;
const int opcodeShowRestMenu = 0x2000018; const int opcodeShowRestMenu = 0x2000018;
const int opcodeGetButtonPressed = 0x2000137; const int opcodeGetButtonPressed = 0x2000137;
const int opcodeToggleFogOfWar = 0x2000145;
void registerExtensions (Compiler::Extensions& extensions) void registerExtensions (Compiler::Extensions& extensions)
{ {
@ -100,6 +114,9 @@ namespace MWScript
extensions.registerInstruction ("showrestmenu", "", opcodeShowRestMenu); extensions.registerInstruction ("showrestmenu", "", opcodeShowRestMenu);
extensions.registerFunction ("getbuttonpressed", 'l', "", opcodeGetButtonPressed); extensions.registerFunction ("getbuttonpressed", 'l', "", opcodeGetButtonPressed);
extensions.registerInstruction ("togglefogofwar", "", opcodeToggleFogOfWar);
extensions.registerInstruction ("tfow", "", opcodeToggleFogOfWar);
} }
void installOpcodes (Interpreter::Interpreter& interpreter) void installOpcodes (Interpreter::Interpreter& interpreter)
@ -135,6 +152,8 @@ namespace MWScript
new OpShowDialogue (MWGui::GM_Rest)); new OpShowDialogue (MWGui::GM_Rest));
interpreter.installSegment5 (opcodeGetButtonPressed, new OpGetButtonPressed); interpreter.installSegment5 (opcodeGetButtonPressed, new OpGetButtonPressed);
interpreter.installSegment5 (opcodeToggleFogOfWar, new OpToggleFogOfWar);
} }
} }
} }

@ -217,7 +217,7 @@ namespace MWScript
const int opcodeFadeOut = 0x200013d; const int opcodeFadeOut = 0x200013d;
const int opcodeFadeTo = 0x200013e; const int opcodeFadeTo = 0x200013e;
const int opcodeToggleWater = 0x2000144; const int opcodeToggleWater = 0x2000144;
const int opcodeTogglePathgrid = 0x2000145; const int opcodeTogglePathgrid = 0x2000146;
void registerExtensions (Compiler::Extensions& extensions) void registerExtensions (Compiler::Extensions& extensions)
{ {

@ -864,6 +864,18 @@ namespace MWWorld
return mRendering->getFader(); return mRendering->getFader();
} }
Ogre::Vector2 World::getNorthVector(Ptr::CellStore* cell)
{
ESMS::CellRefList<ESM::Static, MWWorld::RefData> statics = cell->statics;
ESMS::LiveCellRef<ESM::Static, MWWorld::RefData>* ref = statics.find("northmarker");
if (!ref)
return Vector2(0, 1);
Ogre::SceneNode* node = ref->mData.getBaseNode();
Vector3 dir = node->_getDerivedOrientation().yAxis();
Vector2 d = Vector2(dir.x, dir.z);
return d;
}
void World::setWaterHeight(const float height) void World::setWaterHeight(const float height)
{ {
mRendering->setWaterHeight(height); mRendering->setWaterHeight(height);

@ -139,6 +139,9 @@ namespace MWWorld
bool isCellExterior() const; bool isCellExterior() const;
bool isCellQuasiExterior() const; bool isCellQuasiExterior() const;
Ogre::Vector2 getNorthVector(Ptr::CellStore* cell);
///< get north vector (OGRE coordinates) for given interior cell
Globals::Data& getGlobalVariable (const std::string& name); Globals::Data& getGlobalVariable (const std::string& name);
Globals::Data getGlobalVariable (const std::string& name) const; Globals::Data getGlobalVariable (const std::string& name) const;

Loading…
Cancel
Save