Re: Gridded3DSet.isosurf() method, color levels

Hi Bob,

> i have a question concerning the isosurf() method of the Gridded3DSet
> class.  Two of the parameters,
>
> byte[][] auxValues,
> byte[][] auxLevels,
>
> store R,G,B color values.  The first array looks like the R,G,B color
> values of the original gridded data, and the second array looks like it
> stores the computed R,G,B color values of new polygon vertices.  Is this
> correct?

Yes.  Note that the tempaux array holds the isosurface vertex colors
as they are being computed, then at the end they are copied into
auxLevels.  The size of the tempaux array may increase during the
computation if the iso-surface ends up with more vertices than
initially estimated.

> If this is correct, then my question is, how are the R,G,B color values of
> the new polygon vertices being computed?  It looks like there's a
> repeating pattern of code responsible this:
>
>   for (int j=0; j<naux; j++) {
>     t = (int) ( cp * ((auxValues[j][pt + 1 + ydim + xdim_x_ydim] < 0) ?
>         ((float) auxValues[j][pt + 1 + ydim + xdim_x_ydim]) + 256.0f :
>         ((float) auxValues[j][pt + 1 + ydim + xdim_x_ydim]) ) +
>         (1.0f - cp) * ((auxValues[j][pt + 1 + xdim_x_ydim] < 0) ?
>         ((float) auxValues[j][pt + 1 + xdim_x_ydim]) + 256.0f :
>         ((float) auxValues[j][pt + 1 + xdim_x_ydim]) ) );
>         tempaux[j][nvet] = (byte)
>         ( (t < 0) ? 0 : ((t > 255) ? -1 : ((t < 128) ? t : t - 256) ) );
>   }
>
> i don't quite understand what is happening at a conceptual or
> implementation level here. :)  Anyone have any ideas?  Is there any other
> code computing color levels?  Or is it only this repeating procedure?

This code is linearly interpolating between the color values at two
grid vertices to compute the color value at a point along the edge
between the two vertices - this point will be a vertex of the
iso-surface.  This code looks crazy because RGB color components
are stored as unsigned bytes, which is one of the options specified
by Java3D and Java2D, but unsigned bytes are not a supported data
format of the Java language.  Thus doing arithmetic with them
(e.g., interpolating between two values) requires that they first
be converted to some supported data format, in this case floats.
The byteToFloat() and floatToByte() methods of ShadowType make
this logic a little more transparent.

Note that naux is the number of color components, which may be
either 3 for RGB or 4 for RGBA (with transparency).

Cheers,
Bill
----------------------------------------------------------
Bill Hibbard, SSEC, 1225 W. Dayton St., Madison, WI  53706
hibbard@xxxxxxxxxxxxxxxxx  608-263-4427  fax: 608-263-6738
http://www.ssec.wisc.edu/~billh/vis.html

  • 2000 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the visad archives: