Advertisement
Guest User

Untitled

a guest
Dec 11th, 2016
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.74 KB | None | 0 0
  1.     //Das in deine Klasse
  2.     private static final float PI_HALF = (float) (Math.PI / 2);
  3.    
  4.     private static Vector3f matrixDiffToPHB(Matrix4x4f m1, Matrix4x4f m2){
  5.         Vector3f phb = new Vector3f();
  6.         m1.invert();
  7.         m2.multLeft(m1);
  8.         Tools.matrixToPitchHeadBankPos(m2, phb, null);
  9.         return new Vector3f(-phb.x + PI_HALF, -phb.y, 0);
  10.     }
  11.  
  12.     //Das dann an die Stelle an der die Rotation ausgelesen werden soll:
  13.     Matrix4x4f mCar = new Matrix4x4f();
  14.     train.getCarMatrix(0, mCar);
  15.     Matrix4x4f mView = new Matrix4x4f();
  16.     sim.getViewMatrix(mView);
  17.     Vector3f phb = matrixDiffToPHB(mView, mCar);
  18.     //phb ist dann eigentlich schon die Rotation die, die kamera beim Abspielen annehmen soll
  19.    
  20.     //zum Testen (bzw. beim Abspielen dann)
  21.     elm.setRotation(phb);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement