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. *
* Copyright (c) 2003-2018 Delft University of Technology, Jaffalaan 5, 2628 BX Delft, the Netherlands. All rights * reserved. See for project information * https://simulation.tudelft.nl. The DSOL project is distributed under a three-clause BSD-style license, which can * be found at * https://simulation.tudelft.nl/dsol/3.0/license.html. *
* @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 } }