changeset 89:e269cedd8bae working

Test two fish
author sugi
date Tue, 05 Jun 2012 00:01:27 +0900
parents 33a19ca88e43
children 75aa139d46eb
files src/alice/test/topology/movement/CheckMyName.java src/alice/test/topology/movement/MakeFrame.java src/alice/test/topology/movement/MakeObject.java src/alice/test/topology/movement/checkLocation.java
diffstat 4 files changed, 28 insertions(+), 28 deletions(-) [+]
line wrap: on
line diff
--- a/src/alice/test/topology/movement/CheckMyName.java	Mon Jun 04 16:08:53 2012 +0900
+++ b/src/alice/test/topology/movement/CheckMyName.java	Tue Jun 05 00:01:27 2012 +0900
@@ -24,15 +24,23 @@
 		if (type.equals("cli")){
 			System.out.println("cli"+cliNum);
 			MakeFrame frame =  new MakeFrame();
-			MakeObject obj = null;
-			checkLocation cs = new checkLocation(frame,obj);
+			MakeObject obj = new MakeObject(frame);
+			frame.register(obj);
+			checkLocation cs = new checkLocation(obj,"fish1X");
 			cs.host.setKey("local","host");
 			cs.nowX.setKey("parent","fish1X");
 						
+			MakeObject obj2 = new MakeObject(frame);
+			frame.register(obj2);
+			checkLocation cs2 = new checkLocation(obj2,"fish2X");
+			cs2.host.setKey("local","host");
+			cs2.nowX.setKey("parent","fish2X");
+			
 					
 		}else if(type.equals("node")){
 			System.out.println("node0");
 			ods.update("local", "fish1X", -1000);
+			ods.update("local", "fish2X", -1000);
 			
 		}
 	}
--- a/src/alice/test/topology/movement/MakeFrame.java	Mon Jun 04 16:08:53 2012 +0900
+++ b/src/alice/test/topology/movement/MakeFrame.java	Tue Jun 05 00:01:27 2012 +0900
@@ -60,7 +60,8 @@
 		return scene;
 	}
 	
-	public void register(BranchGroup group){
+	public void register(MakeObject obj){
+		BranchGroup group = obj.createBranch();
 		this.universe.addBranchGraph(group);
 	}
 	
--- a/src/alice/test/topology/movement/MakeObject.java	Mon Jun 04 16:08:53 2012 +0900
+++ b/src/alice/test/topology/movement/MakeObject.java	Tue Jun 05 00:01:27 2012 +0900
@@ -24,15 +24,12 @@
 	private Canvas3D canvas;
 	private KeyInput key;
 	
-	public MakeObject(Canvas3D C){
-		this.canvas = C;
+	public MakeObject(MakeFrame MF){
+		this.canvas = MF.getCanvas();
+		this.key = MF.getKey();
 	}
 	
-	public MakeObject(Canvas3D C,KeyInput K){
-		this.canvas = C;
-		this.key = K;
-	}
-	
+		
 	public BranchGroup createBranch(){
 		BranchGroup scene = new BranchGroup();
 		Box box = new Box(0.1f,0.1f,0.0f,
@@ -42,6 +39,7 @@
 		transform_group.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
 		transform_group.addChild(box);
 		scene.addChild(transform_group);
+		setLocation(-10,0);//default position
 		
 		
 		/*
--- a/src/alice/test/topology/movement/checkLocation.java	Mon Jun 04 16:08:53 2012 +0900
+++ b/src/alice/test/topology/movement/checkLocation.java	Tue Jun 05 00:01:27 2012 +0900
@@ -12,13 +12,14 @@
 	
 	public Receiver nowX = ids.create(CommandType.PEEK);
 	public Receiver host = ids.create(CommandType.PEEK);
-	public MakeFrame frame;
-	public MakeObject obj;
+	MakeFrame frame;
+	MakeObject obj;
 	Pattern pattern = Pattern.compile("^(cli)([0-9]+)$");
+	String myKey;
 	
-	public checkLocation(MakeFrame MF , MakeObject MO){
-		this.frame = MF;
+	public checkLocation(MakeObject MO ,String str){
 		this.obj = MO;
+		this.myKey = str;
 	}
 	
 	@Override
@@ -31,24 +32,16 @@
 		float startX = 2*num - 3.0f;
 		float endX = 2*num -0.9f;
 		float x = (float)this.nowX.asInteger()/1000;
-		System.out.println("now position is :" + x);
-		if (startX < x && x < endX){
-			obj.setLocation(x - 2*(num-1), 0);
-			ods.update("parent", "fish1X", this.nowX.asInteger()+1);
-			
-		} else if(startX == x){
-			this.obj = new MakeObject(frame.getCanvas());
-			frame.register(obj.createBranch());
-			ods.update("parent", "fish1X", this.nowX.asInteger()+1);
-			
-		} else if(endX == x){
-			System.out.println("out of range");
+		System.out.println(myKey+": " + x);
+		if (startX <= x && x < endX){
+			obj.setLocation(x - 2*(num-1), 0.1f*num);
+			ods.update("parent", myKey, this.nowX.asInteger()+1);
 		}
 		
 		
-		checkLocation cs = new checkLocation(this.frame,this.obj);
+		checkLocation cs = new checkLocation(this.obj,this.myKey);
+		cs.nowX.setKey("parent",myKey);
 		cs.host.setKey("local","host");
-		cs.nowX.setKey("parent","fish1X",this.nowX.index);