Guest User

Untitled

a guest
May 26th, 2017
35
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.75 KB | None | 0 0
  1. import com.nolimitscoaster.*;
  2. import nlvm.math3d.*;
  3.  
  4. public class CarAction {
  5.    
  6.     private CarHandler handler;
  7.     private float startTime;
  8.     private float totalTime;
  9.     private float endTime;
  10.     private int direction;
  11.    
  12.     //Animation directions
  13.     private final int LEFT = 0;
  14.     private final int RIGHT = 1;
  15.     private final int FRONT = 2;
  16.     private final int BACK = 3;
  17.    
  18.     private Vector3f objectRotation;
  19.    
  20.     public CarAction(CarHandler handler, float startTime, float totalTime, int direction) {
  21.         this.handler = handler;
  22.         this.startTime = startTime;
  23.         this.totalTime = totalTime;
  24.         this.endTime = startTime + totalTime;
  25.         this.direction = direction;
  26.        
  27.         System.out.println("New action. Start: " + startTime + " / End: " + endTime);
  28.        
  29.         objectRotation = new Vector3f();
  30.     }
  31.    
  32.     public CarAction(CarHandler handler, double startTime, float totalTime, int direction) {
  33.         this(handler, (float) startTime, totalTime, direction);
  34.     }
  35.    
  36.     public void process(float tick) {
  37.         double currentTime = handler.getSim().getCurAbsSimulationTimeSec();
  38.         if (currentTime >= endTime) {
  39.             return;
  40.         }
  41.        
  42.         switch(direction) {
  43.             case LEFT:
  44.                 //System.out.println("left");
  45.                 handler.getSco().getRotation(objectRotation);
  46.                 handler.getSco().setRotation(objectRotation.x, objectRotation.y, (objectRotation.z - .1f));
  47.                 break;
  48.            
  49.             case RIGHT:
  50.                 //System.out.println("right");
  51.                 handler.getSco().getRotation(objectRotation);
  52.                 handler.getSco().setRotation(objectRotation.x, objectRotation.y, (objectRotation.z - .1f));
  53.                 break;
  54.            
  55.             case FRONT:
  56.                 //System.out.println("front");
  57.                 break;
  58.            
  59.             case BACK:
  60.                 //System.out.println("back");
  61.                 break;
  62.            
  63.             default:
  64.                 System.err.println("Wrong movement direction!");
  65.                 break;
  66.         }
  67.     }
  68. }
Add Comment
Please, Sign In to add comment