Advertisement
Guest User

Untitled

a guest
May 28th, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.82 KB | None | 0 0
  1. public void flyTo(double xShapePos, double yShapePos) {
  2.         float x = 0;
  3.         // je nachdem, wem der Token gehört
  4.         if (this._owner.getColor().equals(_colors[0])) {
  5.             x = 1;
  6.         } else if (this._owner.getColor().equals(_colors[1])) {
  7.             x = -1;
  8.         }
  9.        
  10.         Alpha alpha = new Alpha(-1, 5000);
  11.  
  12.         // Achse, um die gedreht werden soll
  13.         Transform3D axisOfRotPos = new Transform3D();
  14.        
  15.         AxisAngle4f axis = new AxisAngle4f(1.0f, 0.0f, 0.0f, 0.0f); // oder normale tranform3d::rotX()
  16.         axisOfRotPos.set(axis);
  17.         // Zeitverhalten - Index der Stützstellen
  18.         float[] knots = {0.0f, 0.5f, 0.7f, 1.0f};
  19.         // Beschreibung der Orientierung
  20.         Quat4f[] quats = new Quat4f[4];
  21. //      quats[0] = new Quat4f(0.0f, 1.0f, 1.0f, 0.0f);
  22. //      quats[1] = new Quat4f(1.0f, 0.0f, 0.0f, 0.0f);
  23. //      quats[2] = new Quat4f(0.0f, 1.0f, 0.0f, 0.0f);
  24. //      quats[3] = new Quat4f(0.0f, 1.0f, 1.0f, 0.0f);
  25.        
  26.         quats[0] = new Quat4f(0.0f, 0.0f, 0.0f, 0.0f);
  27.         quats[1] = new Quat4f(0.0f, 0.0f, 0.0f, 0.0f);
  28.         quats[2] = new Quat4f(0.0f, 1.0f, 0.0f, 0.0f);
  29.         quats[3] = new Quat4f(0.0f, x, 1.0f, 0.0f);
  30.        
  31.         // Beschreibung der Position
  32.         Transform3D ownTransf = new Transform3D();
  33.         this.getTransform(ownTransf);
  34.         Vector3f vtrans = new Vector3f();
  35.         ownTransf.get(vtrans);
  36.         Point3f[] positions = new Point3f[4];
  37.         positions[0] = new Point3f(vtrans.x, vtrans.y, vtrans.z);
  38.         positions[1] = new Point3f(vtrans.x, vtrans.y, vtrans.z+2);
  39.         positions[2] = new Point3f((float) xShapePos, (float) xShapePos, vtrans.z+2);
  40.         positions[3] = new Point3f((float) xShapePos, (float) yShapePos, 0.5f);
  41.        
  42.        
  43.         RotPosPathInterpolator rotPosPath = new RotPosPathInterpolator(alpha, this, axisOfRotPos, knots, quats, positions);
  44.         rotPosPath.setSchedulingBounds(new BoundingSphere());
  45.        
  46.         BranchGroup bg = new BranchGroup();
  47.         bg.addChild(rotPosPath);
  48.         this.addChild(bg);
  49.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement