#include #include #include #include #include const int N_mnt=60; const int N_lago=70; const float coeff=0.5; const float media_x=0.0; const float media_z=0.0; const float dev_std_x=4.0; const float dev_std_z=4.0; #define PI 3.141592654 #define E 2.718281828 typedef struct{ float x,y,z; } point3D; point3D viewer,n; point3D norm; float montagna[N_mnt][N_mnt]; float lago[N_lago][N_lago]; int i,j; GLfloat light_position[]={0.0,15.0,0.0,1.0}; point3D pto1,pto2,pto3,pto4; int fillMode; float gauss(float a,float b) { float risultato; risultato = 1.0/(2.0*PI*dev_std_x*dev_std_z)*exp(-0.5*(pow(((a-media_x)/dev_std_x),2)+pow(((b-media_z)/dev_std_z),2))); return risultato; } inline void calcolaColoreVerticeMontagna(float y) { glEnable(GL_BLEND); if(y>=8.5) glColor4f(1.0,1.0,1.0,1.0); else if(y>=7.0) glColor4f(0.8,0.8,0.8,1.0); else if(y>=5.0) glColor4f(0.437,0.336,0.235,1.0); else if(y>=4.0) glColor4f(0.487,0.387,0.287,1.0); else glColor4f(0.637,0.537,0.437,1.0); } inline void calcolaColoreVerticeLago(float y) { if(y<=-0.2) glColor4f(0.0,0.2,0.8,0.6); else if(y<=0.1) glColor4f(0.0,0.5,0.5,0.6); else if(y<=0.4) glColor4f(0.0,0.7,0.9,0.6); } void calcolaMontagna(float height) { for(i=0;ix*p->x; d+=p->y*p->y; d+=p->z*p->z; d=sqrt(d); if(d>0.0) { p->x/=d; p->y/=d; p->z/=d; } } point3D cross(point3D a,point3D b,point3D c,point3D d) { d.x=(b.y-a.y)*(c.z-a.z)-(b.z-a.z)*(c.y-a.y); d.y=(b.z-a.z)*(c.x-a.x)-(b.x-a.x)*(c.z-a.z); d.z=(b.x-a.x)*(c.y-a.y)-(b.y-a.y)*(c.x-a.x); normal(&d); return d; } void disegna_montagna(float larghezza,float profondita,float spostam_x,float spostam_y,float spostam_z) { for(i=0;i