5 #include "CoreMinimal.h" 6 #include "GameFramework/Actor.h" 8 #include "Components/HierarchicalInstancedStaticMeshComponent.h" 10 #include "ProceduralBuilding.generated.h" 18 TArray<TSubclassOf<AActor>>*
MainBPs =
nullptr;
37 UFUNCTION(BlueprintCallable, Category=
"Procedural Building")
38 UHierarchicalInstancedStaticMeshComponent* GetHISMComp(
const UStaticMesh* SM);
40 UFUNCTION(BlueprintCallable, CallInEditor, Category=
"Procedural Building")
41 void ConvertOldBP_ToNativeCodeObject(AActor* BP_Building);
43 UFUNCTION(BlueprintCallable, CallInEditor, Category=
"Procedural Building")
44 void HideAllChildren();
46 UFUNCTION(BlueprintCallable, Category=
"Procedural Building|Conversion")
47 void SetBaseParameters(
48 const TSet<int>& InDoorsIndexPosition,
49 const TArray<bool>& InUseWallMesh,
54 bool InUseFullBlocks);
56 UFUNCTION(BlueprintCallable, Category=
"Procedural Building|Conversion")
57 void SetVisibilityParameters(
58 const TArray<bool>& InSideVisibility,
59 const TArray<bool>& InCornerVisibility,
60 bool InRoofVisibility);
62 UFUNCTION(BlueprintCallable, Category=
"Procedural Building|Conversion")
64 const TArray<UStaticMesh*>& InBaseMeshes,
65 const TArray<TSubclassOf<AActor>>& InBaseBPs,
66 const TArray<UStaticMesh*>& InCornerBaseMeshes,
67 const TArray<TSubclassOf<AActor>>& InCornerBaseBPs,
68 const TArray<UStaticMesh*>& InDoorMeshes,
69 const TArray<TSubclassOf<AActor>>& InDoorBPs);
71 UFUNCTION(BlueprintCallable, Category=
"Procedural Building|Conversion")
73 const TArray<UStaticMesh*>& InBodyMeshes,
74 const TArray<TSubclassOf<AActor>>& InBodyBPs,
75 const TArray<UStaticMesh*>& InCornerBodyMeshes,
76 const TArray<TSubclassOf<AActor>>& InCornerBodyBPs,
77 const TArray<UStaticMesh*>& InWallMeshes,
78 const TArray<TSubclassOf<AActor>>& InWallBPs);
80 UFUNCTION(BlueprintCallable, Category=
"Procedural Building|Conversion")
82 const TArray<UStaticMesh*>& InTopMeshes,
83 const TArray<TSubclassOf<AActor>>& InTopBPs,
84 const TArray<UStaticMesh*>& InCornerTopMeshes,
85 const TArray<TSubclassOf<AActor>>& InCornerTopBPs,
86 const TArray<UStaticMesh*>& InRoofMeshes,
87 const TArray<TSubclassOf<AActor>>& InRoofBPs);
91 UFUNCTION(BlueprintCallable, CallInEditor, Category=
"Procedural Building")
92 void CreateBuilding();
94 UFUNCTION(BlueprintCallable, CallInEditor, Category=
"Procedural Building")
97 UFUNCTION(BlueprintCallable, CallInEditor, Category=
"Procedural Building")
102 UPROPERTY(BlueprintReadOnly, EditAnywhere, Category=
"Procedural Building|Debug")
103 TMap<FString, UHierarchicalInstancedStaticMeshComponent*> HISMComps;
106 UPROPERTY(BlueprintReadOnly, EditAnywhere, Category="Procedural
Building|Debug")
107 TArray<UChildActorComponent*> ChildActorComps;
109 UPROPERTY(BlueprintReadOnly, EditAnywhere, Category="Procedural
Building")
110 UStaticMeshComponent* RootSMComp =
nullptr;
117 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category="Procedural
Building|Base Parameters", meta=(ToolTip="Index to indicate where the door is placed"))
118 TSet<
int> DoorsIndexPosition;
121 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category="Procedural
Building|Base Parameters", meta=(ToolTip="True to use wall-mesh instead of body-mesh"))
122 TArray<
bool> UseWallMesh;
125 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category="Procedural
Building|Base Parameters", meta=(ClampMin="0", UIMin="0", ToolTip="Number of floors for the building, base and roof not included"))
129 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category="Procedural
Building|Base Parameters")
133 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category="Procedural
Building|Base Parameters")
137 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category="Procedural
Building|Base Parameters")
138 bool Corners = false;
141 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category="Procedural
Building|Base Parameters")
142 bool UseFullBlocks = false;
149 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category="Procedural
Building|Base Parameters|Visibility")
150 TArray<
bool> SideVisibility;
153 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category="Procedural
Building|Base Parameters|Visibility")
154 TArray<
bool> CornerVisibility;
157 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category="Procedural
Building|Base Parameters|Visibility")
158 bool RoofVisibility = true;
170 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category="Procedural
Building|Meshes|Base")
171 TArray<UStaticMesh*> BaseMeshes;
174 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category="Procedural
Building|Meshes|Base")
175 TArray<TSubclassOf<AActor>> BaseBPs;
178 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category="Procedural
Building|Meshes|Base")
179 TArray<UStaticMesh*> DoorMeshes;
182 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category="Procedural
Building|Meshes|Base")
183 TArray<TSubclassOf<AActor>> DoorBPs;
186 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category="Procedural
Building|Meshes|Base")
187 TArray<UStaticMesh*> CornerBaseMeshes;
190 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category="Procedural
Building|Meshes|Base")
191 TArray<TSubclassOf<AActor>> CornerBaseBPs;
198 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category="Procedural
Building|Meshes|Body")
199 TArray<UStaticMesh*> BodyMeshes;
202 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category="Procedural
Building|Meshes|Body")
203 TArray<TSubclassOf<AActor>> BodyBPs;
206 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category="Procedural
Building|Meshes|Body")
207 TArray<UStaticMesh*> WallMeshes;
210 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category="Procedural
Building|Meshes|Body")
211 TArray<TSubclassOf<AActor>> WallBPs;
214 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category="Procedural
Building|Meshes|Body")
215 TArray<UStaticMesh*> CornerBodyMeshes;
218 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category="Procedural
Building|Meshes|Body")
219 TArray<TSubclassOf<AActor>> CornerBodyBPs;
226 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category="Procedural
Building|Meshes|Top")
227 TArray<UStaticMesh*> TopMeshes;
230 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category="Procedural
Building|Meshes|Top")
231 TArray<TSubclassOf<AActor>> TopBPs;
234 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category="Procedural
Building|Meshes|Top")
235 TArray<UStaticMesh*> CornerTopMeshes;
238 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category="Procedural
Building|Meshes|Top")
239 TArray<TSubclassOf<AActor>> CornerTopBPs;
242 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category="Procedural
Building|Meshes|Top")
243 TArray<UStaticMesh*> RoofMeshes;
246 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category="Procedural
Building|Meshes|Top")
247 TArray<TSubclassOf<AActor>> RoofBPs;
253 void CreateFloor(const
FloorMeshCollection& MeshCollection,
bool IncludeDoors,
bool IncludeWalls);
260 const TSet<
int>& AuxiliarPositions,
263 bool CornerVisbility);
265 void CalculateSidesLength();
269 TSet<
int> CalculateDoorsIndexInSide(
int StartIndex,
int Length);
272 TSet<
int> GenerateWallsIndexPositions(
int Length);
275 void CalculateSideVisibilities(
int SideIndex,
bool& MainVisibility,
bool& CornerVisbility);
278 void ChooseGeometryToSpawn(
279 const TArray<UStaticMesh*>& InMeshes,
280 const TArray<TSubclassOf<AActor>>& InMainBPs,
281 UStaticMesh** OutMesh,
282 TSubclassOf<AActor>* OutBP);
286 const UStaticMesh* SelectedMesh,
287 const TSubclassOf<AActor> SelectedBP,
289 FBox& OutSelectedMeshBounds);
292 void AddMeshToBuilding(const UStaticMesh* SM);
295 FVector GetMeshSize(const UStaticMesh* SM);
297 void UpdateTransformPositionToNextChunk(const FVector&
Box);
299 void UpdateTransformPositionToNextSide(const FBox& Box);
303 TArray<
int> SidesLength;
306 FTransform CurrentTransform = FTransform::Identity;
308 FBox LastSelectedMeshBounds;
TArray< TSubclassOf< AActor > > * MainBPs
TArray< TSubclassOf< AActor > > * AuxiliarBPs
TArray< UStaticMesh * > * MainMeshes
TArray< TSubclassOf< AActor > > * CornerBPs
TArray< UStaticMesh * > * AuxiliarMeshes
bg::model::box< Point3D > Box
TArray< UStaticMesh * > * CornerMeshes