diff --git a/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Weather/Weather.cpp b/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Weather/Weather.cpp new file mode 100644 index 000000000..84aafc773 --- /dev/null +++ b/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Weather/Weather.cpp @@ -0,0 +1,30 @@ +// Copyright (c) 2017 Computer Vision Center (CVC) at the Universitat Autonoma +// de Barcelona (UAB). +// +// This work is licensed under the terms of the MIT license. +// For a copy, see . + +#include "Carla.h" +#include "Carla/Weather/Weather.h" + +AWeather::AWeather(const FObjectInitializer& ObjectInitializer) + : Super(ObjectInitializer) +{ + PrimaryActorTick.bCanEverTick = false; + RootComponent = ObjectInitializer.CreateDefaultSubobject(this, TEXT("RootComponent")); +} + +void AWeather::ApplyWeather(const FWeatherParameters &InWeather) +{ + Weather = InWeather; + UE_LOG(LogCarla, Log, TEXT("Changing weather:")); + UE_LOG(LogCarla, Log, TEXT(" - Cloudyness = %.2f"), Weather.Cloudyness); + UE_LOG(LogCarla, Log, TEXT(" - Precipitation = %.2f"), Weather.Precipitation); + UE_LOG(LogCarla, Log, TEXT(" - PrecipitationDeposits = %.2f"), Weather.PrecipitationDeposits); + UE_LOG(LogCarla, Log, TEXT(" - WindIntensity = %.2f"), Weather.WindIntensity); + UE_LOG(LogCarla, Log, TEXT(" - SunAzimuthAngle = %.2f"), Weather.SunAzimuthAngle); + UE_LOG(LogCarla, Log, TEXT(" - SunAltitudeAngle = %.2f"), Weather.SunAltitudeAngle); + + // Call the blueprint that actually changes the weather. + RefreshWeather(Weather); +} diff --git a/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Weather/Weather.h b/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Weather/Weather.h new file mode 100644 index 000000000..c80371cf3 --- /dev/null +++ b/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Weather/Weather.h @@ -0,0 +1,42 @@ +// Copyright (c) 2017 Computer Vision Center (CVC) at the Universitat Autonoma +// de Barcelona (UAB). +// +// This work is licensed under the terms of the MIT license. +// For a copy, see . + +#pragma once + +#include "GameFramework/Actor.h" + +#include "Carla/Weather/WeatherParameters.h" + +#include "Weather.generated.h" + +UCLASS(Abstract) +class CARLA_API AWeather : public AActor +{ + GENERATED_BODY() + +public: + + AWeather(const FObjectInitializer& ObjectInitializer); + + UFUNCTION(BlueprintCallable) + void ApplyWeather(const FWeatherParameters &WeatherParameters); + + UFUNCTION(BlueprintCallable) + const FWeatherParameters &GetCurrentWeather() const + { + return Weather; + } + +protected: + + UFUNCTION(BlueprintImplementableEvent) + void RefreshWeather(const FWeatherParameters &WeatherParameters); + +private: + + UPROPERTY(VisibleAnywhere) + FWeatherParameters Weather; +}; diff --git a/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Weather/WeatherParameters.h b/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Weather/WeatherParameters.h new file mode 100644 index 000000000..8d7b9f408 --- /dev/null +++ b/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Weather/WeatherParameters.h @@ -0,0 +1,33 @@ +// Copyright (c) 2017 Computer Vision Center (CVC) at the Universitat Autonoma +// de Barcelona (UAB). +// +// This work is licensed under the terms of the MIT license. +// For a copy, see . + +#pragma once + +#include "WeatherParameters.generated.h" + +USTRUCT(BlueprintType) +struct CARLA_API FWeatherParameters +{ + GENERATED_BODY() + + UPROPERTY(EditAnywhere, BlueprintReadWrite, meta=(ClampMin = "0.0", ClampMax = "100.0", UIMin = "0.0", UIMax = "100.0")) + float Cloudyness = 0.0f; + + UPROPERTY(EditAnywhere, BlueprintReadWrite, meta=(ClampMin = "0.0", ClampMax = "100.0", UIMin = "0.0", UIMax = "100.0")) + float Precipitation = 0.0f; + + UPROPERTY(EditAnywhere, BlueprintReadWrite, meta=(ClampMin = "0.0", ClampMax = "100.0", UIMin = "0.0", UIMax = "100.0")) + float PrecipitationDeposits = 0.0f; + + UPROPERTY(EditAnywhere, BlueprintReadWrite, meta=(ClampMin = "0.0", ClampMax = "100.0", UIMin = "0.0", UIMax = "100.0")) + float WindIntensity = 0.0f; + + UPROPERTY(EditAnywhere, BlueprintReadWrite, meta=(ClampMin = "0.0", ClampMax = "360.0", UIMin = "0.0", UIMax = "360.0")) + float SunAzimuthAngle = 0.0f; + + UPROPERTY(EditAnywhere, BlueprintReadWrite, meta=(ClampMin = "-90.0", ClampMax = "90.0", UIMin = "-90.0", UIMax = "90.0")) + float SunAltitudeAngle = 0.0f; +};