Tried it, and I thought we had it... It took a while but finally it happened again. (I guess I was just being lucky for a while)

Results:
http://www.youtube.com/watch?v=3ggFWxYgIhs


Curent version of alignToVec:
Code:
function alignToVec(ANGLE* entAng, VECTOR* vec, VECTOR* axis, var factor) {
	vec_rotate(axis, entAng);
	vec_normalize(axis, 1);
	vec_normalize(vec, 1);
	VECTOR rotAxis;
	vec_cross(rotAxis, vec, axis);
	
	//USE ONLY ONE OF THE FOLLOWING TWO LINES!!!!!!!
	//var angle = -acos((float)vec_dot(axis, vec)) * factor; // instant rotation
	var angle = -acos((float)vec_dot(axis, vec)) * factor * vec_length(rotAxis); //smooth rotation
	
	ANGLE rotAngle;
	ang_for_axis(rotAngle, rotAxis, angle);
	ang_add(entAng, rotAngle);
}



Current version of look_at:
Code:
void look_at(ENTITY* Vehicle, VECTOR* Destination, ENTITY* Planet)
{
	VECTOR V_Nrml;
	ANGLE V_Ang;
	VECTOR V_Path;

	// copy my angle
	vec_set(V_Ang, Vehicle.pan);
	
	//get our vehicle's normal from the planet core
	vec_diff(V_Nrml, Vehicle.x, Planet.x);

	// orientate temporary angle as if on a perfect sphere
	alignToVec(V_Ang, V_Nrml, vector(0, 0, 1), 1);
	alignToVec(V_Ang, V_Nrml, vector(0, 0, 1), 1);
	alignToVec(V_Ang, V_Nrml, vector(0, 0, 1), 1);
	alignToVec(V_Ang, V_Nrml, vector(0, 0, 1), 1);
	alignToVec(V_Ang, V_Nrml, vector(0, 0, 1), 1);

	// get destination position relative to the vehicle's orientation
	vec_diff(V_Path, Destination, Vehicle.x);
	vec_rotateback(V_Path, V_Ang);
	
	//DEBUG path
	vec_set(testv1,V_Path);
		vec_normalize(testv1,1000);
		vec_add(testv1,Planet.x);
		draw_line3d(testv1,NULL,100);
		draw_line3d(testv1,COLOR_GREEN,100);
		draw_line3d(Planet.x,COLOR_GREEN,100);

	// convert to an angle
	vec_to_angle(V_Ang, V_Path);
	
	//AVOID GIMBAL LOCK!!!
	if(V_Ang.tilt>85||V_Ang.tilt<-85)
	{
	   return;
	}

	// now, V_Ang's pan is our angle
	ang_rotate(Vehicle.pan, vector(V_Ang.pan, 0, 0));
}




Spherical movement is such a pain! cry

Also... look closely at the video. The green (V_Path) line does seem to have a problem when vertical.
But... look even closer at the blue line and red dot when I am on the opposite side of the planet than the vehicle (the same side as destination). The vehicle is not opposite of destination when the problem happens! (it is sort of close by, but not directly opposite)

I'm confused again... seems the problem is not when opposite of the destination?!?!?!?


"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