Re: color

Hi Doug,
 
> I'm not having much luck getting the colors I want.
 
No worries, mate.
 
> I had something like this:
>
> (x,y) -> (z)
> with z mapped to a display color such that I had some decent looking
> terrain.
>
> I then had
>
> (x,y,z) -> shape
> so I could have a shape fly through the 3D scene. This actually works
> but my shape object changes color with height - an interesting effect,
> but not the one I'm after. :-)
>
> Is there a way to specify the color of a shape without getting fancy
> with mappings (i.e. not like Test47 which about turned my brain inside
> out)?
 
To do this, you need to set the .colors field in your shapes
(i.e., VisADGeometryArrays), as is done in Test 46.  The only
tricky part is that colors are now unsigned bytes, which are not
a supported primitive data type of Java.  If you want a constant
color shape, first decide how to describe that color as
proportions of red, green abd blue - with a float value for
each between 0.0f (off) and 1.0f (on).  Then translate these
proportions to unsigned bytes using the static method
ShadowType.floatToByte, as follows:
 
  byte red_byte = ShadowType.floatToByte(red_float);
  byte green_byte = ShadowType.floatToByte(green_float);
  byte blue_byte = ShadowType.floatToByte(blue_float);
 
Then, after you've constructed your shape, fill this color
into your shape as follows:
 
  VisADGeometryArray shape = ...
  ...
  shape.colors = new byte[shape.coordinates.length];
  for (int i=0; i<shape.coordinates.length; i+=3) {
    shape.colors[i] = red_byte;
    shape.colors[i+1] = green_byte;
    shape.colors[i+2] = blue_byte;
  }
 
> Do I need to use this ColorControl thing? Any examples, suggestions?
 
This is used when you have some RealType mapped to RGB and
you want to change the mapping from RealType values to colors
while the application runs.
 
If you want the user to directly control the color mapping,
then you can construct a visad.util.LabeledRGBWidget from
the ScalarMap to RGB.
 
> I also have
> (x,y,z) -> (u_wind,v_wind)
> and I'd like the wind vectors be colored by height, but not the same as
> terrain.
>
> Do I simply need a different "z" for each of these?
 
Afraid so.  If you want two different color maps according
to height, then you need to define two different height
RealTypes (e.g., "z1" and "z2").
 
> While I'm at it, why do I get blue when I map to Display.Yellow (and
> other related stuff)?
 
Because Yellow is part of the CMY = (Cyan, Magenta, Yellow)
color coordinate system.  The default for these is 1.0f.  Thus
when you map only to Yellow, Cyan and Magenta are always 1.0f,
but Yellow is mostly less than 1.0f, so you get lots of blue.
Works the same way with (Red, Green, Blue).
 
Cheers,
Bill
 
----------------------------------------------------------
Bill Hibbard, SSEC, 1225 W. Dayton St., Madison, WI  53706
whibbard@xxxxxxxxxxxxx  608-263-4427  fax: 608-263-6738
http://www.ssec.wisc.edu/~billh/vis.html