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

Hi!

I was following this tutorial https://wiki.jmonkeyengine.org/jme3/advanced/hinges_and_joints.html and I’m doing a cradle with 6 joints and 6 balls.

The problem is that if I have more than 1 joint, the other joints is going to fall down.

Here is the code. Try to run it and add some hinge joints by removing the comments down there.

Right now the code

bulletAppState.getPhysicsSpace().add(Wire1Joint1);

Is activaded and you should see a pendelum with a square.

Try to activate

bulletAppState.getPhysicsSpace().add(Wire1Joint2);
package mygame;


import com.jme3.app.SimpleApplication;
import com.jme3.asset.AssetManager;
import com.jme3.bullet.BulletAppState;
import static com.jme3.bullet.PhysicsSpace.getPhysicsSpace;
import com.jme3.bullet.collision.shapes.BoxCollisionShape;
import com.jme3.bullet.collision.shapes.CollisionShape;
import com.jme3.bullet.control.RigidBodyControl;
import com.jme3.bullet.joints.HingeJoint;
import com.jme3.math.Vector3f;
import com.jme3.renderer.RenderManager;
import com.jme3.scene.Node;
import com.jme3.scene.Spatial;


/**
 * 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;
    
    public static void main(String[] args) {
        Main app = new Main();
        app.start();
    }

    @Override
    public void simpleInitApp() {
        flyCam.setMoveSpeed(20);
        
        bulletAppState = new BulletAppState();
        stateManager.attach(bulletAppState);
        bulletAppState.setDebugEnabled(true);
        
        // Load Cradle
        //Spatial Frame = assetManager.loadModel("Scenes/CradleScene.j3o");
        // Create node for that Cradle
        Node FrameNode = new Node();
        // Attach the cradle at the node
        //FrameNode.attachChild(Frame);
        rootNode.attachChild(FrameNode);
        
        // Create the static nodes for left wire
        //Node LeftWire1StaticNode = PhysicsTestHelper.createPhysicsTestNode(assetManager, new BoxCollisionShape(new Vector3f( .1f, .1f, .1f)),0);
        //Node LeftWire2StaticNode = PhysicsTestHelper.createPhysicsTestNode(assetManager, new BoxCollisionShape(new Vector3f( .1f, .1f, .1f)),0);
        //Node LeftWire3StaticNode = PhysicsTestHelper.createPhysicsTestNode(assetManager, new BoxCollisionShape(new Vector3f( .1f, .1f, .1f)),0);
        //Node LeftWire4StaticNode = PhysicsTestHelper.createPhysicsTestNode(assetManager, new BoxCollisionShape(new Vector3f( .1f, .1f, .1f)),0);
        //Node LeftWire5StaticNode = PhysicsTestHelper.createPhysicsTestNode(assetManager, new BoxCollisionShape(new Vector3f( .1f, .1f, .1f)),0);
        //Node LeftWire6StaticNode = PhysicsTestHelper.createPhysicsTestNode(assetManager, new BoxCollisionShape(new Vector3f( .1f, .1f, .1f)),0);
        
        Node Wire1StaticNode = createPhysicsTestNode(assetManager, new BoxCollisionShape(new Vector3f( .1f, .1f, .1f)),0);
        Node Wire2StaticNode = createPhysicsTestNode(assetManager, new BoxCollisionShape(new Vector3f( .1f, .1f, .1f)),0);
        Node Wire3StaticNode = createPhysicsTestNode(assetManager, new BoxCollisionShape(new Vector3f( .1f, .1f, .1f)),0);
        Node Wire4StaticNode = createPhysicsTestNode(assetManager, new BoxCollisionShape(new Vector3f( .1f, .1f, .1f)),0);
        Node Wire5StaticNode = createPhysicsTestNode(assetManager, new BoxCollisionShape(new Vector3f( .1f, .1f, .1f)),0);
        Node Wire6StaticNode = createPhysicsTestNode(assetManager, new BoxCollisionShape(new Vector3f( .1f, .1f, .1f)),0);
        
        // Create the static nodes for rigth wire
        //Node RigthWire1StaticNode = PhysicsTestHelper.createPhysicsTestNode(assetManager, new BoxCollisionShape(new Vector3f( .1f, .1f, .1f)),0);
        //Node RigthWire2StaticNode = PhysicsTestHelper.createPhysicsTestNode(assetManager, new BoxCollisionShape(new Vector3f( .1f, .1f, .1f)),0);
        //Node RigthWire3StaticNode = PhysicsTestHelper.createPhysicsTestNode(assetManager, new BoxCollisionShape(new Vector3f( .1f, .1f, .1f)),0);
        //Node RigthWire4StaticNode = PhysicsTestHelper.createPhysicsTestNode(assetManager, new BoxCollisionShape(new Vector3f( .1f, .1f, .1f)),0);
        //Node RigthWire5StaticNode = PhysicsTestHelper.createPhysicsTestNode(assetManager, new BoxCollisionShape(new Vector3f( .1f, .1f, .1f)),0);
        //Node RigthWire6StaticNode = PhysicsTestHelper.createPhysicsTestNode(assetManager, new BoxCollisionShape(new Vector3f( .1f, .1f, .1f)),0);
        
        // Create the dyncamical nodes for the balls
        Node Ball1Node = createPhysicsTestNode(assetManager, new BoxCollisionShape(new Vector3f( .1f, .1f, .1f)),1f);
        Node Ball2Node = createPhysicsTestNode(assetManager, new BoxCollisionShape(new Vector3f( .1f, .1f, .1f)),1);
        Node Ball3Node = createPhysicsTestNode(assetManager, new BoxCollisionShape(new Vector3f( .1f, .1f, .1f)),1);
        Node Ball4Node = createPhysicsTestNode(assetManager, new BoxCollisionShape(new Vector3f( .1f, .1f, .1f)),1);
        Node Ball5Node = createPhysicsTestNode(assetManager, new BoxCollisionShape(new Vector3f( .1f, .1f, .1f)),1);
        Node Ball6Node = createPhysicsTestNode(assetManager, new BoxCollisionShape(new Vector3f( .1f, .1f, .1f)),1);
        
        // Place out the static nodes for left wire
        //LeftWire1StaticNode.getControl(RigidBodyControl.class).setPhysicsLocation(new Vector3f(6f, 14.6214f,-7.56346f));
        //LeftWire2StaticNode.getControl(RigidBodyControl.class).setPhysicsLocation(new Vector3f(3.5f, 14.6214f,-7.56346f));
        //LeftWire3StaticNode.getControl(RigidBodyControl.class).setPhysicsLocation(new Vector3f(1f, 14.6214f,-7.56346f));
        //LeftWire4StaticNode.getControl(RigidBodyControl.class).setPhysicsLocation(new Vector3f(-1.5f, 14.6214f,-7.56346f));
        //LeftWire5StaticNode.getControl(RigidBodyControl.class).setPhysicsLocation(new Vector3f(-4f, 14.6214f,-7.56346f));
        //LeftWire6StaticNode.getControl(RigidBodyControl.class).setPhysicsLocation(new Vector3f(-6.5f, 14.6214f,-7.56346f));
        
        Wire1StaticNode.getControl(RigidBodyControl.class).setPhysicsLocation(new Vector3f(6f, 14.6214f,0f));
        Wire2StaticNode.getControl(RigidBodyControl.class).setPhysicsLocation(new Vector3f(3.5f, 14.6214f,0f));
        Wire3StaticNode.getControl(RigidBodyControl.class).setPhysicsLocation(new Vector3f(1f, 14.6214f,0f));
        Wire4StaticNode.getControl(RigidBodyControl.class).setPhysicsLocation(new Vector3f(-1.5f, 14.6214f,0f));
        Wire5StaticNode.getControl(RigidBodyControl.class).setPhysicsLocation(new Vector3f(-4f, 14.6214f,0f));
        Wire6StaticNode.getControl(RigidBodyControl.class).setPhysicsLocation(new Vector3f(-6.5f, 14.6214f,0f));
        
        // Place out the static nodes for the rigth wire
        //RigthWire1StaticNode.getControl(RigidBodyControl.class).setPhysicsLocation(new Vector3f(6f, 14.6214f,7.56346f));
        //RigthWire2StaticNode.getControl(RigidBodyControl.class).setPhysicsLocation(new Vector3f(3.5f, 14.6214f,7.56346f));
        //RigthWire3StaticNode.getControl(RigidBodyControl.class).setPhysicsLocation(new Vector3f(1f, 14.6214f,7.56346f));
        //RigthWire4StaticNode.getControl(RigidBodyControl.class).setPhysicsLocation(new Vector3f(-1.5f, 14.6214f,7.56346f));
        //RigthWire5StaticNode.getControl(RigidBodyControl.class).setPhysicsLocation(new Vector3f(-4f, 14.6214f,7.56346f));
        //RigthWire6StaticNode.getControl(RigidBodyControl.class).setPhysicsLocation(new Vector3f(-6.5f, 14.6214f,7.56346f));
        
        // Place out the dynamical nodes for the balls
        /*
        Ball1Node.getControl(RigidBodyControl.class).setPhysicsLocation(FrameNode.getChild("Ball1").getLocalTranslation());
        Ball2Node.getControl(RigidBodyControl.class).setPhysicsLocation(FrameNode.getChild("Ball2").getLocalTranslation());
        Ball3Node.getControl(RigidBodyControl.class).setPhysicsLocation(FrameNode.getChild("Ball3").getLocalTranslation());
        Ball4Node.getControl(RigidBodyControl.class).setPhysicsLocation(FrameNode.getChild("Ball4").getLocalTranslation());
        Ball5Node.getControl(RigidBodyControl.class).setPhysicsLocation(FrameNode.getChild("Ball5").getLocalTranslation());
        Ball6Node.getControl(RigidBodyControl.class).setPhysicsLocation(FrameNode.getChild("Ball6").getLocalTranslation());
        */
        
        Ball1Node.getControl(RigidBodyControl.class).setPhysicsLocation(new Vector3f(6, 3, 0));
        Ball2Node.getControl(RigidBodyControl.class).setPhysicsLocation(new Vector3f(3.5f, 3, 0));
        Ball3Node.getControl(RigidBodyControl.class).setPhysicsLocation(new Vector3f(1, 3, 0));
        Ball4Node.getControl(RigidBodyControl.class).setPhysicsLocation(new Vector3f(-1.5f, 3, 0));
        Ball5Node.getControl(RigidBodyControl.class).setPhysicsLocation(new Vector3f(-4, 3, 0));
        Ball6Node.getControl(RigidBodyControl.class).setPhysicsLocation(new Vector3f(-6.5f, 3, 0));
        
        
        // Attach the nodes
        /*
        FrameNode.attachChild(LeftWire1StaticNode);
        FrameNode.attachChild(LeftWire2StaticNode);
        FrameNode.attachChild(LeftWire3StaticNode);
        FrameNode.attachChild(LeftWire4StaticNode);
        FrameNode.attachChild(LeftWire5StaticNode);
        FrameNode.attachChild(LeftWire6StaticNode);
        */
        
        FrameNode.attachChild(Wire1StaticNode);
        FrameNode.attachChild(Wire2StaticNode);
        FrameNode.attachChild(Wire3StaticNode);
        FrameNode.attachChild(Wire4StaticNode);
        FrameNode.attachChild(Wire5StaticNode);
        FrameNode.attachChild(Wire6StaticNode);
        
        /*
        FrameNode.attachChild(RigthWire1StaticNode);
        FrameNode.attachChild(RigthWire2StaticNode);
        FrameNode.attachChild(RigthWire3StaticNode);
        FrameNode.attachChild(RigthWire4StaticNode);
        FrameNode.attachChild(RigthWire5StaticNode);
        FrameNode.attachChild(RigthWire6StaticNode);
        */
        
        // Sett the physics at the nodes
        /*
        getPhysicsSpace().add(LeftWire1StaticNode);
        getPhysicsSpace().add(LeftWire2StaticNode);
        getPhysicsSpace().add(LeftWire3StaticNode);
        getPhysicsSpace().add(LeftWire4StaticNode);
        getPhysicsSpace().add(LeftWire5StaticNode);
        getPhysicsSpace().add(LeftWire6StaticNode);
        */
        
        getPhysicsSpace().add(Wire1StaticNode);
        getPhysicsSpace().add(Wire2StaticNode);
        getPhysicsSpace().add(Wire3StaticNode);
        getPhysicsSpace().add(Wire4StaticNode);
        getPhysicsSpace().add(Wire5StaticNode);
        getPhysicsSpace().add(Wire6StaticNode);
        
        /*
        getPhysicsSpace().add(RigthWire1StaticNode);
        getPhysicsSpace().add(RigthWire2StaticNode);
        getPhysicsSpace().add(RigthWire3StaticNode);
        getPhysicsSpace().add(RigthWire4StaticNode);
        getPhysicsSpace().add(RigthWire5StaticNode);
        getPhysicsSpace().add(RigthWire6StaticNode);
        */
        
        // Sett the nodes for the balls
        FrameNode.attachChild(Ball1Node);
        FrameNode.attachChild(Ball2Node);
        FrameNode.attachChild(Ball3Node);
        FrameNode.attachChild(Ball4Node);
        FrameNode.attachChild(Ball5Node);
        FrameNode.attachChild(Ball6Node);
        
        // Sett the physics for the balls
        getPhysicsSpace().add(Ball1Node);
        getPhysicsSpace().add(Ball2Node);
        getPhysicsSpace().add(Ball3Node);
        getPhysicsSpace().add(Ball4Node);
        getPhysicsSpace().add(Ball5Node);
        getPhysicsSpace().add(Ball6Node);
        
        
        
        // 14.6214f = The static node Y-heigth 
        // 3f = The balls Y-heigth
        // So the rod will be 14.6214 - 3
        
        HingeJoint Wire1Joint1 = new HingeJoint(Wire1StaticNode.getControl(RigidBodyControl.class),
                                                    Ball1Node.getControl(RigidBodyControl.class),
                                                    Wire1StaticNode.getLocalTranslation(),
                                                    new Vector3f(14.6214f - 3f, 0f, 0f),
                                                    Vector3f.UNIT_Z,
                                                    Vector3f.UNIT_Z);
       
        /*
        HingeJoint Wire1Joint2 = new HingeJoint(Wire2StaticNode.getControl(RigidBodyControl.class),
                                                    Ball2Node.getControl(RigidBodyControl.class),
                                                    Wire2StaticNode.getLocalTranslation(),
                                                    new Vector3f(14.6214f - 3f, 0f, 0f),
                                                    Vector3f.UNIT_Z,
                                                    Vector3f.UNIT_Z);
        
        
        HingeJoint Wire1Joint3 = new HingeJoint(Wire3StaticNode.getControl(RigidBodyControl.class),
                                                    Ball3Node.getControl(RigidBodyControl.class),
                                                    Wire3StaticNode.getLocalTranslation(),
                                                    new Vector3f(14.6214f - 3f, 0f, 0f),
                                                    Vector3f.UNIT_Z,
                                                    Vector3f.UNIT_Z);
        
        HingeJoint Wire1Joint4 = new HingeJoint(Wire4StaticNode.getControl(RigidBodyControl.class),
                                                    Ball4Node.getControl(RigidBodyControl.class),
                                                    Wire4StaticNode.getLocalTranslation(),
                                                    new Vector3f(14.6214f - 3f, 0f, 0f),
                                                    Vector3f.UNIT_Z,
                                                    Vector3f.UNIT_Z);
        
        HingeJoint Wire1Joint5 = new HingeJoint(Wire5StaticNode.getControl(RigidBodyControl.class),
                                                    Ball5Node.getControl(RigidBodyControl.class),
                                                    Wire5StaticNode.getLocalTranslation(),
                                                    new Vector3f(14.6214f - 3f, 0f, 0f),
                                                    Vector3f.UNIT_Z,
                                                    Vector3f.UNIT_Z);
        
        HingeJoint Wire1Joint6 = new HingeJoint(Wire6StaticNode.getControl(RigidBodyControl.class),
                                                    Ball6Node.getControl(RigidBodyControl.class),
                                                    Wire6StaticNode.getLocalTranslation(),
                                                    new Vector3f(14.6214f - 3f, 0f, 0f),
                                                    Vector3f.UNIT_Z,
                                                    Vector3f.UNIT_Z);
       */
       // Add joint
       
        // Activate the physics for every joints
        
        bulletAppState.getPhysicsSpace().add(Wire1Joint1);
        //bulletAppState.getPhysicsSpace().add(Wire1Joint2);
        //bulletAppState.getPhysicsSpace().add(Wire1Joint3);
        //bulletAppState.getPhysicsSpace().add(Wire1Joint4);
        //bulletAppState.getPhysicsSpace().add(Wire1Joint5);
        //bulletAppState.getPhysicsSpace().add(Wire1Joint6);
        
        
    }

    @Override
    public void simpleUpdate(float tpf) {
        //TODO: add update code
    }

    @Override
    public void simpleRender(RenderManager rm) {
        //TODO: add render code
    }
    
    private Node createPhysicsTestNode(AssetManager manager, CollisionShape shape, float mass) {
        Node node = new Node("PhysicsNode");
        RigidBodyControl control = new RigidBodyControl(shape, mass);
        node.addControl(control);
        return node;
    }
}

