MCPcopy Create free account
hub / github.com/NVIDIA-RTX/RTXPT / SaveCurrentCamera

Method SaveCurrentCamera

Rtxpt/Sample.cpp:919–968  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

917}
918
919void Sample::SaveCurrentCamera() const
920{
921 float3 worldPos = m_camera.GetPosition();
922 float3 worldDir = m_camera.GetDir();
923 float3 worldUp = m_camera.GetUp();
924 dm::dquat rotation;
925 dm::affine3 sceneWorldToView = dm::scaling(dm::float3(1.f, 1.f, -1.f)) * dm::inverse(m_camera.GetWorldToViewMatrix()); // see SceneCamera::GetViewToWorldMatrix
926 dm::decomposeAffine<double>( daffine3(sceneWorldToView), nullptr, &rotation, nullptr );
927
928 float4x4 projMatrix = m_view->GetProjectionMatrix();
929 bool rowMajor = true;
930 float tanHalfFOVY = 1.0f / (projMatrix.m_data[1 * 4 + 1]);
931 float fovY = atanf(tanHalfFOVY) * 2.0f;
932
933 bool autoExposure = m_ui.ToneMappingParams.autoExposure;
934 float exposureCompensation = m_ui.ToneMappingParams.exposureCompensation;
935 float exposureValue = m_ui.ToneMappingParams.exposureValue;
936
937 std::ofstream file;
938 file.open(app::GetDirectoryWithExecutable( ) / "campos.txt", std::ios_base::out | std::ios_base::trunc );
939 if( file.is_open() )
940 {
941 file << worldPos.x << " " << worldPos.y << " " << worldPos.z << " " << std::endl;
942 file << worldDir.x << " " << worldDir.y << " " << worldDir.z << " " << std::endl;
943 file << worldUp.x << " " << worldUp.y << " " << worldUp.z << " " << std::endl;
944
945 file << std::endl;
946 file << "below is the camera node that can be included into the *.scene.json;" << std::endl;
947 file << "'Cameras' node goes into 'Graph' array" << std::endl;
948 file << std::endl;
949 file << "{" << std::endl;
950 file << " \"name\": \"Cameras\"," << std::endl;
951 file << " \"children\" : [" << std::endl;
952 file << " {" << std::endl;
953 file << " \"name\": \"Default\"," << std::endl;
954 file << " \"type\" : \"PerspectiveCameraEx\"," << std::endl;
955 file << " \"translation\" : [" << std::to_string(worldPos.x) << ", " << std::to_string(worldPos.y) << ", " << std::to_string(worldPos.z) << "]," << std::endl;
956 file << " \"rotation\" : [" << std::to_string(rotation.x) << ", " << std::to_string(rotation.y) << ", " << std::to_string(rotation.z) << ", " << std::to_string(rotation.w) << "]," << std::endl;
957 file << " \"verticalFov\" : " << std::to_string(fovY) << "," << std::endl;
958 file << " \"zNear\" : " << std::to_string(m_cameraZNear) << "," << std::endl;
959 file << " \"enableAutoExposure\" : " << (autoExposure?"true":"false") << "," << std::endl;
960 file << " \"exposureCompensation\" : " << std::to_string(exposureCompensation) << "," << std::endl;
961 file << " \"exposureValue\" : " << std::to_string(exposureValue) << std::endl;
962 file << " }" << std::endl;
963 file << " ]" << std::endl;
964 file << "}," << std::endl;
965
966 file.close();
967 }
968}
969
970void Sample::LoadCurrentCamera()
971{

Callers 1

buildUIMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected