[SOLVED] Cannot handle more than 1 joint - Physical Hinges and Joints

Because you aren’t doing it right :smiley:
You need jme3-bullet which is all the code you see (HingeJoint.java) and a Physics Implementation.
This means EITHER jme3-bullet-native or jme3-jbullet, you have both in your first screenshot, so it’s unclear which is taken and then you removed the binding lib and only leave native in.

The Reason is: there are two: native is c++ original bullet code and jbullet is a java port, so that way we can rule out if it’s a bug from bullet or the binding code.

It’s working now.

I did try different libraries and now it’s working with the joints.

This information about right libraries, should be included inside the tutorial.


Your screenshot still looks wrong, you can only have EITHER jme3-jbullet OR jme3-bullet-native.
So we’d need to know for which it works and for which it doesn’t. Probably one should try to update bullet-native, but I guess there were some problems back then.

The Information surely is somewhere in the wiki, that’s where I learned it from, but I can’t point you into the right direction, maybe @mitm can?

With the first working example, I used this:


The result was that only one joint was working. Or in more correct words, all joints was working, but could not connect to the static nodes.

If I tried to use more than 1 joint, then all the joints could not connect to the nodes.

When I use this libraries

Then all the dynamical nodes is going cracy, two of them spins around.


I will build a new project and try to build it again and see what’s happen. The default libraries I start with is



See Admonition: Only one version of jme3-jbullet OR jme3-bullet with a single “natives” library can be used.

To answer your other question @Darkchaos , jBullet works fine, its bullet-native where things are failing.

Edit: there is also a admonition here about which bullet to use:

I think all the physics examples are based off jBullet, and that at the time when they were written, the SDK.

SDK3.1 stable used jBullet as default so this problem would not show up normally. There are other problems with jBullet so the SDK now defaults to bullet-native as of 3.2.

He’s using a maven SDK build I think? Choosing his own libraries, so probably best to fix bullet-native if possible.

jme3-bullet and jme3-bullet-native is booth attached in the library folder in SDK 3.2.

But I will remove them and only attach jme3-jbullet. Is jbullet more developed than bullet-native?

As it should be.


But or else, it won’t work for me.

The jMonkeyEngine3 has built-in support for jBullet physics via the com.jme3.bullet package.


Have you read this?

Maybe something here will help. I just don’t have time myself to dig into this yet.


No, I haven’t read that, but I will. By the way.

Try to run this code, it’s supposed to be Newton’s cradle.

package mygame;

import com.jme3.app.SimpleApplication;
import com.jme3.bullet.BulletAppState;
import com.jme3.bullet.collision.shapes.BoxCollisionShape;
import com.jme3.bullet.control.RigidBodyControl;
import com.jme3.bullet.joints.HingeJoint;
import com.jme3.math.FastMath;
import com.jme3.math.Vector3f;
import com.jme3.renderer.RenderManager;
import com.jme3.scene.Node;

 * This is the Main Class of your Game. You should only do initialization here.
 * Move your Logic into AppStates or Controls
 * @author normenhansen
public class Main extends SimpleApplication {
    private BulletAppState bulletAppState; 
    private Node node1;
    private Node node2;
    private Node node3;
    private Node node4;
    private Node dyn1;
    private Node dyn2;
    private Node dyn3;
    private Node dyn4;
    private HingeJoint joint1;
    private HingeJoint joint2;
    private HingeJoint joint3;
    private HingeJoint joint4;

