How To Adjust Capsule Shape Center or Midpoint

I have seen a couple post with this same question. I however, did not understand the solutions that were given or perhaps they were not quite the same problem.



I created my character in Blender then exported to Ogre (with blender2ogre). Because of this my characters origin is down at the characters feet along with the root armature bone.



When I add the CapsuleCollisionShape to my character it looks like the capsule uses my characters origin as its origin. From the few post I have read this does appear to be the case. My characters feet are at the middle of the capsule, his hips at the top and his body comes out of the top. This gives the appearance he is walking on air.



Being new at jmonkey, I may need an example to work from.



Here is my code:





physicsCharacter = new CharacterControl(new CapsuleCollisionShape(.5f, .5f), .5f);

physicsCharacter.setJumpSpeed(20);

// physicsCharacter.setFallSpeed(30);

// physicsCharacter.setGravity(30);

physicsCharacter.setFallSpeed(30);

physicsCharacter.setGravity(30);



characterNode = new Node(“character node”);

Spatial model = assetManager.loadModel(“Models/Cube.mesh.xml”);

model.scale(0.5f);

characterNode.addControl(physicsCharacter);

getPhysicsSpace().add(physicsCharacter);

rootNode.attachChild(characterNode);

characterNode.attachChild(model);



physicsCharacter.setPhysicsLocation(new Vector3f(0, 0, 0));

getPhysicsSpace().enableDebug(assetManager);

As expected, I figured it out after posting. I finally noticed what was in this post that I did had not noticed before: http://hub.jmonkeyengine.org/groups/physics/forum/topic/positioning-character-model-in-capsule-collision-shape



I need to set the model’s local translation.



Hopefully this post will help someone else.



model.setLocalTranslation(0, -0.5f, 0);

physicsCharacter.setPhysicsLocation(new Vector3f(0, 1, 0));