Hi jayT


> i have a j3d/swing app and i utilize the ColorChooser from swing
> to control the color of shapes in a J3D scene.  is there some sort
> of mapping between the two? I utilize java.awt.Color and
> javax.vecmath.Color3f.. what i believe should be a blue in Color
> is a light blue in Color3f... if it is a light color (light red, light
blue,
> etc)
> in java.awt.Color, it translates to white in javax.vecmath.Color3f..

In AWT.Color, the RGB elements range from 0 to 255;
In j3d.Color3f the RGB elements range from 0 to 1;
So to convert, you would need to do the following:

Color currentColor = Color.anyColor() ;
Color3f objColor = new Color3f( x / 255f, y / 255f, z / 255f ) ;


>colAttrib.setColor(objColor) ;
Coloring Attributes are only used for unlit geometry. If lighting is
enabled, the Material is used in the lighting equation to produce the final
color.

If you are using lights, create and add a Material object to your
appearance.  By default a material highlights to white,  if you would like
your object to highlight to  a bright version of your base color, you will
need to do something like the following


Color currentColor = Color.anyColor();

// convert to HSB (Hue Saturation, Brightness)
float[] hSB = Color.RGBtoHSB(currentColor .getRed(),currentColor
.getGreen(),currentColor .getBlue(),null);

// create a new color with the brightness set to the 1.
Color highlight = Color.getHSBColor(hSB[0], hSB[1], 1f);

// Convert AWT Color to Color3f
Color3f objColor = new Color3f( currentColor .getRed() / 255, currentColor
.getGreen() / 255 currentColor .getBlue() / 255);
Color3f objHigh = new Color3f(highlight.getRed() / 255,
highlight.getGreen() / 255 , highlight.getBlue() / 255);

// Create a material and add it to your appearance
Material material = new Material();
material.setAmbientColor(objColor);
material.setDiffuseColor(objColor);
material.setSpecularColor(objHigh);
material.setShininess(YOUR_SHINE);
material.setEmissiveColor(BLACK_3F);    // Save glowing objects for special
items : )
appearance.setMaterial(componentMaterial);

Hope This Helps

Regards
Young.


::::::::::::::::::::::::::::::::::
Young Ly
Liquid Edge Games
http://www.roboforge.com
::::::::::::::::::::::::::::::::::

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA3D-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to