Simple problem based on beginners tutorial (solved)

Hi guys.

Sorry to bother with those “newbie” questions. But somehow I have to start learning :wink:

I tried to use the beginner´s tutorial “Hello Collision” which worked fine. By the way, I completed all beginner´s tutorials. But now after I discovered the SceneComposer, TerrainEditor and stuff like that, I would like to exchange the scene mentioned in the tutorial with my own created, simple scene.

The first try, creating an empty project and adding my scene in the basic project worked fine. Then I used the above mentioned Tutorial class, changed from zip loading to the assetManager.load … Method to load my scene. And this led to the following exception:

Uncaught exception thrown in Thread[LWJGL Renderer Thread,5,main]
java.lang.IndexOutOfBoundsException: 8465
at java.nio.DirectIntBufferU.get(
at com.jme3.scene.mesh.IndexIntBuffer.get(
at com.jme3.bullet.util.Converter.convert(
at com.jme3.bullet.collision.shapes.MeshCollisionShape.createCollisionMesh(
at com.jme3.bullet.collision.shapes.MeshCollisionShape.(
at com.jme3.bullet.util.CollisionShapeFactory.createSingleMeshShape(
at com.jme3.bullet.util.CollisionShapeFactory.createCompoundShape(
at com.jme3.bullet.util.CollisionShapeFactory.createCompoundShape(
at com.jme3.bullet.util.CollisionShapeFactory.createCompoundShape(
at com.jme3.bullet.util.CollisionShapeFactory.createMeshCompoundShape(
at com.jme3.bullet.util.CollisionShapeFactory.createMeshShape(
at mygame.Main.simpleInitApp(
at com.jme3.system.lwjgl.LwjglAbstractDisplay.initInThread(

I am wondering how a minimal scene has to be created correctly. My structure right now is just:

- New scene
+ terrain-newScene
+ terrain-newScenePatch1
+ terrain-newScenePatch2
+ terrain-newScenePatch3
+ terrain-newScenePatch4
+ PhysicsControl
+ DirectionalLight

What am I missing?

Somehow the model is not a proper mesh, for collision you need a mesh consisting only of triangles…

hm …

CollisionShape sceneShape = CollisionShapeFactory.createMeshShape((Node)level);

this is the line that causes the crash.

could it be that the floor must not be simply flat? maybe i have to make it somehow solid ? its has no height, it´s just the generated flat floor with a different texture.

As I said, the mesh should be a mesh composed of triangles. If you just want a plane, use a PlaneCollisionShape?

ok now i understood. thx. trying to change the CollisionShapeFactory call for the first. but one question stays, can the SDK also be used to create meshes? how can i proceed from the plane to a mesh? is there a tutorial, a tool or a tip from your side? … thanks norman your support is really great. hope i can give some time back later when i am more experienced with the sdk.

Oh, the “plane” you created was done with the terrain editor and you try to create a collision shape for that? Thats a little different, you would need to call the createCollisionShape on the actual Terrain geometry. However, you can create rigidbody and collision shape right in the editor and simply load them alongside with the model:

normen said:
Oh, the "plane" you created was done with the terrain editor and you try to create a collision shape for that? Thats a little different, you would need to call the createCollisionShape on the actual Terrain geometry.

Thanks for your help again. I managed to get a running example with a geometry box where I can stand on and run in different directions. And I also can see the flat terrain I created with the terrain editor. But the collision detection doesn´t work with that terrain so far, it only works for my geometry box where I stand on.

Now I would like to know, is it possible (tried searching in the tutorials, but didn´t yet find the right one) to create and manipulate geometry spatials with the SDK, too? To fully use it as "level editor"? Your posted video shows how to change surface textures, but it doesn´t show collision detection. Has the texture you chose also effect on collision detection? I don´t think so far. I have to say that I am not using the demo textures, but simple jpg test images and load them via my assetManager. Maybe the demo textures have more informations stored in the jar file (for example collision or the animated stuff seen in the video).

thx in advance!

I think my discussion goes somehow in the same direction as the link I just found:

There you stated:

normen said:
Just create them using e.g. blender and then import the model, apply a collision shape and fly :)

I have someone who takes the part of working with blender and creating models. But I can´t imagine the whole level will only be imported models. So the question remains wether it is possible to create spatial geometry objects via visual Editor in SDK or wether I have to do it programmatically.


Please read the documentation. You can combine mesh parts in a scene, yes. But the parts will have to be generated in an editor. Why exactly cant you imagine that the whole level is just imported models? Its like that in about 99.9% of all FPS games…

@normen got one last tip for me on that topic? :wink: because i already managed doing some of my model imports (some others fail unfortunately) and could also manage collision detection for geom objects. but the collision detection for my imported models doesnt work. tried several options with blender ogre export (static rigid, …) and tried different stuff in the jmonkey code. but i am still missing something. soooory to bother you. but at least you can see i am really hard interested in going on and i keep trying :wink: i LOVE the engine so far. but its not easy to start :wink: so far i only developed with javaEE webstuff (jsf, ejb, …).


import com.jme3.asset.AssetManager;

import com.jme3.bullet.BulletAppState;

import com.jme3.bullet.collision.shapes.SphereCollisionShape;

import com.jme3.bullet.control.RigidBodyControl;

import com.jme3.material.Material;

import com.jme3.math.ColorRGBA;

import com.jme3.math.Vector3f;

import com.jme3.scene.Geometry;

import com.jme3.scene.Node;

import com.jme3.scene.shape.Box;

import com.marlenegame.util.AssetManagerUtils;


  • The first testable level for the game engine


    public class TestLevel extends AbstractLevel {

    private Box floorBox;

    private Geometry floorGeometry;

    private RigidBodyControl floorPhysics;

    private Material floorMaterial;

  • Custom constructor setting the assetManager
  • @param assetManager
  • @param rootNode
  • @param bulletAppState


    public TestLevel(AssetManager assetManager, Node rootNode, BulletAppState bulletAppState) {

    super(assetManager, rootNode, bulletAppState);


  • initializing the scene and all viewable objects



    void init() {




  • setting up the default model for the given level


    private void initScene() {

    //load model and texture

    scene = getAssetManager().loadModel("Scenes/levels/testlevel/testlevel.j3o");

    scene.setLocalTranslation(0, 0, 0);


    AssetManagerUtils.addSimpleTexture(assetManager, scene, "Textures/floor/grass1.jpg");


    //add collision detection for scene

    SphereCollisionShape sphereShape = new SphereCollisionShape(1.0f);

    scene.addControl(new RigidBodyControl(sphereShape, 0));



  • adding a default floor for the given level


    private void initFloor() {

    //add a floor

    floorBox = new Box(new Vector3f(0, -2, 0), 100f, 2f, 100f);

    floorMaterial = new Material(assetManager, UNSHADED_MATERIAL);

    floorMaterial.setColor(COLOR, ColorRGBA.Gray);

    floorGeometry = new Geometry(COLOR, floorBox);


    floorGeometry.setLocalTranslation(0, 0, 0);


    floorPhysics = new RigidBodyControl(0.0f);






    The initScene is loading the j3o fine and it gets shown (even if i have to handle the textures again, because the ogre import doesnt import textured models). But i keep falling through the model.