Hi,
I'm using MD5importer and I can load the mesh pretty well. It has a few bones and stuff. But now I want to animate a few of it's bones (without any physics concern). How do I do it? Is there any sample code about how to twist a arm for example? Anycode would help, her is what I've got so far.
Thanks,
Dirso
public class Main extends SimpleGame {
public static void main(String[] args) {
Main app = new Main();
app.setConfigShowMode(ConfigShowMode.AlwaysShow);
app.start();
}
protected void simpleInitGame() {
try{
MD5Importer.getInstance().loadMesh(Main.class.getClassLoader().getResource("models/Paralept2.md5mesh"), "anim");
}
catch(IOException e){
e.printStackTrace();
}
MD5Node node = (MD5Node)MD5Importer.getInstance().getMD5Node();
MD5Importer.getInstance().cleanup();
// I will rotate this pivot to move my light
Node pivot=new Node("Pivot node");
// This light will rotate around my sphere. Notice I don't give it a position
PointLight pl=new PointLight();
// Color the light red
pl.setDiffuse(ColorRGBA.red.clone());
// Enable the light
pl.setEnabled(true);
// Remove the default light and attach this one
lightState.detachAll();
lightState.attach(pl);
// This node will hold my light
SimpleLightNode ln=new SimpleLightNode("A node for my pointLight",pl);
// I set the light's position thru the node
ln.setLocalTranslation(new Vector3f(0,10,10));
// I attach the light's node to my pivot
pivot.attachChild(ln);
// I create a box and attach it too my lightnode. This lets me see where my light is
Box b=new Box("Blarg",new Vector3f(-.3f,-.3f,-.3f),new Vector3f(.3f,.3f,.3f));
// Give the box bounds
b.setModelBound(new BoundingBox());
b.updateModelBound();
ln.attachChild(b);
// I create a controller to rotate my pivot
SpatialTransformer st=new SpatialTransformer(1);
// I tell my spatial controller to change pivot
st.setObject(node, 0, -1);
// Prepare my controller to start moving around
st.interpolateMissing();
// Tell my pivot it is controlled by st
node.addController(st);
cam.setLocation(new Vector3f(0.0f, 0.0f, 10.0f));
// replace the default handler
input = new InputHandler();
// Attach pivot and sphere to graph
rootNode.attachChild(pivot);
rootNode.attachChild(node);
}
}