player arrow rotated correctly

actorid
scrawl 13 years ago
parent 770b0f2106
commit 06fa310e29

@ -14,6 +14,8 @@
#include "../mwmechanics/stat.hpp"
#include "window_base.hpp"
#include <cmath>
/*
This file contains classes corresponding to window layouts
defined in resources/mygui/ *.xml.
@ -144,11 +146,16 @@ namespace MWGui
mLocalMap->setViewOffset(pos);
mPlayerArrow->setPosition(MyGUI::IntPoint(x*512-16, y*512-16));
}
void setPlayerDir(const float x, const float y)
{
if (!mVisible) return;
MyGUI::ISubWidget* main = mPlayerArrow->getSubWidgetMain();
MyGUI::RotatingSkin* rotatingSubskin = main->castType<MyGUI::RotatingSkin>();
rotatingSubskin->setCenter(MyGUI::IntPoint(16,16));
rotatingSubskin->setAngle(3.141);
float angle = std::atan2(x,y);
rotatingSubskin->setAngle(angle);
}
void onDragStart(MyGUI::Widget* _sender, int _left, int _top, MyGUI::MouseButton _id)

@ -429,3 +429,8 @@ void WindowManager::setPlayerPos(const float x, const float y)
{
map->setPlayerPos(x,y);
}
void WindowManager::setPlayerDir(const float x, const float y)
{
map->setPlayerDir(x,y);
}

@ -155,6 +155,7 @@ namespace MWGui
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 setPlayerDir(const float x, const float y); ///< set player view direction in map space
void setInteriorMapTexture(const int x, const int y);
///< set the index of the map texture that should be used (for interiors)

@ -225,7 +225,7 @@ void LocalMap::render(const float x, const float y,
mRendering->getScene()->setFog(FOG_LINEAR, clr, 0, fStart, fEnd);
}
void LocalMap::setPlayerPosition (const Ogre::Vector3& position)
void LocalMap::updatePlayer (const Ogre::Vector3& position, const Ogre::Vector3& direction)
{
if (sFogOfWarSkip != 0)
{
@ -276,6 +276,7 @@ void LocalMap::setPlayerPosition (const Ogre::Vector3& position)
texName = mInteriorName + "_" + coordStr(x,y);
}
mEnvironment->mWindowManager->setPlayerPos(u, v);
mEnvironment->mWindowManager->setPlayerDir(direction.x, -direction.z);
// explore radius (squared)
const float sqrExploreRadius = 0.01 * sFogOfWarResolution*sFogOfWarResolution;

@ -40,12 +40,13 @@ namespace MWRender
Ogre::AxisAlignedBox bounds);
/**
* Set the position of the player.
* Set the position & direction of the player.
* @remarks This is used to draw a "fog of war" effect
* to hide areas on the map the player has not discovered yet.
* @param position (OGRE coordinates)
* @param view direction (OGRE coordinates)
*/
void setPlayerPosition (const Ogre::Vector3& position);
void updatePlayer (const Ogre::Vector3& position, const Ogre::Vector3& direction);
/**
* Save the fog of war for the current cell to disk.

@ -141,7 +141,7 @@ void RenderingManager::update (float duration){
mRendering.update(duration);
mLocalMap->setPlayerPosition( mRendering.getCamera()->getRealPosition() );
mLocalMap->updatePlayer( mRendering.getCamera()->getRealPosition(), mRendering.getCamera()->getRealDirection() );
}
void RenderingManager::skyEnable ()

Loading…
Cancel
Save