NVIDIA DeepLearning Dataset Synthesizer (NDDS)
 All Classes Namespaces Functions Variables Typedefs Pages
NVAnnotatedActor.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 "GameFramework/Actor.h"
14 #include "NVSceneCapturerUtils.h"
15 #include "NVAnnotatedActor.generated.h"
16 
17 /**
18  * The new actor which get annotated and have its info captured and exported
19  */
20 /// @cond DOXYGEN_SUPPRESSED_CODE
21 UCLASS(Blueprintable, ClassGroup = (NVIDIA), Config = Engine, HideCategories = (Replication, Tick, Tags, Input))
22 /// @endcond DOXYGEN_SUPPRESSED_CODE
23 class NVSCENECAPTURER_API ANVAnnotatedActor : public AActor
24 {
25  GENERATED_BODY()
26 
27 public:
28  ANVAnnotatedActor(const FObjectInitializer& ObjectInitializer);
29 
30  void SetStaticMesh(class UStaticMesh* NewMesh);
31 
32  virtual TSharedPtr<FJsonObject> GetCustomAnnotatedData() const;
33 
34  FNVCuboidData GetCuboidData() const
35  {
36  return MeshCuboid;
37  }
38  FVector GetCuboidCenterLocal() const
39  {
40  return CuboidCenterLocal;
41  }
42  void SetClassSegmentationId(uint32 NewId);
43 
44 protected:
45  virtual void PostLoad() override;
46  virtual void BeginPlay() override;
47  virtual void PostInitializeComponents() override;
48 
49 #if WITH_EDITORONLY_DATA
50  virtual void PostEditChangeProperty(struct FPropertyChangedEvent& PropertyChangedEvent) override;
51  void OnActorSelected(UObject* Object);
52 #endif //WITH_EDITORONLY_DATA
53 
54  void UpdateStaticMesh();
55  void UpdateMeshCuboid();
56 
57  FMatrix GetMeshInitialMatrix() const;
58 
59  FMatrix CalculatePCA(const class UStaticMesh* Mesh);
60  FVector ComputeEigenVector(const FMatrix& Mat);
61 
62 public: // Editor properties
63  UPROPERTY(VisibleAnywhere, BlueprintReadOnly)
64  class UNVCapturableActorTag* AnnotationTag;
65 
66 protected: // Editor properties
67  // TODO: Need to support both static mesh and skeletal mesh types
68  UPROPERTY(VisibleAnywhere, BlueprintReadOnly)
69  class UStaticMeshComponent* MeshComponent;
70 
71  UPROPERTY(VisibleAnywhere, BlueprintReadOnly)
72  class UBoxComponent* BoxComponent;
73 
74 
75  UPROPERTY(VisibleAnywhere, BlueprintReadOnly)
76  class UNVCoordinateComponent* CoordComponent;
77 
78  // If true, the mesh of this actor will be placed so its center of 3d bounding box is at the root of the actor
79  // Otherwise user can place the actor manually
80  UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "AnnotatedActor")
81  bool bForceCenterOfBoundingBoxAtRoot;
82 
83  // If true, this actor's annotation tag will be the same as the mesh
84  UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "AnnotatedActor")
85  bool bSetClassNameFromMesh;
86 
87 protected: // Transient properties
88  UPROPERTY(VisibleAnywhere)
89  FNVCuboidData MeshCuboid;
90 
91  UPROPERTY(VisibleAnywhere)
92  FVector CuboidDimension;
93 
94  UPROPERTY(VisibleAnywhere)
95  FVector CuboidCenterLocal;
96 
97  UPROPERTY(VisibleAnywhere)
98  FVector PCACenter;
99 
100  UPROPERTY(VisibleAnywhere)
101  FRotator PCARotation;
102 
103  UPROPERTY(VisibleAnywhere)
104  FVector PCADirection;
105 };