Idea for CPU based object-wise environment mapping:

GLOBAL ASPECTS:

* Uses triangles only (no polygons).
* First calculates position of points and then the a buffer containing all
  edge-tables. 
* Triangle plotting doesn't recalculate slope everytime for each scanline.

ADVANTAGES:

* No need to recalculate slope every scanline => very fast!
* Doesn't need to recalculate edge-tables every time for a triangle.
  result is 50% less edge-tables to generate.
* Triangles cooperate perfectly with morphing.
* Faster stepping through triangle data, because triangles have fixed
  size in a table and polygons don't.

DISADVANTAGES:

* With plotting big triangles the texture can look really inaccurate.
* Sorting can only be done object-wise and not triangle-wise.
* Objectformat is more difficult to understand.

DECISIONS:

* Will probably need to design objects in a 3d-editor and convert them.
* Will have to use small triangles, so many points and edges. Not very
  accurate for big cubes or pyramids.
* Great for demos, though I'd rather not use this for flexible 3d worlds.

----------------------------------------------------------------------------

GLOBAL LAYOUT OF ROUTINE HANDLING ONE OBJECT:

1) Estitmate rotation and position.
2) Copy object into own buffer and rotate the points at the same time.
   Also estimate the texture-coordinates for every point.
3) Position the object.
4) Perspectivate the object.
5) Execute backface culling and depth-sorting. Mark all visible triangles
   and from that calculate which edges are visible.
6) Calculate edge-tables out of the marked edges. These are put into a
   buffer also containing offsets to the tables.
7) Draw all marked triangles using the calculated edge-tables.

FOCALPOINTS:

(2), (5), (6) and (7)

2) Only the texture-coordinate calculation is an additional point here. This
   is relativily easy, because it can be done by doing some pseudo-normal
   calculations.
5) Just plain ordinary 2d-backface culling. There need to be two extra
   arrays. One for marking the triangles and for marking the edges. Marking
   the triangles is simple, but marking the edges costs some extra indexing
   and lookups.
   The sorting per triangle is done by:
   * Averaging it's Z-coordinate.
   * Constructing a list of all VISIBLE triangles with these Z-coordinates.
   * Sorting this list.
   * Reconstructing the original triangle-array, but now sorted.
   Additional work is to convert the marked edge array, to a list containing
   all visible egde-numbers. This is needed for step (6) and (7).
6) Can probably be done from within step (5). This would cause less
   overhead. Every scanline within an edge is represented as one array-
   element containing X-position, Texture X-position and Texture Y-position.
   Each element is calculated by interpolating from one point to the other.
   Handling of clipped edges can be implemented quite easily:
   * For startpoint and endpoint check if it's inside the screen or outside.
   * If both are in > do standard interpolating
   * If both are out > do not add a new edge-table
   * If one is in and one is out > do special calculations:
     * If it is a vertical clip > check if it is clipped on top or bottom of
       screen and do the approporiate calcs.
       Also.. Don't forget to handle stuff for horizontal clip. An edge can
       be both vertically clipped as well as horizontally clipped.
     * If it is a horizontal clip:
       * If clipped left > do special calcs edge-table.
         (i.e. split it up into two parts.. one is clipped and one not)
       * If clipped right > do special calcs edge-table.
   At the end of this step a buffer has been filled with the egdenumbers and
   the offsets to their edge-tables within the buffer.
7) This draws all marked triangles. This routine CAN ONLY draw a triangles
   and depends on the edgetable-buffer given to us by step (6).
   For every triangle in the new list:
   * Calculate which edges are left and which are right. This can be done
     by checking out the slopes used on the edgetables and their y-points
     too.
   * If the triangle is vertically clipped:
     Use only two edges.
     Else:
     Find out which side has one and which has two edges.
   * Calculate the slope by searching for the widest scanline in the
     triangle.
   * For each scanline in the triangle:
     * Estimate X-start, TX-start, TY-start, X-end, TX-end and TY-end.
     * Calculate number of pixels to do.
     * Interpolate all pixels by adding the slope.

REQUIRED DATASTRUCTURES:

* Objectdata buffer:
  1) number of points
  2) pointtable (X, Y, Z(, TXY)) * number of points
  3) number of edges
  4) edgetable (P1, P2) * number of edges
  5) number of triangles
  6) triangletable (E1, E2, E3) * number of triangles
* Edge marking table:
  mark (boolean) * number of edges
* Triangle marking table:
  mark (boolean) * number of triangles
* Triangle list:
  1) number of visible triangles
  2) (E1, E2, E3(, Z)) * number of visible triangles
* Edgetable:
  1) lenght
  2) Y-start
  3) slope
  4) (X, TX, TY) * lenght
* Edgetable-buffer:
  1) (mark, offset to edgetable) * max number of edges
  2) edgetable * number of visible edges