Created
February 6, 2021 14:37
-
-
Save roy-t/c3ce8d43d730cd861860d7e1322080ac to your computer and use it in GitHub Desktop.
Constructing a billboard Matrix - MonoGame version
This file contains 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 characters
// Based on: https://swiftcoder.wordpress.com/2008/11/25/constructing-a-billboard-matrix/ | |
public static Matrix CreateBillboard(Vector3 position, Matrix view) | |
{ | |
var result = Matrix.Identity; | |
result.Translation = position; | |
result.M11 = view.M11; | |
result.M12 = view.M21; | |
result.M13 = view.M31; | |
result.M21 = view.M12; | |
result.M22 = view.M22; | |
result.M23 = view.M32; | |
result.M31 = view.M13; | |
result.M32 = view.M23; | |
result.M33 = view.M33; | |
return result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment