Merge branch 'master' of https://git.etud.insa-toulouse.fr/serviere/EnginPasTangible
This commit is contained in:
commit
833d7b6e7b
2 changed files with 15 additions and 10 deletions
21
main.c
21
main.c
|
@ -30,6 +30,10 @@ unsigned int VAO;
|
||||||
|
|
||||||
float currentTime, deltaTime, lastFrame,startTime;
|
float currentTime, deltaTime, lastFrame,startTime;
|
||||||
float mousePosX,mousePosY,camPosX,camPosY,camPosZ,camDirX,camDirY,camDirZ;
|
float mousePosX,mousePosY,camPosX,camPosY,camPosZ,camDirX,camDirY,camDirZ;
|
||||||
|
//283=3.14/2 * 180
|
||||||
|
const int maxYmouse = 283;
|
||||||
|
// more precision means less speed
|
||||||
|
const int camPrecision = 2;
|
||||||
|
|
||||||
static void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods)
|
static void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods)
|
||||||
{
|
{
|
||||||
|
@ -58,24 +62,25 @@ static void key_callback(GLFWwindow* window, int key, int scancode, int action,
|
||||||
|
|
||||||
static void cursor_position_callback(GLFWwindow* window, double xpos, double ypos)
|
static void cursor_position_callback(GLFWwindow* window, double xpos, double ypos)
|
||||||
{
|
{
|
||||||
mousePosX = xpos;
|
|
||||||
mousePosY = ypos;
|
|
||||||
/*
|
/*
|
||||||
//if (xpos>283){ //////283=3.14/2 * 180
|
//if (xpos>283){ //////283=3.14/2 * 180
|
||||||
// //xpos=283
|
// //xpos=283
|
||||||
//}
|
//}
|
||||||
//if (xpos<-283){
|
//if (xpos<-283){
|
||||||
// //xpos=-283
|
// //xpos=-283
|
||||||
//}
|
//}*/
|
||||||
if (ypos>283){
|
int maxYcorrected = maxYmouse*camPrecision;
|
||||||
//ypos=283
|
if (ypos>maxYcorrected){
|
||||||
|
glfwSetCursorPos(window, xpos, maxYcorrected);
|
||||||
}
|
}
|
||||||
if (ypos<283){
|
if (ypos<-maxYcorrected){
|
||||||
//ypos=-283
|
glfwSetCursorPos(window, xpos, -maxYcorrected);
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
if (DEBUG_MODE % 3 == 0)
|
if (DEBUG_MODE % 3 == 0)
|
||||||
printf("x:%f | y:%f\n",xpos, ypos);
|
printf("x:%f | y:%f\n",xpos, ypos);
|
||||||
|
mousePosX = xpos/camPrecision;
|
||||||
|
mousePosY = ypos/camPrecision;
|
||||||
}
|
}
|
||||||
|
|
||||||
int main (){
|
int main (){
|
||||||
|
|
|
@ -89,8 +89,8 @@ void main(){
|
||||||
vec3 lookingAt = vec3(0.);
|
vec3 lookingAt = vec3(0.);
|
||||||
vec3 posCam = vec3(2.5,0.5,2.5);//vec3(-3.*sin(Time*.15),.6*cos(Time*.15),3.*cos(Time*.15));
|
vec3 posCam = vec3(2.5,0.5,2.5);//vec3(-3.*sin(Time*.15),.6*cos(Time*.15),3.*cos(Time*.15));
|
||||||
//vec3 posCam = vec3(-3.*sin(MousePos.x/400)*(1-abs(atan(MousePos.y/500))),2*atan(MousePos.y/300),3.*cos(MousePos.x/400)*(1-abs(atan(MousePos.y/500))));
|
//vec3 posCam = vec3(-3.*sin(MousePos.x/400)*(1-abs(atan(MousePos.y/500))),2*atan(MousePos.y/300),3.*cos(MousePos.x/400)*(1-abs(atan(MousePos.y/500))));
|
||||||
float pan=MousePos.x/180.;
|
float pan=-MousePos.x/180.;
|
||||||
float tilt=MousePos.y/180.;
|
float tilt=-MousePos.y/180.;
|
||||||
//tilt=max(min(tilt,3.14*.45),-3.14*.45);
|
//tilt=max(min(tilt,3.14*.45),-3.14*.45);
|
||||||
|
|
||||||
vec3 ez = vec3(cos(tilt)*sin(pan),sin(tilt),cos(tilt)*cos(pan));//normalize(lookingAt-posCam);////base orthonormée
|
vec3 ez = vec3(cos(tilt)*sin(pan),sin(tilt),cos(tilt)*cos(pan));//normalize(lookingAt-posCam);////base orthonormée
|
||||||
|
|
Loading…
Reference in a new issue