OGRE import confusion

I've got a model I'd like o import to replace the box in the PhysicsCar example. I can load the model in the TestOgreLoading file just fine, even when I change the class to extend SimpleBulletApplication to be like the Physics car example. However when I try to load the model in the PhysicsCar example, I get an uncaught exception.    Here is my code showing the replacement of the box in the buildPlayer method of the PhysicsCar example. If I strip that method down to doing nothing but loading the model, I get the same problem.:



////        box stand in
//        Box b = new Box(new Vector3f(0, 0, 0), 0.5f, 0.5f, 2f);
//        Geometry g = new Geometry("Box", b);
//        g.setMaterial(matBox);
//        player = new PhysicsVehicleNode(g, new BoxCollisionShape(new Vector3f(0.5f, 0.5f, 2f)), 1);
//

        /*
         * This attempts to load the BODY of the robot in OGRE format
         */
         assetManager.registerLocator("../", FileLocator.class.getName());
        Spatial car = (Spatial) assetManager.loadModel("dependencies/body.mesh.xml");
        rootNode.attachChild(car);

//this stolen from FancyCar to get bunding box and collision shape of a model
        Node carNode = (Node) car;
        final Geometry chasis = findGeom(carNode, "Car");
        BoundingBox box = (BoundingBox) chasis.getModelBound();
        final Vector3f extent = box.getExtent(null);
        CompoundCollisionShape compoundShape = new CompoundCollisionShape();
        compoundShape.addChildShape(new BoxCollisionShape(extent), Vector3f.UNIT_Y);
        player = new PhysicsVehicleNode(chasis, compoundShape, 1);




Here is the output when I try to run this:
INFO: Child (BitmapFont) attached to this node (Statistics View)
Jul 22, 2010 2:36:48 PM com.jme3.scene.Node attachChild
INFO: Child (Statistics View) attached to this node (Gui Node)
Jul 22, 2010 2:36:48 PM com.jme3.scene.Node attachChild
INFO: Child (Floor) attached to this node (null)
Jul 22, 2010 2:36:48 PM com.jme3.scene.Node attachChild
INFO: Child (null) attached to this node (Root Node)
==========Model Loaded HERE===================
1279820891_1_Color_D02: emissive
1279820891_SketchupDefault: emissive
Jul 22, 2010 2:36:49 PM com.jme3.scene.Node attachChild
INFO: Child (body-geom-1) attached to this node (body-ogremesh)
Jul 22, 2010 2:36:49 PM com.jme3.scene.Node attachChild
INFO: Child (body-ogremesh) attached to this node (Root Node)
Jul 22, 2010 2:36:49 PM com.jme3.app.Application handleError
SEVERE: Uncaught exception thrown in Thread[LWJGL Renderer Thread,5,main]
java.lang.NullPointerException
        at RayTest.PhysicsCar.buildPlayer(PhysicsCar.java:342)
        at RayTest.PhysicsCar.simpleInitApp(PhysicsCar.java:119)
        at com.jme3.app.SimpleBulletApplication.initialize(SimpleBulletApplication.java:259)
        at com.jme3.system.lwjgl.LwjglAbstractDisplay.initInThread(LwjglAbstractDisplay.java:102)
        at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:147)
        at java.lang.Thread.run(Thread.java:619)

I dont know if that code was in the alpha-1 release, but why do you attach the loaded model to the root node? Its later attached to the PhysicsNode anyway… There were massive updates in the physics and physics tests lately, maybe you update to the latest nightly if you havent done so yet.



Also, can you please show which line is #342 where the exception happens?



Cheers,

Normen

Line 342 is the "        BoundingBox box = (BoundingBox) chasis.getModelBound();

" in the code in the original post.



I attached the car to the root node immediately after loading the model because I had commented out everything in that method except the loading of the model during tests.  When I comment out all code except the following, all I get is a grassy floor, no model.

        assetManager.registerLocator("../", FileLocator.class.getName());
        Spatial car = (Spatial) assetManager.loadModel("dependencies/robot.mesh.xml");
        car.setLocalTranslation(new Vector3f(.6f, 4, .5f));
        rootNode.attachChild(car);





I got the latest nightly build, and I attempted to run some of the sample programs in it to see if there were many changes. I can't run ANY of them because of this OpenAL error:

Jul 22, 2010 5:26:47 PM com.jme3.input.lwjgl.LwjglKeyInput initialize
INFO: Keyboard created.
Jul 22, 2010 5:26:47 PM com.jme3.app.Application handleError
SEVERE: Uncaught exception thrown in Thread[LWJGL Renderer Thread,5,main]
java.lang.NoSuchMethodError: Method org.lwjgl.openal.AL10.alEnable(I)V is not declared as native
        at org.lwjgl.openal.AL10.initNativeStubs(Native Method)
        at org.lwjgl.openal.AL.init(AL.java:158)
        at org.lwjgl.openal.AL.create(AL.java:140)
        at org.lwjgl.openal.AL.create(AL.java:104)
        at org.lwjgl.openal.AL.create(AL.java:203)
        at com.jme3.audio.lwjgl.LwjglAudioRenderer.initialize(LwjglAudioRenderer.java:62)
        at com.jme3.app.Application.initAudio(Application.java:119)
        at com.jme3.app.Application.initialize(Application.java:318)
        at com.jme3.app.SimpleBulletApplication.initialize(SimpleBulletApplication.java:223)
        at com.jme3.system.lwjgl.LwjglAbstractDisplay.initInThread(LwjglAbstractDisplay.java:102)
        at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:147)
        at java.lang.Thread.run(Thread.java:619)


