Mercurial > hg > Members > tatsuki > Alice
comparison src/alice/test/topology/aquarium/MakeFrame.java @ 170:6a69891b7232 working
change view point
author | sugi |
---|---|
date | Thu, 27 Dec 2012 14:38:42 +0900 |
parents | 36dc63d1bdcf |
children | 23d6a775a643 |
comparison
equal
deleted
inserted
replaced
169:16418c2c3e72 | 170:6a69891b7232 |
---|---|
26 private int fSizeY = 800; | 26 private int fSizeY = 800; |
27 private ViewChange canvas; | 27 private ViewChange canvas; |
28 private JFrame frame; | 28 private JFrame frame; |
29 private ObjectList list = new ObjectList(); | 29 private ObjectList list = new ObjectList(); |
30 | 30 |
31 public MakeFrame(String str){ | 31 public MakeFrame(String str,float x){ |
32 frame = new JFrame(str); | 32 frame = new JFrame(str); |
33 frame.setSize(fSizeX,fSizeY); | 33 frame.setSize(fSizeX,fSizeY); |
34 frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); | 34 frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); |
35 | 35 |
36 JPanel cp = new JPanel(); | 36 JPanel cp = new JPanel(); |
37 cp.setLayout(null); | 37 cp.setLayout(null); |
38 frame.add(cp); | 38 frame.add(cp); |
39 | 39 |
40 GraphicsConfiguration config = SimpleUniverse.getPreferredConfiguration(); | 40 GraphicsConfiguration config = SimpleUniverse.getPreferredConfiguration(); |
41 canvas = new ViewChange(3.0f,0.01f,config); | 41 canvas = new ViewChange(x,0.01f,config); |
42 canvas.setBounds(0,0,fSizeX,fSizeY); | 42 canvas.setBounds(0,0,fSizeX,fSizeY); |
43 cp.add(canvas); | 43 cp.add(canvas); |
44 | 44 |
45 canvas.universe.addBranchGraph(createLight()); | 45 canvas.universe.addBranchGraph(createLight()); |
46 canvas.universe.addBranchGraph(setBackground()); | 46 canvas.universe.addBranchGraph(setBackground()); |
61 } | 61 } |
62 ImageComponent2D image = | 62 ImageComponent2D image = |
63 new ImageComponent2D(ImageComponent2D.FORMAT_RGBA8,img); | 63 new ImageComponent2D(ImageComponent2D.FORMAT_RGBA8,img); |
64 Background background = new Background(image); | 64 Background background = new Background(image); |
65 background.setImageScaleMode(Background.SCALE_FIT_ALL); | 65 background.setImageScaleMode(Background.SCALE_FIT_ALL); |
66 BoundingSphere bounds = new BoundingSphere(new Point3d(0.0, 0.0, 0.0), Double.POSITIVE_INFINITY); | 66 BoundingSphere bounds = new BoundingSphere(new Point3d(), 10.0); |
67 background.setApplicationBounds(bounds); | 67 background.setApplicationBounds(bounds); |
68 scene.addChild(background); | 68 scene.addChild(background); |
69 return scene; | 69 return scene; |
70 | 70 |
71 } | 71 } |
72 | 72 |
73 private BranchGroup createLight(){ | 73 private BranchGroup createLight(){ |
74 BranchGroup scene = new BranchGroup(); | 74 BranchGroup scene = new BranchGroup(); |
75 Color3f light_color = new Color3f(1.7f,1.7f,1.7f); | 75 Color3f light_color = new Color3f(1.7f,1.7f,1.7f); |
76 Vector3f light_direction = new Vector3f(0.2f,-0.2f,-0.6f); | 76 Vector3f light_direction = new Vector3f(0.0f,0.0f,-1.0f); |
77 DirectionalLight light = new DirectionalLight(light_color,light_direction); | 77 DirectionalLight light = new DirectionalLight(light_color,light_direction); |
78 BoundingSphere bounds = new BoundingSphere(); | 78 BoundingSphere bounds = new BoundingSphere(new Point3d(), 10.0); |
79 light.setInfluencingBounds(bounds); | 79 light.setInfluencingBounds(bounds); |
80 scene.addChild(light); | 80 scene.addChild(light); |
81 return scene; | 81 return scene; |
82 } | 82 } |
83 | 83 |
84 public void register(MakeObject obj){ | 84 public void register(MakeObject obj){ |
85 list.table.add(obj); | 85 list.table.add(obj); |
86 BranchGroup group = obj.createBranch(); | 86 BranchGroup group = obj.createBranch(); |
87 this.canvas.universe.addBranchGraph(group); | 87 this.canvas.universe.addBranchGraph(group); |
88 | |
89 } | 88 } |
90 | 89 |
91 public ViewChange getCanvas(){ | 90 public ViewChange getCanvas(){ |
92 return this.canvas; | 91 return this.canvas; |
93 } | 92 } |