/*
* File name: SnakeSched.java (package eas.users.fabian.snake)
* Author(s): Fabian
* Java version: 6.0
* Generation date: 02.02.2012 (13:29:13)
*
*
* Adapted work from Dr. Juan Gonzalez-Gomez *
*
*
* (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.students.fabian.snake;
import java.util.LinkedList;
import java.util.List;
import org.ode4j.math.DVector3;
import eas.plugins.masterScheduler.AbstractDefaultMaster;
import eas.plugins.standard.visualization.visualization3D.VideoPluginLWJGL;
import eas.simulation.Wink;
import eas.simulation.event.EASEvent;
import eas.startSetup.ParCollection;
import eas.startSetup.SingleParameter;
/**
* @author Fabian
*
*/
public class SnakeSched extends AbstractDefaultMaster<SnakeEnv> {
/**
*
*/
private static final long serialVersionUID = -3266372594408096824L;
DVector3 lastPos;
/* (non-Javadoc)
* @see eas.plugins.Plugin#getRequiredPlugins()
*/
@Override
public List<String> getRequiredPlugins() {
return null;
}
/* (non-Javadoc)
* @see eas.plugins.Plugin#getParameters()
*/
@Override
public List<SingleParameter> getParameters() {
return super.getParameters();
}
/* (non-Javadoc)
* @see eas.plugins.Plugin#id()
*/
@Override
public String id() {
return "defaultmaster-fr.snake";
}
/* (non-Javadoc)
* @see eas.plugins.Plugin#runBeforeSim(eas.simulation.EASRunnable, eas.startSetup.ParCollection)
*/
@Override
public void runBeforeSimulation(SnakeEnv env, ParCollection params) {
env.setMu(1.2);
env.setCFM(1e-5);
env.setERP(0.2);
env.setBounce(0.1);
env.setBounceVel(0.1);
env.setSoftCFM(0.01);
// env.setupEnvironment();
// env.getWorld().setContactMaxCorrectingVel(0.1);
// env.getWorld().setContactSurfaceLayer(0.0001);
env.setRealTime(true);
}
/* (non-Javadoc)
* @see eas.plugins.Plugin#runAfterSim(eas.simulation.EASRunnable, eas.startSetup.ParCollection)
*/
@Override
public void runAfterSimulation(SnakeEnv env, ParCollection params) {
}
/* (non-Javadoc)
* @see eas.plugins.Plugin#runDuringSim(eas.simulation.EASRunnable, eas.simulation.Wink, eas.startSetup.ParCollection)
*/
@Override
public void runDuringSimulation(SnakeEnv env, Wink currentSimTime,
ParCollection params) {
if (currentSimTime.getLastTick() == 0) {
Snake snake = new Snake(0, env, params, 16);
env.addAgent(snake);
lastPos = new DVector3(snake.getPosition());
System.out.println("");
System.out.println("");
System.out.println("Use the number keys to start different motion patterns.");
snake.setMotionInclinedSideWinding(40, 2);
}
env.step(currentSimTime);
// VideoPluginLWJGL.setDrawMode(1);
VideoPluginLWJGL.setRotatingCameraToLookAtObjectFromSpecifiedDistance(env.getAgent(0).getPosition().get0(), env.getAgent(0).getPosition().get1(), env.getAgent(0).getPosition().get2(), 20, 5000);
}
/* (non-Javadoc)
* @see eas.plugins.Plugin#handleEvent(eas.simulation.event.EASEvent, eas.simulation.EASRunnable, eas.simulation.Wink, eas.startSetup.ParCollection)
*/
@Override
public void handleEvent(EASEvent e, SnakeEnv env, Wink lastSimTime,
ParCollection params) {
}
/* (non-Javadoc)
* @see eas.simulation.masterScheduler.MasterScheduler#generateEnvironments(eas.startSetup.ParCollection)
*/
@Override
public SnakeEnv[] generateRunnables(ParCollection params) {
SnakeEnv env = new SnakeEnv(0, params);
return new SnakeEnv[] { env };
}
/* (non-Javadoc)
* @see eas.plugins.Plugin#getSupportedPlugins()
*/
@Override
public List<String> getSupportedPlugins() {
LinkedList<String> list = new LinkedList<String>();
list.add(new VideoPluginLWJGL().id());
return list;
}
}