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.D3.Renderable3D;
22 import nl.tudelft.simulation.dsol.simulators.SimulatorInterface;
23 import nl.tudelft.simulation.language.d3.DirectedPoint;
24
25 import com.sun.j3d.utils.geometry.Box;
26
27 /***
28 * World, a simple world for the ball model 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 World extends Renderable3D
41 {
42
43 /***
44 * Construct the world
45 *
46 * @param staticLocation Static location
47 * @param simulator Simulator
48 */
49 public World(final DirectedPoint staticLocation,
50 final SimulatorInterface simulator)
51 {
52 super(staticLocation, simulator);
53 }
54
55 /***
56 * @see nl.tudelft.simulation.dsol.animation.D3.Renderable3D
57 * #provideModel(javax.media.j3d.TransformGroup)
58 */
59 public void provideModel(final TransformGroup locationGroup)
60 {
61 this.setScale(0.1d);
62
63
64 Appearance app = new Appearance();
65
66 Color3f ambientColor = new Color3f(Color.WHITE);
67 Color3f diffuseColor = new Color3f(Color.WHITE);
68 Color3f specularColor = new Color3f(Color.WHITE);
69 Color3f emissiveColor = new Color3f(Color.WHITE);
70
71 float shininess = 10.0f;
72
73 app.setMaterial(new Material(ambientColor, emissiveColor, diffuseColor,
74 specularColor, shininess));
75
76 Node model = new Box(100f * (float) this.scale,
77 100f * (float) this.scale, 1f * (float) this.scale, app);
78
79
80
81
82
83 locationGroup.addChild(model);
84 }
85
86 /***
87 * @see nl.tudelft.simulation.dsol.animation.D3.
88 * Renderable3D#update(java.util.Enumeration)
89 */
90 protected void update(Enumeration children)
91 {
92
93 }
94 }