Information

openjdk 10.0.1 2018-04-17
OpenJDK Runtime Environment (build 10.0.1+10-Ubuntu-3ubuntu1)
OpenJDK 64-Bit Server VM (build 10.0.1+10-Ubuntu-3ubuntu1, mixed mode)

jMonkeyEngine V3.2.1-Stable SDK 3 with JDK 1.8 as default

Picture:

They falling down if this is active

HingeJoint Wire1Joint2 = new HingeJoint(Wire2StaticNode.getControl(RigidBodyControl.class),
                                                Ball2Node.getControl(RigidBodyControl.class),
                                                Wire2StaticNode.getLocalTranslation(),
                                                new Vector3f(14.6214f - 3f, 0f, 0f),
                                                Vector3f.UNIT_Z,
                                                Vector3f.UNIT_Z);

bulletAppState.getPhysicsSpace().add(Wire1Joint2);

If not, the picture will look like this, which means that the pendulum is working correctly.

I ran TestPhysicsHingeJoint in jmeTests and it did the same thing in 3.1 and 3.2.

The joint fails and the object plunges into the depths below immediately upon start.

edit: Too busy to look at why myself and I don’t use physics for current project.

Good. Not only me having the same problem with the joints.

I think it is someting wrong at HingeJoint class. As long I only use one object of the HingeJoint class, the pendelum will do the job.

