[Contents] [TitleIndex] [WordIndex

surfaceDrawing package

Here is a little transgression of the renderer conception because the surface decomposition actually occures in the Java code and not in the C++ code. Maybe it could be rewritten.

The 3 entry points are SurfaceFacetDrawerGL, SurfaceLineDrawerGL and SurfaceMarkDrawerGL each one of the strategies drawing an aspect of the surface (polygons, wireframe and marks). These 3 classes get the polygons to draw from a SurfaceDecomposer.

The SurfaceDecomposer class actually take the X, Y, and Z datas given in the handle and turn them in a set of polygons. There are 2 implementations of this class one for Plot3d objects (X and Y defining a grid and Z the values on the grid) and one for Fac3D objects (X, Y and Z contains directly the polygons vertices). Using these two class make the drawing of lines and marks pretty straightforward. However for facets, it lacks color.

The color is also computed inside the SurfaceDecomposer which relies on a FacetColorComputer object. This object is computed the color associated which each vertex of a facet with its getFacetColor method. The implementations of FacetColorComputer are ConstantColorComputer for surface with only one color, PerFacetColorComputer in which all facet have their on color(s) which is specified in the color field of the handle and ZDependingColorComputer where the facet color depends on its height.

Knowing positions and color of the facets, it's know almost possible to draw the facets. We just need to know how the color is applied on a facet. This is perfomred by the FacetDrawerGL object. Actually there are two ways to apply color, either using a single color for the facet or by applying an interpolation. The FlatShadedFacetDrawerGL and LinearShaedeFacetDrawerGL do this.

The first implementation of these two last classes used triangles (GL_TRIANGLES) to draw triangular facets and quads (GL_QUADS) to draw quad facets. There are now problems for triangles but with quads the result was not good when the quads were not flats (see http://bugzilla.scilab.org/show_bug.cgi?id=2983 for more information). Finally, we got rid of GL_QUADS and use two triangles instead. However, there are two possibilities when cutting a quad in two triangles. Actually, the possibility giving the most flat quad (using the decomposeQuad algorithm) is used. Normally, Scilab is able to render facets with more than 4 vertices (although in Scilab 4 the result is pretty buggy), such a behaviour as been kept. It's better now, but still not perfect, it will only work well with concave facets. If really needed, it would be better to use a tesselator here again. In conclusion, stay away of GL_QUADS and GL_POLYGON and create your own triangulation instead.


2022-09-08 09:27