NVIDIA DeepLearning Dataset Synthesizer (NDDS)
 All Classes Namespaces Functions Variables Typedefs Pages
RandomMaterialComponent.h
1 /*
2 * Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
3 *
4 * NVIDIA CORPORATION and its licensors retain all intellectual property
5 * and proprietary rights in and to this software, related documentation
6 * and any modifications thereto. Any use, reproduction, disclosure or
7 * distribution of this software and related documentation without an express
8 * license agreement from NVIDIA CORPORATION is strictly prohibited.
9 */
10 
11 #pragma once
12 
13 #include "DomainRandomizationDNNPCH.h"
14 #include "RandomComponentBase.h"
15 #include "DRUtils.h"
16 #include "RandomMaterialComponent.generated.h"
17 
18 /**
19 * RandomMaterialComponent randomly change the materials of the owner's mesh in specified material slot
20 */
21 /// @cond DOXYGEN_SUPPRESSED_CODE
22 UCLASS(Blueprintable, ClassGroup = (NVIDIA), meta = (BlueprintSpawnableComponent))
23 /// @endcond DOXYGEN_SUPPRESSED_CODE
24 class DOMAINRANDOMIZATIONDNN_API URandomMaterialComponent : public URandomComponentBase
25 {
26  GENERATED_BODY()
27 
28 public:
30 
31 protected:
32  virtual void BeginPlay() override;
33  virtual void OnRandomization_Implementation() override;
34 
35 #if WITH_EDITORONLY_DATA
36  virtual void PostEditChangeProperty(struct FPropertyChangedEvent& PropertyChangedEvent) override;
37 #endif //WITH_EDITORONLY_DATA
38 
39  bool HasMaterialToRandomize() const;
40 
41  class UMaterialInterface* GetNextMaterial();
42 
43 protected: // Editor properties
44  UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Randomization, meta = (ShowOnlyInnerProperties))
45  FRandomMaterialSelection MaterialSelectionConfigData;
46 
47  UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Randomization)
48  bool bUseAllMaterialInDirectories;
49 
50  UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Randomization)
51  EAffectedMaterialOwnerComponentType AffectedComponentType;
52 
53  // List of directories where we want to use the static meshes from
54  UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Randomization, meta = (EditCondition = "bUseAllMaterialInDirectories", RelativeToGameContentDir))
55  TArray<FDirectoryPath> MaterialDirectories;
56 
57  // List of the material that the owner actor will switch through
58  UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Randomization, meta = (EditCondition = "!bUseAllMaterialInDirectories"))
59  TArray<UMaterialInterface*> MaterialList;
60 
61 protected:
62  // List of the mesh components from the owner actor that we need to change their materials
63  UPROPERTY(Transient)
64  TArray<class UMeshComponent*> OwnerMeshComponents;
65 
66  UPROPERTY(Transient)
67  TArray<class UDecalComponent*> OwnerDecalComponents;
68 
69  UPROPERTY(Transient)
70  FRandomAssetStreamer MaterialStreamer;
71 };