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 ?
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 ?
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.
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.
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.