Mercurial > hg > Members > tatsuki > Alice
changeset 170:6a69891b7232 working
change view point
author | sugi |
---|---|
date | Thu, 27 Dec 2012 14:38:42 +0900 |
parents | 16418c2c3e72 |
children | 88cc33eeafa6 23d6a775a643 |
files | src/alice/datasegment/DataSegment.java src/alice/datasegment/DataSegmentManager.java src/alice/test/topology/aquarium/CheckMyName.java src/alice/test/topology/aquarium/MakeFrame.java src/alice/test/topology/aquarium/MakeObject.java src/alice/test/topology/aquarium/RefreshWindow.java src/alice/test/topology/aquarium/SetLocation.java src/alice/test/topology/aquarium/TakeMynum.java src/alice/test/topology/aquarium/ViewChange.java |
diffstat | 9 files changed, 38 insertions(+), 26 deletions(-) [+] |
line wrap: on
line diff
--- a/src/alice/datasegment/DataSegment.java Tue Dec 18 14:49:36 2012 +0900 +++ b/src/alice/datasegment/DataSegment.java Thu Dec 27 14:38:42 2012 +0900 @@ -8,7 +8,7 @@ private static DataSegment dataSegment = new DataSegment(); private LocalDataSegmentManager local = new LocalDataSegmentManager(); - private ConcurrentHashMap<String, DataSegmentManager> dataSegmentManageres = new ConcurrentHashMap<String, DataSegmentManager>(); + private ConcurrentHashMap<String, DataSegmentManager> dataSegmentManageres = new ConcurrentHashMap<String, DataSegmentManager>(); //TODO Over Head private ConcurrentHashMap<String, IncomingTcpConnection> acceptHash = new ConcurrentHashMap<String, IncomingTcpConnection>(); private DataSegment() {
--- a/src/alice/datasegment/DataSegmentManager.java Tue Dec 18 14:49:36 2012 +0900 +++ b/src/alice/datasegment/DataSegmentManager.java Thu Dec 27 14:38:42 2012 +0900 @@ -11,7 +11,7 @@ public abstract class DataSegmentManager { - protected ConcurrentHashMap<Integer, Command> seqHash = new ConcurrentHashMap<Integer, Command>(); + protected ConcurrentHashMap<Integer, Command> seqHash = new ConcurrentHashMap<Integer, Command>(); //TODO Over Head protected LinkedBlockingQueue<Command> replyQueue = new LinkedBlockingQueue<Command>(); protected AtomicInteger seq = new AtomicInteger(1);
--- a/src/alice/test/topology/aquarium/CheckMyName.java Tue Dec 18 14:49:36 2012 +0900 +++ b/src/alice/test/topology/aquarium/CheckMyName.java Thu Dec 27 14:38:42 2012 +0900 @@ -1,5 +1,6 @@ package alice.test.topology.aquarium; +import java.util.Random; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -26,8 +27,8 @@ matcher.find(); String type = matcher.group(1); int num = new Integer(matcher.group(2)); - - MakeFrame frame = new MakeFrame(name); + ods.put("local", "host_num", num*2); + MakeFrame frame = new MakeFrame(name,num*2); RoutingTable routing = new RoutingTable(); ods.put("local", "num", 1); @@ -68,7 +69,10 @@ for (int i = 3; i < 6 ; i++){ key = "fish"+i; if (num == 0) new AutoIncrement(key,0); - ods.update("local", key, new FishPoint(-(float)Math.random(), + Random rnd = new Random(); + int tmp = rnd.nextInt(3); + int rand = tmp + 1; + ods.update("local", key, new FishPoint( (float)rand, -(float)Math.random(), -(float)Math.random())); new SetLocation(new MakeObject(frame), key, 0, num); new CheckLocalIndex(key,1); @@ -77,7 +81,10 @@ for (int i = 6; i < 9 ; i++){ key = "fish"+i; if (num == 0) new AutoIncrement(key,0); - ods.update("local", key, new FishPoint(-(float)Math.random(), + Random rnd = new Random(); + int tmp = rnd.nextInt(3); + int rand = tmp + 3; + ods.update("local", key, new FishPoint( (float)rand, (float)Math.random(), -(float)Math.random())); new SetLocation(new MakeObject(frame), key, 0, num); new CheckLocalIndex(key,1); @@ -86,7 +93,12 @@ for (int i = 9; i < 12 ; i++){ key = "fish"+i; if (num == 0) new AutoIncrement(key,0); - ods.update("local", key, new FishPoint(-(float)Math.random(), + + Random rnd = new Random(); + int tmp = rnd.nextInt(3); + int rand = tmp + 5; + + ods.update("local", key, new FishPoint( (float)rand, -(float)Math.random(), (float)Math.random())); new SetLocation(new MakeObject(frame), key, 0, num); new CheckLocalIndex(key,1);
--- a/src/alice/test/topology/aquarium/MakeFrame.java Tue Dec 18 14:49:36 2012 +0900 +++ b/src/alice/test/topology/aquarium/MakeFrame.java Thu Dec 27 14:38:42 2012 +0900 @@ -28,7 +28,7 @@ private JFrame frame; private ObjectList list = new ObjectList(); - public MakeFrame(String str){ + public MakeFrame(String str,float x){ frame = new JFrame(str); frame.setSize(fSizeX,fSizeY); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); @@ -38,7 +38,7 @@ frame.add(cp); GraphicsConfiguration config = SimpleUniverse.getPreferredConfiguration(); - canvas = new ViewChange(3.0f,0.01f,config); + canvas = new ViewChange(x,0.01f,config); canvas.setBounds(0,0,fSizeX,fSizeY); cp.add(canvas); @@ -63,7 +63,7 @@ new ImageComponent2D(ImageComponent2D.FORMAT_RGBA8,img); Background background = new Background(image); background.setImageScaleMode(Background.SCALE_FIT_ALL); - BoundingSphere bounds = new BoundingSphere(new Point3d(0.0, 0.0, 0.0), Double.POSITIVE_INFINITY); + BoundingSphere bounds = new BoundingSphere(new Point3d(), 10.0); background.setApplicationBounds(bounds); scene.addChild(background); return scene; @@ -73,9 +73,9 @@ private BranchGroup createLight(){ BranchGroup scene = new BranchGroup(); Color3f light_color = new Color3f(1.7f,1.7f,1.7f); - Vector3f light_direction = new Vector3f(0.2f,-0.2f,-0.6f); + Vector3f light_direction = new Vector3f(0.0f,0.0f,-1.0f); DirectionalLight light = new DirectionalLight(light_color,light_direction); - BoundingSphere bounds = new BoundingSphere(); + BoundingSphere bounds = new BoundingSphere(new Point3d(), 10.0); light.setInfluencingBounds(bounds); scene.addChild(light); return scene; @@ -85,7 +85,6 @@ list.table.add(obj); BranchGroup group = obj.createBranch(); this.canvas.universe.addBranchGraph(group); - } public ViewChange getCanvas(){
--- a/src/alice/test/topology/aquarium/MakeObject.java Tue Dec 18 14:49:36 2012 +0900 +++ b/src/alice/test/topology/aquarium/MakeObject.java Thu Dec 27 14:38:42 2012 +0900 @@ -27,7 +27,7 @@ private ViewChange canvas; private Matrix4d matrix; private double s; - + public MakeObject(MakeFrame frame){ this.canvas = frame.getCanvas(); @@ -63,12 +63,13 @@ return scene; } + // no use method public Appearance createAppearance(){ Appearance app = new Appearance(); Image image = null; Toolkit toolkit = Toolkit.getDefaultToolkit(); - //image = toolkit.getImage("image/fish.jpg"); - image = toolkit.getImage("../image/fish.jpg"); // jar + URL url = getClass().getClassLoader().getResource("fish.jpg"); + image = toolkit.getImage(url); MediaTracker mt = new MediaTracker(canvas); mt.addImage(image, 0); mt.checkAll(true);
--- a/src/alice/test/topology/aquarium/RefreshWindow.java Tue Dec 18 14:49:36 2012 +0900 +++ b/src/alice/test/topology/aquarium/RefreshWindow.java Thu Dec 27 14:38:42 2012 +0900 @@ -8,7 +8,7 @@ private MakeFrame frame; public RefreshWindow(MakeFrame frame){ - this.host.setKey("local","host"); + this.host.setKey("local","host_num"); this.frame = frame; } @@ -17,7 +17,7 @@ frame.getJFrame().dispose(); ObjectList list = frame.getList(); - frame = new MakeFrame(this.host.asString()); + frame = new MakeFrame(this.host.asString(),host.asInteger()); for (MakeObject obj : list.table) { this.frame.register(obj); }
--- a/src/alice/test/topology/aquarium/SetLocation.java Tue Dec 18 14:49:36 2012 +0900 +++ b/src/alice/test/topology/aquarium/SetLocation.java Thu Dec 27 14:38:42 2012 +0900 @@ -22,7 +22,7 @@ @Override public void run(){ FishPoint fp = this.position.asClass(FishPoint.class); - obj.setLocation(fp.getX() - 2*range, fp.getY(), fp.getZ()); + obj.setLocation(fp.getX(), fp.getY(), fp.getZ()); new SetLocation(this.obj, this.key, this.position.index, this.range); }
--- a/src/alice/test/topology/aquarium/TakeMynum.java Tue Dec 18 14:49:36 2012 +0900 +++ b/src/alice/test/topology/aquarium/TakeMynum.java Thu Dec 27 14:38:42 2012 +0900 @@ -5,7 +5,6 @@ import alice.datasegment.Receiver; public class TakeMynum extends CodeSegment { - // this CodeSegment has bug private Receiver mynum = ids.create(CommandType.TAKE);
--- a/src/alice/test/topology/aquarium/ViewChange.java Tue Dec 18 14:49:36 2012 +0900 +++ b/src/alice/test/topology/aquarium/ViewChange.java Thu Dec 27 14:38:42 2012 +0900 @@ -10,10 +10,10 @@ private static final long serialVersionUID = 1L; float sensitivity; - float distance; + float distance = 2.5f; float camera_x, camera_y, camera_z, camera_xz, camera_xy, camera_yz = 0; - float phi = 0;//(float)Math.PI; - float theta = (float)Math.PI/3; + float phi = 0; // flow + float theta = 0; SimpleUniverse universe; TransformGroup Camera; @@ -22,9 +22,9 @@ Transform3D Transform_camera_theta; Vector3f Vector_camera_pos; - public ViewChange(float Distance, float Sensitivity, GraphicsConfiguration config){ + public ViewChange(float x, float Sensitivity, GraphicsConfiguration config){ super(config); - distance = Distance; + sensitivity = Sensitivity; universe = new SimpleUniverse(this); ViewingPlatform vp = universe.getViewingPlatform(); @@ -32,7 +32,8 @@ camera_y = distance * (float)Math.sin(theta); camera_xz = distance * (float)Math.cos(theta); - camera_x = camera_xz * (float)Math.sin(phi); + System.out.println(x); + camera_x = x; camera_z = camera_xz * (float)Math.cos(phi); Vector_camera_pos = new Vector3f(camera_x, camera_y, camera_z);