Path: chuka.playstation.co.uk!news From: "Nathan Miller" Newsgroups: scee.yaroze.programming.3d_graphics Subject: The ultimate 3d->2d problem Date: Sat, 2 Jan 1999 13:57:01 +0200 Organization: PlayStation Net Yaroze (SCEE) Lines: 47 Message-ID: <76l4u4$qsh23@chuka.playstation.co.uk> NNTP-Posting-Host: 134.235.149.237 X-Newsreader: Microsoft Outlook Express 4.72.2106.4 X-MimeOLE: Produced By Microsoft MimeOLE V4.72.2106.4 To all the math inclined- I have a BIG problem that I cannot seem to figure out. I have been thinking about it for the past few days, but I just cannot seem to figure it out. It involves the process of converting 3d to 2d. I am writing my own polygon rasterizer for a specific type of polygon. I have to convert the points of the polygon myself from 3d to 2d. The polygon is forced to be a quadrilateral. Once the polygon has been converted to 2d screen space the output is always either a quadrilateral or a parallelagram. I then calculate 2 points based on their z components to be the side I want to start drawing from. The other two points are the side I want to draw to. My loop has to determine whether or not it is drawing top to bottom or side to side. This is the point that becomes a problem. I cannot seem to figure out how to determine which side I am drawing based on the two points that the algorithm found. Before I try and clarify the problem with a visual, I am not doing standard texture mapping (if you couldn't tell) I am doing a special :-) texture mapping that requires me to draw back to front (in the z direction). I can find the rear of my 2d polygon based on its converted z component. Here is the visual and why it is a problem (remember it has to be as fast as possible): p1-> x----------x <-p2 / / / / / / / / p3-> x----------x <-p4 p1 and p2 define the edge I want to draw from and p3 and p4 define the edge I want to draw to. This case is easy, but what happens when it looks like this: p1-> x----------x <-p2 p3-> x---------x <-p4 now p3 and p4's x values are left so the algoritm may make a mistake and think it is drawing side to side instead of top to bottom. Is it a lot easier than I am thinking it is or is it an impossible problem? Your help will be appreciated, Nathan Miller