/*
* Datei: PhysicsMaster.java
* Autor(en): Lukas König
* Java-Version: 6.0
* Erstellt: ??.07.2010
*
* (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.physics2DB;
import eas.math.geometry.Vector2D;
import eas.plugins.PluginProperties;
import eas.plugins.masterScheduler.AbstractDefaultMaster;
import eas.simulation.spatial.sim2D.physicalSimulation.physicsEngine.ForceSource;
import eas.simulation.spatial.sim2D.physicalSimulation.physicsEngine.net.phys2d.math.Vector2f;
import eas.simulation.spatial.sim2D.physicalSimulation.standardAgents.PhysicsAgent2D;
import eas.simulation.spatial.sim2D.physicalSimulation.standardAgents.StaticBody;
import eas.simulation.spatial.sim2D.physicalSimulation.standardEnvironments.PhysicsEnvironment2D;
import eas.startSetup.ParCollection;
import eas.users.demos.physics2DA.PhysicsAgent2;
/**
* @author Lukas König
*
*/
@PluginProperties(pluginIsHidden = false)
public class PhysicsMaster extends AbstractDefaultMaster<PhysicsEnvironment2D<PhysicsAgent2D<?>>> {
/**
*
*/
private static final long serialVersionUID = -3632326612508014982L;
@Override
public PhysicsEnvironment2D<PhysicsAgent2D<?>>[] generateRunnables(ParCollection params) {
@SuppressWarnings("unchecked")
PhysicsEnvironment2D<PhysicsAgent2D<?>>[] envs = new PhysicsEnvironment2D[1];
PhysicsEnvironment2D<PhysicsAgent2D<?>> env = new PhysicsEnvironment2D<PhysicsAgent2D<?>>(0, params, new Vector2f(0, 0), 500);
envs[0] = env;
for (int i = 0; i < 200; i += 30) {
for (int j = 0; j < 200; j += 30) {
env.addAgent(new PhysicsAgent2(j * 10 + i, env, 5, params), new Vector2D(i, j), 0);
}
}
PhysicsAgent3 p = new PhysicsAgent3(10000, env, 200, params);
env.addAgent(p, new Vector2D(-200, 100), 0);
// p.adjustVelocity(new Vector2f(100, 0));
env.addAgent(new StaticBody(10001, env, params), new Vector2D(10, -80), 0);
env.addAgent(new StaticBody(10002, env, params), new Vector2D(125, -80), 0);
env.addAgent(new StaticBody(10003, env, params), new Vector2D(250, -80), 0);
env.addAgent(new StaticBody(10004, env, params), new Vector2D(10, 250), 0);
env.addAgent(new StaticBody(10005, env, params), new Vector2D(125, 250), 0);
env.addAgent(new StaticBody(10006, env, params), new Vector2D(250, 250), 0);
env.addAgent(new StaticBody(10007, env, params), new Vector2D(325, -40), 90);
env.addAgent(new StaticBody(10008, env, params), new Vector2D(325, 85), 90);
env.addAgent(new StaticBody(10009, env, params), new Vector2D(325, 210), 90);
env.add(new ForceSource<PhysicsAgent2D<?>>() {
private static final long serialVersionUID = 7669888473552046204L;
@Override
public void apply(PhysicsAgent2D<?> body, float dt) {
if (body.id() == 10000) {
body.addForce(new Vector2f(3500, -150));
}
}
});
return envs;
}
@Override
public String id() {
return eas.simulation.ConstantsSimulation.DEFAULT_MASTER_SCHEDULER_ID + "-lp";
}
}