Last active
May 14, 2020 02:55
-
-
Save DragoniteSpam/b51f1c36c920add86fef979d19538c43 to your computer and use it in GitHub Desktop.
Calculate the roll of a 3D camera
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
// 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