Original Post
Hi all,
If I have a terrain with 128x128 quads, each quad happens to be a width and depth of 96x96 (x,z), to find which patch the camera is over is the following correct :
D3DXVECTOR3 CameraPos = GetCameraPos();
int PatchOnX = (int)CameraPos.x / 96;
int PatchOnZ = (int)CameraPos.z / 96;
Now having these two values, I could index into my heightmap as follows :
int Height = HeightMap[(PatchOnX*128)+PatchOnZ];
It seems correct, but the Height I get back seems to vary, maybe this is because each quad has 4 vertices, thus 4 heights ?
Kind regards,
Steve
As I get older, my mind becomes more cluttered.
[3d Game development]
[edited by - steg on May 22, 2003 7:47:44 AM]