Add more customization.

openmw-39
Aesylwinn 9 years ago
parent 3a676fc456
commit 3c83128abc

@ -19,14 +19,12 @@ namespace CSVRender
const osg::Vec3d CameraController::LocalLeft = osg::Vec3d(1, 0, 0);
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()
: mActive(false)
, mModified(false)
, mMouseScalar(-1/700.f)
, mCameraSensitivity(-1/700.f)
, mSecondaryMoveMult(50)
, mWheelMoveMult(8)
, mCamera(NULL)
{
}
@ -50,9 +48,19 @@ namespace CSVRender
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)
@ -64,9 +72,19 @@ namespace CSVRender
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)
@ -101,7 +119,40 @@ namespace CSVRender
, mRollLeft(false)
, mRollRight(false)
, 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)
@ -171,18 +222,22 @@ namespace CSVRender
if (mode == "p-navi")
{
yaw(x * getMouseScalar());
pitch(y * getMouseScalar());
yaw(x * getCameraSensitivity());
pitch(y * getCameraSensitivity());
setModified();
}
else if (mode == "s-navi")
{
translate(LocalLeft * x + LocalUp * -y);
osg::Vec3d movement;
movement += LocalLeft * -x * getSecondaryMovementMultiplier();
movement += LocalUp * y * getSecondaryMovementMultiplier();
translate(movement);
setModified();
}
else if (mode == "t-navi")
{
translate(LocalForward * x * (mFast ? SpeedMultiplier : 1));
translate(LocalForward * x * (mFast ? getWheelMovementMultiplier() : 1));
}
else
{
@ -197,11 +252,11 @@ namespace CSVRender
if (!isActive())
return;
double linDist = LinearSpeed * dt;
double rotDist = RotationalSpeed * dt;
double linDist = mLinSpeed * dt;
double rotDist = mRotSpeed * dt;
if (mFast)
linDist *= SpeedMultiplier;
linDist *= mSpeedMult;
if (mLeft)
translate(LocalLeft * linDist);
@ -272,7 +327,29 @@ namespace CSVRender
, mRollRight(false)
, mCenter(0,0,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)
@ -336,18 +413,22 @@ namespace CSVRender
if (mode == "p-navi")
{
rotateHorizontal(x * getMouseScalar());
rotateVertical(-y * getMouseScalar());
rotateHorizontal(x * getCameraSensitivity());
rotateVertical(-y * getCameraSensitivity());
setModified();
}
else if (mode == "s-navi")
{
translate(LocalLeft * x + LocalUp * -y);
osg::Vec3d movement;
movement += LocalLeft * x * getSecondaryMovementMultiplier();
movement += LocalUp * -y * getSecondaryMovementMultiplier();
translate(movement);
setModified();
}
else if (mode == "t-navi")
{
zoom(-x * (mFast ? SpeedMultiplier : 1));
zoom(-x * (mFast ? getWheelMovementMultiplier() : 1));
}
else
{
@ -365,10 +446,10 @@ namespace CSVRender
if (!mInitialized)
initialize();
double rotDist = RotationalSpeed * dt;
double rotDist = mOrbitSpeed * dt;
if (mFast)
rotDist *= SpeedMultiplier;
rotDist *= mOrbitSpeedMult;
if (mLeft)
rotateHorizontal(-rotDist);

@ -26,10 +26,6 @@ namespace CSVRender
static const osg::Vec3d LocalLeft;
static const osg::Vec3d LocalForward;
static const double LinearSpeed;
static const double RotationalSpeed;
static const double SpeedMultiplier;
CameraController();
virtual ~CameraController();
@ -37,10 +33,14 @@ namespace CSVRender
bool isModified() const;
osg::Camera* getCamera() const;
double getMouseScalar() const;
double getCameraSensitivity() const;
double getSecondaryMovementMultiplier() const;
double getWheelMovementMultiplier() const;
void setCamera(osg::Camera*);
void setMouseScalar(double value);
void setCameraSensitivity(double value);
void setSecondaryMovementMultiplier(double value);
void setWheelMovementMultiplier(double value);
// moves the camera to an intelligent position
void setSceneBounds(const osg::BoundingBox& bounds, const osg::Vec3d& up);
@ -60,7 +60,9 @@ namespace CSVRender
private:
bool mActive, mModified;
double mMouseScalar;
double mCameraSensitivity;
double mSecondaryMoveMult;
double mWheelMoveMult;
osg::Camera* mCamera;
};
@ -71,6 +73,14 @@ namespace CSVRender
FreeCameraController();
double getLinearSpeed() const;
double getRotationalSpeed() const;
double getSpeedMultiplier() const;
void setLinearSpeed(double value);
void setRotationalSpeed(double value);
void setSpeedMultiplier(double value);
void fixUpAxis(const osg::Vec3d& up);
void unfixUpAxis();
@ -91,6 +101,10 @@ namespace CSVRender
bool mLockUpright;
bool mFast, mLeft, mRight, mForward, mBackward, mRollLeft, mRollRight;
osg::Vec3d mUp;
double mLinSpeed;
double mRotSpeed;
double mSpeedMult;
};
class OrbitCameraController : public CameraController
@ -99,6 +113,12 @@ namespace CSVRender
OrbitCameraController();
double getOrbitSpeed() const;
double getOrbitSpeedMultiplier() const;
void setOrbitSpeed(double value);
void setOrbitSpeedMultiplier(double value);
bool handleKeyEvent(QKeyEvent* event, bool pressed);
bool handleMouseMoveEvent(std::string mode, int x, int y);
@ -120,6 +140,9 @@ namespace CSVRender
bool mFast, mLeft, mRight, mUp, mDown, mRollLeft, mRollRight;
osg::Vec3d mCenter;
double mDistance;
double mOrbitSpeed;
double mOrbitSpeedMult;
};
}

Loading…
Cancel
Save