1template<
typename T, glm::precision P>
2FPSCamera<T, P>::FPSCamera(T fovy, T aspect, T nnear, T nfar) : mWorld(), mMovementSpeed(1), mMouseSensitivity(1), mFov(fovy), mAspect(aspect), mNear(nnear), mFar(nfar), mProjection(), mProjectionInverse(), mMousePosition(glm::tvec2<T, P>(0.0f))
7template<
typename T, glm::precision P>
12template<
typename T, glm::precision P>
19 mProjection = glm::perspective(fovy, aspect, nnear, nfar);
20 mProjectionInverse = glm::inverse(mProjection);
23template<
typename T, glm::precision P>
26 SetProjection(fovy, mAspect, mNear, mFar);
29template<
typename T, glm::precision P>
35template<
typename T, glm::precision P>
38 SetProjection(mFov, a, mNear, mFar);
41template<
typename T, glm::precision P>
48template<
typename T, glm::precision P>
52 glm::tvec2<T, P> mouse_diff = newMousePosition - mMousePosition;
53 mMousePosition = newMousePosition;
56 mouse_diff.y = -mouse_diff.y;
57 mouse_diff *= mMouseSensitivity;
59 mWorld.PreRotateX(mouse_diff.y);
60 mWorld.RotateY(-mouse_diff.x);
64 T move = 0.0f, strafe = 0.0f, levitate = 0.0f;
73 auto const deltaTime_s = std::chrono::duration<T>(deltaTime);
74 auto const movementChange = movementModifier * (mWorld.GetFront() * move + mWorld.GetRight() * strafe + mWorld.GetUp() * levitate);
75 auto const movementSpeed = mMovementSpeed * movementChange;
77 mWorld.Translate(movementSpeed * deltaTime_s.count());
81template<
typename T, glm::precision P>
84 return mWorld.GetMatrix();
87template<
typename T, glm::precision P>
90 return mWorld.GetMatrixInverse();
93template<
typename T, glm::precision P>
96 return GetViewToWorldMatrix() * mProjectionInverse;
99template<
typename T, glm::precision P>
102 return mProjection * GetWorldToViewMatrix();
105template<
typename T, glm::precision P>
108 return mProjectionInverse;
111template<
typename T, glm::precision P>
117template<
typename T, glm::precision P>
120 glm::tvec4<T, P> vv = glm::tvec4<T, P>(GetClipToView(xyw),
static_cast<T
>(1));
121 glm::tvec3<T, P> wv = mWorld.GetMatrix() * vv;
125template<
typename T, glm::precision P>
128 return xyw * glm::tvec3<T, P>(mProjectionInverse[0][0], mProjectionInverse[1][1],
static_cast<T
>(-1));
void Update(std::chrono::microseconds deltaTime, InputHandler &ih, bool ignoreKeyEvents=false, bool ignoreMouseEvents=false)
Definition FPSCamera.inl:49
glm::tmat4x4< T, P > GetClipToViewMatrix()
Definition FPSCamera.inl:106
glm::tmat4x4< T, P > GetWorldToViewMatrix()
Definition FPSCamera.inl:88
T GetAspect()
Definition FPSCamera.inl:42
~FPSCamera()
Definition FPSCamera.inl:8
glm::tmat4x4< T, P > GetViewToClipMatrix()
Definition FPSCamera.inl:112
glm::tmat4x4< T, P > GetViewToWorldMatrix()
Definition FPSCamera.inl:82
void SetProjection(T fovy, T aspect, T nnear, T nfar)
Definition FPSCamera.inl:13
T GetFov()
Definition FPSCamera.inl:30
glm::tmat4x4< T, P > GetWorldToClipMatrix()
Definition FPSCamera.inl:100
glm::tvec3< T, P > GetClipToWorld(glm::tvec3< T, P > xyw)
Definition FPSCamera.inl:118
void SetAspect(T a)
Definition FPSCamera.inl:36
glm::tmat4x4< T, P > GetClipToWorldMatrix()
Definition FPSCamera.inl:94
FPSCamera(T fovy, T aspect, T nnear, T nfar)
Definition FPSCamera.inl:2
void SetFov(T fovy)
Definition FPSCamera.inl:24
glm::tvec3< T, P > GetClipToView(glm::tvec3< T, P > xyw)
Definition FPSCamera.inl:126