I imported my models from Blender in JME3 (character, sword and shield).
Right now, I want to attach the shield in the left hand and the sword in the right hand of the character.
I followed the instructions from TestOgreAnim.java but the transform of the objects relative to the character is wrong. What can be wrong?
Maybe were the bones created wrong in Blender? Or I should mirror the position of the spatial (sword and shield) relative to the character-node inside the JME? I cannot see the source model of the Ogre, used in JME3-examples to determine the best practices.
Code to load the character:
private void loadPlayer() {
String path = WrapperPathsCreationUtil.getPath(false, false, "Models", "Player", "Player.j3o");
var player = (Node) assetManager.loadModel(path);
((Node) rootNode.getChild(0)).attachChild(player);
enableAnimation(player);
loadWeaponAndShield(player);
}
code to load and attach the sword:
private void loadWeaponAndShield(Node person) {
String shieldName = "Shield";
String path = WrapperPathsCreationUtil.getPath(false, false, "Models",shieldName , shieldName + ".j3o");
this.shield = assetManager.loadModel(path);
String swordName = "Sword";
path = WrapperPathsCreationUtil.getPath(false, false, "Models",swordName , swordName + ".j3o");
this.sword = assetManager.loadModel(path);
this.sword.rotate(FastMath.PI, 0, 0); //I have played already with the angles but can not determine the dependency
SkinningControl skinningControl = person.getControl(SkinningControl.class);
Node n = skinningControl.getAttachmentsNode(SHIELD_BONE_NAME);
n.attachChild(this.shield);
Node n1 = skinningControl.getAttachmentsNode(SWORD_BONE_NAME);
n1.attachChild(this.sword);
}