Hi,
I had posted this is a follow up question in my own thread but didn't get any replies. I am attempting to let the user rotate each body part of a character imported from Milkshape. Anyone who has done something about this please let me know. I tried adding a controller to JointMesh in the MilkToJme.java file but had no success. HamsterOfDeath's code is for reading animations per joint. Whereas what I want is that the user of my tool is able to rotate and translate each body part the way it is done in MAX or any modelling software. In a way, I am trying to build the animations programatically.
This is my modification of the readGroups() method in order to set a controller for the joints. But this doesn't seem to work at all.
private void readGroups() throws IOException {
int nNumGroups=inFile.readUnsignedShort();
materialIndexes=new int[nNumGroups];
for (int i=0;i<nNumGroups;i++){
inFile.readByte(); // Ignore flags
inFile.readFully(tempChar,0,32); // Name
int numTriLocal=inFile.readUnsignedShort();
Vector3f[] meshVerts=new Vector3f[numTriLocal*3],meshNormals=new Vector3f[numTriLocal*3];
Vector3f[] origVerts=new Vector3f[numTriLocal*3],origNormals=new Vector3f[numTriLocal*3];
Vector2f[] meshTexCoords=new Vector2f[numTriLocal*3];
int[] meshIndex=new int[numTriLocal*3];
int[] jointIndex=new int[numTriLocal*3];
JointMesh theMesh=new JointMesh(cutAtNull(tempChar));
for (int j=0;j<numTriLocal;j++){
int triIndex=inFile.readUnsignedShort();
for (int k=0;k<3;k++){
meshVerts [j*3+k]=myVerts[myTris[triIndex].vertIndicies[k]].vertex;
meshNormals [j*3+k]=myTris[triIndex].vertNormals[k];
meshTexCoords [j*3+k]=myTris[triIndex].vertTexCoords[k];
meshIndex [j*3+k]=j*3+k;
origVerts [j*3+k]=meshVerts[j*3+k];
origNormals [j*3+k]=meshNormals[j*3+k];
jointIndex [j*3+k]=myVerts[myTris[triIndex].vertIndicies[k]].boneID;
}
}
theMesh.reconstruct(BufferUtils.createFloatBuffer(meshVerts),
BufferUtils.createFloatBuffer(meshNormals), null,
BufferUtils.createFloatBuffer(meshTexCoords),
BufferUtils.createIntBuffer(meshIndex));
theMesh.originalNormal=origNormals;
theMesh.originalVertex=origVerts;
theMesh.jointIndex=jointIndex;
finalNode.attachChild(theMesh);
materialIndexes[i]=inFile.readByte();
InputHandler input = new InputHandler(); //This is New
KeyBindingManager keyboard = KeyBindingManager.getKeyBindingManager(); //This is New
NodeHandler nc1; //This is New
Node selectedNode; //This is New
nc1 = new NodeHandler(theMesh, 5, 1 ); // This is New
input.addToAttachedHandlers( nc1 ); // This is New
keyboard.set("node1", KeyInput.KEY_SPACE); // This is New
InputAction buttonAction = new InputAction() { // This is New
public void performAction( InputActionEvent evt ) { // This is New
System.out.println( "button action performed" ); // This is New
} // This is New
};
input.addAction( buttonAction , "node1", false ); // This is New
finalNode.updateRenderState(); // This is New
}
Please let me know how can I make the controlling of joints through mouse or even keyboard possible.
Thank you
Pranav Bhalla