void GLClass::GLDrawHeightField (Object *GLObjTmp, int GLwire)
{
int X, Y;
float x, y, z;
_HeightField *HF;
CObjects *CObj;
int step_size, width, height, color;
CTransformations *CTrans;
glPushMatrix ();
CTrans = new CTransformations;
CTrans->ExecuteObjTranslations (GLObjTmp);
HF = new _HeightField;
HF = (_HeightField *)GLObjTmp->ObjProperties;
CObj = new CObjects;
step_size = HF->step_size;
width = HF->width;
height = HF->height;
if (!HF->image)
return;
if (GLwire)
{
if (GLObjTmp->Selected)
glColor3f (1.0, 1.0, 0.0);
else
glColor3f (1.0, 1.0, 1.0);
}
glBegin (GL_QUADS);
for (X = 0; X < width; X += step_size)
for (Y = 0; Y < height; Y += step_size)
{
x = X;
y = CObj->HF_Height (HF, X, Y);
z = Y;
if (!GLwire)
{
//Texture Stuff
color = CObj->HF_SetVertexColor (HF, x, z);
glColor3f (color, color, 0.0);
}
glVertex3d (x, y, z);
x = X;
y = CObj->HF_Height (HF, X, Y + step_size);
z = Y + step_size;
if (!GLwire)
{
//Texture Stuff
color = CObj->HF_SetVertexColor (HF, x, z);
glColor3f (color, color, 0.0);
}
glVertex3d (x, y, z);
x = X + step_size;
y = CObj->HF_Height (HF, X + step_size, Y + step_size);
z = Y + step_size;
if (!GLwire)
{
//Texture Stuff
color = CObj->HF_SetVertexColor (HF, x, z);
glColor3f (color, color, 0.0);
}
glVertex3d (x, y, z);
x = X + step_size;
y = CObj->HF_Height (HF, X + step_size, Y);
z = Y;
if (!GLwire)
{
//Texture Stuff
color = CObj->HF_SetVertexColor (HF, x, z);
glColor3f (color, color, 0.0);
}
glVertex3d (x, y, z);
}
glEnd();
glPopMatrix();
}
i know it is long, but i need help please! the code above draws my height field that is loaded. that parts works sortof. the problem i have is it will not shoe th 3d perspective view. it will shpow ortho, bbut not perspective…why? also, if i have a height map 1024x1024 what is appropriate to scale it down to?