MotionPath Airplane Aerobatics?

Have probs rotating airplane following motionpath forinstance while doing a cuban eight. aerobatics.
How to stop spatial from flipping over at wrong moments?

got something like this:
final MotionPath motionPath = new MotionPath();

    motionPath.addWayPoint(new Vector3f(-40, -10, z));
    motionPath.addWayPoint(new Vector3f(-10, -10, z));
    motionPath.addWayPoint(new Vector3f(FastMath.sin(-FastMath.QUARTER_PI * 4) * 10 + 10, FastMath.cos(-FastMath.QUARTER_PI * 4) * 10, z));
    motionPath.addWayPoint(new Vector3f(FastMath.sin(-FastMath.QUARTER_PI * 5) * 10 + 10, FastMath.cos(-FastMath.QUARTER_PI * 5) * 10, z));
    motionPath.addWayPoint(new Vector3f(FastMath.sin(-FastMath.QUARTER_PI * 6) * 10 + 10, FastMath.cos(-FastMath.QUARTER_PI * 6) * 10, z));
    motionPath.addWayPoint(new Vector3f(FastMath.sin(-FastMath.QUARTER_PI * 7) * 10 + 10, FastMath.cos(-FastMath.QUARTER_PI * 7) * 10, z));
    motionPath.addWayPoint(new Vector3f(FastMath.sin(-FastMath.QUARTER_PI * 0) * 10 + 10, FastMath.cos(-FastMath.QUARTER_PI * 0) * 10, z));
    motionPath.addWayPoint(new Vector3f(FastMath.sin(-FastMath.QUARTER_PI * 1) * 10 + 10, FastMath.cos(-FastMath.QUARTER_PI * 1) * 10, z));
    motionPath.addWayPoint(new Vector3f(0, 0, z));
    motionPath.addWayPoint(new Vector3f(FastMath.sin(FastMath.QUARTER_PI * 3) * 10 - 10, FastMath.cos(FastMath.QUARTER_PI * 3) * 10, z));
    motionPath.addWayPoint(new Vector3f(FastMath.sin(FastMath.QUARTER_PI * 4) * 10 - 10, FastMath.cos(FastMath.QUARTER_PI * 4) * 10, z));
    motionPath.addWayPoint(new Vector3f(FastMath.sin(FastMath.QUARTER_PI * 5) * 10 - 10, FastMath.cos(FastMath.QUARTER_PI * 5) * 10, z));
    motionPath.addWayPoint(new Vector3f(FastMath.sin(FastMath.QUARTER_PI * 6) * 10 - 10, FastMath.cos(FastMath.QUARTER_PI * 6) * 10, z));
    motionPath.addWayPoint(new Vector3f(FastMath.sin(FastMath.QUARTER_PI * 7) * 10 - 10, FastMath.cos(FastMath.QUARTER_PI * 7) * 10, z));
    motionPath.addWayPoint(new Vector3f(FastMath.sin(FastMath.QUARTER_PI * 0) * 10 - 10, FastMath.cos(FastMath.QUARTER_PI * 0) * 10, z));
    motionPath.addWayPoint(new Vector3f(FastMath.sin(FastMath.QUARTER_PI * 1) * 10 - 10, FastMath.cos(FastMath.QUARTER_PI * 1) * 10, z));
    motionPath.addWayPoint(new Vector3f(0, 0, z));
    motionPath.addWayPoint(new Vector3f(FastMath.sin(-FastMath.QUARTER_PI * 3) * 10 + 10, FastMath.cos(-FastMath.QUARTER_PI * 3) * 10, z));
    motionPath.addWayPoint(new Vector3f(FastMath.sin(-FastMath.QUARTER_PI * 4) * 10 + 10, FastMath.cos(-FastMath.QUARTER_PI * 4) * 10, z));
    motionPath.addWayPoint(new Vector3f(20, -10, z));
    motionPath.addWayPoint(new Vector3f(40, -10, z));
    motionPath.setCycle(false);
    motionPath.setCurveTension(0.5f);
    
    motionPath.enableDebugShape(assetManager, rootNode);
    motionPath.disableDebugShape();

    MotionEvent motionEvent = new MotionEvent(spatial, motionPath);
    motionEvent.setInitialDuration(15f);
    motionEvent.setSpeed(1.1f);
    motionEvent.setLoopMode(LoopMode.Loop);
    motionEvent.setDirectionType(MotionEvent.Direction.PathAndRotation);
    motionEvent.setRotation(new Quaternion().fromAngleNormalAxis(0, Vector3f.ZERO));
    motionEvent.play();

    motionPath.addListener(new MotionPathListener() {
        public void onWayPointReach(MotionEvent motionControl, int wayPointIndex) {
            if (wayPointIndex == 2) {
                channel.setAnim("level2up");
                channel.setLoopMode(LoopMode.DontLoop);
         //       motionControl.getSpatial().rotate(0,0,1f);
            }
            if (wayPointIndex == 7) {
                channel.reset(true);
            }
            if (wayPointIndex == 8) {
                channel.setAnim("level2leftroll");
                channel.setLoopMode(LoopMode.DontLoop);
           //     airPlane.rotate(0,0,FastMath.HALF_PI);
            }
            if (wayPointIndex == 9) {
                channel.reset(true);
                channel.setAnim("level2up");
                channel.setLoopMode(LoopMode.DontLoop);
            }
            if (wayPointIndex == 15) {
                channel.reset(true);;
            }
            if (wayPointIndex == 16) {
                channel.setAnim("level2leftroll");
                channel.setLoopMode(LoopMode.DontLoop);
            }
            if (wayPointIndex == 17) {
                channel.reset(true);
                channel.setAnim("level2up");
                channel.setLoopMode(LoopMode.DontLoop);
            }
            if (wayPointIndex == 18) {
                channel.reset(true);;
            }
        }
    });

