< Zurück | Inhalt | Weiter >


The ColorInterpolator can be used to linearly interpolate the Material diffuse color of an Appearance between two extremes. Note that the Material must have the ALLOW_COMPONENT_WRITE capability bit set.

//create an Appearance

Appearance app = new Appearance();

//create a Material and assign an initial color Color3f objColor = new Color3f(1.0f, 0.7f, 0.8f); Color3f black = new Color3f(0.0f, 0.0f, 0.0f); Material mat =

new Material(objColor, black, objColor, black, 80.0f);

//ensure the Interpolator has WRITE access to the Material mat.setCapability( Material.ALLOW_COMPONENT_WRITE );

//assign the Material to the Appearance app.setMaterial( mat );

//create the Interpolator–by default interpolate

//between black and white Interpolator interpolator =

new ColorInterpolator( alpha, app.getMaterial() );