Free Rotation Joint SixDofJoint help

I need a “free joint” that holds an object in orbit, but allow it to rotate in any direction.
I thought the SixDofJoint has this behavior, but its working as same from ConeJoint ?
I am using this code :

// Create a Joint of the orbit type
public static SixDofJoint createFreeJoint(Node a, Node b, CollisionShape bshape, float mass ) {
    BulletAppState bulletAppState = Main.bulletAppState;

    // As its a simple free joint, origem shape is a simple stoped box
    RigidBodyControl rigidbox = new RigidBodyControl(new BoxCollisionShape(new Vector3f( .1f, .1f, .1f)), 0);
    rigidbox.setPhysicsLocation( a.getLocalTranslation() );
    a.addControl(rigidbox); bulletAppState.getPhysicsSpace().add(a);

    // Destiny will have a determined shape
    RigidBodyControl rigidbody = new RigidBodyControl(bshape, mass);
    rigidbody.setPhysicsLocation( b.getLocalTranslation() );
    b.addControl(rigidbody); bulletAppState.getPhysicsSpace().add(b);

    // Return this SixDofJoint, control point is the origem Node center of mass
    SixDofJoint thisjoint = createFreeJointJoin(a, b, a.getLocalTranslation());
    return thisjoint;

// PRIVATE - Work with createFreeJoint
private  static SixDofJoint createFreeJointJoin(Node A, Node B, Vector3f connectionPoint) {
    Vector3f pivotA = A.worldToLocal(connectionPoint, new Vector3f());
    Vector3f pivotB = B.worldToLocal(connectionPoint, new Vector3f());
    SixDofJoint joint = new SixDofJoint(A.getControl(RigidBodyControl.class), B.getControl(RigidBodyControl.class), pivotA, pivotB,false);
    return joint;

There is any joint for this ? Or maybe something wrong in my code ?

maybe look at a Hinge joint : see here

Hinge constraint, or revolute joint, restricts two additional angular 
degrees of freedom, so the body can only rotate around one axis, the 
hinge axis. This can be useful to represent doors or wheels rotating 
around one axis. Limits and motor can be specified for the hinge. 

I read, but in Jm3 there some additional type of joints with almost no documentation like the physics joint : “PhysicsJoint - Basic Phyiscs Joint” .
I am not sure if there is one joint that do what I am looking for, maybe this Physic joint ?

PhysicsJoint is an abstract base class…

There is any joint I could use for this case ? Or any other class ?
Or the only way will need to customize it ?
Maybe extending this physics class ?

What do you want to do?

Just want to put one object in orbit of another…
Like asteroids in orbit of a planet ?
It will colide with other asteroids so it needs physics.
I attached it to a joint on the center of the planet, its working, but just rotate as an spin toy, I am expecting to see it rotating in random directions when it colides.

I’d suggest simulating what happens when an asteroid orbits a planet then. Its speed and the gravity towards the planet cancel each other out so that it continuously falls over the horizon of the planet.

Yep, but not in this game :slight_smile:
Do you know if I can do anything with joints or I should give up of joints for this ?

So what are you trying to do then? Using a joint sounds like the completely wrong solution for anything I can imagine you want to do. The 6dof joint has complete freedom though, you just seem to use it wrong.

so maybe try to make a “distance” joint with 3 free rotation axis. But there are not such thing in bullet.

1 Like

I just want the asteroids to roll in the planet orbit, its working with joints, but it seens the rotation is pinned in… I read 6dof should allow me to have this freedom, but for some reason its not working… Can you guys see anything in the code I posted ? Maybe there is a but another place, just want to have sure the code I posted is right.

That was what I was afraid off …

How about you just set the linearVelocity then and let the angularVelocity happen through collisions or whatever is happening in your game.

I guess its kind of what I want… I tried to put this in the code :

joint.setAngularUpperLimit(new Vector3f(Float.POSITIVE_INFINITY, Float.POSITIVE_INFINITY, Float.POSITIVE_INFINITY));

But the results was something funny far away what I want…
I guess I just need to understand how this sets works, right ?

No, not joints. Setting it directly on the object (continuously) so that the linear velocity makes the path around the planet.

Sounds good, but how to do it ?
Putting some math code in the update moving the position of the object around the planet ?

Basically, best put it in the tick callback for a PhysicsTickListener though.

setLinearVelocity ?