Package eas.users.students.fabian.rocket

Source Code of eas.users.students.fabian.rocket.RocketSched

/*
* File name:        RocketSched.java (package eas.users.fabian.rocket)
* Author(s):        Fabian
* Java version:     6.0
* Generation date:  01.02.2012 (14:17:19)
*
* (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.rocket;

import java.util.LinkedList;
import java.util.List;

import org.ode4j.math.DVector3;

import eas.math.geometry.Vector3D;
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;
import eas.startSetup.parameterDatatypes.Datatypes;

/**
* @author Fabian
*
*/
public class RocketSched extends AbstractDefaultMaster<RocketEnv> {

  /**
     *
     */
    private static final long serialVersionUID = -6443786063308997101L;

    @Override
  public List<String> getRequiredPlugins() {
    return null;
  }

  @Override
  public List<SingleParameter> getParameters() {
      List<SingleParameter> liste = super.getParameters();
     
      liste.add(new SingleParameter("numX", Datatypes.integerRange(1, 20), 3));
      liste.add(new SingleParameter("numY", Datatypes.integerRange(1, 20), 3));
      liste.add(new SingleParameter("numZ", Datatypes.integerRange(1, 20), 3));
     
    return liste;
  }

  @Override
  public String id() {
    return "defaultmaster-fr.rocket";
  }

  @Override
  public void runBeforeSimulation(RocketEnv env, ParCollection params) {
    env.setGravity(new DVector3(0, 0, -2.1));
    env.setMu(0.0000001);
    int maxX = params.getParValueInt("numX");
    int maxY = params.getParValueInt("numY");
    int maxZ = params.getParValueInt("numZ");
    double facX = 1.1;
    double facY = 1.1;
    double facZ = 1.1;
    int id = 1;
   
    env.addAgent(new RocketAgent(0, env, params, new Vector3D(0, 0, (maxZ * facZ + 1) + (facZ + 1) + 3)));
   
    for (int i = 0; i < maxX; i++) {
        for (int j = 0; j < maxY; j++) {
            for (int k = 0; k < maxZ; k++) {
                env.addAgent(new PassiveAgent(id++, env, params, new Vector3D(i * facX, j * facY, (maxZ - k + 1) * facZ)));
            }
        }
    }
   
//    float[] xyz = new float[] {0,-6,6};
//    float[] hpr = new float[] {90,-30,0};   
//    VideoPluginODE3D.dsSetViewpoint(xyz, hpr);
  }

  @Override
  public void runAfterSimulation(RocketEnv env, ParCollection params) {
   
  }

  @Override
  public void runDuringSimulation(RocketEnv env, Wink currentSimTime,
      ParCollection params) {
    env.step(currentSimTime);
    RocketAgent rocket = (RocketAgent) env.getAgent(0);
    DVector3 pos = rocket.getPosition().clone();
    VideoPluginLWJGL.setCameraToLookAtPositionFromSpecifiedDistance(pos.get0(), pos.get1(), pos.get2(), 15);
  }

  @Override
  public void handleEvent(EASEvent e, RocketEnv env, Wink lastSimTime,
      ParCollection params) {
   
  }

  @Override
  public RocketEnv[] generateRunnables(ParCollection params) {
    RocketEnv env = new RocketEnv(0, params);
    return new RocketEnv[] { env };
  }

    @Override
    public List<String> getSupportedPlugins() {
        LinkedList<String> list = new LinkedList<String>();
        list.add(new VideoPluginLWJGL().id());
        return list;
    }
}
TOP

Related Classes of eas.users.students.fabian.rocket.RocketSched

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.