Diagonal Roll

Quick question how can i make a ball roll diagonally i set the code up bellow but if i set the velocity to equal magnitudes the ball seems to wobble slightly to the X Axis and stay closer to the Z Axis

rotAxisZ = joint.createRotationalAxis();
      rotAxisZ.setDirection(Vector3f.UNIT_Z);
      rotAxisZ.setAvailableAcceleration(10);
        // and rotation around the x-axis
      rotAxisX = joint.createRotationalAxis();
        rotAxisX.setDirection(Vector3f.UNIT_X);
        rotAxisX.setAvailableAcceleration(10);
        rotAxisX.setRelativeToSecondObject( true );

Have you tried using only a single rotational axis? Say like this:


AxisZ = joint.createRotationalAxis();
rotAxisZ.setDirection(new Vector3f(1, 0, 1));
rotAxisZ.setAvailableAcceleration(10);



When using two rotational axis like you have, the underlying engine (ODE) sees this as being a Hinge2 joint. Refer the the ODE docs to see how this joint is designed to operate. I don't know if it will behave the way you are expecting it to.

ahh yes thx nymon i could of sworn i had begun with that but w/e so anytime two buttons are pressed simutaneously i would simply change the direction of either the X or Z axis or is it possible to give it an extra degree of freedom?

I think the best solution (not really knowing your requirements) would be to only use one axis, and then just modify the direction of it based in the inputs.



If you desire a different behavior, look at all the joints that are supported by ODE. If you don't see one that fits your needs, then you may have to resort implementing your own joint which is fairly involved, or writing some magic code that handles all the forces that is called in a physics update callback.

nymon said:

I think the best solution (not really knowing your requirements) would be to only use one axis, and then just modify the direction of it based in the inputs.

If you desire a different behavior, look at all the joints that are supported by ODE. If you don't see one that fits your needs, then you may have to resort implementing your own joint which is fairly involved, or writing some magic code that handles all the forces that is called in a physics update callback.


ahh so it would be better if i simply had


rotAxisX = joint.createRotationalAxis();
rotAxisX.setDirection(Vector3f.ZERO); //temporary direction


I wouldn't need .setRelativeToSecondObject( true ); since thier was only once axis but then that begs the question why would u ever need two rotational axises and what exactly is .setRelativeToSecondObject( true ); lol

THANK YOU NYMON!!!
Bonechilla said:

I wouldn't need .setRelativeToSecondObject( true ); since thier was only once axis but then that begs the question why would u ever need two rotational axises and what exactly is .setRelativeToSecondObject( true );

ODE Users Guide - Hinge 2 Joint

nymon said:

ODE Users Guide - Hinge 2 Joint


hmm okay thx so i changed the joint and Rotational Joint to OdeJoint and RotationalODEJoint and casted the createJoint method from the physicsSpace to create the ode joint and casted it again to create the RotationalODEJoint i then left second to relativeObject true because i still don't completly understand what it does (does it make the second node connected the mainNode to determine direction?) and attached the two objects to the joint after everything was done thx a lot for the manual i know u had told me to look at it earlier but a lot of the method calls are different though just by reading random parts of it i have more knowledge on the matter thx