Page 1 of 1

A problem with a sphere rolling on terrain

Posted: Wed Oct 06, 2021 7:40 pm
by itay.green
Hello,
I've been using the java port of Bullet and have been having problems with the sphere shape.
In my game, the sphere does interact with the terrain (doesn't go through it) but the rolling effect is glitching.
would love to get some help on how to get the proper rotation values for OpenGL;
this is my code for the rotation, would appreciate any sort of help (:
private static Vector3f getBallRotation(RigidBody ball)
{
Quat4f out = new Quat4f();
ball.getMotionState().getWorldTransform(new Transform()).getRotation(out);
return new Vector3f(out.x, out.y, out.z);
}

Re: A problem with a sphere rolling on terrain

Posted: Wed Oct 06, 2021 11:09 pm
by drleviathan
The rotation out is in Quaternion form, which is a 4D object, not a Vector3. Your could should look more like:

Code: Select all

private static Quat4f getBallRotation(RigidBody ball)
{
    Quat4f out = new Quat4f();
    ball.getMotionState().getWorldTransform(new Transform()).getRotation(out);
    return out;
}