///////////////////////////////////////////////////////////////////////////
Cant Control rotation of spatial correctly.

Would love to learn to fly… :smile:

It’s really hard to say what’s wrong. could you shot a video of the issue?

What’s wrong is most likely me not using the MotionPath system correctly.

When airPlane reaches a waypoint like coming from the left on lower side of an O and reaching the middle right side of the O it flips over 180 degrees around the local z axcis automatically.
I am trying to have it almost around the Whole O and then controlled flip it around (180 degrees on the z)just above hte middel of the O on the left side again so that it flies inverse thru most of the O.

I dont seem to get motionControl.getSpatial().rotate(0,0,FastMath.PI); (or similar) to work in the listener.
MIght be I should use somthing other than MotionEvent.Direction.PathAndRotation.

Ref to cubanEight:
http://cdn6.modelairplanenews.com/wp-content/uploads/2012/03/Capture7.jpg

Hhe, did you find solution?
If so please share it.

No,
I am afraid I just settled for a path in the x z plane avoiding the plane to flip over or do a loop or something
I afraid I have not had the time to look deeper into it….

Many Regards
Harald

Fra: Alexey_Smovzh [mailto:noreply@jmonkeyengine.org]
Sendt: 8. juni 2015 16:29
Til: Harald Gundersen
Emne: {Disarmed} [jMonkeyEngine Hub] [Troubleshooting/General Help] MotionPath Airplane Aerobatics?

[http://jme-hub-cdn.jmonkeyengineor.netdna-cdn.com/letter_avatar/alexey_smovzh/45/5_fcf819f9b3791cb8c87edf29c8984f83.png]

Alexey_Smovzhhttp://mandrillapp.com/track/click/30207841/hub.jmonkeyengine.org?p=eyJzIjoiREhiRlc0ODZFbnVZUHJ4VTVtMGUwZVE1bUcwIiwidiI6MSwicCI6IntcInVcIjozMDIwNzg0MSxcInZcIjoxLFwidXJsXCI6XCJodHRwOlxcXC9cXFwvaHViLmptb25rZXllbmdpbmUub3JnXFxcL3VzZXJzXFxcL2FsZXhleV9zbW92emhcIixcImlkXCI6XCI5MmM4NjM3YTFjNGY0ZDU4YWU0MmFkZGU3ZmJkNTRiM1wiLFwidXJsX2lkc1wiOltcIjI2OTY3MDY5YTU4NTM2OWY2ZWFjNWE1ZTMxYTJhMTViNGI0YTk2ZTNcIl19In0
June 8

Hhe, did you find solution?
If so please share it.

To respond, reply to this email or visit MailScanner has detected a possible fraud attempt from “mandrillapp.com” claiming to be MotionPath Airplane Aerobatics? - #4 by Alexey_Smovzhhttp://mandrillapp.com/track/click/30207841/hub.jmonkeyengine.org?p=eyJzIjoiZWpCdHpCV1k1ay03V3JMejM4ZDB0Mk1SUEc0IiwidiI6MSwicCI6IntcInVcIjozMDIwNzg0MSxcInZcIjoxLFwidXJsXCI6XCJodHRwOlxcXC9cXFwvaHViLmptb25rZXllbmdpbmUub3JnXFxcL3RcXFwvbW90aW9ucGF0aC1haXJwbGFuZS1hZXJvYmF0aWNzXFxcLzMxNzk0XFxcLzRcIixcImlkXCI6XCI5MmM4NjM3YTFjNGY0ZDU4YWU0MmFkZGU3ZmJkNTRiM1wiLFwidXJsX2lkc1wiOltcIjQ5YThkN2VmODkxNWQ2OWY0ZjA1ZGU2ZDJjYzAyMjI3YTljOGNiMTNcIl19In0 in your browser.