Physics doesn't work on preloaded models

Hello, my name is SeySayux, I'm new to these forums so I hope I'm doing everything all right. Excuse me for my English, I'm not that good at it.



I've some problems with the physics engine. It seems I cannot use physics on a model thats loaded.



I'm loading a .jme model (at least, it was a .3ds model, but i converted it) as the terrain for my game. Next I've tried to tell the physics engine to make the terrain a static node. I told it to generate a physics geometry, but then I got this error:


Illegal argument exception: scale shouldn't be 0



It seems to happen in a ODE class (i don't know the exact class anymore, but if you need it, I'll search for it)

Next i tried to make a physics mesh for each TriMesh inside the model (using PhysicsMesh.copyFrom()) but then the engine ignores the model.

Does anyone know what to do?

PS. if you need a method used in my game, I'll be happy to post it

Make sure your model does not contain any geometries with a 0 component in scale (e.g. [1, 0, 1]). As you'd want to generate geometries for a terrain make sure to pass triangleAccuracy == true. Using loaded models should be working fine.

How do I do this? I don't believe the scale is a problem (the terrain is showing up fine)

I tried to replace

gamemap.setLocalScale(.1f);


with

gamemap.setLocalScale(new Vector3f(.1f,.1f,.1f));


but I still get this exception:

java.lang.IllegalArgumentException: scale must not have 0 as a component!
        at com.jmex.physics.impl.ode.geometry.OdeBox.updateWorldVectors(OdeBox.java:69)
        at com.jme.scene.Spatial.updateWorldData(Unknown Source)
        at com.jme.scene.Spatial.updateGeometricState(Unknown Source)
        at com.jme.scene.Node.updateWorldData(Unknown Source)
        at com.jme.scene.Spatial.updateGeometricState(Unknown Source)
        at com.jme.scene.Node.updateWorldData(Unknown Source)
        at com.jme.scene.Spatial.updateGeometricState(Unknown Source)
        at SRBase.initGame(SRBase.java:308)
        at com.jme.app.BaseGame.start(Unknown Source)
        at game.main(game.java:41)
Exception in thread "main" java.lang.NullPointerException
        at SRBase.cleanup(SRBase.java:395)
        at com.jme.app.BaseGame.start(Unknown Source)
        at game.main(game.java:41)



I don't know how to pass the triangleAccuracy thingy.

The parameter to generatePhysicsGeometry must be true to use triangle accuracy.



The problem is not the local scale of your node but of some geometry. Have a look at the scales in you modeling application.

Ahem… can anyone help me?.. please?..

I already solved it myself. I replaced the planes (JME quads) which built up the terrain with very thin boxes. I think 3DS doesn't save a Y scale value of planes.



PS. Thank you very much irrisor, for all the help (little bit sarcasm  }:-@)

SeySayux said:

PS. Thank you very much irrisor, for all the help (little bit sarcasm  }:-@)

I don't think that sarcasm is in any way appropriate. But if you feel better now, that's fine for me :) - glad you found the problem in your model

Yea, thats true  XD. But anyways, this problem is solved, and it's solution opens a way to… tons of new problems.