/*
* 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.physics2DD;
import java.awt.image.BufferedImage;
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 PhysEnvSimple extends PhysicsEnvironment2D<PhysicsAgent2D<?>> {
private static final long serialVersionUID = -8422313209270357228L;
public static final Vector2D BRIGHT_POS = new Vector2D(-74, 90);
@SuppressWarnings("unused")
private int moveableAgentID;
public void setMoveableAgentID(int moveableAgentID) {
this.moveableAgentID = moveableAgentID;
}
public PhysEnvSimple(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 * 2), (float) (v.y * 2));
} catch (Exception e) {
}
}
@Override
public BufferedImage getOutsideView() {
BufferedImage img = super.getOutsideView();
// Graphics2D g = img.createGraphics();
// g.fillOval((int) this.getPointInVisualization(new Vector2D(-74, 90)).x, (int) this.getPointInVisualization(new Vector2D(-74, 90)).y, 10, 10);
return img;
}
}