DEALING WITH THE ISSUE OF HIDING The following is to computationally intensive for PostScript. I suggest that we use GhostScript and have it output a PostScript file. The reason to choose GhostScript over C is that we do not want to write a full fledged Postscript interpreter. GhostScript gives us much of the computing and memory power of C. The only objects that can hide things are filled areas. All areas will have associated 2-dimensional bounded planes. A bounded plane is represented by a set of vertices and straight lines which form a closed curve in any single plane. Each 2-dimensional plane will have an associated projection onto the page or "onto the eye". This is important because it is from the eye that hiding perspective must be calculated. I want to set up a coordinate system for calculations. This coordinate system will basically determine the "hiding" area of the bounded plane. Here are the rules: 1. There will be a "Z" axis drawn from the eye to the origin of the plane. 2. The plane will be perpendicular to the Z axis. So if the actual plane as represented in 3D space is not perpendicular, we project it onto a bounded plane which is perpendicular. 3. We call the dimensions along this new plane X and Y. 4. I need a transformation to turn any bounded plane into a bounded hiding area. It is basically an X,Y,Z -> X,Y,Z transform for each vertex with different coordinate systems for the X,Y,Z's. Now in order to do any drawing, we use this function: A. The user defines a path B. The user uses "stroke" or "fill" to create a drawn object 1. First check to see what might be obstructing the object. 2. Then just draw the object, making sure to break it up anywhere it is hidden. Anywhere it is not hidden it can cover up other objects no problem. C. If it is an area, store the area in memory for later hiding calculations. HOW TO CHECK TO SEE IF A LINE STROKED PATH IS OBSTRUCTED We have kept a list of all bounded areas that might be obstructing. For every possible bounded area do the following: { look along the line stroked path to find the MOST REMOTE POINT from the eye calculate the formula for the hiding bounded area. take each vertex of the hiding bounded area and draw a line from the eye through the vertex to infinity. Infinity is defined as the Z axis coordinate of the MOST REMOTE POINT along the line path We now have the skeleton of a SOLID HIDING VOLUME which encloses everything that will be hidden. This skeleton has sides and a top and a bottom. Each side and top and bottom is a big quadrilateral of some sort. For each side and top and bottom { For every line segment of the line stroked path { If it intersects the side, mark the point of intersection } } Now for each line segment { start at the first point on the line outside the SOLID HIDING VOLUME (if totally enclosed inthe SOLID HIDING VOLUME don't draw it) do an even-odd calculation along the line segment to all marked intersection points: 1. draw a line between points A and B 2. don't draw from B to C - that's inside the object! 3. draw a line between points C and D 4. don't draw from C to D! 5. etcetera } } HOW TO CHECK TO SEE IF A BOUNDED PLANE IS OBSTRUCTED We have kept a list of all bounded areas that might be obstructing. For every possible bounded area do the following: { look along the line stroked path to find the MOST REMOTE POINT from the eye calculate the formula for the hiding bounded area. take each vertex of the hiding bounded area and draw a line from the eye through the vertex to infinity. Infinity is defined as the Z axis coordinate of the MOST REMOTE POINT along the line path We now have the skeleton of a SOLID HIDING VOLUME which encloses everything that will be hidden. This skeleton has sides and a top and a bottom. Each side and top and bottom is a big quadrilateral of some sort. For each side and top and bottom { For every line segment of the line stroked path { If it intersects the side, mark the point of intersection } } Every marked point is along the intersection of two plane segments. Therefore it is probably along a line of other marked points. Calculate all the lines of intersections. Now for the entire path: For each line of intersection { Draw at the first marked point. Continue the path along the line of intersection INSTEAD OF THROUGH THE SOLID VOLUME Use the even odd rule to determine when to continue. 1. Draw a new line segment along the line of intersection from A to B. Continue along the path until you get to C 2. Draw a new line segment along the line of intersection from C to D. Continue along the path until you get to E 3. etcetera and then fill } } IN THE CASE OF ANY CONFLICT WITH EQUAL COORDINATES, WHATEVER GOES LAST COMES ON TOP...