Skip to content

Instantly share code, notes, and snippets.

@DragoniteSpam
Last active May 14, 2020 02:55
Show Gist options
  • Save DragoniteSpam/b51f1c36c920add86fef979d19538c43 to your computer and use it in GitHub Desktop.
Save DragoniteSpam/b51f1c36c920add86fef979d19538c43 to your computer and use it in GitHub Desktop.
Calculate the roll of a 3D camera
// I haven't used this in anything yet, but TheSnidr on the GameMaker discord posted
// this in response to a question about camera roll. He's usually pretty good at 3D
// math so I'm going to assume it works. "roll" is the angle around the direction the
// camera is looking at. Use for the view matrix.
var c = dcos(roll);
var s = dsin(roll) / max(math_get_epsilon(), sqrt(sqr(xdir) + sqr(ydir)));
matrix_build_lookat(x, y, z, x + xdir, y + ydir, z + zdir, ydir * s, -xdir * s, c);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment