AMotor Joint

As far as I can tell the amotor joint is the only joint that allows you to set an angle directly. I have been using a rotational joint and Im thinking its going to be impossible to sync (for multiplayer) the rotational position of a physics node without an amotor.I have been staring at the physics code for days and Im not having much luck figuring out amotors. I found the TODO in OdeJoint and I added an amotor there 

private OdeJavaJoint odeAMotor;

//TODO AMotor

                    odeAMotor = new JointAMotor(this.getName(), odeJavaWorld);


but odeAMotor is an OdeJavaJoint and I have no idea where to put the setAngle() method. there is Joint, OdeJavaJoint, OdeJoint, and JointAxis and im just confused at this point. Here is my joint creation code, Im pretty sure the amotor joint is there but how can I access it? :?

Joint joint1 = getPhysicsSpace().createJoint();
        joint1.attach( dynamicNode1, dynamicNode2 );
        JointAxis axis = joint1.createRotationalAxis();
        Joint joint2 = getPhysicsSpace().createJoint();
        joint2.attach( dynamicNode1, dynamicNode2 );
        JointAxis axis1 = joint2.createRotationalAxis();
        JointAxis axis2 = joint2.createRotationalAxis();
        JointAxis axis3 = joint2.createRotationalAxis();
        axis1.setDirection( new Vector3f( 0, 1, 0 ) );
        axis2.setDirection( new Vector3f( 0, 1, 0 ) );
        axis3.setDirection( new Vector3f( 0, 1, 0 ) );

edit: I also tried

public void setAngle(int anum, int angle){
       Ode.dJointSetAMotorAngle(jointId, anum, angle);

in OdeJavaJoint but same issue, how do I access from above joint creation?

As the jME Physics 2 readme states, support for AMotor is still missing. The lines you added are not enough to support it. One would have to insert the abstraction layer for AMotor like for the other ODE joints.

Once that is done your code to create such a joint is nearly ok. Only the axis directions shouldn't be the same.

I won't have the time in the near future to write that AMotor support. It's not that complicated - quite the same like for the other joints - but will take time. Probably someone else feels up to it?

the ode docs are puzzling.Im wondering if an amotor is what I even need. I read this in the amotor section:

An angular motor (AMotor) allows the relative angular velocities of two bodies to be controlled.
and this in "general" section of docs:
Note that there are no functions to set joint angles or positions (or their rates) directly, instead you must set the corresponding body positions and velocities.
seems ratrher contradictory. :?

By "setting directly" they mean without applying forces. AMotor applies forces to achieve an angular position or rate.

We could surely figure out whether you need that AMotor when you describe what you want to achieve a little more…

We could surely figure out whether you need that AMotor when you describe what you want to achieve a little more...

ok here goes, I am using setDesiredVelocity to rotate my foosball players

player1RotAxis[8].setDesiredVelocity( -( (distance/ time) * mouseForce ) / 10000 );

It works great for spinning the players but, Im thinking when I need to check the rotation for multiplayer and sync the positions of the players so everyone sees the same thing, Im going to need to say, ok player1 guys are at 45 degree angle and player2 is at 46 or whatever. so im thinking with an amotor I can use: player2RotAxis.setAngle(45); Is this even right? if not how would one check and set the rotation of a joint without forcing it? this is my first attempt at multiplayer 

Yes, if you want to do it like you describe it, it sounds like AMotor would be a good choice. I'm not so sure that it would result in good multiplayer experience to simulate physics that way on all machines, though.

My approach would be to have one machine being the master, the physics computation of this one is always "right". It would receive player input from all machines. Other machines would simulate physics, too (and likely receive player input), but will always apply the state sent by the master. The application of the state would simply be setPosition/Angle and setVelocity/Rate.

This a least worked well in MultiShufflePuck.

excellent, thanks irrisor. Im going to hook up jgn and give it all a try, Im sure ill have more questions for you soon though  :smiley:

Are you using the jME-Physics 2 JGN extension?

Are you using the jME-Physics 2 JGN extension?
well, I downloaded the 3 src packages from:,94.0.html
and Im about to try it out right now. looks like youre working on having physics synchronization built in, suhweet! 8) nice work