8#include "CoreMinimal.h"
9#include "Components/ActorComponent.h"
10#include "Math/Color.h"
11#include "Engine/Texture2D.h"
12#include "TreeHeightsFromImageComponent.generated.h"
14UCLASS(ClassGroup = (Custom), meta = (BlueprintSpawnableComponent))
15class AGRARSENSE_API UTreeHeightsFromImageComponent :
public UActorComponent
21 UTreeHeightsFromImageComponent();
25 virtual
void BeginPlay() override;
29 float EuclideanDistance(const FColor& Color1, const FColor& Color2);
31 FColor FindClosestColor(const FColor& TargetColor, const TMap<int32, FColor>& ColorMap);
33 UFUNCTION(BlueprintCallable)
34 int GetColorFromPixel(FVector point);
36 const TMap<
int, FColor> colorHeight = {
37 {0, FColor(48, 18, 59)},
38 {1, FColor(59, 48, 129)},
39 {2, FColor(67, 77, 183)},
40 {3, FColor(70, 104, 222)},
41 {4, FColor(70, 130, 247)},
42 {5, FColor(61, 156, 252)},
43 {6, FColor(44, 182, 239)},
44 {7, FColor(30, 205, 216)},
45 {8, FColor(26, 223, 190)},
46 {9, FColor(42, 237, 163)},
47 {10, FColor(73, 247, 130)},
48 {11, FColor(111, 253, 97)},
49 {12, FColor(147, 253, 71)},
50 {13, FColor(177, 248, 56)},
51 {14, FColor(203, 236, 53)},
52 {15, FColor(226, 219, 56)},
53 {16, FColor(243, 199, 57)},
54 {17, FColor(252, 176, 53)},
55 {18, FColor(253, 148, 43)},
56 {19, FColor(249, 118, 30)},
57 {20, FColor(239, 89, 17)},
58 {21, FColor(224, 65, 9)},
59 {22, FColor(205, 45, 5)},
60 {23, FColor(181, 28, 2)},
61 {24, FColor(153, 14, 1)},
62 {25, FColor(122, 4, 3)}
72 UPROPERTY(EditAnywhere, Category = "Generate")
76 virtual void PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent)
override;
79 UPROPERTY(EditAnywhere)
80 UTexture2D* treeMapImage;