A Demo Project for the UnrealEngineSDK
Loading...
Searching...
No Matches
PixoVRLaser.h
Go to the documentation of this file.
1// Copyright(c) Pixo Group. All Rights Reserved.
2
3#pragma once
4
5#include "CoreMinimal.h"
6#include "Components/WidgetInteractionComponent.h"
7#include "GameFramework/Actor.h"
8#include "PixoVRLaser.generated.h"
9
10DECLARE_LOG_CATEGORY_EXTERN(LogPixoVRLaser, Log, All);
11
12DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FLaserBeamActivated, APixoVRLaser*, Laser, bool, bActivated);
13
18UCLASS(Blueprintable)
19class PIXOCORE_API APixoVRLaser : public AActor
20{
21 GENERATED_BODY()
23public:
25
30 UFUNCTION(BlueprintCallable, Server, Reliable, Category = "PixoVR | Laser")
31 void ActivateLaserBeam(bool InActivate);
32
38 UFUNCTION(BlueprintCallable, Category = "PixoVR | Laser")
39 bool IsOverWidgetUse(bool InPressed);
40
46 UFUNCTION(BlueprintCallable, Category = "PixoVR | Laser")
47 void SetHandType(EControllerHand HandType, bool InIsLocal);
48
53 UFUNCTION(BlueprintPure, Category = "PixoVR | Laser")
54 bool IsActivated() const;
55
60 UFUNCTION(BlueprintNativeEvent, Category = "PixoVR | Laser")
61 void OnHoverBegin(const FHitResult& HitResult);
62
67 UFUNCTION(BlueprintNativeEvent, Category = "PixoVR | Laser")
68 void OnHoverEnd(const FHitResult& HitResult);
69
74 UFUNCTION(BlueprintNativeEvent, Category = "PixoVR | Laser")
75 void OnSelected(const FHitResult& HitResult);
76
81 UFUNCTION(BlueprintNativeEvent, Category = "PixoVR | Laser")
82 void OnUnSelected(const FHitResult& HitResult);
83
88 UFUNCTION(BlueprintCallable, Category = "PixoVR | Laser")
89 void TriggerSelect(bool State);
90
91 UFUNCTION(Server, Reliable, WithValidation)
92 void ServerTriggerSelect(bool State, AActor* InteractableObject, const FHitResult& HitResult, APlayerController* Executor);
93
100 UFUNCTION(BlueprintCallable, Category = "PixoVR | Laser")
101 void TriggerHover(bool State, AActor* InteractableObject, const FHitResult& HitResult);
102
103 UFUNCTION(Server, Reliable, WithValidation)
104 void ServerTriggerHover(bool State, AActor* InteractableObject, const FHitResult& HitResult, APlayerController* Executor);
105
106 UFUNCTION(NetMulticast, Reliable, WithValidation)
107 void MulticastTriggerHover(bool State, AActor* InteractableObject, const FHitResult& HitResult, APlayerController* Executor);
108
109private:
110 virtual void Tick(float DeltaTime) override;
111 virtual void OnConstruction(const FTransform& Transform) override;
112 UFUNCTION(Client, Unreliable)
113 void ClientTickLaserBeam(float DeltaTime);
114
115 UFUNCTION()
116 void OnRep_LaserBeamActive();
117 void UpdateStateLaserBeam();
118
119public:
120 UPROPERTY(VisibleDefaultsOnly, BlueprintReadWrite)
121 USceneComponent* SceneComponent;
122
123 UPROPERTY(VisibleDefaultsOnly, BlueprintReadWrite)
124 UStaticMeshComponent* LaserBeam;
125
126 UPROPERTY(VisibleDefaultsOnly, BlueprintReadWrite)
127 UStaticMeshComponent* LaserBeamEndPoint;
128
129 UPROPERTY(VisibleDefaultsOnly, BlueprintReadWrite)
130 UStaticMeshComponent* LaserPointerMesh;
131
132 UPROPERTY(VisibleDefaultsOnly, BlueprintReadWrite)
133 UWidgetInteractionComponent* WidgetInteraction;
134
135 UPROPERTY(BlueprintReadOnly, Transient, ReplicatedUsing=OnRep_LaserBeamActive, Category = "PixoVR | Laser")
136 bool bIsLaserBeamActive;
137
138 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "PixoVR | Laser")
139 float LaserBeamMaxDistance;
140
141 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "PixoVR | Laser")
142 float LaserBeamRadius;
143
144 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "PixoVR | Laser")
145 float LaserBeamEndpointRadius;
146
147 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "PixoVR | Laser")
148 FLinearColor LaserBeamColor;
150 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "PixoVR | Laser")
151 FLinearColor LaserBeamEndpointColor;
152
153 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "PixoVR | Laser")
154 bool bActivateHovering;
155
156 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "PixoVR | Laser")
157 bool bLinkToInteraction;
158
159 UPROPERTY(BlueprintAssignable, Category = "PixoVR | Laser")
160 FLaserBeamActivated OnLaserBeamActivated;
161
162 FHitResult HoverHitResult;
163 TWeakObjectPtr<class AActor> HitActor;
164 UMaterial* LaserBeamMaterial;
165 UMaterialInstanceDynamic* LaserBeamMaterialDynamic;
166 UMaterialInstanceDynamic* LaserBeamEndpointMaterialDynamic;
168private:
169 bool bIsLocal;
170
171#if WITH_EDITOR
172 virtual void PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent) override;
173#endif
174};
DECLARE_LOG_CATEGORY_EXTERN(LogPixoVRLaser, Log, All)
DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FLaserBeamActivated, APixoVRLaser *, Laser, bool, bActivated)
Class for VR laser interaction. It can interact with widget buttons or actors derived from IPixoVRInt...
Definition PixoVRLaser.h:23
UMaterial * LaserBeamMaterial
UStaticMeshComponent * LaserBeamEndPoint
UPROPERTY(VisibleDefaultsOnly, BlueprintReadWrite)
UStaticMeshComponent * LaserBeam
UPROPERTY(VisibleDefaultsOnly, BlueprintReadWrite)
FLinearColor LaserBeamColor
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "PixoVR | Laser")
UStaticMeshComponent * LaserPointerMesh
UPROPERTY(VisibleDefaultsOnly, BlueprintReadWrite)
FHitResult HoverHitResult
void ServerTriggerSelect(bool State, AActor *InteractableObject, const FHitResult &HitResult, APlayerController *Executor)
UFUNCTION(Server, Reliable, WithValidation)
void OnUnSelected(const FHitResult &HitResult)
Called when the user unselects the hovered object.
TWeakObjectPtr< class AActor > HitActor
UWidgetInteractionComponent * WidgetInteraction
UPROPERTY(VisibleDefaultsOnly, BlueprintReadWrite)
void ActivateLaserBeam(bool InActivate)
Activate or deactivate the laser beam.
FLaserBeamActivated OnLaserBeamActivated
UPROPERTY(BlueprintAssignable, Category = "PixoVR | Laser")
UMaterialInstanceDynamic * LaserBeamEndpointMaterialDynamic
float LaserBeamEndpointRadius
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "PixoVR | Laser")
void OnSelected(const FHitResult &HitResult)
Called when the user selects the hovered object.
UMaterialInstanceDynamic * LaserBeamMaterialDynamic
void MulticastTriggerHover(bool State, AActor *InteractableObject, const FHitResult &HitResult, APlayerController *Executor)
UFUNCTION(NetMulticast, Reliable, WithValidation)
float LaserBeamRadius
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "PixoVR | Laser")
float LaserBeamMaxDistance
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "PixoVR | Laser")
void ServerTriggerHover(bool State, AActor *InteractableObject, const FHitResult &HitResult, APlayerController *Executor)
UFUNCTION(Server, Reliable, WithValidation)
bool bActivateHovering
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "PixoVR | Laser")
bool bIsLaserBeamActive
UPROPERTY(BlueprintReadOnly, Transient, ReplicatedUsing=OnRep_LaserBeamActive, Category = "PixoVR | L...
void OnHoverBegin(const FHitResult &HitResult)
Called when an object enters the hover state.
bool bLinkToInteraction
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "PixoVR | Laser")
void OnHoverEnd(const FHitResult &HitResult)
Called when an object exits the hover state.
USceneComponent * SceneComponent
UPROPERTY(VisibleDefaultsOnly, BlueprintReadWrite)
FLinearColor LaserBeamEndpointColor
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "PixoVR | Laser")
void ClientTickLaserBeam(float DeltaTime)
UFUNCTION(Client, Unreliable)