|
Post by mikehense on Feb 21, 2015 2:27:22 GMT
Use GetHeading() to get the heading of any object passed to it... useful for making a compass pointer...
///////////////////////////////////////////////////////////////////////////// // // A FUNCTION THAT GETS THE HEADING OF AN OBJECT // //////////////////////////////////////////////////////////////////////////////
int GetHeading(int obj) { Quaternion x90Rotation; Quaternion vehicleOrientation, spriteOrientation; float xRot, yRot, zRot;
iQuaternionFromEulerAngles(x90Rotation,-90,0,0,"xyz"); //create a quaternion rotating -90 degs about X iObjectOrientation(obj,vehicleOrientation); //get vehicle orientation iQuaternionMultiply(spriteOrientation,vehicleOrientation,x90Rotation); // rotate the quaternion to transform from XZ plane to XY plane
// compass part // iQuaternionToEulerAngles(spriteOrientation,xRot,yRot,zRot); if(zRot>1)zRot=361-zRot; if(zRot<0)zRot*=-1; if(zRot>=0 && zRot<1)zRot=360;
return(zRot); //out_6 is a value print object with 3.0f digits set } --Mike
|
|
|
Post by NicusorN5 on Feb 21, 2015 8:12:06 GMT
this is for 3D Rad or other engines?
|
|
|
Post by Power Supersport on Feb 21, 2015 8:56:36 GMT
It is for 3DRad... Just you need to return that before Void Main() function...
Then in Void Main() you just type your output value (OUT_X) and type the fx like that "GetHeading(OBJ_Y)";
The final result should look: OUT_X = GetHeading(OBJ_Y); OUT_X - ValuePrint's output... OBJ_Y - Heading object...
|
|