Getting a angle for an entity relative to a surface normal it has collided with?

Blitz3D Forums/Blitz3D Programming/Getting a angle for an entity relative to a surface normal it has collided with?

Craig H. Nisbet(Posted 2004) [#1]
I have a hovercar that needs to move over numerous obsticles. I'd like the car's pitch, and roll angle to reflect the pitch, and roll angle of the track underneath the car. I am using a collision sphere under the car to settle the car on the ground with some gravity physics, and collecting the collision normal information of the track surface. I'm not quite sure how to convert that normal to an angle relative to the facing of the car, because the track normal is in world space, and that normal, or angle, need to be converted to the relative space of my car. I can't quite seem to get it to work. I'm tried some the Tform functions, but I don't totally grasp them complete as of yet. I guess I need the pitch and roll infomatin for the car entity. Any idias?


N(Posted 2004) [#2]
Take a look at this
http://www.blitzbasic.com/codearcs/codearcs.php?code=392


Craig H. Nisbet(Posted 2004) [#3]
Actually that is only one part of the problem. I need to get a relative angle so I can match a vehicle, no matter which way it's facing to the contours of the track below it. Thanks for the code link though, I will use it also:)


(tu) sinu(Posted 2004) [#4]
try using the values from either

tformvector collx,colly,collz,1,car,0 or

tformvector collx,colly,collz,1,0,car

iirc one of these will report values relative to the car. So hitting head on will always return 1/ positive z value etc


tvtom(Posted 2004) [#5]
Craig is helping me with this thing. So far I have this:

TFormVector Nx,Ny,Nz,0,car
Nx = TFormedX()
Ny = TFormedY()
Nz = TFormedZ()

carpitch# = -(VectorPitch(Nx,Ny,Nz)+90) ;+90 to make car sit upright

RotateEntity car,carpitch,EntityYaw(car),0


With this the car will angle correctly going up a ramp... but coming back down the other side it angles itself on the pitch as if it's going up the ramp (even though it's heading down the ramp). The value we are getting back from the carpitch is the same going up the ramp as it is going down... don't know why?


tvtom(Posted 2004) [#6]
He figured it out with AlignVector........ so nevermind but thanks for the input!