I run linux and there are no drivers for my sound card, so I use a generic ALSA driver. I don't know if that has something to do with it or not. I don't need sound in anything I'm writing, so I don't know why OpenAL is default.

So your shape has got no bounding volume, which is a bit strange, but can be cured: chasis.setModelBound(new BoundingBox());



Cheers,

Normen

I added that line to the code as shown below. This is all that resides in the buildPlayer method now.:



        System.err.println("===============HERE===================");
         /*
         * This attempts to load the BODY of the robot in OGRE format
         */
        assetManager.registerLocator("../", FileLocator.class.getName());
        Spatial car = (Spatial) assetManager.loadModel("dependencies/robot.mesh.xml");
        car.setLocalTranslation(new Vector3f(.6f, 4, .5f));
       
        //this stolen from FancyCar to get bunding box and collision shape of a model
        Node carNode = (Node) car;
        final Geometry chasis = findGeom(carNode, "Car");
        chasis.setModelBound(new BoundingBox());                //New line just added
        BoundingBox box = (BoundingBox) chasis.getModelBound();
        final Vector3f extent = box.getExtent(null);
        CompoundCollisionShape compoundShape = new CompoundCollisionShape();
        compoundShape.addChildShape(new BoxCollisionShape(extent), Vector3f.UNIT_Y);
        player = new PhysicsVehicleNode(chasis, compoundShape, 1);
        player.updateModelBound();
        rootNode.attachChild(player);
        getPhysicsSpace().add(player);




Here is the output:
INFO: Child (Statistics View) attached to this node (Gui Node)
Jul 22, 2010 6:04:49 PM com.jme3.scene.Node attachChild
INFO: Child (Floor) attached to this node (null)
Jul 22, 2010 6:04:49 PM com.jme3.scene.Node attachChild
INFO: Child (null) attached to this node (Root Node)
===============HERE===================
1279820591_1_Color_D02: emissive
1279820591_SketchupDefault: emissive
Jul 22, 2010 6:04:50 PM com.jme3.scene.Node attachChild
INFO: Child (robot-geom-1) attached to this node (robot-ogremesh)
Jul 22, 2010 6:04:50 PM com.jme3.scene.Node attachChild
INFO: Child (robot-geom-2) attached to this node (robot-ogremesh)
Jul 22, 2010 6:04:50 PM com.jme3.app.Application handleError
SEVERE: Uncaught exception thrown in Thread[LWJGL Renderer Thread,5,main]
java.lang.NullPointerException
        at RayTest.PhysicsCar.buildPlayer(PhysicsCar.java:342)
        at RayTest.PhysicsCar.simpleInitApp(PhysicsCar.java:119)
        at com.jme3.app.SimpleBulletApplication.initialize(SimpleBulletApplication.java:259)
        at com.jme3.system.lwjgl.LwjglAbstractDisplay.initInThread(LwjglAbstractDisplay.java:102)
        at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:147)
        at java.lang.Thread.run(Thread.java:619)




What I am not understanding is why this code works in the TestOgreLoading file but not the PhysicsCar.  I literally tested it in the OGRELoading file, once successful copied and pasted into the PhysicsCar. I've even tried in the FancyCar demo with no luck.

Hm, sorry that wouldn't have thrown a nullpointer anyway… So you sure your model is at projectRoot/…/dependencies? Maybe its "./" instead of "…/" for the file locator? Although its strange you dont get an error message that the model could not be loaded… But apparently loading fails…

Yeah, try printing out where …/ points to, using new File("…/").getAbsolutePath()

Actually it is expected that you pass an absolute path to the FileLocator so you might want to do that instead of using things like …/

I know where that points to because I used it in the "setupFloor" method to load custom textures for the ground.



As a side note, I was testing loading a COLLADA file with this same example, and it doesn't work either, however the COLLADA file also loads f I put the code in the TestOgreLoading file.  I think there is just something wacky with this version of the PhysicsCar code.



Again, I am using the build from July-22 using updated libraries however the sample code I am using if from an older build. For some reason I cannot get any of the newer sample code to load due to the OpenAL errors I mentioned. I hope openAL isn't a permanent addition. I can only dev jme3 stuff on one of my 5 computers due to the video card supporting OpenGL2+ and If i can't run it at all because of OpenAL that would just really irk me.

The OpenAL error happens because you're using the LWJGL jars for version 2.5 but the native libs from 2.4.

Make sure jME3-lwjgl-natives-2.5.jar is the only natives jar in your classpath.

To prevent this issue from happening, I deleted all old versions from the repository.

That fixed it! I didn't even notice that, I use Netbeans and when updating the libs using the nightly builds, I delete my old lib references and add all the new ones.  I'll be more careful next time. Thanks for the tip!