i am thinking about the way how to move and position and also rotate a unit on terrain in a RTS game. First of all my actual point where i am:

I have a quadtree terrain engine that can give me back any interpolated height value by giving it the X and Y(will be the 3D Z coord) coords. So i can move a unit around and adjust the Y axis value of the unit so that it will not drown or fly over the terrain. Next i calculated the angle using pythagoream by using the X and Y(Z axis in 3D space again) movement (from a top down view) in which the unit is moving. So there is not at least any smooth rotation animation or so but some basic stuff.

I think the next step is rotating the unit also along the X and Z axis in 3D space. Therefore a thought of 4 vectors in world coords at the 4 bounding corners of my unit, then i want to get the height from the terrain at this points. After that i would like to calculate 2 angles for the X and 2 for the Z axis rotation and get and average value.

I think this is not really easy and at least the very often needed transformation of vector coords from unit projection coords to world coords gets me totally crazy so that i can't get an idea how to calculate that stuff anymore

Hopefully someone can give me some advice and/or practical used sample for that.

Greets Thunder2002