thank you very much

these are part of what i used to test it (comments added so you know what i'm doing):
Code:

VECTOR camera_axis;

function cam_control()
{
temp.x = - 300; // put the camera 300 quants behind the ball, based on camera's orientation
temp.y = 0;
temp.z = 0;
vec_rotate(temp,camera.pan);
vec_add(temp,my.x);
vec_lerp(camera.x,camera.x,temp,0.5);
camera.pan -= mouse_force.x * 5; // mouse controls pan and tilt of camera
camera.tilt -= mouse_force.y * 5;
temp.x = 0; // this sets the global VECTOR "camera_axis", which is
temp.y = 1; // relative to the camera and used to test quaternion
temp.z = 0; // rotations. play with these values for different axes :P
vec_rotate(temp,camera.pan);
vec_set(camera_axis,temp);
}

action ball()
{
wait(1);
c_setminmax(me);
vec_set(camera_axis,nullvector); // sorts out initialization problems
QUATERNION my_rot; // this quaternion contains my orientation
QUATERNION my_spin;// and this contains how i want to spin the ball
ANGLE my_angle; // euler orientation
vec_set(my_angle,my.pan);
my_rot.w = 1; // this is like a default orientation, as quat_for_ang doesn't work yet
my_rot.x = 0;
my_rot.y = 0;
my_rot.z = 0;
var js = 0; // you'll see what this is for...
while(1)
{
js += time_frame*50/16; // basically this loop will run 50 times a second, which
while(js>0) // isn't needed for quaternions at all, but just something i do.
{
quaternize((key_w*2),camera_axis,my_spin); //create a quaternion that will rotate around the camera-controlled axis, and spin if "w" is pressed
quat_to_unit(my_spin); // normalize both
quat_to_unit(my_rot);
quat_multiply(my_rot,my_spin,my_rot); // rotate
ang_for_quat(my_angle,my_rot); // and convert to euler for GS use
vec_sub(my_angle,my.pan); // just finds the rotation needed for c_rotate
c_rotate(me,my_angle,IGNORE_PASSENTS|IGNORE_PASSABLE);
cam_control(); // control the camera
js -= 1; // don't want an infinite loop!
}
wait(1);
}
}

GS does use Euler angles, and in fact most sources use a different Euler rotation order, so it wasn't easy finding what i needed it still ends up using a Euler angle, but the quaternion representation is unaffected by the Euler translation, and is MUCH easier to use when rotating around an arbitrary axis. i plan on using these for my car game i'm making, as Euler angles were proving to be really annoying and often unrealistic.

julz

EDIT: i realized that x- and y- seem to be inverted when using quaternize, which doesn't seem to be fixing as easily as i thought i am certain the euler representations of the quaternions are correct, tho. when rotating around a vector using quaternize, i think the x and y values need to each be multiplied by -1 first. i'm pretty sure this won't be too much of a problem.

EDIT 2: above edit no longer applicable!

Last edited by JulzMighty; 02/28/07 10:09.

Formerly known as JulzMighty.
I made KarBOOM!