use of com.jme3.animation.AnimControl in project jmonkeyengine by jMonkeyEngine.
the class FbxNode method createScene.
public static Spatial createScene(FbxNode fbxNode) {
Spatial jmeSpatial = fbxNode.getJmeObject();
if (jmeSpatial instanceof Node) {
// Attach children to Node
Node jmeNode = (Node) jmeSpatial;
for (FbxNode fbxChild : fbxNode.children) {
if (!(fbxChild instanceof FbxLimbNode)) {
createScene(fbxChild);
FbxNode preferredParent = fbxChild.getPreferredParent();
Spatial jmeChild = fbxChild.getJmeObject();
if (preferredParent != null) {
System.out.println("Preferred parent for " + fbxChild + " is " + preferredParent);
Node jmePreferredParent = (Node) preferredParent.getJmeObject();
relocateSpatial(jmeChild, fbxChild.jmeWorldNodeTransform, preferredParent.jmeWorldNodeTransform);
jmePreferredParent.attachChild(jmeChild);
} else {
jmeNode.attachChild(jmeChild);
}
}
}
}
if (fbxNode.skeleton != null) {
jmeSpatial.addControl(new AnimControl(fbxNode.skeleton));
jmeSpatial.addControl(new SkeletonControl(fbxNode.skeleton));
SkeletonDebugger sd = new SkeletonDebugger("debug", fbxNode.skeleton);
Material mat = new Material(fbxNode.assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
mat.getAdditionalRenderState().setWireframe(true);
mat.getAdditionalRenderState().setDepthTest(false);
mat.setColor("Color", ColorRGBA.Green);
sd.setMaterial(mat);
((Node) jmeSpatial).attachChild(sd);
}
return jmeSpatial;
}
use of com.jme3.animation.AnimControl in project jmonkeyengine by jMonkeyEngine.
the class MeshLoader method compileModel.
private Node compileModel() {
Node model = new Node(meshName + "-ogremesh");
for (int i = 0; i < geoms.size(); i++) {
Geometry g = geoms.get(i);
Mesh m = g.getMesh();
// New code for buffer extract
if (sharedMesh != null && usesSharedMesh.get(i)) {
m.extractVertexData(sharedMesh);
}
model.attachChild(geoms.get(i));
}
if (animData != null) {
for (int i = 0; i < geoms.size(); i++) {
Geometry g = geoms.get(i);
Mesh m = geoms.get(i).getMesh();
//FIXME the parameter is now useless.
//It was !HADWARE_SKINNING before, but since toggleing
//HW skinning does not happen at load time it was always true.
//We should use something similar as for the HWBoneIndex and
//HWBoneWeight : create the vertex buffers empty so that they
//are put in the cache, and really populate them the first time
//software skinning is used on the mesh.
m.generateBindPose(true);
}
// Put the animations in the AnimControl
HashMap<String, Animation> anims = new HashMap<String, Animation>();
ArrayList<Animation> animList = animData.anims;
for (int i = 0; i < animList.size(); i++) {
Animation anim = animList.get(i);
anims.put(anim.getName(), anim);
}
AnimControl ctrl = new AnimControl(animData.skeleton);
ctrl.setAnimations(anims);
model.addControl(ctrl);
// Put the skeleton in the skeleton control
SkeletonControl skeletonControl = new SkeletonControl(animData.skeleton);
// This will acquire the targets from the node
model.addControl(skeletonControl);
}
return model;
}
Aggregations