Skip to content

Instantly share code, notes, and snippets.

@roy-t
Created February 6, 2021 14:37
Show Gist options
  • Save roy-t/c3ce8d43d730cd861860d7e1322080ac to your computer and use it in GitHub Desktop.
Save roy-t/c3ce8d43d730cd861860d7e1322080ac to your computer and use it in GitHub Desktop.
Constructing a billboard Matrix - MonoGame version
// 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