mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-16 18:19:55 +00:00
Create a visual representation of the center of the orbit camera.
For debugging purposes.
This commit is contained in:
parent
c8bae38a8e
commit
2c894acd98
3 changed files with 30 additions and 3 deletions
|
@ -3,8 +3,12 @@
|
||||||
#include <QKeyEvent>
|
#include <QKeyEvent>
|
||||||
|
|
||||||
#include <osg/Camera>
|
#include <osg/Camera>
|
||||||
|
#include <osg/Geode>
|
||||||
|
#include <osg/Group>
|
||||||
#include <osg/Matrixd>
|
#include <osg/Matrixd>
|
||||||
#include <osg/Quat>
|
#include <osg/Quat>
|
||||||
|
#include <osg/Shape>
|
||||||
|
#include <osg/ShapeDrawable>
|
||||||
|
|
||||||
namespace CSVRender
|
namespace CSVRender
|
||||||
{
|
{
|
||||||
|
@ -261,7 +265,7 @@ namespace CSVRender
|
||||||
Orbit Camera Controller
|
Orbit Camera Controller
|
||||||
*/
|
*/
|
||||||
|
|
||||||
OrbitCameraController::OrbitCameraController()
|
OrbitCameraController::OrbitCameraController(osg::Group* group)
|
||||||
: mInitialized(false)
|
: mInitialized(false)
|
||||||
, mFast(false)
|
, mFast(false)
|
||||||
, mLeft(false)
|
, mLeft(false)
|
||||||
|
@ -271,7 +275,10 @@ namespace CSVRender
|
||||||
, mRollLeft(false)
|
, mRollLeft(false)
|
||||||
, mRollRight(false)
|
, mRollRight(false)
|
||||||
, mCenter(0,0,0)
|
, mCenter(0,0,0)
|
||||||
|
, mCenterNode(new osg::PositionAttitudeTransform())
|
||||||
{
|
{
|
||||||
|
group->addChild(mCenterNode);
|
||||||
|
createShape();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool OrbitCameraController::handleKeyEvent(QKeyEvent* event, bool pressed)
|
bool OrbitCameraController::handleKeyEvent(QKeyEvent* event, bool pressed)
|
||||||
|
@ -383,6 +390,8 @@ namespace CSVRender
|
||||||
if (mRollRight)
|
if (mRollRight)
|
||||||
roll(rotDist);
|
roll(rotDist);
|
||||||
|
|
||||||
|
mCenterNode->setPosition(mCenter);
|
||||||
|
|
||||||
lookAtCenter();
|
lookAtCenter();
|
||||||
|
|
||||||
// Normalize the matrix to counter drift
|
// Normalize the matrix to counter drift
|
||||||
|
@ -409,6 +418,19 @@ namespace CSVRender
|
||||||
mInitialized = true;
|
mInitialized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void OrbitCameraController::createShape()
|
||||||
|
{
|
||||||
|
const float boxWidth = 100;
|
||||||
|
|
||||||
|
osg::ref_ptr<osg::Box> box = new osg::Box(osg::Vec3f(0, 0, 0), boxWidth);
|
||||||
|
osg::ref_ptr<osg::ShapeDrawable> drawable = new osg::ShapeDrawable(box);
|
||||||
|
drawable->setColor(osg::Vec4f(0.f, 0.9f, 0.f, 1.f));
|
||||||
|
|
||||||
|
osg::ref_ptr<osg::Geode> geode = new osg::Geode();
|
||||||
|
geode->addChild(drawable);
|
||||||
|
mCenterNode->addChild(geode);
|
||||||
|
}
|
||||||
|
|
||||||
void OrbitCameraController::rotateHorizontal(double value)
|
void OrbitCameraController::rotateHorizontal(double value)
|
||||||
{
|
{
|
||||||
osg::Vec3d position = getCamera()->getViewMatrix().getTrans();
|
osg::Vec3d position = getCamera()->getViewMatrix().getTrans();
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include <osg/BoundingBox>
|
#include <osg/BoundingBox>
|
||||||
|
#include <osg/PositionAttitudeTransform>
|
||||||
#include <osg/ref_ptr>
|
#include <osg/ref_ptr>
|
||||||
#include <osg/Vec3d>
|
#include <osg/Vec3d>
|
||||||
|
|
||||||
|
@ -12,6 +13,7 @@ class QKeyEvent;
|
||||||
namespace osg
|
namespace osg
|
||||||
{
|
{
|
||||||
class Camera;
|
class Camera;
|
||||||
|
class Group;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace CSVRender
|
namespace CSVRender
|
||||||
|
@ -97,7 +99,7 @@ namespace CSVRender
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
OrbitCameraController();
|
OrbitCameraController(osg::Group* group);
|
||||||
|
|
||||||
bool handleKeyEvent(QKeyEvent* event, bool pressed);
|
bool handleKeyEvent(QKeyEvent* event, bool pressed);
|
||||||
bool handleMouseMoveEvent(std::string mode, int x, int y);
|
bool handleMouseMoveEvent(std::string mode, int x, int y);
|
||||||
|
@ -109,6 +111,7 @@ namespace CSVRender
|
||||||
void onActivate();
|
void onActivate();
|
||||||
|
|
||||||
void initialize();
|
void initialize();
|
||||||
|
void createShape();
|
||||||
|
|
||||||
void rotateHorizontal(double value);
|
void rotateHorizontal(double value);
|
||||||
void rotateVertical(double value);
|
void rotateVertical(double value);
|
||||||
|
@ -121,6 +124,8 @@ namespace CSVRender
|
||||||
bool mInitialized;
|
bool mInitialized;
|
||||||
bool mFast, mLeft, mRight, mUp, mDown, mRollLeft, mRollRight;
|
bool mFast, mLeft, mRight, mUp, mDown, mRollLeft, mRollRight;
|
||||||
osg::Vec3d mCenter;
|
osg::Vec3d mCenter;
|
||||||
|
|
||||||
|
osg::ref_ptr<osg::PositionAttitudeTransform> mCenterNode;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -164,7 +164,7 @@ SceneWidget::SceneWidget(boost::shared_ptr<Resource::ResourceSystem> resourceSys
|
||||||
, mPrevMouseX(0)
|
, mPrevMouseX(0)
|
||||||
, mPrevMouseY(0)
|
, mPrevMouseY(0)
|
||||||
, mFreeCamControl(new FreeCameraController())
|
, mFreeCamControl(new FreeCameraController())
|
||||||
, mOrbitCamControl(new OrbitCameraController())
|
, mOrbitCamControl(new OrbitCameraController(mRootNode))
|
||||||
, mCurrentCamControl(mFreeCamControl.get())
|
, mCurrentCamControl(mFreeCamControl.get())
|
||||||
, mCamPositionSet(false)
|
, mCamPositionSet(false)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue