/*
* File name: PhysEnv.java (package eas.users.lukas.demos.lukesPhysics4)
* Author(s): Lukas König
* Java version: 6.0
* Generation date: 03.05.2012 (12:35:07)
*
* (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.physics2DC;
import eas.math.geometry.Vector2D;
import eas.plugins.standard.visualization.AllroundVideoPlugin;
import eas.simulation.Wink;
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.standardEnvironments.PhysicsEnvironment2D;
import eas.startSetup.ParCollection;
/**
* @author Lukas König
*/
public class PhysEnv extends PhysicsEnvironment2D<PhysicsAgent2D<?>> {
/**
*
*/
private static final long serialVersionUID = -8422313209270357228L;
@SuppressWarnings("unused")
private int moveableAgentID;
public void setMoveableAgentID(int moveableAgentID) {
this.moveableAgentID = moveableAgentID;
}
public PhysEnv(int id, ParCollection params, Vector2f gravity, int iterations) {
super(id, params, gravity, iterations);
}
int z = 0;
int i = 100;
int b = 1;
@Override
public void step(Wink simTime) {
super.step(simTime);
this.setGravity(0, 40);
try {
AllroundVideoPlugin vid = (AllroundVideoPlugin) this.getSimTime().getPluginObject(new AllroundVideoPlugin().id());
double cameraAngle = vid.getEnv2D().getVisualizationAngleRAD() + Math.PI / 2;
Vector2D v = new Vector2D(Math.cos(cameraAngle), Math.sin(cameraAngle));
this.setGravity((float) -(v.x * 40), (float) (v.y * 40));
} catch (Exception e) {
}
// if (simTime.getLastTick() % i >= 0 && simTime.getLastTick() % i <= 2) {
// this.getAgent(this.moveableAgentID)
// .addForce(new Vector2f(b * 1000000 * this.getAgents().size() / 200 * z, 15000000));
// if (simTime.getLastTick() % i == 2) {
// z += 1;
// b *= -1;
// }
// }
}
}