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 Node
 
           
 

 

  

 

 

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.9 Color



Color { 

  exposedField MFColor color  []         # [0,1]

}

This node defines a set of RGB colors to be used in the fields of another node.

Color nodes are only used to specify multiple colors for a single geometric shape, such as a colors for the faces or vertices of an IndexedFaceSet. A Material node is used to specify the overall material parameters of lit geometry. If both a Material and a Color node are specified for a geometric shape, the colors shall replace the diffuse component of the material.

TIP: Using the Color node to specify colors per vertex of IndexedFaceSet nodes is a very efficient and effective alternative to texture mapping. If designed properly, color per vertex can produce rich lighting and color effects. Typically, color-per-vertex rendering is much faster than texture mapping and is thus worth the effort. Note, however, that some browsers do not support color-per-vertex rendering; verify that it is supported before using this feature.


Textures take precedence over colors; specifying both a Texture and a Color node for geometric shape will result in the Color node being ignored. Details on lighting equations are described in "2.14 Lighting model."

TIP: Color nodes are specified in the color field of ElevationGrid, IndexedFaceSet, IndexedLineSet, or PointSet nodes. A Color node can function as a general color map for IndexedFaceSet and IndexedLineSet nodes. You simply DEF the Color node and USE it repeatedly, using the indexing feature of IndexedFaceSet or IndexedLineSet to refer to colors by index rather than by absolute RGB value. If you are translating from an application that only supports a limited (e.g., 256-color) color palette, then this technique can make the resulting VRML files much smaller than respecifying the RGB colors over and over.

EXAMPLE (click to run): The following example illustrates the use of the Color node in conjunction with the IndexedFaceSet node (see Figure 3-9). The first IndexedFaceSet uses a Color node that specifies two colors: black (0,0,0) and white (1,1,1). Each vertex of each face of the IndexedFaceSet is assigned one of these two colors by the colorIndex field of the IndexedFaceSet. The second IndexedFaceSet/Color is almost identical, but does not specify a colorIndex field in the IndexedFaceSet and thus relies on the coordIndex field to assign colors (see IndexedFaceSet). The third IndexedFaceSet/Color applies color to each face of the IndexedFaceSet by setting colorPerVertex FALSE and specifying colorIndex for each face.



#VRML V2.0 utf8 

Group { children [ 

  Transform { 

    translation -3 0 0 

    children Shape { 

      appearance DEF A1 Appearance { material Material {} } 

      geometry IndexedFaceSet { 

        coord DEF C1 Coordinate { 

          point [ 1 0 1, 1 0 -1, -1 0 -1, -1 0 1, 0 3 0 ] 

        } 

        coordIndex [ 0 1 4 -1 1 2 4 -1 2 3 4 -1 3 0 4 ] 

        color Color { color [ 0 0 0, 1 1 1 ] } 

        colorIndex [ 0 0 1 -1 0 0 1 -1 0 0 1 -1 0 0 1 ] 

      } 

    } 

  } 

  Transform { 

    children Shape { 

      appearance USE A1 

      geometry IndexedFaceSet {

        # uses coordIndex for colorIndex 

        coord USE C1 

        coordIndex [ 0 1 4 -1 1 2 4 -1 2 3 4 -1 3 0 4 ] 

        color Color { color [ 1 1 1, 1 1 1, 1 1 1, 1 1 1, 0 0 0 ]} 

      } 

    } 

  } 

  Transform { 

    translation 3 0 0 

    children Shape { 

      appearance USE A1 

      geometry IndexedFaceSet { 

        coord USE C1 

        coordIndex [ 0 1 4 -1 1 2 4 -1 2 3 4 -1 3 0 4 ] 

        color Color { color [ 0 0 0, 1 1 1 ] } 

        colorIndex [ 0, 1, 0, 1 ] # alt every other face 

        colorPerVertex FALSE 

      } 

    } 

  } 

  Background { skyColor 1 1 1 } 

]}
 

Color node example

Figure 3-9 Color Node Example