Error creating physics geometry

Hey guys,



I have a fairly complex model im trying to use as a "floor" in the engine. Its basically a piece of the city I live in… The model will load in the engine fine unless i call generatePhysicsGeometry on it. Then it will crash with the following error



com.jmex.physics.PhysicsNode createPhysicsGeometry
WARNING: Skipped geometry:
java.lang.IllegalArgumentException: Extent cannot have a component that is 0 to generate collision geometries!
   at com.jmex.physics.PhysicsNode.createPhysicsGeometry(PhysicsNode.java:357)
   at com.jmex.physics.PhysicsNode.generatePhysicsGeometry(PhysicsNode.java:304)
   at com.jmex.physics.PhysicsNode.addPhysicsGeometries(PhysicsNode.java:202)
   at com.jmex.physics.PhysicsNode.addPhysicsGeometries(PhysicsNode.java:223)
   at com.jmex.physics.PhysicsNode.addPhysicsGeometries(PhysicsNode.java:223)
   at com.jmex.physics.PhysicsNode.generatePhysicsGeometry(PhysicsNode.java:172)
   at com.jmex.physics.PhysicsNode.generatePhysicsGeometry(PhysicsNode.java:147)
   at com.jmex.physics.PhysicsNode.generatePhysicsGeometry(PhysicsNode.java:132)
   at com.jmex.physics.PhysicsNode.generatePhysicsGeometry(PhysicsNode.java:119)
   at RtsMain.simpleInitGame(RtsMain.java:138)
   at com.jme.app.BaseSimpleGame.initGame(BaseSimpleGame.java:503)
   at com.jme.app.BaseGame.start(BaseGame.java:69)
   at RtsMain.main(RtsMain.java:374)
Jun 2, 2008 3:20:40 PM class RtsMain start()
SEVERE: Exception in game loop
java.lang.IllegalArgumentException: scale must not have 0 as a component (geom 'Line185##0')!
   at com.jmex.physics.impl.ode.geometry.OdeBox.updateWorldVectors(OdeBox.java:69)
   at com.jme.scene.Spatial.updateWorldData(Spatial.java:386)
   at com.jme.scene.Spatial.updateGeometricState(Spatial.java:351)
   at com.jme.scene.Node.updateWorldData(Node.java:395)
   at com.jme.scene.Spatial.updateGeometricState(Spatial.java:351)
   at com.jmex.physics.impl.ode.OdePhysicsSpace.updateScene(OdePhysicsSpace.java:827)
   at com.jmex.physics.impl.ode.OdePhysicsSpace.update(OdePhysicsSpace.java:620)
   at com.jmex.physics.util.SimplePhysicsGame.update(SimplePhysicsGame.java:141)
   at com.jme.app.BaseGame.start(BaseGame.java:79)
   at RtsMain.main(RtsMain.java:374)



What is wrong with my model that Jmonkey doesn't like? Any Ideas?

A Floor has no volume for Boundings, or is it a box?



for static stuff like terrain you can use generatePhysicsGeometry(true), for generating PolygonPhysics instead of Primitives, perhabs there the error doesn't come.



Good luck

it has a bounding box for boundings. I called generatePhysicsGeometry(true) but I get this error:



 An unexpected error has been detected by Java Runtime Environment:
#
#  EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x7d620f30, pid=1648, tid=2760
#
# Java VM: Java HotSpot(TM) Client VM (10.0-b19 mixed mode windows-x86)
# Problematic frame:
# C  [ntdll.dll+0x20f30]
#
# An error report file with more information is saved as:
# C:Documents and Settingsa.simonworkspaceSkylineRTSv2hs_err_pid1648.log
#
# If you would like to submit a bug report, please visit:
#   http://java.sun.com/webapps/bugreport/crash.jsp
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#

[error occurred during error reporting , id 0xc0000005]



Thanks for the suggestion :)

I think i've found the problem with the model… It seems when there is an object in the model that is completely flat, like a plane, thats what the error is talking about "extent.x cannot be less than 0"…

Interesting…



So i have some weird things going on with this model. I think im giong to ask the model guys to fix it since i kind of hacked the engine code to make it work.



Heres the method i hacked a little bit… Basically told it for force the bounding box not to be zero and to just make it small.


 private PhysicsCollisionGeometry createPhysicsGeometry( BoundingBox box ) {
        if ( box.xExtent <= 0) {
           box.xExtent = 1;}
        if ( box.yExtent <= 0) {
           box.yExtent = 1;}
        if ( box.zExtent <= 0) {
           box.zExtent = 1;}
           // Logger.getLogger( PhysicsSpace.LOGGER_NAME ).log( Level.WARNING, "Skipped geometry:" ,
                    //new IllegalArgumentException( "Extent cannot have a component that is 0 to generate " +
                   // "collision geometries!" ) );
       
        PhysicsBox geom = createBox( null );
        geom.getLocalScale().set( box.xExtent * 2, box.yExtent * 2, box.zExtent * 2 );
        geom.getLocalTranslation().set( box.getCenter() );
        return geom;
    }



Now the model actually works. I also had to call generatePhysicsGeometry(true) or else there would be no collisions at all... Driving my car on some parts of the model causes that weird access violation error...

Anyways, just thought i'd share with everyone!