Mercurial > hg > Members > tatsuki > Alice
changeset 91:19f3bd33277d working
add KeyInput
author | sugi |
---|---|
date | Tue, 05 Jun 2012 00:35:58 +0900 |
parents | 75aa139d46eb |
children | 8e3c1217aad4 |
files | src/alice/test/topology/movement/CheckFishLocation.java src/alice/test/topology/movement/CheckMyName.java src/alice/test/topology/movement/MakeObject.java |
diffstat | 3 files changed, 62 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/alice/test/topology/movement/CheckFishLocation.java Tue Jun 05 00:35:58 2012 +0900 @@ -0,0 +1,48 @@ +package alice.test.topology.movement; + +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import alice.codesegment.CodeSegment; +import alice.datasegment.CommandType; +import alice.datasegment.Receiver; + + +public class CheckFishLocation extends CodeSegment{ + + public Receiver nowX = ids.create(CommandType.PEEK); + public Receiver host = ids.create(CommandType.PEEK); + MakeFrame frame; + MakeObject obj; + Pattern pattern = Pattern.compile("^(cli)([0-9]+)$"); + String myKey; + + public CheckFishLocation(MakeObject MO ,String str){ + this.obj = MO; + this.myKey = str; + } + + @Override + public void run(){ + String name = host.asString(); + Matcher matcher = pattern.matcher(name); + matcher.find(); + int num = new Integer(matcher.group(2)); + + float startX = 2*num - 3.0f; + float endX = 2*num -0.9f; + float x = (float)this.nowX.asInteger()/1000; + 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); + } + + CheckFishLocation cs = new CheckFishLocation(this.obj,this.myKey); + cs.nowX.setKey("parent",myKey,this.nowX.index); + cs.host.setKey("local","host"); + + } + + +}
--- a/src/alice/test/topology/movement/CheckMyName.java Tue Jun 05 00:26:13 2012 +0900 +++ b/src/alice/test/topology/movement/CheckMyName.java Tue Jun 05 00:35:58 2012 +0900 @@ -26,13 +26,13 @@ MakeFrame frame = new MakeFrame(); MakeObject obj = new MakeObject(frame); frame.register(obj); - checkLocation cs = new checkLocation(obj,"fish1X"); + CheckFishLocation cs = new CheckFishLocation(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"); + CheckFishLocation cs2 = new CheckFishLocation(obj2,"fish2X"); cs2.host.setKey("local","host"); cs2.nowX.setKey("parent","fish2X");
--- a/src/alice/test/topology/movement/MakeObject.java Tue Jun 05 00:26:13 2012 +0900 +++ b/src/alice/test/topology/movement/MakeObject.java Tue Jun 05 00:35:58 2012 +0900 @@ -30,23 +30,26 @@ } + public BranchGroup createKeyBranch(){ + BranchGroup scene = new BranchGroup(); + Box box = new Box(0.1f,0.1f,0.0f, + Box.GENERATE_NORMALS|Box.GENERATE_TEXTURE_COORDS,createAppearance()); + key.transformGroup.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); + key.transformGroup.addChild(box); + scene.addChild(key.transformGroup); + return scene; + + } + public BranchGroup createBranch(){ BranchGroup scene = new BranchGroup(); Box box = new Box(0.1f,0.1f,0.0f, - Box.GENERATE_NORMALS|Box.GENERATE_TEXTURE_COORDS,createAppearance()); - + Box.GENERATE_NORMALS|Box.GENERATE_TEXTURE_COORDS,createAppearance()); transform_group = new TransformGroup(); transform_group.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); transform_group.addChild(box); scene.addChild(transform_group); setLocation(-10,0);//default position - - - /* - key.transformGroup.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); - key.transformGroup.addChild(box); - scene.addChild(key.transformGroup); - */ return scene; }