Thanks for the help! The code seems to be working, but now I’m getting different errors:
Error 2 error : Failed to produce item: E:\Blueprint_Lampe_Schwebe\Binaries\Win64\UE4Editor-Lampe_Reife.pdb E:\Blueprint_Lampe_Schwebe\Intermediate\ProjectFiles\ERROR Lampe_Reife
Error 1 error LNK1104: cannot open file 'E:\Blueprint_Lampe_Schwebe\Binaries\Win64\UE4Editor-Lampe_Reife.dll' E:\Blueprint_Lampe_Schwebe\Intermediate\ProjectFiles\LINK Lampe_Reife
Error 3 error MSB3073: The command ""E:\Programme\Unreal Engine\4.4\Engine\Build\BatchFiles\Build.bat" Lampe_ReifeEditor Win64 Development "E:\Blueprint_Lampe_Schwebe\Lampe_Reife.uproject" -rocket" exited with code -1. C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\Microsoft.MakeFile.Targets 38 5 Lampe_Reife
My Code now:
WaterManager.h
#pragma once
#include "GameFramework/Actor.h"
#include "WaterManager.generated.h"
/**
*
*/
UCLASS()
class LAMPE_REIFE_API AWaterManager : public AActor
{
GENERATED_UCLASS_BODY()
UFUNCTION(BlueprintCallable, Category = "Gerstner Wave")
static void GetWaveHeight(FVector PointLocation, float Time, float WaterPlaneHeight, float& WaveHeight);
protected:
static float CalculateGerstnerWave(float wavelength, float amplitude, FVector2D position, FVector2D direction, float angle, float steepness, float time, float phase);
static float CalculateGerstnerWaveCluster(float medianWavelength, float medianAmplitude, FVector2D position, FVector2D medianDirection, float steepness, float time);
};
WaterManager.cpp
#include "Lampe_Reife.h"
#include "WaterManager.h"
AWaterManager::AWaterManager(const class FPostConstructInitializeProperties& PCIP)
: Super(PCIP)
{
}
void AWaterManager::GetWaveHeight(FVector PointLocation, float Time, float WaterPlaneHeight, float& WaveHeight)
{
float sum = 0;
sum += CalculateGerstnerWaveCluster(2500, 200, FVector2D(PointLocation.X, PointLocation.Y), FVector2D(0, 1), 0.5f, Time);
sum += CalculateGerstnerWaveCluster(1000, 115, FVector2D(PointLocation.X, PointLocation.Y), FVector2D(0, 1), 0.5f, Time);
WaveHeight = sum / 2 + WaterPlaneHeight;
}
float AWaterManager::CalculateGerstnerWave(float wavelength, float amplitude, FVector2D position, FVector2D direction, float angle, float steepness, float time, float phase)
{
float lambda = (2 * PI) / wavelength;
FVector dir = FVector(direction.X, direction.Y, 0);
dir = dir.RotateAngleAxis(angle * 360, FVector(0, 0, 1));
FVector2D rotatedDirection = FVector2D(dir.X, dir.Y);
float wavePhase = lambda * FVector2D::DotProduct(rotatedDirection, position) + (time + phase);
float s = FMath::Sin(wavePhase);
return amplitude * s;
}
float AWaterManager::CalculateGerstnerWaveCluster(float medianWavelength, float medianAmplitude, FVector2D position, FVector2D medianDirection, float steepness, float time)
{
float sum = 0;
sum += CalculateGerstnerWave(medianWavelength, medianAmplitude, position, medianDirection, 0, steepness, time, 0);
sum += CalculateGerstnerWave(medianWavelength * 0.5f, medianAmplitude * 0.5f, position, medianDirection, -0.1f, steepness, time, 0);
sum += CalculateGerstnerWave(medianWavelength * 2.0f, medianAmplitude * 2.0f, position, medianDirection, 0.1f, steepness, time, 0);
sum += CalculateGerstnerWave(medianWavelength * 1.25f, medianAmplitude * 1.25f, position, medianDirection, 0.05f, steepness, time, 0);
sum += CalculateGerstnerWave(medianWavelength * 0.75f, medianAmplitude * 0.75f, position, medianDirection, 0.075f, steepness, time, 0);
sum += CalculateGerstnerWave(medianWavelength * 1.5f, medianAmplitude * 1.5f, position, medianDirection, -0.125f, steepness, time, 0);
sum += CalculateGerstnerWave(medianWavelength * 0.825f, medianAmplitude * 0.825f, position, medianDirection, 0.063f, steepness, time, 0);
sum += CalculateGerstnerWave(medianWavelength * 0.65f, medianAmplitude * 0.65f, position, medianDirection, -0.11f, steepness, time, 0);
return sum / 8;
}