Lost between j3o and rigidbodycontrol

Hi there ,

I was experimenting the new terrain editor ( which is very nice and i hope there will be smooth inside but that’s another subject ) , and i was loading until now my terrain with a simple plane with xml ( the old method i guess ) , now i did a terrain and saved in my j3o scene and i’m a little lost with how i must proceed to make it colliding.

That is my terrain.xml working code :


public static Spatial terrainp;

/// **** Game Code

///*** Terrain Code

terrainp = assetManager.loadModel("/Models/Terrain/Plane.mesh.xml");



//CollisionShape sceneShape = CollisionShapeFactory.createMeshShape(terrainp);

//terrainp_phy = new RigidBodyControl(sceneShape, 0);

terrainp_phy = new RigidBodyControl(0);


terrainp_phy.setPhysicsLocation(new Vector3f(0, 30, 0));





How do i use my j3o file there ? thank you so much for any answer

First create the RigidBodyControl on the terrain node, then use assetManager.loadModel(“myFile.j3o”); and physicsSpace.addAll(loadedModel);


terrainp_phy = new RigidBodyControl(0);

scene = (Node) assetManager.loadModel("/Scenes/myscene.j3o");





This is what i did , i still new on the rigidbody stories sorry , what is wrong with my code ?

You are first doing something to the scene spatial and then assign a new spatial to that variable, that code is definitely wrong…

I edited , is that better now ? :stuck_out_tongue:

Just create the collisionshape in the editor right away.

You mean in the scene composer ?

i don’t know how to do that and didn’t find a documentation about that ( just checked SDK documentation )

Editor = Scene composer right ?

Terrain Editor or Scene Composer, yeah. Theres a button in scenecomposer for it (create collisionshape) or you can right-click the terrain in the SceneExplorer and select “Add RigidBodyControl” in any editor.

This is not good , when i do that the platform is freezing … i’m on windows 7 64 bits.

If i try to create another terrain and applying a rigitbodycontrol it’s also freezing , then when i try to reload my j3o it makes an error.

Could you do an example or screen exactly the step to create a collisionshape in the elements stuff on the terrain editor ?



Thanks for the video ,but that’s what i did , can you check again my code and tell me if it’s correct ?

Yes it is and no I don’t know “whats wrong then”. It works fine for me and others.

I’ll post the error i get when i get home thanks for the answers

I understand now where is the issue , it’s not about the code but about the editor … , when i do link to scenecomposer if i select the terrainquad to apply a collisionshape it just disappear and the composer is black … , the editor is still bugged >.>

Edit :

Now when i try to access to the terrain ( editing terrain ) the soft is freezing…

The editor is a lot unstable to be used as real project tool , i really hope there will be some corrections sooner

Edit 2 :

You should correct this bug :

com.jme3.asset.AssetNotFoundException: com/jme3/gde/terraineditor/dirt.jpg (Flipped) (Mipmaped)

Edit 3 :

Anyone who successed in windows 7 64 bits by loading a colliding terrain please tell me how did you do it … >_< it’s driving me crazy

Edit 4 :

This is the error message :

GRAVE: Uncaught exception thrown in Thread[LWJGL Renderer Thread,5,main]

java.lang.IndexOutOfBoundsException: 8465

at java.nio.DirectIntBufferU.get(DirectIntBufferU.java:209)

at com.jme3.scene.mesh.IndexIntBuffer.get(IndexIntBuffer.java:52)

at com.jme3.bullet.util.Converter.convert(Converter.java:248)

at com.jme3.bullet.collision.shapes.MeshCollisionShape.createCollisionMesh(MeshCollisionShape.java:70)

at com.jme3.bullet.collision.shapes.MeshCollisionShape.(MeshCollisionShape.java:65)

at com.jme3.bullet.util.CollisionShapeFactory.createSingleMeshShape(CollisionShapeFactory.java:194)

at com.jme3.bullet.util.CollisionShapeFactory.createCompoundShape(CollisionShapeFactory.java:95)

at com.jme3.bullet.util.CollisionShapeFactory.createCompoundShape(CollisionShapeFactory.java:92)

at com.jme3.bullet.util.CollisionShapeFactory.createCompoundShape(CollisionShapeFactory.java:92)

at com.jme3.bullet.util.CollisionShapeFactory.createCompoundShape(CollisionShapeFactory.java:117)

at com.jme3.bullet.util.CollisionShapeFactory.createMeshCompoundShape(CollisionShapeFactory.java:126)

at com.jme3.bullet.util.CollisionShapeFactory.createMeshShape(CollisionShapeFactory.java:153)

at com.jme3.bullet.control.RigidBodyControl.createCollisionShape(RigidBodyControl.java:134)

at com.jme3.bullet.control.RigidBodyControl.setSpatial(RigidBodyControl.java:109)

at com.jme3.scene.Spatial.addControl(Spatial.java:535)

By desactivating the RigidBody system in my code it’s loading properly so the problem is absolutely linked to that system what should i do ?

Yes, the terrain editor is in alpha but I can create terrain with collision shape from scratch no problem:


I even got an exception shortly but could just ignore it in this case.

1 Like

Thanks a lot for your patience and your video , but i can see you didn’t write anything about rigidbody or addcontrol does this code can manage a character walking on the terrain ?

I’m at work so i won’t be able to test it before tonight

Yes I do, at 3:00 I create a collision shape.