Skip to content
Snippets Groups Projects
Commit 12282b68 authored by Nicolas Pope's avatar Nicolas Pope
Browse files

WIP More attempts at eye poses

parent e8fe5259
No related branches found
No related tags found
1 merge request!110Feature/121/vr
Pipeline #12514 passed
......@@ -271,7 +271,17 @@ const GLTexture &ftl::gui::Camera::captureFrame() {
{
auto pose = ConvertSteamVRMatrixToMatrix4( rTrackedDevicePose_[vr::k_unTrackedDeviceIndex_Hmd].mDeviceToAbsoluteTracking );
pose.inverse();
if (src_->hasCapabilities(ftl::rgbd::kCapMovable)) src_->setPose(pose);
// Lerp the Eye
eye_[0] += (neye_[0] - eye_[0]) * lerpSpeed_ * delta_;
eye_[1] += (neye_[1] - eye_[1]) * lerpSpeed_ * delta_;
eye_[2] += (neye_[2] - eye_[2]) * lerpSpeed_ * delta_;
Eigen::Translation3d trans(eye_);
Eigen::Affine3d t(trans);
Eigen::Matrix4d viewPose = t.matrix() * pose;
if (src_->hasCapabilities(ftl::rgbd::kCapMovable)) src_->setPose(viewPose);
} else {
LOG(ERROR) << "No VR Pose";
}
......
......@@ -37,7 +37,7 @@ namespace {
uv = vertex;
vec2 scaledVertex = (vertex * scaleFactor) + position;
gl_Position = vec4(2.0*scaledVertex.x - 1.0,
1.0 - 2.0*scaledVertex.y,
2.0*scaledVertex.y - 1.0,
0.0, 1.0);
})";
......@@ -365,6 +365,7 @@ void ftl::gui::Screen::draw(NVGcontext *ctx) {
if (hasVR() && imageSize[0] > 0 && camera_->getLeft().isValid() && camera_->getRight().isValid()) {
vr::Texture_t leftEyeTexture = {(void*)(uintptr_t)leftEye_, vr::TextureType_OpenGL, vr::ColorSpace_Gamma };
vr::VRCompositor()->Submit(vr::Eye_Left, &leftEyeTexture );
glBindTexture(GL_TEXTURE_2D, rightEye_);
vr::Texture_t rightEyeTexture = {(void*)(uintptr_t)rightEye_, vr::TextureType_OpenGL, vr::ColorSpace_Gamma };
vr::VRCompositor()->Submit(vr::Eye_Right, &rightEyeTexture );
}
......
......@@ -13,6 +13,21 @@ Splatter::~Splatter() {
}
static Eigen::Matrix4f adjustPose(const Eigen::Matrix4f &pose, float baseline) {
Eigen::Affine3f transform(Eigen::Translation3f(baseline,0.0f,0.0f));
Eigen::Matrix4f matrix = pose;
Eigen::Matrix4f rmat = pose;
rmat(0,3) = 0.0f;
rmat(1,3) = 0.0f;
rmat(2,3) = 0.0f;
Eigen::Matrix4f tmat = transform.matrix();
tmat(0,0) = 0.0f;
tmat(1,1) = 0.0f;
tmat(2,2) = 0.0f;
tmat(3,3) = 0.0f;
return (tmat * pose) + pose;
}
void Splatter::render(ftl::rgbd::Source *src, cudaStream_t stream) {
if (!src->isReady()) return;
......@@ -37,8 +52,14 @@ void Splatter::render(ftl::rgbd::Source *src, cudaStream_t stream) {
// Parameters object to pass to CUDA describing the camera
SplatParams params;
params.m_flags = 0;
params.m_viewMatrix = MatrixConversion::toCUDA(src->getPose().cast<float>().inverse());
params.m_viewMatrixInverse = MatrixConversion::toCUDA(src->getPose().cast<float>());
// Adjust pose to left eye position
Eigen::Matrix4f matrix = adjustPose(src->getPose().cast<float>(), -camera.baseline/2.0f);
params.m_viewMatrix = MatrixConversion::toCUDA(matrix.inverse());
params.m_viewMatrixInverse = MatrixConversion::toCUDA(matrix);
//params.m_viewMatrix = MatrixConversion::toCUDA(src->getPose().cast<float>().inverse());
//params.m_viewMatrixInverse = MatrixConversion::toCUDA(src->getPose().cast<float>());
params.voxelSize = scene_->getHashParams().m_virtualVoxelSize;
params.camera.flags = 0;
params.camera.fx = camera.fx;
......@@ -82,13 +103,7 @@ void Splatter::render(ftl::rgbd::Source *src, cudaStream_t stream) {
src->writeFrames(colour1_, depth2_, stream);
} else if (src->getChannel() == ftl::rgbd::kChanRight) {
// Adjust pose to right eye position
Eigen::Affine3f transform(Eigen::Translation3f(camera.baseline,0.0f,0.0f));
Eigen::Matrix4f tmat = transform.matrix();
Eigen::Matrix4f rmat = src->getPose().cast<float>();
rmat(3,0) = 0.0f;
rmat(3,1) = 0.0f;
rmat(3,2) = 0.0f;
Eigen::Matrix4f matrix = (rmat * transform.matrix()) + src->getPose().cast<float>();
Eigen::Matrix4f matrix = adjustPose(src->getPose().cast<float>(), camera.baseline/2.0f);
params.m_viewMatrix = MatrixConversion::toCUDA(matrix.inverse());
params.m_viewMatrixInverse = MatrixConversion::toCUDA(matrix);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment