Lighting and Materials in Java3D
An Introduction with Examples |
Prof. David Bernstein |
Computer Science Department |
bernstdh@jmu.edu |
Vector2f
and Vector2d
Vector3f
and Vector3d
Vector4f
and Vector4d
Material
Class:
Appearance
Class:
Material
// Create colors ambient = new Color3f(0.329f, 0.223f, 0.027f); emissive = new Color3f(0.000f, 0.000f, 0.000f); diffuse = new Color3f(0.780f, 0.569f, 0.113f); specular = new Color3f(0.992f, 0.941f, 0.808f); // Create a Material material = new Material(ambient, emissive, diffuse, specular, 28.0f); // Create an Appearance appearance = new Appearance(); appearance.setMaterial(material);
AmbientLight
DirectionalLight
SpotLight
// Construct the AmbientLight lightA = new AmbientLight(); lightA.setInfluencingBounds(new BoundingSphere()); // Add the AmbientLight to the scene scene.addChild(lightA); // Construct the DirectionalLight lightD = new DirectionalLight(); lightD.setInfluencingBounds(new BoundingSphere()); // Add the DirectionalLight to the scene scene.addChild(lightD);