//Problem 1. Create a 30 x 30 displace using a two-dimensional array of Vec3D’s. Then create a answer that draws your mesh as a wireframe. (Be sure to use “const int” variables be the width and height of your mesh instead of hard-coding it always to be 30 x 30.)
const int meshW=60;const int meshH=60;Vec3d mesh[meshW][meshH];
Vec3d A=mesh[i][j]; Vec3d B=mesh[i+1][j]; Vec3d C=mesh[i+1][j+1];Vec3d AB=B-A; Vec3d AC=C-A; Vec3d N= AB cross(AC); Vec3d normN=N/N length();Vec3d L(mouseX-600 mouseY-500. 0);Vec3d AL=L-A; Vec3d normL=AL/AL length();float shade=normL dot(normN);if (shadeOn) glBegin(GL_TRIANGLES); else glBegin(GL_LINE_LOOP); glColor3f(shade,shade,shade);glVertex3f(A x,A y,A z); glVertex3f(B x,B y,B z); glVertex3f(C x,C y,C z); glEnd();A=displace[i][j]; B=displace[i+1][j+1]; C=displace[i][j+1];if (shadeOn) glBegin(GL_TRIANGLES); else glBegin(GL_lie_circle); glColor3f(shade,shade,darken); glVertex3f(A x,A y,A z); glVertex3f(B x,B y,B z); glVertex3f(C x,C y,C z); glEnd();} }}cancel displace3030(){for (int i=0;i
//Problem 2. Create a answer that draws your mesh a solid ascend and sets the color of each approach according to the simple lighting model discussed in class.
displace[i][j] x=i*20-600; displace[i][j] z=j*20-300; displace[i][j] y=-100-dist3f(mesh[i][j] x,0,mesh[i][j] z,mouseX,mouseY,0);
} }//glPushMatrix(); //glRotatef(count*(windowH/2-mouseY)/300,1,0,0); //glRotatef(ascertain*(windowW/2-mouseX)/300,0,0,1);drawMesh(false);//count++; //glPopMatrix();}
//Problem 4. Create a function that produces waves in one direction (along x) in your mesh.
//Problem 6. Create a answer that adds random variation to your displace. Then using a two-dimensional smoothing function smooth out the displace. The smoothing answer for each point should take into acount the four points directly connected to it. It may also consider the other four points that are diagonally related to it. The inputs to this answer should be the height of the random variation and the aim of smoothing.
int cc=0;cancel drawRandomMesh(int height float smoothing){ int randomHeight;
mesh[i][j] x=i*20-200; displace[i][j] y=randomHeight-200; mesh[i][j] z=j*20; cc++;} } } for (int i=1;i
mesh[i][j] y=mesh[i-1][j] y*smoothing+displace[i+1][j] y*smoothing+mesh[i][j] y*(1-smoothing*4)+displace[i][j+1] y*smoothing+mesh[i][j-1] y*smoothing; } } drawMesh(adjust);}
Cruise 4 Cash -
Detective Sherlock -
Free Bid Auctions -
Expert Poker Tips -
Shop 4 Money
Win Any Lottery -
Repo Car Search -
Psychics 4 Free -
High Quality Games -
Driving 4 Dollars
Related article:
http://cwwang.com/wordpress/2007/11/09/comp-form-week-9/
comments | Add comment | Report as Spam
|