Everything looks right but attaching the physics debug material shows several problems with the objects in the room.
There you can see the physics of the couch and plants are not rotated correctly. Several objects have this problem. All the chairs in the room - which are the same model just rotated differently - are all the same rotation in the physics.
The second problem arrises when I try and load this model in after exporting it with BinaryExporter.
Creating the physics node as before it seems everything gets re-centered to one spot. Again this is only the physics space - the visual of everything is perfectly fine.
You can sort of see how every object is there clumped up together.
And here's a shot from outside:
Again if I'm just doing this completely wrong just let me know.
You should not attach the loaded spatial to the rootNode before creating the physics collision shape on it. Try adding it after and see if that works and if not, can you maybe try and see if objects collide with your scene. Maybe its also a bug in the debug display.
Cheers,
Normen
Edit: also, your models rotations should be applied before exporting the model (ctrl-a in blender)
Why would the scene display correctly but the generated physics be off?
Well it can happen on collision shape creation or with messed up imported data. Animations for example also get messed up when the rotations are not properly applied to the meshes but still are dynamic.
Are you absoluetly sure your model is not attached to a rootNode or other node when you create the collision shape? I updated the latest svn version of jme3 with a check that throws an exception when that happens because it is certain to mess up the data.
Ok, I need to know exactly which version of jme you use and also if it works when you apply all rotations to the meshes (no object has local rotation or translation, but the meshes are translated).
You can of course recurse through your loaded model and create a CompoundCollisionShape yourself, combining multiple mesh shapes you create while you encounter meshes/geometrys in the model, thats what the CollisionShapeFactory does. This way you might find out what data is not synced here and maybe we have more info to help debugging this…
Cheers,
Normen
Edit: Also, if you use a not so current version of jme3, try calling updateGeometricState() on it after loading the node.
I tried scaling, translating and rotating the meshes. It's always the same.
Exactly thats what you're not supposed to do. You should apply those values to the mesh so they are all zero/one. Is there a way to combine the meshes in your modeller?
It seems it the physics doesn’t know how to handle rotations within 3dsmax.
Made a simple test scene:
Translating or scaling any object I made in max resulted in no problem for the physics. The tube has been scaled and almost everything has been moved around.
Rotation however doesn’t work. You can see the cone and box, rotated in max, display in the engine just fine, but the physics is wrong.
Edit: This is created using 3dsmax 2009 and exported with ogremax as an xml scene and loaded in like the above code.
Okay, so I guess this is related to the bad experiences people sometimes have when they want to animate models with rotated objects… Probably a bug or insufficiency in the OgreXML importer… Could you try obj import just for fun?
I am not sure how exactly JBullet-jME gets the transforms, but there might be rotations up the hierarchy in the scene file, and you need to make sure they are properly applied.
Call newsroom.updateGeometricState() right after you load it:
Does it happen when you import the single ogre meshes instead of the whole .scene file? Momoko, I think this might be correlated with the animation/rotation bugs, huh?
It obviously won't happen if loading the individual mesh.xml files because they are in model space without transforms. After the call to updateGeometricState() the Geometries will have valid world transforms, if jbullet isn't using that then something will be incorrect.
kirdel, maybe you can attach/send us the exported files so we can check?