Mercurial > hg > Database > Alice
comparison src/alice/test/topology/movement/MakeFrame.java @ 88:33a19ca88e43 working
Singleton is removed .
author | sugi |
---|---|
date | Mon, 04 Jun 2012 16:08:53 +0900 |
parents | src/alice/test/topology/movement/FishMovement.java@f8d86641b2ec |
children | e269cedd8bae |
comparison
equal
deleted
inserted
replaced
87:899b2b78ac75 | 88:33a19ca88e43 |
---|---|
1 package alice.test.topology.movement; | |
2 | |
3 import java.awt.GraphicsConfiguration; | |
4 | |
5 import javax.media.j3d.BoundingSphere; | |
6 import javax.media.j3d.BranchGroup; | |
7 import javax.media.j3d.Canvas3D; | |
8 import javax.media.j3d.DirectionalLight; | |
9 | |
10 import javax.swing.JFrame; | |
11 import javax.swing.JPanel; | |
12 import javax.vecmath.Color3f; | |
13 import javax.vecmath.Vector3f; | |
14 | |
15 import com.sun.j3d.utils.universe.SimpleUniverse; | |
16 import com.sun.j3d.utils.universe.ViewingPlatform; | |
17 | |
18 public class MakeFrame { | |
19 | |
20 int fSizeX = 800; | |
21 int fSizeY = 800; | |
22 private Canvas3D canvas; | |
23 private SimpleUniverse universe; | |
24 private KeyInput key; | |
25 | |
26 public MakeFrame(){ | |
27 JFrame frame = new JFrame(); | |
28 frame.setSize(fSizeX,fSizeY); | |
29 frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); | |
30 | |
31 JPanel cp = new JPanel(); | |
32 cp.setLayout(null); | |
33 frame.add(cp); | |
34 | |
35 GraphicsConfiguration config = SimpleUniverse.getPreferredConfiguration(); | |
36 canvas = new Canvas3D(config); | |
37 canvas.setBounds(0,0,fSizeX,fSizeY); | |
38 cp.add(canvas); | |
39 | |
40 universe = new SimpleUniverse(canvas); | |
41 universe.addBranchGraph(createLight()); | |
42 | |
43 key = new KeyInput(); | |
44 canvas.addKeyListener(key); | |
45 | |
46 frame.setVisible(true); | |
47 | |
48 ViewingPlatform camera = universe.getViewingPlatform(); | |
49 camera.setNominalViewingTransform(); | |
50 } | |
51 | |
52 private BranchGroup createLight(){ | |
53 BranchGroup scene = new BranchGroup(); | |
54 Color3f light_color = new Color3f(1.7f,1.7f,1.7f); | |
55 Vector3f light_direction = new Vector3f(0.2f,-0.2f,-0.6f); | |
56 DirectionalLight light = new DirectionalLight(light_color,light_direction); | |
57 BoundingSphere bounds = new BoundingSphere(); | |
58 light.setInfluencingBounds(bounds); | |
59 scene.addChild(light); | |
60 return scene; | |
61 } | |
62 | |
63 public void register(BranchGroup group){ | |
64 this.universe.addBranchGraph(group); | |
65 } | |
66 | |
67 public Canvas3D getCanvas(){ | |
68 return this.canvas; | |
69 } | |
70 | |
71 public KeyInput getKey(){ | |
72 return this.key; | |
73 } | |
74 | |
75 public SimpleUniverse getUniverse(){ | |
76 return this.universe; | |
77 } | |
78 | |
79 } |