package nl.tudelft.simulation.examples.dsol.animation3d; import java.util.Enumeration; import javax.media.j3d.Appearance; import javax.media.j3d.Material; import javax.media.j3d.TransformGroup; import javax.vecmath.Color3f; import nl.tudelft.simulation.dsol.animation.Locatable; import nl.tudelft.simulation.dsol.animation.D3.Renderable3D; import nl.tudelft.simulation.dsol.simulators.SimulatorInterface; /** * BallAnimation3D, animation of a ball in 3D
* (c) copyright 2003 Delft University of Technology , the Netherlands. *
* See for project information www.simulation.tudelft.nl
* License of use: General Public License (GPL) , no warranty
* @version 1.0 10.05.2004
* @author Roy Chin */ public class BallAnimation3D extends Renderable3D { /** * constructs a new BallAnimation3D. * @param source the source * @param simulator the simulator */ public BallAnimation3D(final Locatable source, final SimulatorInterface.TimeDouble simulator) { super(source, simulator); } @Override public void provideModel(final TransformGroup locationGroup) { this.setScale(0.1d); // ---------------- // The shape itself Appearance app = new Appearance(); // Create colors for the material Color3f ambientColor = new Color3f(1.0f, 0.0f, 0.0f); Color3f diffuseColor = new Color3f(1.0f, 0.0f, 0.0f); Color3f specularColor = new Color3f(1.0f, 1.0f, 1.0f); Color3f emissiveColor = new Color3f(0.0f, 0.0f, 0.0f); // Define shininess float shininess = 10.0f; // Set material app.setMaterial(new Material(ambientColor, emissiveColor, diffuseColor, specularColor, shininess)); // Create a ball // TODO: Node model = new Sphere(5f * (float) this.scale, app); // Node model = new ColorCube(0.4); // --------------- // Put it together // TODO: locationGroup.addChild(model); } @Override protected void update(final Enumeration children) { // Do nothing } }