• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Free 3D camera

TheSnidr

Heavy metal viking dentist
GMC Elder
GM Version: GameMaker Studio 2.3
Target Platform: All
Download: https://www.dropbox.com/s/h3sfhwc33gmucxy/FreeCamera.yyz
Links: N/A

Summary:
A video tutorial on how to freely rotate a 3D camera using the built-in matrix functions, plus some useful matrix knowledge.

Tutorial:

Matrix build and matrix multiply are two very useful functions, and learning how to use these will be invaluable if you intend to work with 3D in GM.
When it comes to rotating a camera, a lot of implementations make use of Euler angles/spherical coordinates for keeping track of camera orientation. This makes sense for games where there is a set up direction, like in most first-person shooters; when looking straight up in an FPS and then rotating to the side, the camera ends up spinning in place. This actually represents the loss of one axis of rotation, since both changing the yaw and the roll of the camera will result in the same transformation. This "locking" of one axis to another is what's called gimbal lock.
For other kinds of games, like flight simulators, gimbal lock is an undesired property. There's been a lot of confusion around how to avoid gimbal lock, and people often like suggesting using quaternions as the go-to solution. And while it's true, quaternions allow for gimbal lock-free rotations, they're not the only available solution; matrices will do the job just fine.
And since GM has basic matrix support built in, I would rather suggest this as the go-to solution.

Enjoy the video! Feedback is always appreciated!
 
Last edited:
Hmmm. Saw "free" and "3d camera", and thought to myself "I'm looking for a free 3d camera that doesn't get stuck on 360 degree vision. Yayyyy!"

See's it's for GMS 2............

Booo!

I just prefer using GMS 1, and wish both could be supported when people do things like this. But thank you for posting it anyway.
 

TheSnidr

Heavy metal viking dentist
GMC Elder
Hmmm. Saw "free" and "3d camera", and thought to myself "I'm looking for a free 3d camera that doesn't get stuck on 360 degree vision. Yayyyy!"

See's it's for GMS 2............

Booo!

I just prefer using GMS 1, and wish both could be supported when people do things like this. But thank you for posting it anyway.
The matrix functions used in the video are also available in GMS 1.4.
I have no intention of providing further support for a version of GameMaker that has been deprecated for literal years.
 

kburkhart84

Firehammer Games
I have no intention of providing further support for a version of GameMaker that has been deprecated for literal years.
I dropped support for GMS1 on my single currently available asset a long time ago..not as soon as Yoyo did, but some time after. People developing PC games I guess are just lucky that GMS1 still works since PC doesn't change like mobile does. But certainly you are much more than reasonable not supporting GMS1 this long after the deprecation.

quaternions allow for gimbal lock-free rotations, they're not the only available solution; matrices will do the job just fine.
I seem to remember that quats are often typically used because there are simply less numbers to mess around with. As I understand it, matrix rotation requires actual less operations than quat rotation(meaning it isn't the performance), but the storage for large amounts of these things may matter in some cases so it is a workable tradeoff. I also seem to remember something about interpolation between quats being better than with matrices but that part isn't clear(as you can tell I haven't messed with these things in quite a many years).
 

TheSnidr

Heavy metal viking dentist
GMC Elder
[...]
I seem to remember that quats are often typically used because there are simply less numbers to mess around with. As I understand it, matrix rotation requires actual less operations than quat rotation(meaning it isn't the performance), but the storage for large amounts of these things may matter in some cases so it is a workable tradeoff. I also seem to remember something about interpolation between quats being better than with matrices but that part isn't clear(as you can tell I haven't messed with these things in quite a many years).
You are correct, matrices require 3x3 indices to store rotation, whereas quaternions only need 4 values, so they're a lot more light weight. My main point was that GM has native matrix support, so it's a bit easier to work with when you have functions for manipulating them out of the box! :D
I also prefer matrices for the simple fact that you can easily extract the component vectors from them in order to displace the camera like I do in the video.

Dual quaternions are also very interesting. They allow for translation as well, making them super useful for skeletal animation. I use dual quaternions for my skeletal animation system, cutting the required amount of uniforms sent to the shader to a minimum.
 

kburkhart84

Firehammer Games
cutting the required amount of uniforms sent to the shader to a minimum.
This is also quite important. On that 3d system I'm talking about maybe doing I'd be doing the same. I don't think the technique was common back when I was fiddling with it, but that was when a lot of games were still doing vertex skinning instead of skeletons, and it wasn't all that common to even do the animation on the GPU(from what I remember).
 
Just what I've been looking for, thanks a lot. I'll use it in a different way, though, but your vid has shown me some important information that was hardly to find elsewhere.
 
I want to use parts of the script for an HTML 3d game but when I switch to HTML, it crashes like after .2 seconds. What's needed to get this code running in HTML?
 
Top