forked from mirror/openmw-tes3mp
Add option to move the mouse against the screen frame of reference.
This commit is contained in:
parent
89bb616cbc
commit
a21958d007
3 changed files with 42 additions and 24 deletions
|
@ -175,6 +175,14 @@ void CSMSettings::UserSettings::buildSettingModelDefaults()
|
||||||
"For testing mouse movement directions.");
|
"For testing mouse movement directions.");
|
||||||
mouseWheel->setDefaultValue (defaultValue);
|
mouseWheel->setDefaultValue (defaultValue);
|
||||||
mouseWheel->setDeclaredValues (values);
|
mouseWheel->setDeclaredValues (values);
|
||||||
|
|
||||||
|
defaultValue = "screen";
|
||||||
|
values = QStringList() << defaultValue << "world";
|
||||||
|
|
||||||
|
Setting *mouseCoord = createSetting (Type_RadioButton, "mouse-reference",
|
||||||
|
"For testing mouse movement frame of reference.");
|
||||||
|
mouseCoord->setDefaultValue (defaultValue);
|
||||||
|
mouseCoord->setDeclaredValues (values);
|
||||||
}
|
}
|
||||||
|
|
||||||
declareSection ("table-input", "Table Input");
|
declareSection ("table-input", "Table Input");
|
||||||
|
|
|
@ -3,11 +3,7 @@
|
||||||
#include <OgreSceneNode.h>
|
#include <OgreSceneNode.h>
|
||||||
#include <OgreSceneManager.h>
|
#include <OgreSceneManager.h>
|
||||||
#include <OgreEntity.h>
|
#include <OgreEntity.h>
|
||||||
|
|
||||||
#include <OgreMeshManager.h>
|
#include <OgreMeshManager.h>
|
||||||
#include <OgreManualObject.h> // FIXME: for debugging
|
|
||||||
#include <OgreMaterialManager.h> // FIXME: for debugging
|
|
||||||
#include <OgreHardwarePixelBuffer.h> // FIXME: for debugging
|
|
||||||
|
|
||||||
#include <QMouseEvent>
|
#include <QMouseEvent>
|
||||||
#include <QElapsedTimer>
|
#include <QElapsedTimer>
|
||||||
|
@ -15,27 +11,9 @@
|
||||||
#include "../../model/settings/usersettings.hpp"
|
#include "../../model/settings/usersettings.hpp"
|
||||||
#include "../world/physicssystem.hpp"
|
#include "../world/physicssystem.hpp"
|
||||||
|
|
||||||
#include "elements.hpp" // FIXME: for debugging
|
#include "elements.hpp"
|
||||||
#include "worldspacewidget.hpp"
|
#include "worldspacewidget.hpp"
|
||||||
|
|
||||||
namespace
|
|
||||||
{
|
|
||||||
//plane Z, upvector Y, mOffset z : x-y plane, wheel up/down
|
|
||||||
//plane Y, upvector X, mOffset y : y-z plane, wheel left/right
|
|
||||||
//plane X, upvector Y, mOffset x : x-z plane, wheel closer/further
|
|
||||||
std::pair<Ogre::Vector3, Ogre::Vector3> planeAxis()
|
|
||||||
{
|
|
||||||
CSMSettings::UserSettings &userSettings = CSMSettings::UserSettings::instance();
|
|
||||||
QString wheelDir = userSettings.setting("debug/mouse-wheel", QString("Closer/Further"));
|
|
||||||
if(wheelDir == "Up/Down")
|
|
||||||
return std::make_pair(Ogre::Vector3::UNIT_Z, Ogre::Vector3::UNIT_Y);
|
|
||||||
else if(wheelDir == "Left/Right")
|
|
||||||
return std::make_pair(Ogre::Vector3::UNIT_Y, Ogre::Vector3::UNIT_X);
|
|
||||||
else
|
|
||||||
return std::make_pair(Ogre::Vector3::UNIT_X, Ogre::Vector3::UNIT_Y);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace CSVRender
|
namespace CSVRender
|
||||||
{
|
{
|
||||||
// mouse picking
|
// mouse picking
|
||||||
|
@ -187,7 +165,6 @@ namespace CSVRender
|
||||||
mGrabbedSceneNode = result.first;
|
mGrabbedSceneNode = result.first;
|
||||||
// ray test agaist the plane to get a starting position of the
|
// ray test agaist the plane to get a starting position of the
|
||||||
// mouse in relation to the object position
|
// mouse in relation to the object position
|
||||||
//mPlane->redefine(Ogre::Vector3::UNIT_Z, result.second);
|
|
||||||
std::pair<Ogre::Vector3, Ogre::Vector3> planeRes = planeAxis();
|
std::pair<Ogre::Vector3, Ogre::Vector3> planeRes = planeAxis();
|
||||||
mPlane->redefine(planeRes.first, result.second);
|
mPlane->redefine(planeRes.first, result.second);
|
||||||
std::pair<bool, Ogre::Vector3> planeResult = mousePositionOnPlane(event->pos(), *mPlane);
|
std::pair<bool, Ogre::Vector3> planeResult = mousePositionOnPlane(event->pos(), *mPlane);
|
||||||
|
@ -351,6 +328,38 @@ namespace CSVRender
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//plane Z, upvector Y, mOffset z : x-y plane, wheel up/down
|
||||||
|
//plane Y, upvector X, mOffset y : y-z plane, wheel left/right
|
||||||
|
//plane X, upvector Y, mOffset x : x-z plane, wheel closer/further
|
||||||
|
std::pair<Ogre::Vector3, Ogre::Vector3> MouseState::planeAxis()
|
||||||
|
{
|
||||||
|
CSMSettings::UserSettings &userSettings = CSMSettings::UserSettings::instance();
|
||||||
|
QString coord = userSettings.setting("debug/mouse-reference", QString("screen"));
|
||||||
|
|
||||||
|
QString wheelDir = userSettings.setting("debug/mouse-wheel", QString("Closer/Further"));
|
||||||
|
if(wheelDir == "Left/Right")
|
||||||
|
{
|
||||||
|
if(coord == "world")
|
||||||
|
return std::make_pair(Ogre::Vector3::UNIT_Y, Ogre::Vector3::UNIT_X);
|
||||||
|
else
|
||||||
|
return std::make_pair(getCamera()->getDerivedRight(), getCamera()->getDerivedDirection());
|
||||||
|
}
|
||||||
|
else if(wheelDir == "Up/Down")
|
||||||
|
{
|
||||||
|
if(coord == "world")
|
||||||
|
return std::make_pair(Ogre::Vector3::UNIT_Z, Ogre::Vector3::UNIT_Y);
|
||||||
|
else
|
||||||
|
return std::make_pair(getCamera()->getDerivedUp(), getCamera()->getDerivedRight());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if(coord == "world")
|
||||||
|
return std::make_pair(Ogre::Vector3::UNIT_X, Ogre::Vector3::UNIT_Y);
|
||||||
|
else
|
||||||
|
return std::make_pair(getCamera()->getDerivedDirection(), getCamera()->getDerivedRight());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
std::pair<bool, Ogre::Vector3> MouseState::mousePositionOnPlane(const QPoint &pos, const Ogre::Plane &plane)
|
std::pair<bool, Ogre::Vector3> MouseState::mousePositionOnPlane(const QPoint &pos, const Ogre::Plane &plane)
|
||||||
{
|
{
|
||||||
// using a really small value seems to mess up with the projections
|
// using a really small value seems to mess up with the projections
|
||||||
|
|
|
@ -71,6 +71,7 @@ namespace CSVRender
|
||||||
std::pair<std::string, Ogre::Vector3> terrainUnderCursor(const int mouseX, const int mouseY);
|
std::pair<std::string, Ogre::Vector3> terrainUnderCursor(const int mouseX, const int mouseY);
|
||||||
std::pair<std::string, Ogre::Vector3> objectUnderCursor(const int mouseX, const int mouseY);
|
std::pair<std::string, Ogre::Vector3> objectUnderCursor(const int mouseX, const int mouseY);
|
||||||
void updateSelectionHighlight(const std::string sceneNode, const Ogre::Vector3 &position);
|
void updateSelectionHighlight(const std::string sceneNode, const Ogre::Vector3 &position);
|
||||||
|
std::pair<Ogre::Vector3, Ogre::Vector3> planeAxis();
|
||||||
void updateSceneWidgets();
|
void updateSceneWidgets();
|
||||||
bool isDebug();
|
bool isDebug();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue