Greetings, I am testing the SixDofSpringJoint class (docs: https://javadoc.jmonkeyengine.org/v3.x/com/jme3/bullet/joints/SixDofSpringJoint.html#enableSpring-int-boolean- , source code: https://github.com/jMonkeyEngine/jmonkeyengine/blob/master/jme3-bullet/src/main/java/com/jme3/bullet/joints/SixDofSpringJoint.java) for a future project that I already mentioned earlier in other article (Gravitation Simulator 2 is released! (public domain) and Universor Project is being worked). I want to connect two cubes with a SixDofSpringJoint but they don’t come together. When I put an index on enableSpring(…) between 0 and 3, the cubes disappear. If I make it bigger, the cubes don’t come together. What am I doing wrong?
// Box 1 Box b1 = new Box(0.5f, 0.5f, 0.5f); Geometry geom1 = new Geometry("Box 1", b1); Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md"); mat.setColor("Color", ColorRGBA.Gray); geom1.setMaterial(mat); rootNode.attachChild(geom1); RigidBodyControl rbc1 = new RigidBodyControl(3); geom1.addControl(rbc1); bulletAppState.getPhysicsSpace().add(rbc1); rbc1.setGravity(ZERO); // Box 2 Box b2 = new Box(0.5f, 0.5f, 0.5f); Geometry geom2 = new Geometry("Box 2", b2); geom2.setMaterial(mat); rootNode.attachChild(geom2); geom2.setLocalTranslation(Vector3f.UNIT_X.mult(2)); RigidBodyControl rbc2 = new RigidBodyControl(3); geom2.addControl(rbc2); bulletAppState.getPhysicsSpace().add(rbc2); rbc2.setGravity(ZERO); rbc2.setLinearVelocity(Vector3f.UNIT_X.mult(2)); // Joint SixDofSpringJoint joint = new SixDofSpringJoint(rbc1, rbc2, Vector3f.UNIT_X, Vector3f.UNIT_X.mult(-1), rot1, rot2, true); joint.enableSpring(4, true); bulletAppState.getPhysicsSpace().add(joint);
Since I didn’t know much about the usefulness of the matrices that are passed as a parameter in SixDofSpringJoint, I tried to put all the elements of the rot1 and rot2 matrices with ones. I changed them to 0 or 0.2f but nothing changes.