Help with ZClip
Posted on 2003-03-13
Im having problems with 3dclip a face againt plane screen.
My face routine take the 4 2d mapped coords to calc texture map and gouraud colors.
But i can´t calculate 2d coords if some 3d point lies behind camera (get inverted xy coords only)!!!
The function that transform 3d in 2d:
function Trans3Dto2D(Point: T3DPoint): T2DPoint;
var ZV: Single;
if Point.z <> 0 then ZV := Z_FACTOR/(Point.z)
else ZV := Z_FACTOR/0.000001;
Result.X := (Point.x*(-ZV))+HALF_WIDTH;
Result.Y := (Point.y*(ZV))+HALF_HEIGHT;
Theres a way to calculate correct 2d coords even if behind screen?
I tryied by taking the deltax and deltay of point in front of screen (2d mapped) and the clipped point
on screen plane (2d mapped too), but it dont works (i forgot the perspective?)
Or I should map the texture and gouraud shades on the 3d space, but how do this?
Thanks, for any help!!!