jmonkeyengine/HingeJoint.java at master · jMonkeyEngine/jmonkeyengine · GitHub seems like a wrapper class to me though.
You can try to replace jme3-bullet-native with jme3-jbullet and see if that changes things

How can I do that?

I notice now that the bug can be shown just by typing.

HingeJoint WireJoint2 = new HingeJoint(); 

Without arguments.

And this code should not be active:

//bulletAppState.getPhysicsSpace().add(WireJoint2);

Now the joints won’t work. According to the class HingeJoint, there are two constructors, one with arguments and one without arguments.

The constructor without arguments is written as:

public HingeJoint() {
}

Just empty! So why does the joints physics fails?

I suspect you shouldn’t use the null constructor. Often in JME3 a null constructor is provided for serialization purposes which isn’t otherwise useful.

I don’t use the null constructor. I did just trail and error search. I found out that If I use this code.

package mygame;

import com.jme3.app.SimpleApplication;
import com.jme3.asset.AssetManager;
import com.jme3.bullet.BulletAppState;
import com.jme3.bullet.PhysicsSpace;
import com.jme3.bullet.collision.shapes.BoxCollisionShape;
import com.jme3.bullet.collision.shapes.CollisionShape;
import com.jme3.bullet.control.RigidBodyControl;
import com.jme3.bullet.joints.HingeJoint;
import com.jme3.input.KeyInput;
import com.jme3.input.controls.AnalogListener;
import com.jme3.input.controls.KeyTrigger;
import com.jme3.math.Vector3f;
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 implements AnalogListener {
    private BulletAppState bulletAppState;
    private HingeJoint joint;
    private HingeJoint joint2;
    

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

    private void setupKeys() {
        inputManager.addMapping("Left", new KeyTrigger(KeyInput.KEY_H));
        inputManager.addMapping("Right", new KeyTrigger(KeyInput.KEY_K));
        inputManager.addMapping("Swing", new KeyTrigger(KeyInput.KEY_SPACE));
        inputManager.addListener(this, "Left", "Right", "Swing");
    }
    
    @Override
    public void onAnalog(String binding, float value, float tpf) {
        if(binding.equals("Left")){
            joint.enableMotor(true, 1, .1f);
        }
        else if(binding.equals("Right")){
            joint.enableMotor(true, -1, .1f);
        }
        else if(binding.equals("Swing")){
            joint.enableMotor(false, 0, 0);
        }
    }

    @Override
    public void simpleInitApp() {
        bulletAppState = new BulletAppState();
        stateManager.attach(bulletAppState);
        bulletAppState.setDebugEnabled(true);
        setupKeys();
        setupJoint();
    }

    private PhysicsSpace getPhysicsSpace(){
        return bulletAppState.getPhysicsSpace();
    }

    public void setupJoint() {
        
        Node holderNode = createPhysicsTestNode(assetManager, "Node1", new BoxCollisionShape(new Vector3f( .1f, .1f, .1f)),0);
        holderNode.getControl(RigidBodyControl.class).setPhysicsLocation(new Vector3f(0f,0,0f));
        rootNode.attachChild(holderNode);
        getPhysicsSpace().add(holderNode);

        Node hammerNode = createPhysicsTestNode(assetManager, "Node2", new BoxCollisionShape(new Vector3f( .3f, .3f, .3f)),1);
        hammerNode.getControl(RigidBodyControl.class).setPhysicsLocation(new Vector3f(0f,-1,0f));
        rootNode.attachChild(hammerNode);
        getPhysicsSpace().add(hammerNode);

        joint=new HingeJoint(holderNode.getControl(RigidBodyControl.class), hammerNode.getControl(RigidBodyControl.class), Vector3f.ZERO, new Vector3f(0f,-1,0f), Vector3f.UNIT_Z, Vector3f.UNIT_Z);
        getPhysicsSpace().add(joint);
        
        // New pendelum
        Node holderNode2 = createPhysicsTestNode(assetManager, "Node3", new BoxCollisionShape(new Vector3f( .1f, .1f, .1f)),0);
        holderNode2.getControl(RigidBodyControl.class).setPhysicsLocation(new Vector3f(5f,0,0f));
        rootNode.attachChild(holderNode2);
        getPhysicsSpace().add(holderNode2);
        
        Node hammerNode2 = createPhysicsTestNode(assetManager, "Node4", new BoxCollisionShape(new Vector3f( .3f, .3f, .3f)),1);
        hammerNode2.getControl(RigidBodyControl.class).setPhysicsLocation(new Vector3f(5f,-1,0f));
        rootNode.attachChild(hammerNode2);
        getPhysicsSpace().add(hammerNode2);
        
        // Joint2 won't work - Why?
        joint2 = new HingeJoint(holderNode2.getControl(RigidBodyControl.class), hammerNode2.getControl(RigidBodyControl.class), Vector3f.ZERO, new Vector3f(0f,-1f,0f), Vector3f.UNIT_Z, Vector3f.UNIT_Z);
        getPhysicsSpace().add(joint2);
    }

    @Override
    public void simpleUpdate(float tpf) {

    }
    
    private Node createPhysicsTestNode(AssetManager manager, String nodeName, CollisionShape shape, float mass) {
        Node node = new Node(nodeName); // "PhysicsNode"
        RigidBodyControl control = new RigidBodyControl(shape, mass);
        node.addControl(control);
        return node;
    }
    


}

And I change this line

joint2 = new HingeJoint(holderNode2.getControl(RigidBodyControl.class), hammerNode2.getControl(RigidBodyControl.class), Vector3f.ZERO, new Vector3f(0f,-1f,0f); 

To this

joint2 = new HingeJoint(holderNode.getControl(RigidBodyControl.class), hammerNode2.getControl(RigidBodyControl.class), Vector3f.ZERO, new Vector3f(0f,-1f,0f); 

Then it going to looks something like this

Which is very interesting, because it seems that holderNode2 won’t work at all.

Do you use the SDK or Gradle?
In the SDK modify the Libraries (Add Library, Remove Library), in Gradle just change jme3-bullet-native to jme3-jbullet

Hi!

I didn’t solve my problem.

Then I change to the Jbullet native library.

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

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

Markering_060

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:

Markering_061

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
Markering_062

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

Markering_063

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

Markering_064

https://wiki.jmonkeyengine.org/jme3/maven.html

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:
https://wiki.jmonkeyengine.org/jme3/jme3_source_structure.html#structure-of-lib-directory

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.

https://hub.jmonkeyengine.org/search?q=bullet%20vs%20jbullet

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

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

https://wiki.jmonkeyengine.org/jme3/advanced/hinges_and_joints.html