[Solved] Bones don't draw in the proper location

Hey, I’ve recently implemented Skeletal Animation with .fbx files in the engine I’m writing. Anyway I can’t get the bones in the proper location.

Also, before you start in, I know that this is not the best way to implement skeletal animation, but it’s just a start :wink:

Anyway here’s the recursive function that traverses the skeleton to draw the joints (FYI Bones are actually Joints)



	private int drawBones(GL2 gl, Bone b, int index)
	{
		//Get the transform from the current frame for the current bone
		Transform t = m_animation.m_frames[m_animation.m_curr_frame].m_transforms[index];
		//Set the transformations on the bone (prep for next frame)
		b.m_transform.setTranslate(t.getTranslate().m_x, t.getTranslate().m_y, t.getTranslate().m_z);
		b.m_transform.setRotation(t.getRotation().m_x, t.getRotation().m_y, t.getRotation().m_z);
		b.m_transform.setScale(t.getScale().m_x, t.getScale().m_y, t.getScale().m_z);

		//Push the current matrix on the stack
		gl.glMatrixMode(GL2.GL_MODELVIEW);
		gl.glPushMatrix();
		System.out.println("push: " + b.m_name + " " + index);
		
		//Update the model view matrix with our current transform
		gl.glTranslatef(b.m_transform.getTranslate().m_x, b.m_transform.getTranslate().m_y, b.m_transform.getTranslate().m_z);
		gl.glScalef(b.m_transform.getScale().m_x, b.m_transform.getScale().m_y, b.m_transform.getScale().m_z);
		gl.glRotatef(b.m_transform.getRotation().m_x, 1.0f, 0.0f, 0.0f);
		gl.glRotatef(b.m_transform.getRotation().m_y, 0.0f, 1.0f, 0.0f);
		gl.glRotatef(b.m_transform.getRotation().m_z, 0.0f, 0.0f, 1.0f);
		
		//draw the current bone
		gl.glPointSize(5);
		gl.glBegin(GL.GL_POINTS);
			gl.glColor3f((float)index / (float)m_bones.length, 0.0f, 0.0f);
			gl.glVertex3f(0.0f, 0.0f, 0.0f);
		gl.glEnd();

		//Now for each of the children on this bone, draw them
		if(b.m_children.length > 0) 
			for(int i = 0; i < b.m_children.length; i++)
				index = drawBones(gl, m_bones[b.m_children[i]], index+1);
		
		//Pop the current matrix off the stack
		gl.glPopMatrix();
		System.out.println("pop: " + b.m_name + " " + index);
		
		//return the index of the current bone
		return index;
	}