changeset 114:7dbaaa0de144 working

remove vector3f and add Matrix4d
author sugi
date Wed, 18 Jul 2012 20:40:50 +0900
parents 52156e4517b1
children 9845b74063ec
files scripts/fishAlpha_run.sh src/alice/test/topology/fishmodel/alpha/AutoIncrement.java src/alice/test/topology/fishmodel/alpha/FishPoint.java src/alice/test/topology/fishmodel/alpha/MakeObject.java src/alice/test/topology/fishmodel/alpha/SetLocation.java src/alice/test/topology/fishmodel/beta/CheckMyName.java
diffstat 6 files changed, 45 insertions(+), 38 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/fishAlpha_run.sh	Wed Jul 18 11:06:22 2012 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,15 +0,0 @@
-#!/bin/bash
-max=$1
-child_num=$2
-ruby ./topology/treen.rb $1 $2 > ./topology/tree.dot
-#dot -Tpng ./topology/tree.dot > ./topology/tree.png
-#open ./topology/tree.png
-java -cp ../Alice.jar alice.topology.manager.TopologyManager -p 10000 -conf ./topology/tree.dot -log ./output/manager.log -level debug > ./output/std_manager.log &
-
-cnt=0
-while [ $cnt -lt $max ]
-do
-    java -cp ../Alice.jar alice.test.topology.fishmodel.alpha.FishMovementTopology -host `hostname` -port 10000 -p `expr 20000 + $cnt` -log ./output/modelalpha${cnt}.log -level debug > ./output/std_modelalpha${cnt}.log &
-    cnt=`expr $cnt + 1`
-done
-wait
--- a/src/alice/test/topology/fishmodel/alpha/AutoIncrement.java	Wed Jul 18 11:06:22 2012 +0900
+++ b/src/alice/test/topology/fishmodel/alpha/AutoIncrement.java	Wed Jul 18 20:40:50 2012 +0900
@@ -17,16 +17,11 @@
 	}
 
 	@Override
-	public synchronized void run() {
+	public void run() {
 		FishPoint FP = this.position.asClass(FishPoint.class);
 		FP.setXY(FP.getX()+0.01f, FP.getY());
 		ods.update("local", key, FP);
-		try {
-			wait(500);
-		} catch (InterruptedException e) {
-			// TODO Auto-generated catch block
-			e.printStackTrace();
-		}
+		
 		new AutoIncrement(this.key,this.position.index);
 		
 	}
--- a/src/alice/test/topology/fishmodel/alpha/FishPoint.java	Wed Jul 18 11:06:22 2012 +0900
+++ b/src/alice/test/topology/fishmodel/alpha/FishPoint.java	Wed Jul 18 20:40:50 2012 +0900
@@ -5,8 +5,10 @@
 @Message
 public class FishPoint {
 	// public fields are serialized.
-	public float x = 0;
-	public float y = 0;
+	public float x = 0.0f;
+	public float y = 0.0f;
+	public float z = 0.0f;
+	public String vector = "light"; 
 	
 	public FishPoint(){}
 	
@@ -15,18 +17,23 @@
 		this.y = y;
 	}
 	
-	public void setX(float x){
+	public FishPoint(float x,float y,float z){
 		this.x = x;
-	}
-	
-	public void setY(float y){
 		this.y = y;
+		this.z = z;
 	}
 	
 	public void setXY(float x,float y){
 		this.x = x;
 		this.y = y;
 	}
+	
+	public void setXYZ(float x,float y,float z){
+		this.x = x;
+		this.y = y;
+		this.z = z;
+	}
+	
 	public float getX(){
 		return this.x;
 	}
@@ -35,6 +42,12 @@
 		return this.y;
 	}
 	
+	public float getZ(){
+		return this.z;
+	}
 	
+	public String getVector(){
+		return this.vector;
+	}
 
 }
--- a/src/alice/test/topology/fishmodel/alpha/MakeObject.java	Wed Jul 18 11:06:22 2012 +0900
+++ b/src/alice/test/topology/fishmodel/alpha/MakeObject.java	Wed Jul 18 20:40:50 2012 +0900
@@ -11,7 +11,7 @@
 import javax.media.j3d.Texture;
 import javax.media.j3d.Transform3D;
 import javax.media.j3d.TransformGroup;
