Hi, I’m trying to recreate these tutorials., but I can’t for the life of me figure out the C++ part.
Header
#pragma once
#include "GameFramework/Actor.h"
#include "OceanManager.generated.h"
/**
*
*/
UCLASS()
class WASSER_API AOceanManager : public AActor
{
GENERATED_UCLASS_BODY()
UFUNCTION(BlueprintCallable, Category = "HeightMap|Texture Helper")
FVector GetWaveHeightValue(FVector location, float time);
UFUNCTION(BlueprintCallable, Category = "HeightMap|Texture Helper")
FVector CalculateGerstnerWaveCluster(float medianWavelength, float medianAmplitude, FVector2D position, FVector2D medianDirection, float steepness, float time);
UFUNCTION(BlueprintCallable, Category = "HeightMap|Texture Helper")
FVector CalculateGerstnerWave(float wavelength, float amplitude, FVector2D position, FVector2D direction, float angle, float steepness, float time, float phase);
};
CPP
#include "Wasser.h"
#include "OceanManager.h"
FVector AOceanManager::GetWaveHeightValue(FVector location, float time)
{
FVector sum = FVector(0, 0, 0);
sum + -CalculateGerstnerWaveCluster(1000, 10, FVector2D(location.X, location.Y), FVector2D(0, 1), 0.5f, time);
sum + -CalculateGerstnerWaveCluster(300, 7, FVector2D(location.X, location.Y), FVector2D(0, 1), 0.5f, time);
return sum / 2;
}
FVector AOceanManager::CalculateGerstnerWaveCluster(float medianWavelength, float medianAmplitude, FVector2D position, FVector2D medianDirection, float steepness, float time)
{
FVector sum = FVector(0, 0, 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;
}
FVector AOceanManager::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 c = FMath::Cos(wavePhase);
float s = FMath::Sin(wavePhase);
float QA = steepness * amplitude;
return FVector(QA * rotatedDirection.X * c, QA * rotatedDirection.Y * c, amplitude * s);
}
When I try to compile, I get this error:
Error 2 error LNK2019: unresolved external symbol "public: __cdecl AOceanManager::AOceanManager(class FPostConstructInitializeProperties const &)" (??0AOceanManager@@QEAA@AEBVFPostConstructInitializeProperties@@@Z) referenced in function "void __cdecl InternalConstructor<class AOceanManager>(class FPostConstructInitializeProperties const &)" (??$InternalConstructor@VAOceanManager@@@@YAXAEBVFPostConstructInitializeProperties@@@Z) E:\UE4Projects\Wasser\Wasser\Intermediate\ProjectFiles\Wasser.generated.cpp.obj Wasser
I hope someone can help me.