Commit ebb127e3 authored by Sreekanth Arikatla's avatar Sreekanth Arikatla
Browse files

BUG: Fix camera rotation and translational offset

Separates camera rotation and translational offset with that of the device
parent 50aec694
......@@ -28,7 +28,7 @@
namespace imstk
{
void
void
CameraController::setOffsetUsingCurrentCameraPose()
{
auto pos = m_camera.getPosition();
......@@ -59,10 +59,38 @@ CameraController::runModule()
return;
}
// Apply Offsets
p = p + m_cameraTranslationOffset;
r *= m_cameraRotationOffset;
// Set camera info
m_camera.setPosition(p);
m_camera.setFocalPoint((r*FORWARD_VECTOR) + p);
m_camera.setViewUp(r*UP_VECTOR);
}
void
CameraController::setCameraRotationOffset(const Quatd& r)
{
m_cameraRotationOffset = r;
}
void
CameraController::setCameraTranslationOffset(const Vec3d& t)
{
m_cameraTranslationOffset = t;
}
const imstk::Vec3d&
CameraController::getCameraTranslationOffset() const
{
return m_cameraTranslationOffset;
}
const imstk::Quatd&
CameraController::getCameraRotationOffset() const
{
return m_cameraRotationOffset;
}
} // imstk
......@@ -57,7 +57,27 @@ public:
///
/// \brief
///
void setOffsetUsingCurrentCameraPose();
void setOffsetUsingCurrentCameraPose();
///
/// \brief
///
void setCameraRotationOffset(const Quatd& r);
///
/// \brief
///
void setCameraTranslationOffset(const Vec3d& t);
///
/// \brief
///
const Vec3d& getCameraTranslationOffset() const;
///
/// \brief
///
const Quatd& getCameraRotationOffset() const;
protected:
///
......@@ -77,6 +97,9 @@ protected:
Camera& m_camera; ///< Camera controlled by the external device
Vec3d m_cameraTranslationOffset = WORLD_ORIGIN; ///< Translation offset for the camera over tracking data
Quatd m_cameraRotationOffset = Quatd::Identity(); ///< Rotation offset for the camera over tracking data
};
} // imstk
......
......@@ -43,7 +43,7 @@ using namespace imstk;
const unsigned int scanarioNumber = 1; //possible values: 1, 2, 3, 4
// Camera settings
const double cameraAngulation = 0.0; //possible values: 0, 30, 45 deg
const double cameraAngulation = PI_4; //possible values: 0, 30, 45 deg
const double cameraViewAngle = 80.0; //possible values: 80 deg
const double cameraZoomFactor = 1.0; //possible values: TBD
......@@ -103,7 +103,7 @@ void createScenario1()
// Set camera controller
cam->setupController(client0, cameraControllerScaling);
cam->getController()->setRotationOffset(Quatd(Eigen::AngleAxisd(cameraAngulation, Vec3d::UnitY())));
cam->getController()->setCameraRotationOffset(Quatd(Eigen::AngleAxisd(cameraAngulation, Vec3d::UnitY())));
//cam->getController()->setInversionFlags(imstk::CameraController::InvertFlag::rotY | imstk::CameraController::InvertFlag::rotZ);
sdk->addModule(server);
......@@ -159,7 +159,7 @@ void createScenario2()
// Set camera controller
cam->setupController(client0, cameraControllerScaling);
cam->getController()->setRotationOffset(Quatd(Eigen::AngleAxisd(cameraAngulation, Vec3d::UnitY())));
cam->getController()->setCameraRotationOffset(Quatd(Eigen::AngleAxisd(cameraAngulation, Vec3d::UnitY())));
//cam->getController()->setInversionFlags(imstk::CameraController::InvertFlag::rotY | imstk::CameraController::InvertFlag::rotZ);
#ifdef ADD_TOOL_CONTROLLER
......@@ -238,7 +238,7 @@ void createScenario3()
// Set camera controller
cam->setupController(client0, cameraControllerScaling);
cam->getController()->setRotationOffset(Quatd(Eigen::AngleAxisd(cameraAngulation, Vec3d::UnitY())));
cam->getController()->setCameraRotationOffset(Quatd(Eigen::AngleAxisd(cameraAngulation, Vec3d::UnitY())));
//cam->getController()->setInversionFlags(imstk::CameraController::InvertFlag::rotY | imstk::CameraController::InvertFlag::rotZ);
#ifdef ADD_TOOL_CONTROLLER
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment