Free Web Site - Free Web Space and Site Hosting - Web Hosting - Internet Store and Ecommerce Solution Provider - High Speed Internet
Search the Web

Sensory Combinatronics Using 3D to Surf the WEB


Intro  

Concepts  3 Nodes  4 Fields/Events   5 Conformance
A Grammar   B Java   C JavaScript      D Examples       Quick Nodes
 
           
 

  

 

 

Chapter 3:
Node Reference

Intro
Anchor
Appearance
AudioClip
Background
Billboard
Box
Collision
Color
ColorInterpolator
Cone
Coordinate
CoordinateInterpolator
Cylinder
CylinderSen
sor
DirectionalLight
ElevationGrid
Extrusion
Fog
FontStyle
Group
ImageTexture
IndexedFaceSet
IndexedLineSet
Inline
LOD
Material
MovieTexture
NavigationInfo
Normal
NormalInterpolator
OrientationInterpolator
PixelTexture
PlaneSensor
PointLight
PointSet
PositionInterpolator
ProximitySensor
ScalarInterpolator
Script
Shape
Sound
Sphere
SphereSensor
SpotLight
Switch
Text
TextureCoordinate
TextureTransform
TimeSensor
TouchSensor
Transform
Viewpoint
VisibilitySensor
WorldInfo

 

+ 3.10 ColorInterpolator

ColorInterpolator { 

  eventIn      SFFloat set_fraction        # (-INF,INF)

  exposedField MFFloat key           []    # (-INF,INF)

  exposedField MFColor keyValue      []    # [0,1]

  eventOut     SFColor value_changed

}

This node interpolates among a set of MFColor key values to produce an SFColor (RGB) value_changed event. The number of colours in the keyValue field shall be equal to the number of keyframes in the key field. The keyValue field and value_changed events are defined in RGB colour space. A linear interpolation using the value of set_fraction as input is performed in HSV space.  Results are undefined when interpolating between two consecutive keys with complementary hues.

Section "2.6.8 Interpolators" contains a detailed discussion of interpolators.

TIP: The ColorInterpolator outputs an SFColor, suitable for use in any of the color fields of a Material node (diffuseColor, specularColor, emissiveColor). Unfortunately, a ColorInterpolator cannot be used to interpolate multiple colors (it does not generate an MFColor output) and so cannot be used with a Color node. If you do need to change the colors in a Color node, you will have to write a Script that does the appropriate calculations.

TECHNICAL NOTE: Defining the keys in RGB space but doing the interpolation in HSV space may seem somewhat strange. If the key values are very close together, then the differences between the two spaces are minimal. However, if there are large differences between the keys, then doing the interpolation in HSV space gives better perceptual results, since interpolating between two keys with the same intensity will not result in any intensity changes. That isn't true of RGB space: Interpolate from full-intensity red (1,0,0) to full-intensity green (0,1,0) and halfway you'll get half-intensity yellow (0.5,0.5,0).

The following example illustrates the use of the ColorInterpolator node. An infinitely looping TimeSensor is routed to a ColorInterpolator that is routed to the diffuseColor of a Material that is coloring the Box, Sphere, and Cone:


#VRML V2.0 utf8 

Transform { children [ 

  Transform { 

    translation -4 0 0 

    children Shape { 

      geometry Box {} 

      appearance DEF A Appearance { 

        material DEF M Material { diffuseColor .8 .2 .2 } 

      } 

    } 

  } 

  Transform { 

    translation 0 0 0 

    children Shape { geometry Sphere {} appearance USE A } 

  } 

  Transform { 

    translation 4 0 0 

    children Shape { geometry Cone {} appearance USE A } 

  } 

  NavigationInfo { type "EXAMINE" } 

]} 

DEF CI ColorInterpolator { 

  key [ 0 .2 .4 .6 .8 1 ] 

  keyValue [ .8 .2 .2, .2 .8 .2, .2 .2 .8, .8 .8 .8,

             1 0 1, .8 .2 .2 ] 

} 

DEF TS TimeSensor { loop TRUE cycleInterval 5 } 

ROUTE TS.fraction_changed TO CI.set_fraction 

ROUTE CI.value_changed TO M.set_diffuseColor