I have been stuck on this problem for the last few days and cannot seem to get it working correctly. Any help would be great.

I have gone through various different aproaches to the problem, this is my current one:


Transforming the positions:
-First I take the position of my origin (vehicle to be moved) and calculate the angle I would need to rotate that vector by if I wanted it at the center (north pole).
-then I rotate the destination by that same angle.

Calculating angles:
-In a temporary variable I store the pan our vehicle would have if it was looking at our new destination from the center.
-In another temporary variable transform our vehicle's current angle to what it would have if it was stating straight (aligned to north pole).

Calculating the final result:
-I subtract the pan of our two stored (temporary) angles to get the difference between the two.
-I ang_add() the difference of both pans to our vehicle's angle (to get a pan rotation aligned to it's local axis).

Current code:
Code:
void look_at(ENTITY* Vehicle, VECTOR* Destination, ENTITY* Planet)
{
   VECTOR Dest;
   VECTOR V_Nrml;
   ANGLE V_Ang;
   VECTOR V_Path;
   var Displacement;
   ANGLE T_Ang;

	
   //get our vehicle's normal from the planet core
   vec_diff(V_Nrml,Vehicle.x,Planet.x);
	  
 
   //get vehicle's absolute angle from core
   vec_to_angle(V_Ang,V_Nrml);
   //transform it to angle from the top of our planet
   V_Ang.tilt=90-V_Ang.tilt;

   
   //translate Path
   vec_diff(V_Path,Destination,Planet.x);
   vec_rotate(V_Path,V_Ang);

   
   //get our absolute pan angle towards new path
   vec_to_angle(T_Ang,V_Path);

   
   //get our vehicle's absolute pan angle
   vec_set(V_Ang,Vehicle.pan);
   alignToVec(V_Ang, vector(0, 0, 1), vector(0, 0, 1), 1);

   
   //get the difference in angles
   Displacement=V_Ang.pan-T_Ang.pan;
   //rotate vehicle's local axsis
   ang_rotate(Vehicle.pan,vector(Displacement,0,0));
}



Result:
http://www.youtube.com/watch?v=UUCzsM9d3rg


"The more you know, the more you realize how little you know..."

I <3 HORUS
http://www.opserver.de/ubb7/ubbthreads.php?ubb=showflat&Number=401929&page=1