- Timestamp:
- Jun 25, 2017, 7:15:12 PM (7 years ago)
- Branches:
- feature/imgui-sdl, master, points-test
- Children:
- fe70cd3
- Parents:
- 8a6d19d
- Location:
- common
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
common/controls-new.cpp
r8a6d19d r92bc4fe 2 2 #include <GLFW/glfw3.h> 3 3 extern GLFWwindow* window; // The "extern" keyword here is to access the variable "window" declared in tutorialXXX.cpp. This is a hack to keep the tutorials simple. Please avoid this. 4 5 #include <iostream> 6 7 using namespace std; 4 8 5 9 // Include GLM … … 22 26 23 27 // Initial position : on +Z 24 glm::vec3 position = glm::vec3(4, 3,-3); //glm::vec3( 0, 0, 5 );28 glm::vec3 position = glm::vec3(4,6,-3); //glm::vec3( 0, 0, 5 ); 25 29 // Initial horizontal angle : toward -Z 26 30 float horizontalAngleBase = 3.14f * 3.0f / 2.0f; // 3.14f; … … 36 40 37 41 38 void computeMatricesFromInputs( ){42 void computeMatricesFromInputs(int windowWidth, int windowHeight) { 39 43 40 44 // glfwGetTime is called only once, the first time this function is called … … 52 56 // The call has no effect the first several times it's called 53 57 if (centeredCount < 100) { 54 glfwSetCursorPos(window, 1024/2, 768/2);58 glfwSetCursorPos(window, windowWidth/2, windowHeight/2); 55 59 centeredCount++; 56 60 } … … 58 62 // Compute new orientation 59 63 /* STOP ROTATION FOR NOW */ 60 float horizontalAngle = horizontalAngleBase + mouseSpeed * float( 1024/2 - xpos );61 // verticalAngle += mouseSpeed * float( 768/2 - ypos );64 float horizontalAngle = horizontalAngleBase + mouseSpeed * float(windowWidth/2 - xpos ); 65 // verticalAngle += mouseSpeed * float( windowHeight/2 - ypos ); 62 66 63 67 // Direction : Spherical coordinates to Cartesian coordinates conversion … … 67 71 cos(verticalAngle) * cos(horizontalAngle) 68 72 ); 73 glm::vec3 lookDirection( 74 0.0f, 75 -3.0f, 76 0.0f 77 ); 78 lookDirection = lookDirection + 3.0f * direction; 69 79 70 80 // Right vector … … 105 115 // and looks here : at the same position, plus "direction" 106 116 // position+glm::vec3(-4,0,0), // position+glm::vec3(-4,-3,3), 107 position+ direction,117 position+lookDirection, 108 118 glm::vec3(0,1,0) //up // Head is up (set to 0,-1,0 to look upside-down) 109 119 ); -
common/controls.cpp
r8a6d19d r92bc4fe 35 35 36 36 37 void computeMatricesFromInputs( ){37 void computeMatricesFromInputs(int windowWidth, int windowHeight) { 38 38 39 39 // glfwGetTime is called only once, the first time this function is called -
common/controls.hpp
r8a6d19d r92bc4fe 2 2 #define CONTROLS_HPP 3 3 4 void computeMatricesFromInputs( );4 void computeMatricesFromInputs(int windowWidth, int windowHeight); 5 5 glm::mat4 getViewMatrix(); 6 6 glm::mat4 getProjectionMatrix();
Note:
See TracChangeset
for help on using the changeset viewer.