|
|
@ -19,14 +19,12 @@ namespace CSVRender
|
|
|
|
const osg::Vec3d CameraController::LocalLeft = osg::Vec3d(1, 0, 0);
|
|
|
|
const osg::Vec3d CameraController::LocalLeft = osg::Vec3d(1, 0, 0);
|
|
|
|
const osg::Vec3d CameraController::LocalForward = osg::Vec3d(0, 0, 1);
|
|
|
|
const osg::Vec3d CameraController::LocalForward = osg::Vec3d(0, 0, 1);
|
|
|
|
|
|
|
|
|
|
|
|
const double CameraController::LinearSpeed = 1000;
|
|
|
|
|
|
|
|
const double CameraController::RotationalSpeed = osg::PI / 2.f;
|
|
|
|
|
|
|
|
const double CameraController::SpeedMultiplier = 8;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CameraController::CameraController()
|
|
|
|
CameraController::CameraController()
|
|
|
|
: mActive(false)
|
|
|
|
: mActive(false)
|
|
|
|
, mModified(false)
|
|
|
|
, mModified(false)
|
|
|
|
, mMouseScalar(-1/700.f)
|
|
|
|
, mCameraSensitivity(-1/700.f)
|
|
|
|
|
|
|
|
, mSecondaryMoveMult(50)
|
|
|
|
|
|
|
|
, mWheelMoveMult(8)
|
|
|
|
, mCamera(NULL)
|
|
|
|
, mCamera(NULL)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -50,9 +48,19 @@ namespace CSVRender
|
|
|
|
return mCamera;
|
|
|
|
return mCamera;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
double CameraController::getMouseScalar() const
|
|
|
|
double CameraController::getCameraSensitivity() const
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return mCameraSensitivity;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
double CameraController::getSecondaryMovementMultiplier() const
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return mSecondaryMoveMult;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
double CameraController::getWheelMovementMultiplier() const
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return mMouseScalar;
|
|
|
|
return mWheelMoveMult;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CameraController::setCamera(osg::Camera* camera)
|
|
|
|
void CameraController::setCamera(osg::Camera* camera)
|
|
|
@ -64,9 +72,19 @@ namespace CSVRender
|
|
|
|
onActivate();
|
|
|
|
onActivate();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CameraController::setMouseScalar(double value)
|
|
|
|
void CameraController::setCameraSensitivity(double value)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
mCameraSensitivity = value;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void CameraController::setSecondaryMovementMultiplier(double value)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
mMouseScalar = value;
|
|
|
|
mSecondaryMoveMult = value;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void CameraController::setWheelMovementMultiplier(double value)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
mWheelMoveMult = value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CameraController::setSceneBounds(const osg::BoundingBox& bounds, const osg::Vec3d& up)
|
|
|
|
void CameraController::setSceneBounds(const osg::BoundingBox& bounds, const osg::Vec3d& up)
|
|
|
@ -101,7 +119,40 @@ namespace CSVRender
|
|
|
|
, mRollLeft(false)
|
|
|
|
, mRollLeft(false)
|
|
|
|
, mRollRight(false)
|
|
|
|
, mRollRight(false)
|
|
|
|
, mUp(LocalUp)
|
|
|
|
, mUp(LocalUp)
|
|
|
|
|
|
|
|
, mLinSpeed(1000)
|
|
|
|
|
|
|
|
, mRotSpeed(osg::PI / 2)
|
|
|
|
|
|
|
|
, mSpeedMult(8)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
double FreeCameraController::getLinearSpeed() const
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
return mLinSpeed;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
double FreeCameraController::getRotationalSpeed() const
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return mRotSpeed;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
double FreeCameraController::getSpeedMultiplier() const
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return mSpeedMult;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void FreeCameraController::setLinearSpeed(double value)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
mLinSpeed = value;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void FreeCameraController::setRotationalSpeed(double value)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
mRotSpeed = value;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void FreeCameraController::setSpeedMultiplier(double value)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
mSpeedMult = value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void FreeCameraController::fixUpAxis(const osg::Vec3d& up)
|
|
|
|
void FreeCameraController::fixUpAxis(const osg::Vec3d& up)
|
|
|
@ -171,18 +222,22 @@ namespace CSVRender
|
|
|
|
|
|
|
|
|
|
|
|
if (mode == "p-navi")
|
|
|
|
if (mode == "p-navi")
|
|
|
|
{
|
|
|
|
{
|
|
|
|
yaw(x * getMouseScalar());
|
|
|
|
yaw(x * getCameraSensitivity());
|
|
|
|
pitch(y * getMouseScalar());
|
|
|
|
pitch(y * getCameraSensitivity());
|
|
|
|
setModified();
|
|
|
|
setModified();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (mode == "s-navi")
|
|
|
|
else if (mode == "s-navi")
|
|
|
|
{
|
|
|
|
{
|
|
|
|
translate(LocalLeft * x + LocalUp * -y);
|
|
|
|
osg::Vec3d movement;
|
|
|
|
|
|
|
|
movement += LocalLeft * -x * getSecondaryMovementMultiplier();
|
|
|
|
|
|
|
|
movement += LocalUp * y * getSecondaryMovementMultiplier();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
translate(movement);
|
|
|
|
setModified();
|
|
|
|
setModified();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (mode == "t-navi")
|
|
|
|
else if (mode == "t-navi")
|
|
|
|
{
|
|
|
|
{
|
|
|
|
translate(LocalForward * x * (mFast ? SpeedMultiplier : 1));
|
|
|
|
translate(LocalForward * x * (mFast ? getWheelMovementMultiplier() : 1));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -197,11 +252,11 @@ namespace CSVRender
|
|
|
|
if (!isActive())
|
|
|
|
if (!isActive())
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
double linDist = LinearSpeed * dt;
|
|
|
|
double linDist = mLinSpeed * dt;
|
|
|
|
double rotDist = RotationalSpeed * dt;
|
|
|
|
double rotDist = mRotSpeed * dt;
|
|
|
|
|
|
|
|
|
|
|
|
if (mFast)
|
|
|
|
if (mFast)
|
|
|
|
linDist *= SpeedMultiplier;
|
|
|
|
linDist *= mSpeedMult;
|
|
|
|
|
|
|
|
|
|
|
|
if (mLeft)
|
|
|
|
if (mLeft)
|
|
|
|
translate(LocalLeft * linDist);
|
|
|
|
translate(LocalLeft * linDist);
|
|
|
@ -272,7 +327,29 @@ namespace CSVRender
|
|
|
|
, mRollRight(false)
|
|
|
|
, mRollRight(false)
|
|
|
|
, mCenter(0,0,0)
|
|
|
|
, mCenter(0,0,0)
|
|
|
|
, mDistance(0)
|
|
|
|
, mDistance(0)
|
|
|
|
|
|
|
|
, mOrbitSpeed(osg::PI / 4)
|
|
|
|
|
|
|
|
, mOrbitSpeedMult(4)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
double OrbitCameraController::getOrbitSpeed() const
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return mOrbitSpeed;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
double OrbitCameraController::getOrbitSpeedMultiplier() const
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
return mOrbitSpeedMult;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void OrbitCameraController::setOrbitSpeed(double value)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
mOrbitSpeed = value;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void OrbitCameraController::setOrbitSpeedMultiplier(double value)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
mOrbitSpeedMult = value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool OrbitCameraController::handleKeyEvent(QKeyEvent* event, bool pressed)
|
|
|
|
bool OrbitCameraController::handleKeyEvent(QKeyEvent* event, bool pressed)
|
|
|
@ -336,18 +413,22 @@ namespace CSVRender
|
|
|
|
|
|
|
|
|
|
|
|
if (mode == "p-navi")
|
|
|
|
if (mode == "p-navi")
|
|
|
|
{
|
|
|
|
{
|
|
|
|
rotateHorizontal(x * getMouseScalar());
|
|
|
|
rotateHorizontal(x * getCameraSensitivity());
|
|
|
|
rotateVertical(-y * getMouseScalar());
|
|
|
|
rotateVertical(-y * getCameraSensitivity());
|
|
|
|
setModified();
|
|
|
|
setModified();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (mode == "s-navi")
|
|
|
|
else if (mode == "s-navi")
|
|
|
|
{
|
|
|
|
{
|
|
|
|
translate(LocalLeft * x + LocalUp * -y);
|
|
|
|
osg::Vec3d movement;
|
|
|
|
|
|
|
|
movement += LocalLeft * x * getSecondaryMovementMultiplier();
|
|
|
|
|
|
|
|
movement += LocalUp * -y * getSecondaryMovementMultiplier();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
translate(movement);
|
|
|
|
setModified();
|
|
|
|
setModified();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (mode == "t-navi")
|
|
|
|
else if (mode == "t-navi")
|
|
|
|
{
|
|
|
|
{
|
|
|
|
zoom(-x * (mFast ? SpeedMultiplier : 1));
|
|
|
|
zoom(-x * (mFast ? getWheelMovementMultiplier() : 1));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -365,10 +446,10 @@ namespace CSVRender
|
|
|
|
if (!mInitialized)
|
|
|
|
if (!mInitialized)
|
|
|
|
initialize();
|
|
|
|
initialize();
|
|
|
|
|
|
|
|
|
|
|
|
double rotDist = RotationalSpeed * dt;
|
|
|
|
double rotDist = mOrbitSpeed * dt;
|
|
|
|
|
|
|
|
|
|
|
|
if (mFast)
|
|
|
|
if (mFast)
|
|
|
|
rotDist *= SpeedMultiplier;
|
|
|
|
rotDist *= mOrbitSpeedMult;
|
|
|
|
|
|
|
|
|
|
|
|
if (mLeft)
|
|
|
|
if (mLeft)
|
|
|
|
rotateHorizontal(-rotDist);
|
|
|
|
rotateHorizontal(-rotDist);
|
|
|
|