-
Notifications
You must be signed in to change notification settings - Fork 5
/
LatticeGrid.h
96 lines (70 loc) · 3.96 KB
/
LatticeGrid.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#pragma once
#include "CoreMinimal.h"
#include "UDynamicMesh.h"
#include "BuildingEnums.h"
#include "LatticeGrid.generated.h"
UENUM(BlueprintType)
enum class ELatticeMaterialSlots : uint8
{
All,
Framing_All,
Framing_Horizontal,
Framing_Vertical,
Border_All,
Border_Horizontal,
Border_Vertical
};
USTRUCT(BlueprintType)
struct PROCEDURALBUILDINGS_API FLatticeGridOptions
{
GENERATED_BODY()
UPROPERTY(EditAnywhere, meta = (InlineEditConditionToggle))
bool bUseLocalSeed = true;
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (DisplayName = "Random Seed", ToolTip = "Randomness Seed", EditCondition = "bUseLocalSeed"))
int32 RandomSeed = 1;
UPROPERTY(EditAnywhere, meta = (InlineEditConditionToggle))
bool bHasRows = true;
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (DisplayName = "Lattice Rows", ToolTip = "Number of Lattice Rows (Horizontal), Setting to 0 will fit as many as possible", EditCondition = "bHasRows"))
int32 Rows = 0;
UPROPERTY(EditAnywhere, meta = (InlineEditConditionToggle))
bool bHasColumns = true;
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (DisplayName = "Lattice Columns", ToolTip = "Number of Lattice Columns (Vertical), Setting to 0 will fit as many as possible", EditCondition = "bHasColumns"))
int32 Columns = 0;
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (DisplayName = "Size", ToolTip = "Size of Rows,Columns,Depth in cm", ClampMin = 1, UIMax = 100000, Unit = "Centimeter"))
FVector Size = FVector(50.f, 100.f, 10.f);
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (DisplayName = "Size Variance", ToolTip = "Size of Rows,Columns,Depth variance in cm", Unit = "Centimeter"))
FVector SizeVariance = FVector(0.f);
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (DisplayName = "Spacing", ToolTip = "Distance between the edge of each Row/Column", ClampMin = 1, Unit = "Centimeter"))
FVector2D Spacing = FVector2D(500.f, 450.f);
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (DisplayName = "Spacing Variance", ToolTip = "Randomness in distance between edge of each row/column", Unit = "Centimeter"))
FVector2D SpacingVariance = FVector2D(0.f);
UPROPERTY(EditAnywhere, meta = (InlineEditConditionToggle))
bool bHasBorder = false;
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (DisplayName = "Border Size", ToolTip = "Randomness in distance between edge of each row/column", EditCondition = "bHasBorder", Unit = "Centimeter"))
FVector BorderSize = FVector(50.f, 30.f, 10.f);
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (DisplayName = "Materials", ToolTip = "Materials to apply"))
TMap<ELatticeMaterialSlots, UMaterialInterface*> MaterialSlots;
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (DisplayName = "UV Scale Mode", ToolTip = "UV Scaling Mode"))
EBuildingUVScaleMode UVScaleMode = EBuildingUVScaleMode::Fixed;
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (DisplayName = "UV Size", ToolTip = "UV Scale Size - The UV coordinates will repeat after this distance on the mesh", Unit = "Centimeter", EditCondition = "UVScaleMode == EBuildingUVScaleMode::Fixed"))
float UVSize = 1000.f; // 10 meters
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (DisplayName = "UV Origin Mode", ToolTip = "UV Origin - Detemrines where on the mesh the center of the UV coordinates will be, setting this to random will create a non-uniform appearance in the exture layout"))
EBuildingUVOriginMode UVOriginMode = EBuildingUVOriginMode::MinCoordinate;
};
/**
*
*/
class PROCEDURALBUILDINGS_API LatticeGrid
{
public:
static const int32 RANDOM_OFFSET = 972959;
static const int32 MAX_LATTICES = 100;
LatticeGrid();
LatticeGrid(FLatticeGridOptions* Options);
void ApplyLattice(UDynamicMesh* Mesh, TArray<UMaterialInterface*>& MaterialSet);
~LatticeGrid();
private:
FLatticeGridOptions* Options;
// TODO move to static utility function
FTransform GetMeshUVTransform(FBox& MeshBounds, EBuildingUVScaleMode ScaleMode, EBuildingUVOriginMode OriginMode, FRandomStream* Randomizer = nullptr, float UVSize = 0.f);
};