Original Post
Reading the z buffer value..
Code :
ddsd.dwSize := SizeOf(ddsd);
if IZBuffer.Lock(nil, ddsd, DDLOCK_READONLY, 0)=DD_OK then
begin
try
case ddsd.ddpfPixelFormat.dwRGBBitCount of
// do stuff
end;
finally
IZBuffer.Unlock(nil);
end;
end;
What i need is the actualy Z value of a poly at any given
point in the buffer.
The point is when moving a "character/Camera" over a landscape,
it should follow the terrain, according to the terrain-mesh.
Idea is to place a camera that looks stright down at the x,y
position of were the Character is standing, and then
read the z value from the zbuffer, to determin the z cord.
of the Character.
The Camera that looks stright down, would of cuz not be showen
to the player.
However this meens rendering the sceen 2 times for eatch move
the character dose.
If any has a better idea of how to move over a terrain, let me know
I first tryed to make a Map of the terrain based of all the
z values. However this makes the Characters movement seem
likes walking up and down staires, method simply not
precise enuf.
And when adding other Meshes to the sceen, like rocks etc.
the z cord. simply is not good enuf.