I did try a test starting out with a non-rotated angle and then aligning that to the surface normal (as if it were a perfect sphere).

Didn't work out, seems like the vec_rotate, vec_to_angle, and ang_rotate are working. But it looks like the alignToVec instruction does not...

Result:
http://www.youtube.com/watch?v=Y-UgW4IUHrs

Code:
void look_at(ENTITY* Vehicle, VECTOR* Destination, ENTITY* Planet)
{
	VECTOR V_Nrml;
	ANGLE V_Ang;
	VECTOR V_Path;
	ANGLE Path_Ang;
	var hemisphere;	
	
	//this time I start off with a nuetral angle for the calculations
	vec_fill(V_Ang, 0);//standing stright up with zero pan
	
	//get our vehicle's normal from the planet core
	vec_diff(V_Nrml, Vehicle.x, Planet.x);

	// orient angle by planet normal (perfect sphere)
	alignToVec(V_Ang, V_Nrml, vector(0, 0, 1), 1);

	// get destination position relative to the planet core
	vec_diff(V_Path, Destination, Vehicle.x);
	//rotate relative destination by absolute orientation
	vec_rotateback(V_Path, V_Ang);
	// convert to an angle
	vec_to_angle(Path_Ang, V_Path);
	
	
	//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);
	
	//avoid gimbal lock
	if(Path_Ang.tilt>89||Path_Ang.tilt<-89)
	{
		return;//don't rotate
	}

	// rotate angle by Path_Ang
	ang_rotate(V_Ang, vector(Path_Ang.pan, 0, 0));
	vec_set(Vehicle.pan,V_Ang);
}



I don't undertand it though, in my align_to_surface() function it works, but in my look_at() it seems to not do anything when I use alignToVec().

Also if you take a look at the movement code I posted in the above post, it actually calls look_at first, then moves, then align_to_surface... So if it was a problem with rotating several times, the last one should be failing, not the look_at()

I just don't understand it...


"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