how does the physics geometry work with a bounding volume of an object?
im having a problem using jme physics with an animated model, because the physics geometry is not updated when the character is animated (jump, attack, etc), i see this using PhysicsDebugger.drawPhysics(), but when I use Debugger.drawBounds() the bounding box is actually updated when the character performing some animation movement, however, the physics geom translation and rotation still work, i wonder if the jointcontroller used to animate the character only updating the bounding volume but not the physics geometry, is it true?
anyway, my first objective is actually to make the character can hit the enemy when he performs attack, or whatsoever to make the battle system looking good (as in zelda ocarina of time :p), i thought using jme physics collision detection can make my life easier… anyone can help me with this problem?
You would probably have to use
pNode.generateGeometry( true );
Boundings are used to generate the initial physics geometries as a convenience method (generatePhysicsGeometry). The geometries are not altered afterwards - only spatial transformations (translations, rotation, scale) are applied. They are not meant to adapt like boundings (which is important for most use cases).
What method do you use to animate your character? Do you change the mesh? Can you post a video with physics debugger switched on?
well, actually my team mate did some workaround to make it works, by calling the
PhysicsNode.generatePhysicsGeometry(dynamicPlayer, dynamicPlayer,
false, collisionGeometryMap);
and then add this in the update method:
for (Spatial key : collisionGeometryMap.keySet()) {
PhysicsCollisionGeometry phyGeom = collisionGeometryMap.get(
key);
BoundingBox box = (BoundingBox) ((Geometry) key).getBatch(0)
.getModelBound();
phyGeom.getLocalScale().set(box.xExtent * 2, box.yExtent * 2,
box.zExtent * 2);
phyGeom.getLocalTranslation().set(box.getCenter());
}
Im using JointController to animate ms3d character.
This approach works in many cases, yes. But be aware that it can cause strange effects in the simulation as setting positions of physical geoms directly is not the recommended way. But if it works for you, that's fine.