Skip to content

Commit

Permalink
Merge branch 'aburgm-projection-mode'
Browse files Browse the repository at this point in the history
  • Loading branch information
sytelus committed Feb 22, 2018
2 parents 97b591e + 2e5f704 commit dc95052
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 1 deletion.
13 changes: 13 additions & 0 deletions AirLib/include/common/AirSimSettings.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ struct AirSimSettings {
float auto_exposure_histogram_log_max = Utils::nan<float>(); // 4;
float motion_blur_amount = Utils::nan<float>();
float target_gamma = Utils::nan<float>(); //1.0f; //This would be reset to kSceneTargetGamma for scene as default
int projection_mode = 0; // ECameraProjectionMode::Perspective
float ortho_width = Utils::nan<float>();

};

struct NoiseSetting {
Expand Down Expand Up @@ -453,6 +456,16 @@ struct AirSimSettings {
capture_setting.image_type = settings.getInt("ImageType", 0);
capture_setting.target_gamma = settings.getFloat("TargetGamma",
capture_setting.image_type == 0 ? CaptureSetting::kSceneTargetGamma : Utils::nan<float>());

std::string projection_mode = Utils::toLower(settings.getString("ProjectionMode", ""));
if (projection_mode == "" || projection_mode == "perspective")
capture_setting.projection_mode = 0; // Perspective
else if (projection_mode == "orthographic")
capture_setting.projection_mode = 1; // Orthographic
else
throw std::invalid_argument(std::string("CaptureSettings projection_mode has invalid value in settings ") + projection_mode);

capture_setting.ortho_width = settings.getFloat("OrthoWidth", capture_setting.ortho_width);
}

void loadSubWindowsSettings(const Settings& settings)
Expand Down
5 changes: 5 additions & 0 deletions Unreal/Plugins/AirSim/Source/NedTransform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ float NedTransform::toNedMeters(float length)
return length / world_to_meters_;
}

float NedTransform::toNeuUU(float length)
{
return length * world_to_meters_;
}

NedTransform::Vector3r NedTransform::toNedMeters(const FVector& position, bool use_offset)
{
return NedTransform::toVector3r(position - (use_offset ? offset_ : FVector::ZeroVector), 1 / world_to_meters_, true);
Expand Down
1 change: 1 addition & 0 deletions Unreal/Plugins/AirSim/Source/NedTransform.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class NedTransform
static FQuat toFQuat(const Quaternionr& q, bool convert_from_ned);
static Quaternionr toQuaternionr(const FQuat& q, bool convert_to_ned);
static float toNedMeters(float length);
static float toNeuUU(float length);

//TODO: make below private
static FVector toFVector(const Vector3r& vec, float scale, bool convert_from_ned);
Expand Down
9 changes: 9 additions & 0 deletions Unreal/Plugins/AirSim/Source/PIPCamera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "Materials/MaterialInstanceDynamic.h"
#include "AirBlueprintLib.h"
#include "ImageUtils.h"
#include "NedTransform.h"


APIPCamera::APIPCamera()
Expand Down Expand Up @@ -140,8 +141,12 @@ void APIPCamera::updateCaptureComponentSetting(USceneCaptureComponent2D* capture
if (!std::isnan(setting.target_gamma))
render_target->TargetGamma = setting.target_gamma;

capture->ProjectionType = static_cast<ECameraProjectionMode::Type>(setting.projection_mode);

if (!std::isnan(setting.fov_degrees))
capture->FOVAngle = setting.fov_degrees;
if (!std::isnan(setting.ortho_width))
capture->OrthoWidth = NedTransform::toNeuUU(setting.ortho_width);

updateCameraPostProcessingSetting(capture->PostProcessSettings, setting);
}
Expand All @@ -151,8 +156,12 @@ void APIPCamera::updateCameraSetting(UCameraComponent* camera, const CaptureSett
//if (!std::isnan(setting.target_gamma))
// camera-> = setting.target_gamma;

camera->SetProjectionMode(static_cast<ECameraProjectionMode::Type>(setting.projection_mode));

if (!std::isnan(setting.fov_degrees))
camera->SetFieldOfView(setting.fov_degrees);
if (!std::isnan(setting.ortho_width))
camera->SetOrthoWidth(NedTransform::toNeuUU(setting.ortho_width));

updateCameraPostProcessingSetting(camera->PostProcessSettings, setting);
}
Expand Down
4 changes: 3 additions & 1 deletion docs/settings.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ Below are complete list of settings available along with their default values. I
"AutoExposureMaxBrightness": 0.64,
"AutoExposureMinBrightness": 0.03,
"MotionBlurAmount": 0,
"TargetGamma": 1.0
"TargetGamma": 1.0,
"ProjectionMode": "perspective",
"OrthoWidth": 5.12
}
],
"NoiseSettings": [
Expand Down

0 comments on commit dc95052

Please sign in to comment.