Agrarsense
Tagger.h
Go to the documentation of this file.
1// Copyright (c) 2023 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 "Kismet/GameplayStatics.h"
11#include "ObjectLabel.h"
12#include "PhysicsEngine/PhysicsAsset.h"
13
14#include "ObjectLabel.h"
15
16#include "Tagger.generated.h"
17
18class UStaticMeshComponent;
19class USkeletalMeshComponent;
20
21/*
22* ATagger - Actor responsible for tagging static and skeletal mesh Actors.
23* During BeginPlay runtime, this Actor iterates through all Actors in the level, setting stencil value for object if it's not set.
24* This stencil value is used by SemanicSegmentationCamera in its post processing material.
25* Additionally, each time a new Actor is spawned, this Actor will automatically check it as well.
26*/
27UCLASS()
28class AGRARSENSE_API ATagger : public AActor
29{
30 GENERATED_BODY()
31
32public:
33
34 ATagger();
35
36protected:
37
38 virtual void BeginPlay() override;
39
40 virtual void EndPlay(const EEndPlayReason::Type EndPlayReason) override;
41
42private:
43
44 void TagExistingActors();
45
46 void OnActorSpawned(AActor* Actor);
47
48 void TagActor(AActor& Actor, bool TagForSemanticSegmentation);
49
50 void SetStencilValue(UPrimitiveComponent& Component, const ELabels& Label, const bool SetRenderCustomDepth);
51
52 ELabels GetLabelFromString(const FString& String);
53
54 ELabels GetLabelFromStaticComponent(UStaticMeshComponent* StaticMeshComponentPtr);
55
56 ELabels GetLabelFromSkeletalMeshComponent(USkeletalMeshComponent* USkeletalMeshComponentPtr);
57
58 ELabels GetLabelFromPath(const FString& Path, FString& FolderName);
59
60 template <typename T>
61 ELabels GetLabelFromTag(const T* Object)
62 {
63 if (!Object->ComponentTags.IsEmpty())
64 {
65 return GetLabelFromString(Object->ComponentTags[0].ToString());
66 }
67
68 return ELabels::None;
69 }
70
72
73 TMap<FString, ELabels> LabelMap;
74};
ELabels
Definition: ObjectLabel.h:14
Definition: Tagger.h:29
TMap< FString, ELabels > LabelMap
Definition: Tagger.h:73
ELabels GetLabelFromTag(const T *Object)
Definition: Tagger.h:61
FDelegateHandle ActorSpawnedDelegateHandle
Definition: Tagger.h:71