Commit 9db036d3 authored by Alexis Girault's avatar Alexis Girault
Browse files

BUG: Correct orientation offset for cam controller

parent 8f889e12
......@@ -85,7 +85,7 @@ Camera::setViewUp(const double& x,
const double& y,
const double& z)
{
m_viewUp = Vec3d(x,y,z);
m_viewUp = Vec3d(x,y,z).normalized();
}
const double& Camera::getViewAngle() const
......@@ -115,8 +115,15 @@ Camera::setupController(std::shared_ptr<DeviceClient> deviceClient, double scali
m_cameraController->setDeviceClient(deviceClient);
m_cameraController->setTranslationScaling(scaling);
m_cameraController->setTranslationOffset(m_position);
//m_cameraController->setRotationOffset(m_orientation);
//m_cameraController->setLoopDelay(1000);
auto viewNormal = (m_position - m_focalPoint).normalized();
auto viewSide = m_viewUp.cross(viewNormal).normalized();
m_viewUp = viewNormal.cross(viewSide);
Mat3d rot;
rot.col(0) = viewSide;
rot.col(1) = m_viewUp;
rot.col(2) = viewNormal;
m_cameraController->setRotationOffset(Quatd(rot));
return m_cameraController;
}
......
......@@ -94,14 +94,11 @@ void testDevices()
// Update Camera position
auto cam = scene->getCamera();
cam->setPosition(8*imstk::RIGHT_VECTOR);
//LOG(INFO) << cam->getPosition();
cam->setPosition(imstk::Vec3d(8,-8,8));
// Set camera controller
auto controller = cam->setupController(client, 100);
//LOG(INFO) << controller->getTranslationOffset(); // should be the same than initial cam position
controller->setRotationOffset(imstk::Quatd(imstk::Rotd(imstk::PI_2, imstk::UP_VECTOR)));
//LOG(INFO) << controller->getRotationOffset().toRotationMatrix();
//controller->setInversionFlags( (imstk::CameraController::InvertFlag::transX | imstk::CameraController::InvertFlag::transY) );
// Run
......
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