Add Weather class

This commit is contained in:
nsubiron 2018-10-11 18:22:03 +02:00
parent c83078d700
commit 856ecde332
3 changed files with 105 additions and 0 deletions

View File

@ -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 <https://opensource.org/licenses/MIT>.
#include "Carla.h"
#include "Carla/Weather/Weather.h"
AWeather::AWeather(const FObjectInitializer& ObjectInitializer)
: Super(ObjectInitializer)
{
PrimaryActorTick.bCanEverTick = false;
RootComponent = ObjectInitializer.CreateDefaultSubobject<USceneComponent>(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);
}

View File

@ -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 <https://opensource.org/licenses/MIT>.
#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;
};

View File

@ -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 <https://opensource.org/licenses/MIT>.
#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;
};