Thanks Thanks Thanks Thanks !!
I nearly went mad, but it finally works. Nightshade you were right the code above is ok.I tested it again and again . Now I know that the error is somewhere else. I usually was calculating the height of the camera after it received a new position. So I set // in front of it and the walking routine worked fine . And finally I found the bug in the height calculation method , but there's still something wrong with it. The Camera is jumping up and down as if it walks over a ground with many holes and stairs.
I hope you can help me again.
void objekt::Camera()
{
glRotatef(HRangle,1,0,0);
glRotatef(LRangle,0,1,0);
glTranslatef(-position.x,-(position.y+1),-position.z);
// I am not sure about this anymore, here must be the second error
}
float objekt::hoehe(xyz &point)
{
int x,z; // next lower grid point
float deltax,deltaz; // distance along x and z axis to the next lower grid point
float ux,vz; // height difference between two grid points in x and z direction
x = (int)point.x;
deltax = point.x-x;
z = (int)point.z;
deltaz = point.z-z;
if(deltax+deltaz<1.0F) // example 1
{
ux = (surface[ z *width + x+1] - surface[z*width + x])*deltax;
vz = (surface[(z+1)*width + x ] - surface[z*width + x])*deltaz;
}
else // example 2 - I think here is something wrong
{
x++; // Position of P
z++;
deltax--; // new deltax and deltaz
deltaz--;
ux = (surface[ z *width + x-1] - surface[z*width + x])*deltax;
vz = (surface[(z-1)*width + x ] - surface[z*width + x])*deltaz;
}
punkt.y=surface[z*width + x] + ux + vz;
return point.y;
}
example 1
P-------o-------
|###|##/|######/ deltaz
|---*##/#|#####/#
|####/##|####/# *:=position of example 1
|###/###|###/## P:=next lower grid point of *
|##/####|##/### o:=grid point
|#/#####|#/####
|/######|/#####
o-------Z----
deltax
example 2 deltax+deltaz > 1
o-------o-------
|######/|######/
|#####/#|#####/ +:=position of example 2
|####/##|####/ P:=next grid point of +
|###/#+-|###/# o:=grid point
|##/##|#|##/##
|#/###|#|#/### deltaz
|/####|#|/####
o-------P----
deltax
# := empty space - ignore this
[This message has been edited by TheMummy (edited December 14, 1999).]
[This message has been edited by TheMummy (edited December 14, 1999).]
[This message has been edited by TheMummy (edited December 14, 1999).]