/*
* File name: Phys3Master.java (package eas.simulation.users.lukas.lukesPhysics3)
* Author(s): aifb
* Java version: 6.0
* Generation date: 28.01.2011 (19:51:12)
*
* (c) This file and the EAS (Easy Agent Simulation) framework containing it
* is protected by Creative Commons by-nc-sa license. Any altered or
* further developed versions of this file have to meet the agreements
* stated by the license conditions.
*
* In a nutshell
* -------------
* You are free:
* - to Share -- to copy, distribute and transmit the work
* - to Remix -- to adapt the work
*
* Under the following conditions:
* - Attribution -- You must attribute the work in the manner specified by the
* author or licensor (but not in any way that suggests that they endorse
* you or your use of the work).
* - Noncommercial -- You may not use this work for commercial purposes.
* - Share Alike -- If you alter, transform, or build upon this work, you may
* distribute the resulting work only under the same or a similar license to
* this one.
*
* + Detailed license conditions (Germany):
* http://creativecommons.org/licenses/by-nc-sa/3.0/de/
* + Detailed license conditions (unported):
* http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en
*
* This header must be placed in the beginning of any version of this file.
*/
package eas.users.demos.rocketMan;
import eas.math.geometry.Vector2D;
import eas.plugins.masterScheduler.AbstractDefaultKeyEventMaster;
import eas.simulation.ConstantsSimulation;
import eas.simulation.Wink;
import eas.simulation.event.EASEvent;
import eas.simulation.spatial.sim2D.physicalSimulation.physicsEngine.FixedJoint;
import eas.simulation.spatial.sim2D.physicalSimulation.physicsEngine.Joint;
import eas.simulation.spatial.sim2D.physicalSimulation.physicsEngine.net.phys2d.math.Vector2f;
import eas.startSetup.ParCollection;
/**
* @author aifb
*
*/
public class Phys3MasterB extends AbstractDefaultKeyEventMaster<Phys3Env> {
/**
*
*/
private static final long serialVersionUID = 93877266810139320L;
private Joint j1, j2;
@Override
public Phys3Env[] generateRunnables(ParCollection params) {
Phys3Env[] envs = new Phys3Env[1];
final Phys3Env env = new Phys3Env(0, params, new Vector2f(0, 5), 1000);
envs[0] = env;
env.addAgent(new Phys3Agent(0, env, "Agent0", 10, params), new Vector2D(0, -5), 180);
env.addAgent(new Phys3JetAgent(1, env, "Agent1", 10, params), new Vector2D(-3, 1), 180);
env.addAgent(new Phys3JetAgent(2, env, "Agent2", 10, params), new Vector2D(3, 1), 180);
j1 = new FixedJoint(
env.getAgent(0),
env.getAgent(1));
j2 = new FixedJoint(
env.getAgent(0),
env.getAgent(2));
env.add(j1);
env.add(j2);
// env.addAgent(new StaticObstacleLong(100, env), new Vector2D(0, 1), 0);
env.addAgent(new StaticObstacleRound(101, env, params), new Vector2D(-50, -80), 0);
// ((Phys3Agent) env.getAgent(0)).setDamping(0.1f);
// ((Phys3Agent) env.getAgent(0)).setRotDamping(0.1f);
env.setPerfectFit(true);
return envs;
}
@Override
public synchronized void handleEvent(EASEvent e, Phys3Env env, Wink lastTick,
ParCollection params) {
super.handleEvent(e, env, lastTick, params);
if (e.getEventDescription().equals(ConstantsSimulation.KEY_EVENT_IDENTIFIER + "r") && !((StaticObstacleRound) env.getAgent(101)).gesperrt) {
env.remove(j1);
env.remove(j2);
env.removeAgent(0);
env.removeAgent(1);
env.removeAgent(2);
env.removeAgent(100);
env.removeAgent(101);
env.addAgent(new Phys3Agent(0, env, "Agent0", 10, params), new Vector2D(0, -5), 180);
env.addAgent(new Phys3JetAgent(1, env, "Agent1", 10, params), new Vector2D(-3, 1), 180);
env.addAgent(new Phys3JetAgent(2, env, "Agent2", 10, params), new Vector2D(3, 1), 180);
j1 = new FixedJoint(
env.getAgent(0),
env.getAgent(1));
j2 = new FixedJoint(
env.getAgent(0),
env.getAgent(2));
env.add(j1);
env.add(j2);
// env.addAgent(new StaticObstacleLong(100, env3), new Vector2D(0, 1), 0);
env.addAgent(new StaticObstacleRound(101, env, params), new Vector2D(-50, -80), 0);
env.setPerfectFit(true);
}
}
@Override
public String id() {
return ConstantsSimulation.DEFAULT_MASTER_SCHEDULER_ID + "-rocketB";
}
}