|
Vec_to_Angle and spinning at 90 and 270
#166450
11/08/07 03:30
11/08/07 03:30
|
Joined: Apr 2002
Posts: 1,246 ny
jumpman
OP
Serious User
|
OP
Serious User
Joined: Apr 2002
Posts: 1,246
ny
|
Is there a way to script an aiming function with vec_to_angle, so that when the tilt angle of the aiming object reaches the 90 and 270 degrees, that it doesn't flip?
I have an object thats aiming at a target and when the target's position is immediatly over the aiming object's position, the aiming object will spin. It will still successfully aim at the object, but it looks like its rolling. The closest thing I know how to call this effect is a Pole Vector if any of you used Maya. The pole vector was an imaginary line that if crossed, would spin the aiming object around its up axis. So it seems an object's pole vector in maya is it's z axis.
I'm not sure if this is gimbal lock or something, because Ive never run into the problem and gimbal lock search results have given me flight simulator rotations(adding rotation to already rotated objects if I'm correct). I think this effect is restricting the rotation values, or exceeding values, not sure how to call it.
Another example would be as if you were a floating head. A plane comes and flies under you while you are tracking it. It flies under and behind you, and now your head is upside down, while you are still tracking the plane.
If I didnt explain it right, tell me, I can post a picture.
Last edited by jumpman; 11/08/07 03:30.
|
|
|
Re: Vec_to_Angle and spinning at 90 and 270
[Re: jumpman]
#166451
11/08/07 09:14
11/08/07 09:14
|
Joined: Aug 2005
Posts: 1,558 HK
vlau
Serious User
|
Serious User
Joined: Aug 2005
Posts: 1,558
HK
|
It is hard to do without spin, I've never succeed, but you may try this : Code:
while(my) { vec_diff(temp,targetA.x,my.x); temp.tilt %= 90; // play with 90 vec_to_angle(my.pan,temp); wait(1); }
It still spin but smoothly. If you want to track a taget with arbitrary angle, you can try the example "chase camera" code from the manual->ang_add/anng_rotate.
|
|
|
Re: Vec_to_Angle and spinning at 90 and 270
[Re: vlau]
#166452
11/08/07 21:28
11/08/07 21:28
|
Joined: Apr 2002
Posts: 1,246 ny
jumpman
OP
Serious User
|
OP
Serious User
Joined: Apr 2002
Posts: 1,246
ny
|
hey Vlau,
I was able to look at and test the chase camera code from the manual:
var cam_dist[3] = -100,0,100; // xyz distance vector from camera towards the target
function chase_camera(target) { my = target; // The target Entity // calculate the camera view's direction angle to the target var cam_ang[3]; // direction angle of the camera to the target. vec_diff(temp,nullvector,cam_dist); vec_to_angle(cam_ang,temp); cam_ang.roll = 0; // roll didn't change vec_to_angle
// permanent updating of the camera's position and angle while (1) { // place the camera at the right position to the target vec_set(camera.x,cam_dist); vec_rotate(camera.x,my.pan); vec_add(camera.x,my.x); // Set the camera angles to the camera view direction vec_set(camera.pan,cam_ang); // and rotate it about the target angle ang_add(camera.pan,my.pan); wait(1); } }
////////////////////////
That code does work, the camera does not flip around its axis when it is immediatly above the target object, but I wouldnt know how to change it so that its not contrained to the pan and tilt values of the chased object.
What do I need to change to make it so that the camera will track another object from the camera's own position, without flipping?
Is this even possible with eulers?
|
|
|
|