/*
* File name: ClothSched.java (package eas.users.fabian.cloth)
* Author(s): Fabian
* Java version: 6.0
* Generation date: 15.02.2012 (16:33:05)
*
* (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.cloth;
import java.util.LinkedList;
import java.util.List;
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 ClothSched2 extends AbstractDefaultMaster<ClothEnv> {
/**
*
*/
private static final long serialVersionUID = -4130344245593843867L;
private int gridsize = 30;
private double distancefactor = 1.5;
@Override
public List<String> getRequiredPlugins() {
return null;
}
@Override
public List<SingleParameter> getParameters() {
return super.getParameters();
}
@Override
public String id() {
return "defaultmaster-fr.cloth2";
}
@Override
public void runBeforeSimulation(ClothEnv env, ParCollection params) {
ClothAgent3 cloth = new ClothAgent3(0, env, params, gridsize, distancefactor);
env.addAgent(cloth);
ObstacleAgent obstacle = new ObstacleAgent(1, env, params);
env.addAgent(obstacle);
env.setUseGroundPlane(true);
env.setRealTime(false);
env.setMu(0.001);
env.setLinearDamping(0.5);
}
@Override
public void runAfterSimulation(ClothEnv env, ParCollection params) {
}
@Override
public void runDuringSimulation(ClothEnv env, Wink currentSimTime,
ParCollection params) {
env.step(currentSimTime);
if (currentSimTime.getLastTick() == 100) {
ClothAgent3 agent = (ClothAgent3) env.getAgent(0);
agent.getBodyMatrix()[1][1].setDynamic();
}
if (currentSimTime.getLastTick() == 500) {
ClothAgent3 agent = (ClothAgent3) env.getAgent(0);
agent.getBodyMatrix()[1][gridsize-2].setDynamic();
}
if (currentSimTime.getLastTick() == 300) {
ClothAgent3 agent = (ClothAgent3) env.getAgent(0);
agent.getBodyMatrix()[gridsize-2][1].setDynamic();
}
if (currentSimTime.getLastTick() == 700) {
ClothAgent3 agent = (ClothAgent3) env.getAgent(0);
agent.getBodyMatrix()[gridsize-2][gridsize-2].setDynamic();
}
}
@Override
public void handleEvent(EASEvent e, ClothEnv env, Wink lastSimTime,
ParCollection params) {
}
@Override
public ClothEnv[] generateRunnables(ParCollection params) {
ClothEnv env = new ClothEnv(0, params);
return new ClothEnv[] {env};
}
@Override
public List<String> getSupportedPlugins() {
LinkedList<String> list = new LinkedList<String>();
list.add(new VideoPluginLWJGL().id());
return list;
}
}