From d26a07cb95003e1be2a214a4b23e9eeb7eb35ffd Mon Sep 17 00:00:00 2001
From: Nicolas Pope <nwpope@utu.fi>
Date: Mon, 10 Jun 2019 11:33:21 +0300
Subject: [PATCH] Remove recon disp, fix key controls

---
 applications/gui/src/main.cpp         | 18 ++++++++++++------
 applications/reconstruct/src/main.cpp | 15 +++++++--------
 components/rgbd-sources/src/net.cpp   |  2 +-
 3 files changed, 20 insertions(+), 15 deletions(-)

diff --git a/applications/gui/src/main.cpp b/applications/gui/src/main.cpp
index 47c1aa7c5..be2ac713a 100644
--- a/applications/gui/src/main.cpp
+++ b/applications/gui/src/main.cpp
@@ -128,6 +128,7 @@ class FTLApplication : public nanogui::Screen {
 		lookPoint_ = Eigen::Vector3f(0.0f,0.0f,-4.0f);
 		lerpSpeed_ = 0.4f;
 		depth_ = false;
+		ftime_ = (float)glfwGetTime();
 
 		mShader.init("RGBDShader", defaultImageViewVertexShader,
                  defaultImageViewFragmentShader);
@@ -175,14 +176,14 @@ class FTLApplication : public nanogui::Screen {
 		if (Screen::keyboardEvent(key, scancode, action, modifiers)) {
 			return true;
 		} else {
-			LOG(INFO) << "Key press" << key << " - " << action;
-			if (key == 81 || key == 83) {
+			LOG(INFO) << "Key press " << key << " - " << action;
+			if (key == 263 || key == 262) {
 				// TODO Should rotate around lookAt object, but requires correct depth
-				Eigen::Quaternion<float> q;  q = Eigen::AngleAxis<float>((key == 81) ? 0.01f : -0.01f, up_);
+				Eigen::Quaternion<float> q;  q = Eigen::AngleAxis<float>((key == 262) ? 0.01f : -0.01f, up_);
 				eye_ = (q * (eye_ - centre_)) + centre_;
 				return true;
-			} else if (key == 84 || key == 82) {
-				float scalar = (key == 84) ? 0.99f : 1.01f;
+			} else if (key == 264 || key == 265) {
+				float scalar = (key == 264) ? 0.99f : 1.01f;
 				eye_ = ((eye_ - centre_) * scalar) + centre_;
 				return true;
 			}
@@ -196,9 +197,13 @@ class FTLApplication : public nanogui::Screen {
 		auto src_ = swindow_->getSource();
 		Vector2f imageSize(0, 0);
 
+		float now = (float)glfwGetTime();
+		float delta = now - ftime_;
+		ftime_ = now;
+
 		if (src_) {
 			cv::Mat rgb, depth;
-			centre_ += (lookPoint_ - centre_) * (lerpSpeed_ * 0.1f);
+			centre_ += (lookPoint_ - centre_) * (lerpSpeed_ * delta);
 			Eigen::Matrix4f viewPose = lookAt<float>(eye_,centre_,up_).inverse();
 
 			src_->setPose(viewPose);
@@ -267,6 +272,7 @@ class FTLApplication : public nanogui::Screen {
 	Eigen::Vector3f lookPoint_;
 	float lerpSpeed_;
 	bool depth_;
+	float ftime_;
 };
 
 int main(int argc, char **argv) {
diff --git a/applications/reconstruct/src/main.cpp b/applications/reconstruct/src/main.cpp
index 72f0673ab..003e8cc48 100644
--- a/applications/reconstruct/src/main.cpp
+++ b/applications/reconstruct/src/main.cpp
@@ -156,7 +156,7 @@ static void run(ftl::Configurable *root) {
 	LOG(INFO) << "Using sources:";
 	for (auto &input : inputs) { LOG(INFO) << "    " + (string) input.source->getURI(); }
 	
-	ftl::rgbd::Display *display = ftl::create<ftl::rgbd::Display>(root, "display");
+	//ftl::rgbd::Display *display = ftl::create<ftl::rgbd::Display>(root, "display");
 	ftl::rgbd::Source *virt = ftl::create<ftl::rgbd::Source>(root, "virtual", net);
 
 	auto virtimpl = new ftl::rgbd::VirtualSource(virt);
@@ -164,7 +164,7 @@ static void run(ftl::Configurable *root) {
 
 	ftl::voxhash::SceneRep *scene = ftl::create<ftl::voxhash::SceneRep>(root, "voxelhash");
 	virtimpl->setScene(scene);
-	display->setSource(virt);
+	//display->setSource(virt);
 
 	ftl::rgbd::Streamer *stream = ftl::create<ftl::rgbd::Streamer>(root, "stream", net);
 	stream->add(virt);
@@ -177,12 +177,12 @@ static void run(ftl::Configurable *root) {
 	bool paused = false;
 
 	// Keyboard camera controls
-	display->onKey([&paused](int key) {
-		if (key == 32) paused = !paused;
-	});
+	//display->onKey([&paused](int key) {
+	//	if (key == 32) paused = !paused;
+	//});
 
 	int active = inputs.size();
-	while (ftl::running && display->active()) {
+	while (ftl::running) {
 		if (active == 0) {
 			LOG(INFO) << "Waiting for sources...";
 			sleep_for(milliseconds(1000));
@@ -203,7 +203,6 @@ static void run(ftl::Configurable *root) {
 					auto &cam = inputs[i];
 					auto in = inputs[i].source;
 					if (cam.params.m_imageWidth == 0) {
-						LOG(INFO) << "SETTING UP CAM PARAMS: " << in->parameters().fx;
 						cam.params.fx = in->parameters().fx;
 						cam.params.fy = in->parameters().fy;
 						cam.params.mx = -in->parameters().cx;
@@ -246,7 +245,7 @@ static void run(ftl::Configurable *root) {
 		frameCount++;
 
 		stream->poll();
-		display->update();
+		//display->update();
 		//sleep_for(milliseconds(10));
 	}
 }
diff --git a/components/rgbd-sources/src/net.cpp b/components/rgbd-sources/src/net.cpp
index 96b6d762a..a52bfea4e 100644
--- a/components/rgbd-sources/src/net.cpp
+++ b/components/rgbd-sources/src/net.cpp
@@ -89,7 +89,7 @@ void NetSource::setPose(const Eigen::Matrix4f &pose) {
 	} catch (...) {
 
 	}
-	Source::setPose(pose);
+	//Source::setPose(pose);
 }
 
 void NetSource::_updateURI() {
-- 
GitLab