Camera Rotation With Quaternions // OpenGL Tutorial #15

Опубликовано: 04 Октябрь 2024
на канале: OGLDEV
20,482
418

AEJuice Free Plugins https://aejuice.com/free-plugins/?ref...
AEJuice I Want It All Bundle https://aejuice.com/product/i-want-it...
AEJuice YouTube Channel    / @aejuice  

In this video we complete the development of the camera by adding mouse support and calculating the camera rotations using Quaternions. This allows us to rotate the camera 360 degrees like in a first person shooter.

🔥 I'm using the following books as background information for my tutorials and I highly recommend them for learning more about OpenGL and Vulkan.
These are affiliate links so if you use them to buy the books the price is the same for you and I will get a small commision (thank-you!).

📖 OpenGL 4 Shading Language Cookbook - Third Edition: Build high-quality, real-time 3D graphics with OpenGL 4.6, GLSL 4.6 and C++17 3rd ed. Edition: https://amzn.to/3XO2J3S

📖 3D Graphics Rendering Cookbook: A comprehensive guide to exploring rendering algorithms in modern OpenGL and Vulkan: https://amzn.to/3MMJQbf
(Watch my short video review on this book:    • The 2nd book I'm using for my Vulkan ...  )

📖 Vulkan Programming Guide: The Official Guide to Learning Vulkan: https://amzn.to/3XwBjhr
(Watch my short video review on this book:    • The book I'm using for my Vulkan seri...  )

Make sure to watch all the previous tutorials in the "OpenGL For Beginners" playlist at    • OpenGL for Beginners  

Please visit https://ogldev.org to see more of my tutorials on modern OpenGL.

Link to source: https://github.com/emeiri/ogldev/blob...
If you want to get the same version that was used in the video checkout the tag TUT_15_FPS_CAMERA.

OpenGL 4.6 specification: https://www.khronos.org/registry/Open...

3D Math Primer For Graphics & Game Development book:
Amazon affiliate link: https://amzn.to/3tWgcoM
Free online version: https://gamemath.com/

Recommended videos for more background on Quaternions:
Quaternion sub-series by Jorge Rodriguez:    • MFGD - Quaternions   (also check out his entire "Math For Game Developers" playlist!).

A video by Sociamix:    • 10 mins GameDev tips - Quaternions  

Timecodes
0:00 - Intro
0:13 - Fixing the camera transformation matrix
1:41 - Handling the mouse
3:30 - The Horizontal Angle Of Rotation
4:08 - The Vertical Angle Of Rotation
4:42 - Quaternions introduction
5:47 - Quaternion notation
6:10 - Initializing the Quaternion
7:08 - Quaternion magnitude
7:37 - Quaternion conjugate
8:03 - Rotation using quaternions
10:08 - Starting the code review
10:45 - Switching to full screen mode
12:05 - Register a mouse callback
13:01 - Changes to the camera class
14:25 - Initialize the horizontal and vertical angles
17:27 - Handling mouse movements
18:44 - Update the UVN vectors
19:35 - Implement Quaternion rotation
21:28 - Handle the case where the mouse is on the edge of the screen
22:13 - Test the new camera
22:58 - Conclusion

Feel free to comment below.

Email: [email protected]
Facebook:   / ogldev-188319114585587  
Github: https://github.com/emeiri/ogldev.git
Twitter: @ogldev
One time donations (Paypal): https://ogldev.org/donate.html
Patreon:   / ogldev  

Credits:
William Rowan Hamilton image: https://en.wikipedia.org/wiki/William...
Sponza Palace image: https://en.wikipedia.org/wiki/Sponza_...
Music: "Sweet" from https://bensound.com

Enjoy,

Etay Meiri

#opengl #ogldev #opengtutorials