Error with enabling debug for physics engine while working with player control

So here is the code snippet that is making trouble:



Node myCharacter = (Node) assetManager.loadModel(“Models/Soldier.v1.mesh.xml”);

myCharacter.setLocalTranslation(0,10,0);

CapsuleCollisionShape capsuleShape = new CapsuleCollisionShape(1f, 3f, 1);

CharacterControl myCharacter_phys = new CharacterControl(capsuleShape, 0.01f);

myCharacter.addControl(myCharacter_phys);

rootNode.attachChild(myCharacter);

bulletAppState.getPhysicsSpace().add(myCharacter_phys);



When this section of code work perfectly if my physics space does not have debug turned on; however if this line of code is run:



bulletAppState.getPhysicsSpace().enableDebug(assetManager);



A whole pair of intermittent errors will randomly pop-up:



May 19, 2012 1:48:40 PM com.jme3.bullet.BulletAppState postRender

SEVERE: null

java.util.concurrent.ExecutionException: java.lang.ClassCastException: com.bulletphysics.collision.shapes.TriangleShape cannot be cast to com.bulletphysics.collision.shapes.ConcaveShape



or



May 19, 2012 1:49:25 PM com.jme3.app.Application handleError

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

java.lang.ArrayIndexOutOfBoundsException



If i remove either of the above code sections my whole program works perfectly. I think this may be a bug, but I don’t know where to report it, and I might just be being stupid. What should I do?

Can you make a test case for this? Can’t really reproduce it, when creating a test case you’ll either see whats wrong in your code or you’ll get the same issue and I can track it down using that test case.

1 Like

Great idea Normen! So in doing this I can recreate the error, but it does require more steps than I previously thought. For the error to occur my map also has to be in the scene. I made the map in blender out of a series of nothing but scaled cubes. Exported it as a scene form blender and then I load the entire scene in jmonkey. I added physics to it by opening the .j3o in the scene editor selecting the top of the object tree and then clicking “add collision shape.” If there is an easy way to share this with you I would be happy to. Thanks for the help!



This is my test case which does reproduce the error:



package Test;



import com.jme3.app.SimpleApplication;

import com.jme3.material.Material;

import com.jme3.math.ColorRGBA;

import com.jme3.math.Vector3f;

import com.jme3.renderer.RenderManager;

import com.jme3.scene.shape.Box;

import com.jme3.scene.*;

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

import com.jme3.bullet.control.CharacterControl;

import com.jme3.bullet.BulletAppState;

import com.jme3.bullet.control.PhysicsControl;



/**

  • test
  • @author normenhansen

    */

    public class CharacterErrorTest extends SimpleApplication {



    public static void main(String[] args) {

    CharacterErrorTest app = new CharacterErrorTest();

    app.start();

    }



    @Override

    public void simpleInitApp() {

    BulletAppState bulletAppState;

    bulletAppState = new BulletAppState();

    bulletAppState.setThreadingType(BulletAppState.ThreadingType.PARALLEL);

    stateManager.attach(bulletAppState);

    Box b = new Box(Vector3f.ZERO, 1, 1, 1);

    Geometry geom = new Geometry(“Box”, b);



    Material mat = new Material(assetManager, “Common/MatDefs/Misc/Unshaded.j3md”);

    mat.setColor(“Color”, ColorRGBA.Blue);

    geom.setMaterial(mat);



    Spatial map = assetManager.loadModel(“Models/Map.j3o”);

    PhysicsControl cnt = map.getControl(PhysicsControl.class);



    bulletAppState.getPhysicsSpace().add(cnt);

    rootNode.attachChild(map);



    Node myCharacter = (Node) assetManager.loadModel(“Models/Cube.mesh.xml”);

    myCharacter.setLocalTranslation(0,10,0);

    CapsuleCollisionShape capsuleShape = new CapsuleCollisionShape(1f, 3f, 1);

    CharacterControl myCharacter_phys = new CharacterControl(capsuleShape, 0.01f);

    myCharacter.addControl(myCharacter_phys);

    rootNode.attachChild(myCharacter);

    bulletAppState.getPhysicsSpace().add(myCharacter_phys);

    bulletAppState.getPhysicsSpace().enableDebug(assetManager);

    rootNode.attachChild(geom);

    }



    @Override

    public void simpleUpdate(float tpf) {

    //TODO: add update code

    }



    @Override

    public void simpleRender(RenderManager rm) {

    //TODO: add render code

    }

    }

Normen I have set my test case on a git server so that you will be able to access it if you want



git clone http://174.45.208.195:8081/CharacterTestCase.git



will allow you to clone the repository through git.



A temporary password and username have been created so you can access this project



username : Normen

password : Normen



Hope this helps