• Home
  • Textbooks
  • Mathematics for Game Programming and Computer Graphics: Explore the essential mathematics for creating, rendering, and manipulating 3D virtual environments
  • Navigating the View Space

Mathematics for Game Programming and Computer Graphics: Explore the essential mathematics for creating, rendering, and manipulating 3D virtual environments

Penny de Byl

Chapter 15

Navigating the View Space - all with Video Answers

Educators


Section 1

Flying maneuvers

Problem 1

Make a copy of the Chapter_14 folder and name it Chapter_15.
The rotation matrices we need for the camera are in the Transform class. In fact, all the operations required for matrix manipulation to move and orient the camera are in the Transform class, and therefore rather than repeat code, it makes more sense to give the camera a transform component that can do all the work.

Check back soon!

Problem 2

To achieve this, go ahead and modify the Camera class as follows:
import pygame
import math

Check back soon!

Problem 3

Because the movement of the camera means that the oppositive movement is added to any game objects in world coordinates, we must detail with its position update in the opposite order. To Transform . py make the following modifications:
def update_position(self, position: pygame.Vector3,
local=True) :
if local:
self.MVM = self.MVM @ np.matrix $\left(\left[\begin{array}{ll}1,0,0,0],\end{array}\right.\right.$
$[0,1,0,0]$,
$[0,0,1,0]$,
[position.x,
position.y,
position.z,
1] ])
else:
self.MVM $=$ np.matrix $\left(\left[\begin{array}{lll}1, & 0,0,0],\end{array}\right.\right.$
$[0,1,0,0]$,
$[0,0,1,0]$,
[position.x, position.y,
position.z, 1]])
(@) self.MVM

Check back soon!