1#include <IO/CameraLoader/CameraLoader.hpp>
3#include <Core/Asset/FileData.hpp>
4#include <Core/Utils/StringUtils.hpp>
15using namespace Core::Utils;
16using namespace Core::Asset;
22bool CameraFileLoader::handleFileExtension(
const std::string& extension )
const {
23 return extension == camExt;
26FileData* CameraFileLoader::loadFile(
const std::string& filename ) {
28 auto fileData =
new FileData( filename );
29 if ( !fileData->isInitialized() ) {
31 LOG( logERROR ) <<
"[CameraLoader] Filedata cannot be initialized.";
34 if ( fileData->isVerbose() ) { LOG( logERROR ) <<
"[CameraLoader] File Loading begin..."; }
38 if ( !ss.is_open() ) {
40 LOG( logERROR ) <<
"[CameraLoader] Camera file " << filename <<
" cannot be read.";
49 Scalar fov, znear, zfar, zoom, aspect;
51 bool result = !ss.fail();
54 for ( uint i = 0; i < 16; ++i ) {
58 ss >> fov >> znear >> zfar >> zoom >> aspect;
62 LOG( logERROR ) <<
"[CameraLoader] Could not load camera file data: " << filename;
68 Camera* camera =
new Camera();
72 frame << M[0], M[1], M[2], M[3], M[4], M[5], M[6], M[7], M[8], M[9], M[10], M[11], M[12], M[13],
74 camera->setFrame( Core::Transform { frame } );
75 camera->setFOV( fov );
76 camera->setZNear( znear );
77 camera->setZFar( zfar );
78 camera->setZoomFactor( zoom );
79 camera->setViewport( aspect, 1 );
80 fileData->m_cameraData.emplace_back( camera );
81 if ( fileData->isVerbose() ) { fileData->displayInfo(); }
83 fileData->m_loadingTime = ( endTime - startTime ) / Scalar( CLOCKS_PER_SEC );
84 fileData->m_processed =
true;
89 return "CameraLoader";
ProjType
Define the projection type.
hepler function to manage enum as underlying types in VariableSet