RigidBodyControl

Hello,

I get the newest version of JMP3 and have some problems with my old code.



I created the World like that:



[java]

CompoundCollisionShape levelShape = (CompoundCollisionShape)CollisionShapeFactory.createMeshShape((Node)worldmodel);

PhysicsNode levelNode = new PhysicsNode(worldmodel, levelShape, 0);

getRootNode().attachChild(levelNode);

getBulletAppState().getPhysicsSpace().add(levelNode);

[/java]



There were no problems. But JMP3-Alpha4 removed the PhysicsNode (Okay I can use it till now but…) So I tried to get it work with RigidBodyControl.



[java]

com.jme3.bullet.control.RigidBodyControl rbody =

new com.jme3.bullet.control.RigidBodyControl(CollisionShapeFactory.createMeshShape(worldmodel));

worldmodel.addControl(rbody);

getRootNode().attachChild(worldmodel);

getBulletAppState().getPhysicsSpace().add(rbody);

[/java]



But It doesn’t work :frowning:



(I’m really sorry for my bad english, I hope you can understand me :stuck_out_tongue: )

How does it not work? You can enable the debug view using

[java]getBulletAppState().getPhysicsSpace().enableDebug();[/java]

Ahh okay, I edit the position with that:



worldmodel.setLocalTranslation();

Thats why he fell down. Now I use rbody.setPhysicsLocation(new Vector3f(0, -100, 0)); and it works fine, thank you :slight_smile:

1 Like

Okay… I have some other problems now, and I don’t know why.



I add the World with this Code:

[java]



Spatial worldmodel = getAssetManager().loadModel(“Scenes/Island01.j3o”);



com.jme3.bullet.control.RigidBodyControl rbody =

new com.jme3.bullet.control.RigidBodyControl(CollisionShapeFactory.createMeshShape(worldmodel));



rbody.setKinematicSpatial(true);

rbody.setKinematic(true);





worldmodel.addControl(rbody);

getRootNode().attachChild(worldmodel);

Game.Scene.SceneManager.getGame().getBulletAppState().getPhysicsSpace().add(rbody);



[/java]



But if I enable debug-View it looks like that:

http://www.mainclain.de/cw_bug.png





Than I have a second problem.

I created some other players:



[java]

charModel.setModel((Node)getAssetManager().loadModel(model));



CapsuleCollisionShape capsule = new CapsuleCollisionShape(10f, 19f);

charModel.setCharacter(new CharacterControl(capsule, 1.00f));



charModel.getCharacter().setFallSpeed(80.0f);

charModel.getCharacter().setJumpSpeed(40.0f);



charModel.getCharacter().setGravity(60.0f);









getRootNode().attachChild(charModel.getModel());



RigidBodyControl rbc = new RigidBodyControl(40f);

charModel.getModel().addControl(rbc);

getBulletAppState().getPhysicsSpace().add(rbc);

charModel.getModel().addControl(charModel.getCharacter());

getPhysicsSpace().add(charModel.getCharacter());





charModel.getCharacter().setPhysicsLocation(position);

[/java]





They spawn on their position, they hit the world but if I go to them I can go in them - In Debug Mode all looks okay.



'http://www.mainclain.de/cw_bug3.png





And the last error - There is some little think, when I have only the map, but with my NPC and my Player there is some big error:



http://www.mainclain.de/cw_bug2.png



I can see it if I only spawn the world. But it’s only a little point.



If I only spawn my Player without NPC it looks like that:

http://www.mainclain.de/cw_bug4.png









What did I wrong?

And are there some example or tutorials for the new version?

  1. Debug view bug, the random lines are not there
  2. Characters dont collide with each other
  3. Also the debug view bug… Wonder why its so bad for you, could you upload the terrain mesh you are using?

How can I do that with the Characters? xD



And the other things weren’t my fault? Thats good :stuck_out_tongue:



I uploaded all Files to:

www.mainclain.de/World.tar.gz