Mercurial > hg > Database > Alice
view src/main/java/alice/test/topology/aquarium/fx/CreateObject.java @ 390:e29cf08ad1f3 multicast
add CalculatePosition CodeSegment
author | sugi |
---|---|
date | Mon, 16 Jun 2014 21:45:43 +0900 |
parents | 56d4f93a3921 |
children | c0cf9fe00d77 |
line wrap: on
line source
package alice.test.topology.aquarium.fx; import javafx.beans.binding.When; import javafx.beans.property.BooleanProperty; import javafx.beans.property.SimpleBooleanProperty; import javafx.scene.Group; import javafx.scene.shape.DrawMode; import javafx.scene.shape.MeshView; import com.interactivemesh.jfx.importer.obj.ObjModelImporter; import alice.codesegment.CodeSegment; import alice.datasegment.CommandType; import alice.datasegment.Receiver; public class CreateObject extends CodeSegment{ private Receiver info = ids.create(CommandType.TAKE); private Receiver info1 = ids.create(CommandType.PEEK); public CreateObject(){ info.setKey("fishData"); info1.setKey("host"); } @Override public void run() { FishInfo fishInfo = info.asClass(FishInfo.class); String myName = info1.asString(); BooleanProperty showWireframe = new SimpleBooleanProperty(false); ObjModelImporter objImporter = new ObjModelImporter(); objImporter.read(getClass().getClassLoader().getResource("objects/Scooter-smgrps.obj")); MeshView[] dukeMesh = objImporter.getImport(); objImporter.close(); Group obj = new Group(); for (MeshView _dukeMesh : dukeMesh) { obj.getChildren().addAll(_dukeMesh); _dukeMesh.drawModeProperty().bind(new When(showWireframe).then(DrawMode.LINE).otherwise(DrawMode.FILL)); } obj.setScaleX(fishInfo.size); // twice size obj.setScaleY(fishInfo.size); obj.setScaleZ(fishInfo.size); obj.setId(fishInfo.name); if (myName.equals(fishInfo.name)){ new CalculatePosition(fishInfo.name); } new SetTranslate(fishInfo.name+"Fish"); ods.put("addOffer", obj); ods.put("register", fishInfo); new SendDataOthers(info, "fishData"); new CreateObject(); } }