I am working on a Kinect Project. I have the position of the joints coming from the Kinect OpenNI.
in this case the shoulder position and the elbow postition
Looking at TestCustomAnim, TestOgreComplexAnim
I was trying to follow setUserTransforms
bone.setUserTransforms(Vector3f.ZERO, rotate, Vector3f.UNIT_XYZ);
If i pass in a constant say 90.0f as the angle the bone stays in one place
If I pass in a variable 90.0f to 0.0f it spins around and around like its adding the rotation to the current rotation instead of just setting it to that rotation.
Anyone have any Ideas why this is?
[java]
private float angleFromParent(Vector3f parentLocation, Vector3f childLocation){
float deltaY = childLocation.getY() - parentLocation.getY();
float deltaX = childLocation.getX() - parentLocation.getX();
return Math.round(FastMath.atan2(deltaY, deltaX) * 180 / FastMath.PI);
}
public void setBonePosition(String boneName, float angle){
if(USER_CONTROL){
Bone bone = getBone( control.getSkeleton().getRoots()[0], boneName);
if(bone!=null){
bone.setUserControl(true);
Quaternion rotate = new Quaternion();
rotate.fromAngleAxis(angle, Vector3f.UNIT_X); <
This angle
bone.setUserTransforms(Vector3f.ZERO, rotate, Vector3f.UNIT_XYZ);
}else {
System.out.println("Could Not Find" + boneName);
}
}
}[/java]