SHARE
TWEET

Untitled

a guest Aug 25th, 2019 75 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. float4x4 GetRotationDir(float3 direction, float3 up = float3(0, 1, 0))
  2. {
  3.   float4x4 result;
  4.   float3 xaxis = normalize(cross(up, direction));
  5.   float3 yaxis = normalize(cross(direction, xaxis));
  6.  
  7.   result._11 = xaxis.x;
  8.   result._12 = yaxis.x;
  9.   result._13 = direction.x;
  10.   result._14 = 0;
  11.  
  12.   result._21 = xaxis.y;
  13.   result._22 = yaxis.y;
  14.   result._23 = direction.y;
  15.   result._24 = 0;
  16.  
  17.   result._31 = xaxis.z;
  18.   result._32 = yaxis.z;
  19.   result._33 = direction.z;
  20.   result._34 = 0;
  21.  
  22.   result._41 = 0;
  23.   result._42 = 0;
  24.   result._43 = 0;
  25.   result._44 = 1;
  26.   return result;
  27. }
  28.  
  29. float4x4 GetRotationDir(float3 direction, float3 xaxis, float3 yaxis)
  30. {
  31.   float4x4 result;
  32.  
  33.   result._11 = xaxis.x;
  34.   result._12 = yaxis.x;
  35.   result._13 = direction.x;
  36.   result._14 = 0;
  37.  
  38.   result._21 = xaxis.y;
  39.   result._22 = yaxis.y;
  40.   result._23 = direction.y;
  41.   result._24 = 0;
  42.  
  43.   result._31 = xaxis.z;
  44.   result._32 = yaxis.z;
  45.   result._33 = direction.z;
  46.   result._34 = 0;
  47.  
  48.   result._41 = 0;
  49.   result._42 = 0;
  50.   result._43 = 0;
  51.   result._44 = 1;
  52.   return result;
  53. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top