diff --git a/TextureTest.cu b/TextureTest.cu index c3795c8..b76e1e5 100644 --- a/TextureTest.cu +++ b/TextureTest.cu @@ -13,6 +13,7 @@ #define VERTICAL 1 #define HORIZONTAL 1 stim::camera cam; + stim::camera Parker; GLuint texID; float a = -1.0; float b = 1.0; @@ -39,6 +40,7 @@ stim::vec up; stim::vec d; static bool button1 = FALSE; + static bool button_shift = FALSE; static float degtorad = 360/(2*M_PI); static GLfloat adjustTex = 1.0/426.0; static GLfloat adjustDrw = 2.0/426.0; @@ -76,7 +78,7 @@ glInit() glLoadIdentity(); glOrtho(-5.0, 2.0,-5.0, 2.0, -0.0, 1000.0); glMatrixMode(GL_MODELVIEW); - spidey = stim::gl_spider(0.5, 0.5, 0.5, -0.1, -0.1, -0.1, 0.5, 0.5); + spidey = stim::gl_spider(0.5, 0.5, 0.5, -0.1, -0.1, -0.1, 0.1, 0.1); CHECK_OPENGL_ERROR } @@ -303,29 +305,24 @@ renderScene() void MouseButton(int button, int state, int x, int y) { + if (button == GLUT_LEFT_BUTTON) { button1 = (state == GLUT_DOWN) ? TRUE : FALSE; + button_shift = glutGetModifiers(); prevmousePos[0] = (float)x; prevmousePos[1] = (float)y; } if (button == GLUT_RIGHT_BUTTON) { - float clicked[2] = {(float) x*1.0/ (float) size[0], - (float) y*1.0/ (float) size[1]}; - std::cout << "clicked at " << clicked[0] << ":" << clicked[1] << std::endl; - if (clicked[0] > vertexDrw[0][0] && clicked[1] > vertexDrw[0][1]) - if(clicked[0] < vertexDrw[2][0] && clicked[1] < vertexDrw[2][1]) - { - std::cout << (float)x/(float)size[0]*3 << " " - << (float)y/(float)size[1]*3 << std::endl; - } + std::cout << spidey.getPosition() << std::endl + << spidey.getDirection() << std::endl; } } void MouseMotion(int x, int y) { - if(button1) + if(button1 && !button_shift) { mousePos[0] = (prevmousePos[0] - (float) x)*0.0005; mousePos[1] = ((float)y - prevmousePos[1])*0.0005; @@ -333,6 +330,20 @@ void MouseMotion(int x, int y) prevmousePos[1] = (float)y; cam.OrbitFocus(mousePos[0]*degtorad, mousePos[1]*degtorad); } + if(button1 && button_shift) + { + mousePos[0] = (prevmousePos[0] - (float) x)*0.00001; + mousePos[1] = ((float)y - prevmousePos[1])*0.00001; + prevmousePos[0] = (float)x; + prevmousePos[1] = (float)y; + Parker.setPosition(spidey.getPosition()); + Parker.LookAt(spidey.getDirection()); + Parker.Pan(mousePos[0]*degtorad); + Parker.Tilt(mousePos[1]*degtorad); + spidey.setDirection(Parker.getLookAt()); + spidey.Update(); + std::cout << Parker.getLookAt() << std::endl; + } } void @@ -354,6 +365,13 @@ switch(key) { else{ oriDrw[2] = oriDrw[2] + adjustDrw; } + if (glutGetModifiers() == 1) + { + stim::vec temp = spidey.getPosition(); + temp[1] += 0.0001; + spidey.setPosition(temp); + spidey.Update(); + } break; case GLUT_KEY_DOWN: oriTex[2] = oriTex[2]-adjustTex; @@ -363,6 +381,13 @@ switch(key) { else{ oriDrw[2] = oriDrw[2] - adjustDrw; } + if (glutGetModifiers() == 1) + { + stim::vec temp = spidey.getPosition(); + temp[1] -= 0.0001; + spidey.setPosition(temp); + spidey.Update(); + } break; case GLUT_KEY_LEFT: oriTex[1] = oriTex[1]+adjustTex; @@ -372,6 +397,13 @@ switch(key) { else{ oriDrw[1] = oriDrw[1] + adjustDrw; } + if (glutGetModifiers() == 1) + { + stim::vec temp = spidey.getPosition(); + temp[0] += 0.0001; + spidey.setPosition(temp); + spidey.Update(); + } break; case GLUT_KEY_RIGHT: oriTex[1] = oriTex[1]-adjustTex; @@ -382,6 +414,13 @@ switch(key) { oriDrw[1] = oriDrw[1] - adjustDrw; } break; + if (glutGetModifiers() == 1) + { + stim::vec temp = spidey.getPosition(); + temp[0] -= 0.0001; + spidey.setPosition(temp); + spidey.Update(); + } } glutPostRedisplay(); } diff --git a/stim b/stim index 2dbd88b..879321c 160000 --- a/stim +++ b/stim @@ -1 +1 @@ -Subproject commit 2dbd88bd02065df7f76f7bf9c3b5eca09891fbc6 +Subproject commit 879321c4a5e974144996aae02c44c6583e4a2fbd -- libgit2 0.21.4