Agrarsense
TreeHeightsFromImage.h
Go to the documentation of this file.
1// Copyright (c) 2024 FrostBit Software Lab at the Lapland University of Applied Sciences
2//
3// This work is licensed under the terms of the MIT license.
4// For a copy, see <https://opensource.org/licenses/MIT>.
5
6#pragma once
7
8#include "CoreMinimal.h"
9#include "GameFramework/Actor.h"
10#include "Math/Color.h"
11#include "Engine/Texture2D.h"
12#include "TreeHeightsFromImage.generated.h"
13
14UCLASS()
15class AGRARSENSE_API ATreeHeightsFromImage : public AActor
16{
17 GENERATED_BODY()
18
19public:
20
22
23protected:
24
25 virtual void BeginPlay() override;
26
27 float EuclideanDistance(const FColor& Color1, const FColor& Color2);
28
29 FColor FindClosestColor(const FColor& TargetColor, const TMap<int32, FColor>& ColorMap);
30
31 const TMap<int, FColor> colorHeight = {
32 {0, FColor(48, 18, 59)},
33 {1, FColor(59, 48, 129)},
34 {2, FColor(67, 77, 183)},
35 {3, FColor(70, 104, 222)},
36 {4, FColor(70, 130, 247)},
37 {5, FColor(61, 156, 252)},
38 {6, FColor(44, 182, 239)},
39 {7, FColor(30, 205, 216)},
40 {8, FColor(26, 223, 190)},
41 {9, FColor(42, 237, 163)},
42 {10, FColor(73, 247, 130)},
43 {11, FColor(111, 253, 97)},
44 {12, FColor(147, 253, 71)},
45 {13, FColor(177, 248, 56)},
46 {14, FColor(203, 236, 53)},
47 {15, FColor(226, 219, 56)},
48 {16, FColor(243, 199, 57)},
49 {17, FColor(252, 176, 53)},
50 {18, FColor(253, 148, 43)},
51 {19, FColor(249, 118, 30)},
52 {20, FColor(239, 89, 17)},
53 {21, FColor(224, 65, 9)},
54 {22, FColor(205, 45, 5)},
55 {23, FColor(181, 28, 2)},
56 {24, FColor(153, 14, 1)},
57 {25, FColor(122, 4, 3)}
58 };
59
60
61public:
62
63 UPROPERTY(EditAnywhere)
64 UTexture2D* treeMapImage;
65};