I'm doing a software 3d-engine for my old Atari Falcon030 and after getting up to work 3d trasformation, 2d projection, 3d-2d line clipping, shaded wire-frame rendering, shaded particle-rendering, spherical lightning on asm; I felt pretty kool and said to myself: time to kill my cpu and draw some shaded poligon on the screen.
So I coded a test 2d drawing rutine something like this:
And all worked fine until I thought about clipping:
First of all I thought it would be enough to clip by the two y's planes 'cause x-clipping a scannline is child's play, but when I realized that I had to clip also by the z's plane to overcome the z<=0 problem, I become very confuse.
I tryed to get working a clipping rutine based on the line's one. But the resulting poligon was a n-sided one (3<=n<=6).
Then I tryed to code a rutine to split it into triangles.
After 500 lines of code I stopped and wrote this post, I may be on the right way but before continue on this way I'd like to know if there is a better way 'cose this one is full of condition and exception...not very elegant.
I know, my english is not very correct, sorry for that.
If i wasn't very clear here the rude question:
How the hell I perform a 3d-clipping uppon a triangle ?
(by clipping dont mean find out if the triangle is inside the screen, but cutting it in the way it's drawed inside the screen)
10xffffor your Answer, Mutilate.