tentative de camera n°532
This commit is contained in:
parent
ac64911f60
commit
2376977ca7
2 changed files with 28 additions and 7 deletions
16
main.c
16
main.c
|
@ -16,7 +16,7 @@
|
||||||
*
|
*
|
||||||
* For instance if you want fps and position set the value to 2*3=6
|
* For instance if you want fps and position set the value to 2*3=6
|
||||||
*/
|
*/
|
||||||
#define DEBUG_MODE 1
|
#define DEBUG_MODE 3
|
||||||
|
|
||||||
GLuint screenWidth = 720, screenHeight = 480;
|
GLuint screenWidth = 720, screenHeight = 480;
|
||||||
const GLFWvidmode* mode;
|
const GLFWvidmode* mode;
|
||||||
|
@ -60,6 +60,20 @@ static void cursor_position_callback(GLFWwindow* window, double xpos, double ypo
|
||||||
{
|
{
|
||||||
mousePosX = xpos;
|
mousePosX = xpos;
|
||||||
mousePosY = ypos;
|
mousePosY = ypos;
|
||||||
|
/*
|
||||||
|
//if (xpos>283){ //////283=3.14/2 * 180
|
||||||
|
// //xpos=283
|
||||||
|
//}
|
||||||
|
//if (xpos<-283){
|
||||||
|
// //xpos=-283
|
||||||
|
//}
|
||||||
|
if (ypos>283){
|
||||||
|
//ypos=283
|
||||||
|
}
|
||||||
|
if (ypos<283){
|
||||||
|
//ypos=-283
|
||||||
|
}
|
||||||
|
*/
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,7 +40,7 @@ float SDF_Circle(vec3 p,float r){
|
||||||
}
|
}
|
||||||
|
|
||||||
float SDF_Global(vec3 p){
|
float SDF_Global(vec3 p){
|
||||||
return SDF_Box_Frame(rotate(infinity(p,vec3(2.,2.,2.)),vec3(.2*Time,.4*Time,.6*Time)),vec3(.5,.5,.5),.1);//min(SDF_Box_Frame(p,vec3(.5,.5,.5),0.1),SDF_Circle(mod(p+vec3(.5),vec3(1.,1.,1.))-vec3(.5),.15));
|
return SDF_Box_Frame(rotate(p,vec3(0.,.2*Time,0.)),vec3(.5,.5,.5),.1);//min(SDF_Box_Frame(p,vec3(.5,.5,.5),0.1),SDF_Circle(mod(p+vec3(.5),vec3(1.,1.,1.))-vec3(.5),.15));
|
||||||
}
|
}
|
||||||
|
|
||||||
vec4 Get_Impact(vec3 origin,vec3 dir){//must have length(dir)==1
|
vec4 Get_Impact(vec3 origin,vec3 dir){//must have length(dir)==1
|
||||||
|
@ -64,7 +64,7 @@ vec3 grad(vec3 p){
|
||||||
|
|
||||||
vec3 Get_Color(vec3 origin,vec3 dir){
|
vec3 Get_Color(vec3 origin,vec3 dir){
|
||||||
vec4 impact = Get_Impact(origin,dir);
|
vec4 impact = Get_Impact(origin,dir);
|
||||||
if(impact.w<0.) return vec3(.5,.7,1.);
|
if(impact.w<0.) return (impact.y+1.)*.05*vec3(.5,.7,1.);
|
||||||
vec3 normale=grad(impact.xyz);
|
vec3 normale=grad(impact.xyz);
|
||||||
vec3 sunPos=vec3(3.,3.5,.5);//vec3(3.*sin(Time*1.5),3.*cos(Time*3.),3.*cos(Time*1.5));
|
vec3 sunPos=vec3(3.,3.5,.5);//vec3(3.*sin(Time*1.5),3.*cos(Time*3.),3.*cos(Time*1.5));
|
||||||
return vec3(clamp(0.,1.,dot(sunPos-impact.xyz,normale)));//normale;
|
return vec3(clamp(0.,1.,dot(sunPos-impact.xyz,normale)));//normale;
|
||||||
|
@ -87,10 +87,17 @@ float Mandel(vec2 co){
|
||||||
|
|
||||||
void main(){
|
void main(){
|
||||||
vec3 lookingAt = vec3(0.);
|
vec3 lookingAt = vec3(0.);
|
||||||
vec3 posCam = vec3(2.5,2.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.;
|
||||||
vec3 ez = normalize(lookingAt-posCam);////base orthonormée
|
float tilt=MousePos.y/180.;
|
||||||
|
//tilt=max(min(tilt,3.14*.45),-3.14*.45);
|
||||||
|
int parity = int(tilt/3.14-.5);
|
||||||
|
if(parity%2==1){
|
||||||
|
pan+=3.14;
|
||||||
|
}
|
||||||
|
|
||||||
|
vec3 ez = vec3(cos(tilt)*sin(pan),sin(tilt),cos(tilt)*cos(pan));//normalize(lookingAt-posCam);////base orthonormée
|
||||||
vec3 ex = normalize(cross(ez,vec3(0.,1.,0.)));
|
vec3 ex = normalize(cross(ez,vec3(0.,1.,0.)));
|
||||||
vec3 ey = cross(ex,ez);
|
vec3 ey = cross(ex,ez);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue