Quarternion q = new Quarternion();
Quarternion tq = new Quarternion();
float[] rtemp = new float[3];
public void adjust_rotation(float[] vector)
{
if (grounded_rotation)
{
// rotation axis is the cross of the grounded plane normal
// and the vector of movement
rtemp = vector3d.normalize(vector);
axis = vector3d.cross_product(gnormal,rtemp);
}
// amount of rotation is the length of the vector
rangle = vector3d.length(vector)*2;
tq.set(rangle, axis);
q.multiply(tq);
// Note that I don't actually normalize here.
// I just added this to this example to show that I am normalizing elsewhere.
// I am normalizing after all frame rotations are multiplied together.
q.normalize();
}