Re: getting color values from rgb values

Mario Juric - XV Gimnazija (Mario.Juric@public.srce.hr)
Mon, 27 Nov 1995 21:14:58 +0100 (MET)


> From www-vrml-owner@wired.com Mon Nov 27 20:40 MET 1995
> From: "David Ashman" <dashman@xhost2.tripos.com>
> Date: Mon, 27 Nov 1995 11:34:42 -0600
> To: www-vrml <www-vrml@wired.com>
> Subject: getting color values from rgb values
> Mime-Version: 1.0
>
> I'm attempting to write a program for a class which will allow a user to draw
> the floor plans of a building and have a VRML file built of it. I need to
> allow colors to be applied to the walls and other objects. The only color info
> available will be the physical color, none of the lighting effects will be
> handled yet. How can I convert the rgb values of the color into VRML
> compatible values?
>
> dave
>

VRML specifies RGB values as three floats in interval from 0 to 1.
To convert RGB values ranging from 0 to 255 (or any other interval)
you use this formula :

VRMLColor = YourColor / upperlimit

For example, VRML equivalent for 100 120 140 in color intensity map ranging
from 0 to 255 would be 0.39 0.47 0.55 (100/255 120/255 140/255). Then you
specify this as a diffuseColor field in the material node.

Material {
diffuseColor 0.39 0.47 0.55
}

and that's it.

Hope that's what you had in mind,

Mario J.
(majuric@jagor.srce.hr)


  • Next message: Greg Hale: "+LANGUAGE+"
  • Previous message: Bernie Roehl: "PHIL: Government Involvement"
  • Maybe in reply to: David Ashman: "getting color values from rgb values"