#include "Land.h" #include #include using namespace std; const float SCALE_HEIGHT = 1; Land::Land(int xdim, int ydim) { xDim = xdim; yDim = ydim; SetType(GL_TRIANGLES); return; } GLfloat Land::Height(int x, int y) { float scale = sqrt(xDim*xDim+yDim*yDim)/24; float d =sqrt(float(x)*x+y*y)/scale; //return(cos(d)*SCALE_HEIGHT) ; return 0; } void Land::Init() { Vertex vertex; int x,y; vertex.color = color; for(y=0;y<=yDim; y++) { for(x =0; x<=xDim ; x++) { vertex.position.x = x; vertex.position.y = Height(x,y); vertex.position.z = y; points.push_back(vertex); } } for(y = 0; y < yDim; y++) { for(x=0; x< xDim; x++) { index.push_back(y * (xDim+1) + x); index.push_back((y + 1) * (xDim+1) + x+1); index.push_back(y * (xDim+1) + x + 1); index.push_back(y * (xDim+1) + x); index.push_back((y + 1) * (xDim+1) + x); index.push_back((y + 1) * (xDim+1) + x+1); } } return; }