Last active
July 28, 2022 05:31
-
-
Save mattatz/76d59f96c9eebeb319819d0a504ecf25 to your computer and use it in GitHub Desktop.
Revisions
-
mattatz revised this gist
Apr 28, 2016 . 1 changed file with 1 addition and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -5,14 +5,11 @@ float4x4 look_at_matrix(float3 at, float3 eye, float3 up) { float3 zaxis = normalize(at - eye); float3 xaxis = normalize(cross(up, zaxis)); float3 yaxis = cross(zaxis, xaxis); return float4x4( xaxis.x, yaxis.x, zaxis.x, 0, xaxis.y, yaxis.y, zaxis.y, 0, xaxis.z, yaxis.z, zaxis.z, 0, 0, 0, 0, 1 ); } -
mattatz created this gist
Apr 28, 2016 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,19 @@ #ifndef _LOOK_AT_MATRIX_ #define _LOOK_AT_MATRIX_ float4x4 look_at_matrix(float3 at, float3 eye, float3 up) { float3 zaxis = normalize(at - eye); float3 xaxis = normalize(cross(up, zaxis)); float3 yaxis = cross(zaxis, xaxis); float dx = -dot(xaxis, eye); float dy = -dot(yaxis, eye); float dz = -dot(zaxis, eye); return float4x4( xaxis.x, yaxis.x, zaxis.x, 0, xaxis.y, yaxis.y, zaxis.y, 0, xaxis.z, yaxis.z, zaxis.z, 0, dx, dy, dz, 1 ); } #endif