    public static void main(String[] args) {
        Main app = new Main();

    public void simpleInitApp() {
        bulletAppState = new BulletAppState();
    private void setupStaticalNodes(){
        // Static nodes
        node1 = createControl(new BoxCollisionShape(new Vector3f(0.1f, 0.1f, 0.1f)), 0);
        node2 = createControl(new BoxCollisionShape(new Vector3f(0.1f, 0.1f, 0.1f)), 0);
        node3 = createControl(new BoxCollisionShape(new Vector3f(0.1f, 0.1f, 0.1f)), 0);
        node4 = createControl(new BoxCollisionShape(new Vector3f(0.1f, 0.1f, 0.1f)), 0);
        // Place out the static nodes
        node1.getControl(RigidBodyControl.class).setPhysicsLocation(new Vector3f(0f, 0, 0f));
        node2.getControl(RigidBodyControl.class).setPhysicsLocation(new Vector3f(1f, 0, 0f));
        node3.getControl(RigidBodyControl.class).setPhysicsLocation(new Vector3f(2f, 0, 0f));
        node4.getControl(RigidBodyControl.class).setPhysicsLocation(new Vector3f(3f, 0, 0f));
        // Attach them to physical space
        // Attach the static nodes to the rootNode
    private void setupDynamicalNodes(){
        // Static nodes
        dyn1 = createControl(new BoxCollisionShape(new Vector3f(0.5f, 0.5f, 0.5f)), 100);
        dyn2 = createControl(new BoxCollisionShape(new Vector3f(0.5f, 0.5f, 0.5f)), 100);
        dyn3 = createControl(new BoxCollisionShape(new Vector3f(0.5f, 0.5f, 0.5f)), 100);
        dyn4 = createControl(new BoxCollisionShape(new Vector3f(0.5f, 0.5f, 0.5f)), 100);
        // Place out the static nodes
        dyn1.getControl(RigidBodyControl.class).setPhysicsLocation(new Vector3f(-10f, -5, 0f));
        dyn2.getControl(RigidBodyControl.class).setPhysicsLocation(new Vector3f(1f, -5, 0f));
        dyn3.getControl(RigidBodyControl.class).setPhysicsLocation(new Vector3f(2f, -5, 0f));
        dyn4.getControl(RigidBodyControl.class).setPhysicsLocation(new Vector3f(3f, -5, 0f));
        // Attach them to physical space
        // Attach the static nodes to the rootNode
    private void setupJoints(){
        // Joints
        joint1 = new HingeJoint(node1.getControl(RigidBodyControl.class), // A
                     dyn1.getControl(RigidBodyControl.class), // B
                     Vector3f.ZERO,  // pivot point local to A
                     new Vector3f(0f, 5, 0),  // pivot point local to B
                     Vector3f.UNIT_Z,           // DoF Axis of A (Z axis)
                     Vector3f.UNIT_Z);        // DoF Axis of B (Z axis)
        joint2 = new HingeJoint(node2.getControl(RigidBodyControl.class), // A
                     dyn2.getControl(RigidBodyControl.class), // B
                     Vector3f.ZERO,  // pivot point local to A
                     new Vector3f(0f, 5, 0),  // pivot point local to B
                     Vector3f.UNIT_Z,           // DoF Axis of A (Z axis)
                     Vector3f.UNIT_Z);        // DoF Axis of B (Z axis)
        joint3 = new HingeJoint(node3.getControl(RigidBodyControl.class), // A
                     dyn3.getControl(RigidBodyControl.class), // B
                     Vector3f.ZERO,  // pivot point local to A
                     new Vector3f(0f, 5, 0),  // pivot point local to B
                     Vector3f.UNIT_Z,           // DoF Axis of A (Z axis)
                     Vector3f.UNIT_Z);        // DoF Axis of B (Z axis)
        joint4 = new HingeJoint(node4.getControl(RigidBodyControl.class), // A
                     dyn4.getControl(RigidBodyControl.class), // B
                     Vector3f.ZERO,  // pivot point local to A
                     new Vector3f(0f, 5, 0),  // pivot point local to B
                     Vector3f.UNIT_Z,           // DoF Axis of A (Z axis)
                     Vector3f.UNIT_Z);        // DoF Axis of B (Z axis)
    // Add control to a node. 
    // Static nodes has 0 mass and dynamicla nodes hass mass > 0
    private Node createControl(BoxCollisionShape shape, float mass){
        Node node = new Node();
        RigidBodyControl rigidBodyControl = new RigidBodyControl(shape, mass);
        return node;

    boolean flag = true;
    public void simpleUpdate(float tpf) {

    public void simpleRender(RenderManager rm) {
        //TODO: add render code

I jused the jme3- jbullet library and not the jme3-bullet and jme3-bullet-native.


Not really what I expected, but it’s bullet physics.
I expected a real simulation of newton’s cradle.

I think restitution defaults to zero to save on math. Try setting it to somewhere near 1 on all of your physicscontrols. It is mentioned here.


1 Like

Thank you. Now it looks like a real newton cradle. Not 100%, but more like 85% of behavior.

Hi again!

Why can’t I set the gravity at the RigidBodyControl?

I try to sett some random vectors at the dynamical nodes, but nothing happens. Why?

dyn2.getControl(RigidBodyControl.class).setGravity(new Vector3f(10f, 0, 0));
dyn3.getControl(RigidBodyControl.class).setGravity(new Vector3f(100f, 0, 0));
dyn4.getControl(RigidBodyControl.class).setGravity(new Vector3f(1000f, 0, 0));
dyn5.getControl(RigidBodyControl.class).setGravity(new Vector3f(10000f, 0, 0));

maybe try setting the Y value instead?

Yes, But still nothing happens. It’s just a easy code of line and I don’t understand why the code won’t change the gravity of a individual spatials.

Setting the global gravity works.

bulletAppState.getPhysicsSpace().setGravity(new Vector3f(0, -10f, 0));

I set gravity on a RigidBodyControl, and it seemed to work. What evidence convinced you that nothing is happening?

Because you are doing it before you add it to the physics space… which will then set the gravity.


Ok! Not it’s working! Thank you.

Is there a way to fix the inner balls so they stand still, but still can give forces to the outer balls?



Found the solution:

1 Like