## Why doesn't this work? - z-depth problem

### Why doesn't this work? - z-depth problem

I'm having a problem under D3D-IM with the z-depth of my polys.
Everything appears normal in the distance, but as polys get closer to the
camera they start doing strange things.

For example, I have terrain with a depression and a water mesh (just
a flat mesh, all co-planar polys) above it...so basically a small pond.
As the camera approaches the pond, the terrain looks like its moving
upward and will actually show through the pond.  Depending on the view
angle and the range, the pond will completely disappear.  Note that the
water mesh is fairly high above the terrain...so I don't think this is a
precision problem.

I've checked all my rotation matrices and they seem fine.  I rotated
my object points with them, throwing the result back into the object's
point buffer, and the objects haven't become deformed.

I believe the problem is in my 3D->2D point conversion function...I
just can't think of why anything else would be the problem.  I assumed
what is below is correct, but hopefully it isn't and I can get this
resolved.

Is there something wrong with the code below that would cause this
depth problem?

-----
void _Convert3DTo2D (_Point *inPoint1, _Point *inPoint2, _Point *inPoint3)
long theCounter;
float theHalfWidth = 320;
float theHalfHeight = 240;
float theWidth = 640;
float theHeight = 480;
float theYon = (5280.0f * 400.0f);
float theHither = 10.0f;
float theZoom = 512.0f;
float theYonHither = 1.0f/(inYon - inHither);
_Point *thePoint[3] = {inPoint1, inPoint2, inPoint3};

for (theCounter = 0; theCounter < 3; theCounter++)
{
if (thePoint[theCounter])
{
float theOneZ = ((1.0f/(thePoint[theCounter].z - theHither)) * theZoom);

thePoint[theCounter].x = (thePoint[theCounter].x * theOneZ) + theHalfWidth;
thePoint[theCounter].y = theHalfHeight - (thePoint[theCounter].y * theOneZ);

thePoint[theCounter].w = 1.0f/((thePoint[theCounter].z - theHither) *
theYonHither);

thePoint[theCounter].z = (thePoint[theCounter].z - theHither) * theYonHither;

Quote:}
}

-----

--
Replace "nospam" with "ericd" - anti-spam measures

Hi folks-

I'm trying to get a small sphere to orbit a larger sphere. (I'll add
interesting details to the spheres later...) I've never tried to do the
animation before, and thought this wouldn't be too tough.

When I render the sences, nothing changes! It has to be something simple,
but it escapes me. Any help would be nice.

Norman

----------------------------------
scene file:
#include "colors.inc"
#include "textures.inc"

camera {
location < 0, 50, 0 >
look_at 0
angle 36

// light_source { < 700, 200, -50 > White }
light_source { < -500, 0, 10 > White }
// light_source { < -10, -5, -10 > Red }

plane { y, -25
texture {
pigment { Yellow }
finish { reflection .5 specular 1 ambient 0.3 }
}

sphere { < 0, 0, 0 > 2
texture {
pigment { Red }
}

sphere { < 0, 0, 0 > .5
texture {
pigment { Blue }
finish { reflection 0.9
specular 1
phong 1 phong_size 20
metallic
}
}

------------------------------------------
animation ini file:
; Persistence Of Vision raytracer version 3.0 sample file.

Antialias=Off

Antialias_Threshold=0.2
Antialias_Depth=3

Test_Abort_Count=100

Input_File_Name=planet.pov

Initial_Frame=0
Final_Frame=9
Initial_Clock=0
Final_Clock=2*pi

Cyclic_Animation=on
Pause_when_Done=off

Width=320
Height=200
Display=off

|  it to makes voodoo seem like a science.
http://www.geocities.com/CapeCanaveral/5280