SpiecsEngine
 
Loading...
Searching...
No Matches

◆ GetActiveCameraMatrix()

std::tuple< glm::mat4, glm::mat4, unsigned int, float > Spices::Renderer::GetActiveCameraMatrix ( FrameInfo & frameInfo)
protectedinherited

Get The activated camera entity's view matrix and projection matrix.

Parameters
[in]frameInfoThe current frame data.
Returns
Returns a tuple of view matrix, projection matrix, stable frames, fov.

Init viewmatrix and projectionmatrix.

Iter CameraComponent, finding a active camera.

Viewmaterix is the inverse of camera's modelmatrix.

Since we enable Negative viewport, we do not need reverse y axis here.

Break if finded.

Continue if not finded.

Throwout a warning if not a active camera.

Init viewmatrix and projectionmatrix.

Iter CameraComponent, finding a active camera.

Viewmaterix is the inverse of camera's modelmatrix.

Since we enable Negative viewport, we do not need reverse y axis here.

Break if finded.

Continue if not finded.

Throwout a warning if not a active camera.

Definition at line 304 of file Renderer.cpp.

305 {
307
311 glm::mat4 invViewMat = glm::mat4(1.0f);
312 glm::mat4 projectionMat = glm::mat4(1.0f);
313 unsigned int stableFrames = 0;
314 float fov = 0.0f;
315
316 bool find = false;
317
321 IterWorldCompWithBreak<CameraComponent>(
322 frameInfo,
323 [&](
324 int entityId ,
325 TransformComponent& transComp ,
326 CameraComponent& camComp
327 ){
328
329 if (camComp.IsActive())
330 {
334 invViewMat = transComp.GetModelMatrix();
335 projectionMat = camComp.GetCamera()->GetPMatrixReverseZ();
336 stableFrames = camComp.GetCamera()->GetStableFrames();
337 fov = glm::radians(camComp.GetCamera()->GetPerspectiveParam().fov);
338
342 //projectionMat[1][1] *= -1;
343
347 find = true;
348 return find;
349 }
350
354 return false;
355 });
356
360 if (!find)
361 {
362 std::stringstream ss;
363 ss << m_RendererName << ": " << "not find a active camera in world, please check again";
364
365 SPICES_CORE_WARN(ss.str())
366 }
367
368 return std::make_tuple(invViewMat, projectionMat, stableFrames, fov);
369 }
#define SPICES_PROFILE_ZONE
std::string m_RendererName
Specific renderer name, Passed by instanced.
Definition Renderer.h:2017

References Spices::CameraComponent::IsActive(), and Spices::Renderer::m_RendererName.