Trouble adding Node in Jbullet

I'm having this error below, trying to insert a 3ds Model , in PhysicsVehicleNode:



erro:



SEVERE: Exception
java.lang.NullPointerException
   at com.jmex.jbullet.collision.shapes.BoxCollisionShape.createCollisionBox(BoxCollisionShape.java:67)
   at com.jmex.jbullet.collision.shapes.BoxCollisionShape.createCollisionBox(BoxCollisionShape.java:63)
   at com.jmex.jbullet.collision.shapes.BoxCollisionShape.<init>(BoxCollisionShape.java:27)
   at com.jmex.jbullet.nodes.PhysicsNode.createCollisionShape(PhysicsNode.java:582)
   at com.jmex.jbullet.nodes.PhysicsNode.<init>(PhysicsNode.java:154)
   at com.jmex.jbullet.nodes.PhysicsNode.<init>(PhysicsNode.java:139)
   at com.jmex.jbullet.nodes.PhysicsVehicleNode.<init>(PhysicsVehicleNode.java:85)
   at TestSimplePhysicsCar.setupGame(TestSimplePhysicsCar.java:211)
   at TestSimplePhysicsCar$3.call(TestSimplePhysicsCar.java:300)
   at TestSimplePhysicsCar$3.call(TestSimplePhysicsCar.java:1)
   at com.jme.util.GameTask.invoke(GameTask.java:140)
   at com.jme.util.GameTaskQueue.execute(GameTaskQueue.java:111)
   at com.jmex.game.StandardGame.update(StandardGame.java:378)
   at com.jmex.game.StandardGame.run(StandardGame.java:250)
   at java.lang.Thread.run(Unknown Source)



code is:


physicsCar=new PhysicsVehicleNode(GetCar(),CollisionShape.ShapeTypes.BOX);
        physicsCar.setMaxSuspensionTravelCm(500);
        physicsCar.setSuspensionCompression(4.4f);
        physicsCar.setSuspensionDamping(2.3f);
        physicsCar.setSuspensionStiffness(20f);



method


public static Node GetCar(){
      if (modelToLoad == null) {
            modelToLoad = Fiat500.class.getClassLoader().getResource(
                    "modelos/fiat500/fiat500.3ds");
        }
        try {
            MaxToJme C1 = new MaxToJme();
            ByteArrayOutputStream BO = new ByteArrayOutputStream();
            C1.convert(new BufferedInputStream(modelToLoad.openStream()), BO);
            r1 = (Node)BinaryImporter.getInstance().load(new ByteArrayInputStream(BO.toByteArray()));
          
            r1.setLocalScale(.075f);
          
            if (r1.getChild(0).getControllers().size() != 0){
               
                r1.getChild(0).getController(0).setSpeed(20);
            }
        } catch (IOException e) {
            System.out.println("Erro ao ler " );
            e.printStackTrace();
            System.exit(0);
        }
        Quaternion temp = new Quaternion();
        temp.fromAngleAxis(FastMath.PI / 2, new Vector3f(-1, 0, 0));
        //r1.setLocalRotation(temp);
      
        
        return r1;
      
   }



by google translate

Hm, funny. Seems like jbullet-jme cannot set a BoundingBox as the Nodes WorldBounds… You could try creating the BoxCollisionShape before… But surely theres some more work to do in jbullet-jme, this should not fail like it does, sorry.



BoxCollisionShape collShape=new BoxCollisionShape(new Vector3f(x,y,z));
new PhysicsVehicleNode(GetCar(),collShape);

Can anyone tell me why this fails with the node of this GetNode() method?


node.setModelBound(new BoundingBox());
node.updateModelBound();
node.updateWorldBound();
BoundingBox volume=(BoundingBox)node.getWorldBound();


volume=null, why?

I have added a fix for this problem to the svn version of jbullet-jme.

You can also auto-compute a collision shape using


Node car=GetCar();
car.updateGeometricState(0,true);
BoxCollisionShape collShape=new BoxCollisionShape(car);
new PhysicsVehicleNode(car,collShape);


as a workaround if you dont want to build jbullet-jme from svn.

Thank you very much





the chance worked :smiley: :smiley: