1
2
3
4
5
6
7
8
9
10 package nl.tudelft.simulation.dsol.tutorial.section44;
11
12 import java.awt.Color;
13 import java.util.Enumeration;
14
15 import javax.media.j3d.Appearance;
16 import javax.media.j3d.Material;
17 import javax.media.j3d.Node;
18 import javax.media.j3d.TransformGroup;
19 import javax.vecmath.Color3f;
20
21 import nl.tudelft.simulation.dsol.animation.LocatableInterface;
22 import nl.tudelft.simulation.dsol.animation.D3.Renderable3D;
23 import nl.tudelft.simulation.dsol.simulators.SimulatorInterface;
24
25 import com.sun.j3d.utils.geometry.Sphere;
26
27 /***
28 * BallAnimation3D, animation of a ball in 3D <br>
29 * (c) copyright 2003 <a href="http://www.simulation.tudelft.nl">Delft
30 * University of Technology </a>, the Netherlands. <br>
31 * See for project information <a
32 * href="http://www.simulation.tudelft.nl">www.simulation.tudelft.nl </a> <br>
33 * License of use: <a href="http://www.gnu.org/copyleft/gpl.html">General Public
34 * License (GPL) </a>, no warranty <br>
35 *
36 * @version 1.0 10.05.2004 <br>
37 * @author <a href="http://www.tbm.tudelft.nl/webstaf/royc/index.htm">Roy Chin
38 * </a>
39 */
40 public class BallAnimation3D extends Renderable3D
41 {
42 /***
43 * constructs a new BallAnimation3D
44 *
45 * @param source the source
46 * @param simulator the simulator
47 */
48 public BallAnimation3D(final LocatableInterface source,
49 final SimulatorInterface simulator)
50 {
51 super(source, simulator);
52 }
53
54 /***
55 * provides the model for the animationObject
56 *
57 * @param locationGroup
58 */
59 public void provideModel(final TransformGroup locationGroup)
60 {
61 this.setScale(0.1d);
62
63
64
65 Appearance app = new Appearance();
66
67
68 Color3f ambientColor = new Color3f(Color.ORANGE);
69 Color3f diffuseColor = new Color3f(Color.ORANGE);
70
71 Color3f specularColor = new Color3f(Color.WHITE);
72 Color3f emissiveColor = new Color3f(Color.orange);
73
74
75 float shininess = 10.0f;
76
77 app.setMaterial(new Material(ambientColor, emissiveColor, diffuseColor,
78 specularColor, shininess));
79
80 Node model = new Sphere(5f * (float) this.scale, app);
81
82
83
84
85
86 locationGroup.addChild(model);
87 }
88
89 /***
90 * updates the animation of this object
91 *
92 * @param children the children to update
93 */
94 protected void update(Enumeration children)
95 {
96
97 }
98 }