The Solution code
void calcmissiletilt( int id)
{
EZro_Vec LimbDir;
EZro_Vec EulerAngles;
EZro_Mat objectMatrix;
LimbDir.x = dbLimbDirectionX( id, 0);
LimbDir.y = dbLimbDirectionY( id, 0);
LimbDir.z = dbLimbDirectionZ( id, 0);
objectMatrix = EZro_Euler2Matrix(LimbDir);
//unglue object
dbUnGlueObject( id );
//Rotate Missile at new values
EulerAngles = EZro_Matrix2Euler(objectMatrix);
dbRotateObject(id, EulerAngles.x, EulerAngles.y, EulerAngles.z);
}
Perfect Tilt Function
void calctilt( int id, double angle, double move)
{
if (move == 0)
{ move = 0.65f;}
EZro_Vec EulerAngles;
EZro_Vec Point1;
EZro_Vec Point2;
EZro_Vec Point3;
EZro_Vec SurfNormal;
EZro_Mat objectMatrix;
// Object Positioning
//-----------------------------------------
//Point 1 = object position
Point1.x = dbObjectPositionX( id );
Point1.y = dbObjectPositionY( id );
Point1.z = dbObjectPositionZ( id );
//Point 2 = object position + 1Z
Point2.x = Point1.x;
Point2.y = dbGetTerrainGroundHeight( 1, Point1.x, Point1.z + move);
Point2.z = Point1.z + move;
//Point 3 = object position + 1X
Point3.x = Point1.x + move;
Point3.y = dbGetTerrainGroundHeight( 1, Point1.x + move, Point1.z);
Point3.z = Point1.z;
//Use FIND NORMAL Feature to find the normal of the surface
//--------------------------------------------------------
SurfNormal = EZro_FindNormal(Point1, Point2, Point3);
//Use Poly Align Feature to calculate angle
//-------------------------------------------
objectMatrix = EZro_AlignToPoly(angle, SurfNormal);
// Rotate object correctly
EulerAngles = EZro_Matrix2Euler(objectMatrix);
dbRotateObject(id, EulerAngles.x, EulerAngles.y, EulerAngles.z);
//return SurfNormal;
}
The missile Move Function
void movemissile( int id, double move, double rot)
{
EZro_Vec EulerAngles;
EZro_Mat objectMatrix;
EZro_Vec PointBelow;
//Setup EZrotate with the objects current rotation
EulerAngles.x = dbObjectAngleX( id );
EulerAngles.y = dbObjectAngleY( id );
EulerAngles.z = dbObjectAngleZ( id );
objectMatrix = EZro_Euler2Matrix(EulerAngles);
//Setup EZrotate with the objects position
objectMatrix.pos.x = dbObjectPositionX( id );
objectMatrix.pos.y = dbObjectPositionY( id );
objectMatrix.pos.z = dbObjectPositionZ( id );
//Use "PITCH TO" to slowly rotate the missile to a point directly below the missile:
PointBelow.x = objectMatrix.pos.x;
PointBelow.y = objectMatrix.pos.y - 1;
PointBelow.z = objectMatrix.pos.z;
objectMatrix = EZro_PitchTo(objectMatrix, PointBelow, rot);
//Find new Euler angles and apply to object
EulerAngles = EZro_Matrix2Euler(objectMatrix);
dbRotateObject(id, EulerAngles.x, EulerAngles.y, EulerAngles.z);
//Move object forward
dbMoveObject( id, move);
}
Thanks To the help and support from WOLF
fubar