The link dosn't work.

Oh and I barely had to change the code to get it to work, just a couple tweaks and also setting the water POLYGON flag.

Code:
void align_to_surface(ENTITY* Planet, ENTITY* Vehicle)
{
   VECTOR start_trace;
	VECTOR Temp_Vec;
	
	
	//get the surface position
   vec_set(start_trace,Vehicle.x);
	vec_sub(start_trace,Planet.x);
	      
	vec_normalize(start_trace,vec_length(start_trace)*2);
	vec_add(start_trace,Planet.x);
	me=Vehicle;
	c_trace(start_trace, Planet.x,IGNORE_ME|IGNORE_PASSABLE);
	
	      //DEBUGGING
	      //draw_line3d(start_trace,NULL,100);
	      //draw_line3d(start_trace,COLOR_RED,100);
	      //draw_line3d(Planet.x,COLOR_RED,100);
	      //draw_point3d(hit.x,COLOR_RED,100,16);
	
	//place vehicle on surface 
	//(taking into account vehicle min_z)
	vec_set(Temp_Vec,hit.x);
	vec_sub(Temp_Vec,Planet.x);
	      //DEBUGGING
	      DEBUG_VAR(vec_length(Temp_Vec), 100);
	vec_normalize(Temp_Vec,vec_length(Temp_Vec.x)-Vehicle.min_z);
	      //DEBUGGING
	      DEBUG_VAR(vec_length(Temp_Vec), 120);
	vec_add(Temp_Vec,Planet.x);
	vec_set(Vehicle.x,Temp_Vec);
	
	//rotate towards planet core
	vec_sub(Temp_Vec,Planet.x);
	alignToVec(Vehicle.pan, hit.nx, vector(0, 0, 1), 1); 
	alignToVec(Vehicle.pan, hit.nx, vector(0, 0, 1), 1); 
	alignToVec(Vehicle.pan, hit.nx, vector(0, 0, 1), 1); 
	alignToVec(Vehicle.pan, hit.nx, vector(0, 0, 1), 1); 
	alignToVec(Vehicle.pan, hit.nx, vector(0, 0, 1), 1); 
}


There are several alignToVec calls at the end to speed up the rotation smooth a little. Don't know if there is a better way to do it... And on monday I will also take a look at the code and try to optimize the calculations and simplify my code.

and here is the movement code:
Code:
c_move(vehicle,vector(key_w-key_s,0,0),nullvector,IGNORE_MODELS);
		ang_rotate(vehicle.pan,vector(key_a-key_d,0,0));
		align_to_surface(Planet[1], vehicle);


I'm also thinking of tweaking the movement code. that c_move bothers me since I'm not really going to use collision detection (hence the IGNORE_MODELS) for the "planet overview" in my game, I just use c_move to get the movement forward/back aligned with the vehicle orientation.
So I might think of doing those calculations myself in a custom function to get it working faster than a standard c_move.


"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