A problem with a sphere rolling on terrain

Post Reply
itay.green
Posts: 1
Joined: Tue Oct 05, 2021 3:54 pm

A problem with a sphere rolling on terrain

Post 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);
}
User avatar
drleviathan
Posts: 849
Joined: Tue Sep 30, 2014 6:03 pm
Location: San Francisco

Re: A problem with a sphere rolling on terrain

Post 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;
}
Post Reply