PEG diceable--tjl: General dicing for polygonal things

Author: Tuomas J. Lukka
Revision: 1.3
Status: Incomplete

Re: recent discussion on gzz-dev, we need a general API for specifying polygons in the Java level, and then transforming and dicing them for non-linear coordinate systems on the OpenGL level.



Currently there's a lot of code in Java using the OpenGL transformation pipeline by using CallGL code such as

Vertex 0.5 1 1000
Vertex 0.5 -1 1000
Vertex -1 1 1000
Vertex -1 -1 1000

to draw something. This is not good, since the transformation pipeline may contain non-linear transformations and these commands will not be correctly transformed since the non-linear transformations cannot be implemented as OpenGL transformations matrices.

It would, of course, be possible to use vertex programs on architectures where those are available, but this does not really help much, since the non-linear transformation can take the above rectangle to a shape with curved edges --- the transformation would be inaccurate anyway.

Currently, this problem is solved in PaperQuad by dicing the rectangle appropriately before transformation. However, the trivial generalization of this solution --- having a renderable for each of the polygonal things we want to render in OpenGL --- is unreasonable.

We need a general way to specify polygons and texture coordinates (and other attributes) to be diced. At the same time, we can solve the other problem: it has not been possible to create polygonal data to be rendered depending on more than one coordinate system, e.g. connections.


A new renderable, DiceableMesh, containing

  • A set of indexed vertices, each containing

    • vertex location
    • possibly other vertex data: texture coordinates, normal, etc.
  • A set of lines and polygons as an unstructured mesh between the vertices

  • A vector of CallGL codes

  • A vector of primitive sets:

    • whether the primitive set is GL line or libline line or GL triangle
    • the vector of vertex indices of the primitives
  • center and radius of nonlinearity query

When rendering and dicing, all vertex attributes are interpolated linearly.