Commit 642265e6 by Kai Westerkamp

camera smooth

parent 8cad1c31
......@@ -35,6 +35,9 @@ Camera::~Camera()
void Camera::move(glm::vec3 relative)
{
if (length(relative) < 0.001f) return;
relative = normalize(relative);
glm::vec3 right = cross(direction, up);
vec3 uplocal = cross(right, direction);
......
......@@ -15,9 +15,14 @@ bool init(int argc, char* argv[]) {
glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA);
glutInitWindowSize(width,height);
glutCreateWindow("Kinect VR Point Cloud");
glutKeyboardFunc(keyPressed);
glutIgnoreKeyRepeat(1);
glutKeyboardUpFunc(keyReleased);
glutMouseFunc(mouseButton);
glutMotionFunc(mouseMove);
glutDisplayFunc(draw);
glutIdleFunc(draw);
glewInit();
......
......@@ -56,7 +56,7 @@ ICoordinateMapper* mapper; // Converts between depth, color, and 3d coor
SteamTracking* steamTracking = nullptr;
glm::mat4x4* currentControlerPos = nullptr;
Camera mainCam;
glm::vec3 cameraMove;
static bool writeFile = false;
static bool captureFrame = false;
......@@ -277,6 +277,9 @@ void drawElementArray(drawData data, GLenum mode) {
void mainRenderLoop() {
steamTracking->processEvents();
mainCam.move(cameraMove);
//get controler pos
delete currentControlerPos;
currentControlerPos = steamTracking->getTransformationForDevice(1);
......@@ -351,22 +354,22 @@ void keyPressed(unsigned char key, int x, int y)
writeFile = true;
break;
case 'w':
mainCam.move(glm::vec3(1.0f,0.0f,0.0f));
cameraMove += (glm::vec3(1.0f,0.0f,0.0f));
break;
case 's':
mainCam.move(glm::vec3(-1.0f, 0.0f, 0.0f));
cameraMove += (glm::vec3(-1.0f, 0.0f, 0.0f));
break;
case 'a':
mainCam.move(glm::vec3(0.0f, 0.0f, -1.0f));
cameraMove += (glm::vec3(0.0f, 0.0f, -1.0f));
break;
case 'd':
mainCam.move(glm::vec3(0.0f, 0.0f, 1.0f));
cameraMove += (glm::vec3(0.0f, 0.0f, 1.0f));
break;
case 'q':
mainCam.move(glm::vec3(0.0f, 1.0f, 0.0f));
cameraMove += (glm::vec3(0.0f, 1.0f, 0.0f));
break;
case 'e':
mainCam.move(glm::vec3(0.0f, -1.0f, 0.0f));
cameraMove += (glm::vec3(0.0f, -1.0f, 0.0f));
break;
case 27: // Escape key
exit(0);
......@@ -379,6 +382,32 @@ void keyPressed(unsigned char key, int x, int y)
instantly */
}
void keyReleased(unsigned char key, int x, int y) {
switch (key) {
case 'w':
cameraMove -= (glm::vec3(1.0f, 0.0f, 0.0f));
break;
case 's':
cameraMove -= (glm::vec3(-1.0f, 0.0f, 0.0f));
break;
case 'a':
cameraMove -= (glm::vec3(0.0f, 0.0f, -1.0f));
break;
case 'd':
cameraMove -= (glm::vec3(0.0f, 0.0f, 1.0f));
break;
case 'q':
cameraMove -= (glm::vec3(0.0f, 1.0f, 0.0f));
break;
case 'e':
cameraMove -= (glm::vec3(0.0f, -1.0f, 0.0f));
break;
default:
break;
}
}
void mouseButton(int button, int state, int x, int y) {
lastX = x;
lastY = y;
......@@ -402,6 +431,7 @@ void captureNextFrame(vr::VREvent_t event)
int main(int argc, char* argv[]) {
cameraMove = glm::vec3(0.0f, 0.0f, 0.0f);
std::cout << "Starting Kinect VR Point Cloud creator\n";
if (!init(argc, argv)) return 1;
if (!initKinect()) return 1;
......
......@@ -8,6 +8,7 @@ const int colorheight = 1080;
void mainRenderLoop();
void keyPressed(unsigned char key, int x, int y);
void keyReleased(unsigned char key, int x, int y);
void mouseButton(int button, int state, int x, int y);
void mouseMove(int x, int y);
......
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