# Help with ZClip

Hi

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;
begin
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;
end;

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!!!
###### Who is Participating?

Commented:
No, those points cannot be calculated correctly.

You need to clip all lines which have an point with with negative z on the near clipping plane. The near clipping is a plane paralell to xy with a z value above 0. If you have a triangle reaching behind that plane, you must clip everything with a lower z, which may result in two trangles.
0

Commented:
You wrote the software rendering program ?
I tried :-(
Performance is too low (especielly on texturing and alpha)
Use the OpenGL or DirectX API
Hardware Z-Buffer is very fast
The good tutorial for OpenGL (reccomend)
http://nehe.gamedev.net/

I have a lot of experience in writing
3d and 2d applications and games (Delphi)
So EMail me if is there any question
0

Commented:
L-Tryosine:
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.