use of com.jme3.scene.plugins.fbx.anim.FbxBindPose in project jmonkeyengine by jMonkeyEngine.
the class SceneLoader method loadObjects.
private void loadObjects(FbxElement element) throws IOException {
FbxObject obj = null;
for (FbxElement e : element.children) {
switch(e.id) {
case "Geometry":
FbxMesh mesh = new FbxMesh(this, e);
obj = mesh;
if (mesh.geometries != null)
geomMap.put(mesh.id, mesh);
break;
case "Material":
obj = new FbxMaterial(this, e);
break;
case "Model":
FbxNode node = new FbxNode(this, e);
obj = node;
modelMap.put(node.id, node);
if (node.isLimb())
limbMap.put(node.id, node);
break;
case "Pose":
FbxBindPose pose = new FbxBindPose(this, e);
obj = pose;
bindMap.put(pose.id, pose);
break;
case "Texture":
obj = new FbxTexture(this, e);
break;
case "Video":
obj = new FbxImage(this, e);
break;
case "Deformer":
obj = loadDeformer(e);
break;
case "AnimationLayer":
FbxObject layer = new FbxObject(this, e);
obj = layer;
alayerMap.put(layer.id, layer);
break;
case "AnimationCurve":
obj = new FbxAnimCurve(this, e);
break;
case "AnimationCurveNode":
obj = new FbxAnimNode(this, e);
break;
default:
obj = null;
}
if (obj != null)
allObjects.put(obj.id, obj);
}
}
use of com.jme3.scene.plugins.fbx.anim.FbxBindPose in project jmonkeyengine by jMonkeyEngine.
the class FbxLoader method applyBindPoses.
/**
* Copies the bind poses from FBX BindPose objects to FBX nodes.
* Must be called prior to {@link #updateWorldTransforms()}.
*/
private void applyBindPoses() {
for (FbxBindPose bindPose : bindPoses) {
Map<FbxId, Matrix4f> bindPoseData = bindPose.getJmeObject();
logger.log(Level.INFO, "Applying {0} bind poses", bindPoseData.size());
for (Map.Entry<FbxId, Matrix4f> entry : bindPoseData.entrySet()) {
FbxObject obj = objectMap.get(entry.getKey());
if (obj instanceof FbxNode) {
FbxNode node = (FbxNode) obj;
node.setWorldBindPose(entry.getValue());
} else {
logger.log(Level.WARNING, "Bind pose can only be applied to FBX nodes. Ignoring.");
}
}
}
}
use of com.jme3.scene.plugins.fbx.anim.FbxBindPose in project jmonkeyengine by jMonkeyEngine.
the class SceneLoader method applySkinning.
private void applySkinning() {
for (FbxBindPose pose : bindMap.values()) pose.fillBindTransforms();
if (limbMap == null)
return;
List<Bone> bones = new ArrayList<>();
for (FbxNode limb : limbMap.values()) {
if (limb.bone != null) {
bones.add(limb.bone);
limb.buildBindPoseBoneTransform();
}
}
skeleton = new Skeleton(bones.toArray(new Bone[bones.size()]));
skeleton.setBindingPose();
for (FbxNode limb : limbMap.values()) limb.setSkeleton(skeleton);
for (FbxSkin skin : skinMap.values()) skin.generateSkinning();
// Attach controls
animControl = new AnimControl(skeleton);
sceneNode.addControl(animControl);
SkeletonControl control = new SkeletonControl(skeleton);
sceneNode.addControl(control);
}
Aggregations