-import javax.vecmath.Vector3d;
+import javax.vecmath.Matrix4d;
 import javax.vecmath.Vector3f;
 
 import com.sun.j3d.loaders.IncorrectFormatException;
@@ -27,6 +27,9 @@
 	private Transform3D transform;  
 	private TransformGroup transform_group;
 	private Canvas3D canvas;
+	private Matrix4d matrix;
+	private double s = 0.3;
+	
 	
 	public MakeObject(MakeFrame MF){
 		this.canvas = MF.getCanvas();
@@ -38,9 +41,9 @@
 		/*Box box = new Box(0.1f,0.1f,0.0f,
 				Box.GENERATE_NORMALS|Box.GENERATE_TEXTURE_COORDS,createAppearance());*/
 		ObjectFile obj = new ObjectFile(ObjectFile.RESIZE);
-		Scene S = null;
+		Scene img = null;
 		try{
-			S = obj.load("../image/TUNA");
+			img = obj.load("../image/TUNA");
 		} catch(FileNotFoundException e){
 			System.err.println(e);
 			System.exit(1);
@@ -54,7 +57,7 @@
 		
 		transform_group = new TransformGroup();
 		transform_group.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
-		transform_group.addChild(S.getSceneGroup());
+		transform_group.addChild(img.getSceneGroup());
 		scene.addChild(transform_group);
 		return scene;		
 	}
@@ -81,19 +84,27 @@
 		
 	}
 	
+	
 	public void setLocation(float x,float y){
 		transform = new Transform3D();
-		vector = new Vector3f(x,y,0.0f);
-		transform.setTranslation(vector);
-		transform.setScale(new Vector3d(0.3d, 0.3d, 0.3d));
+		matrix = new Matrix4d(s,0,0,x,
+							  0,s,0,y,
+							  0,0,s,0,
+							  0,0,0,1);
+		transform.set(matrix);
 		transform_group.setTransform(transform);
 	}
 	
 	public void setLocation(float x,float y,float z){
 		transform = new Transform3D();
-		vector = new Vector3f(x,y,z);
-		transform.setTranslation(vector);
+		matrix = new Matrix4d(s,0,0,x,
+				  			  0,s,0,y,
+				  			  0,0,s,z,
+				  			  0,0,0,1);
+		transform.set(matrix);
 		transform_group.setTransform(transform);
 	}
+	
+	
 }
 
--- a/src/alice/test/topology/fishmodel/alpha/SetLocation.java	Wed Jul 18 11:06:22 2012 +0900
+++ b/src/alice/test/topology/fishmodel/alpha/SetLocation.java	Wed Jul 18 20:40:50 2012 +0900
@@ -10,6 +10,7 @@
 	private Receiver position = ids.create(CommandType.PEEK);
 	MakeObject obj;
 	String key;
+	String vector;
 	int range;
 	
 	public SetLocation(MakeObject MO ,String key,int index,int range){
@@ -24,6 +25,7 @@
 		
 		FishPoint FP = this.position.asClass(FishPoint.class);
 		obj.setLocation(FP.getX() - 2*range, FP.getY());
+		
 		/*
 		float startX = 2*range - 1;
 		float endX = 2*range + 1;
--- a/src/alice/test/topology/fishmodel/beta/CheckMyName.java	Wed Jul 18 11:06:22 2012 +0900
+++ b/src/alice/test/topology/fishmodel/beta/CheckMyName.java	Wed Jul 18 20:40:50 2012 +0900
@@ -57,13 +57,14 @@
 		new SetLocation(new MakeObject(frame),key,0,num);
 		new CheckLocalIndex(key,1);
 		
-		for (int i = 0;i < 5 ; i++){
+		for (int i = 0;i < 3 ; i++){
 			key = "fish"+i;
 			if (num == 0) new AutoIncrement(key,0);
 			ods.update("local", key, new FishPoint(0.2f*i,0.2f*i));
 			new SetLocation(new MakeObject(frame),key,0,num);
 			new CheckLocalIndex(key,1);
 		}
+		
 		/*
 		for (int i = 6;i < 10 ; i++){
 			key = "fish"+i;