21void AssimpCameraDataLoader::loadData(
const aiScene* scene,
25 if ( scene ==
nullptr ) {
26 LOG( logDEBUG ) <<
"AssimpCameraDataLoader : scene is nullptr.";
30 if ( !sceneHasCamera( scene ) ) {
31 LOG( logDEBUG ) <<
"AssimpCameraDataLoader : scene has no Cameras.";
36 LOG( logINFO ) <<
"File contains Camera.";
37 LOG( logINFO ) <<
"Camera Loading begin...";
40 uint CameraSize = sceneCameraSize( scene );
41 data.reserve( CameraSize );
42 for ( uint CameraId = 0; CameraId < CameraSize; ++CameraId ) {
44 loadCameraData( scene, *( scene->mCameras[CameraId] ), *camera );
49 if ( m_verbose ) { LOG( logINFO ) <<
"Camera Loading end.\n"; }
60void AssimpCameraDataLoader::loadCameraData(
const aiScene* scene,
61 const aiCamera& camera,
63 Core::Matrix4 rootMatrix;
64 rootMatrix = Core::Matrix4::Identity();
65 Core::Matrix4 frame = loadCameraFrame( scene, rootMatrix, camera );
66 Core::Vector3 pos = assimpToCore( camera.mPosition );
67 Core::Vector3 lookAt = -assimpToCore( camera.mLookAt ).normalized();
68 Core::Vector3 up = assimpToCore( camera.mUp ).normalized();
69 Core::Vector3 right = lookAt.cross( up );
73 frame.block( 0, 0, 3, 1 ).normalize();
74 frame.block( 0, 1, 3, 1 ).normalize();
75 frame.block( 0, 2, 3, 1 ).normalize();
77 view.block<3, 1>( 0, 0 ) = right;
78 view.block<3, 1>( 0, 1 ) = up;
79 view.block<3, 1>( 0, 2 ) = lookAt;
80 view.block<3, 1>( 0, 3 ) = pos;
81 view.block<1, 3>( 0, 0 ) *= -1_ra;
82 data.
setFrame( Core::Transform { view * frame } );
84 data.
setType( Camera::ProjType::PERSPECTIVE );
88 data.
setFOV( camera.mHorizontalFOV );
89 data.
setZNear( camera.mClipPlaneNear );
90 data.
setZFar( camera.mClipPlaneFar );