116

Controlling appearance
Material attributes example code

  • Create Material to set shape colors
    Material myMat = new Material( );
    myMat.setAmbientColor(  0.3f, 0.3f, 0.3f );
    myMat.setDiffuseColor(  1.0f, 0.0f, 0.0f );
    myMat.setEmissiveColor( 0.0f, 0.0f, 0.0f );
    myMat.setSpecularColor( 1.0f, 1.0f, 1.0f );
    myMat.setShininess( 64.0f );
  • Create Appearance, set the material, and assemble the shape
    Appearance myAppear = new Appearance( );
    myAppear.setMaterial( myMat );
    Shape3D myShape = new Shape3D( myGeom, myAppear );