Select Git revision
RWTHVRPawn.h
-
Kris Tabea Helwig authoredKris Tabea Helwig authored
RWTHVRPawn.h 4.19 KiB
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "LiveLinkRole.h"
#include "Pawn/Navigation/CollisionHandlingMovement.h"
#include "RWTHVRPawn.generated.h"
class UInputMappingContext;
class UInputAction;
class UCameraComponent;
class UMotionControllerComponent;
struct FLiveLinkTransformStaticData;
DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FOnScaleChangedDelegate, FVector, OldScale, float, NewUniformScale);
/**
* Pawn implementation with additional VR functionality, can be used in the Cave, with an HMD and on desktop.
*/
UCLASS(Abstract)
class RWTHVRTOOLKIT_API ARWTHVRPawn : public APawn
{
GENERATED_BODY()
public:
ARWTHVRPawn(const FObjectInitializer& ObjectInitializer);
virtual void BeginPlay() override;
virtual void Tick(float DeltaSeconds) override;
virtual void NotifyControllerChanged() override;
UFUNCTION(BlueprintCallable)
void SetScale(float NewScale);
UFUNCTION(BlueprintCallable)
float GetScale();
UPROPERTY(BlueprintAssignable)
FOnScaleChangedDelegate OnScaleChanged;
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Pawn|Input")
TArray<UInputMappingContext*> InputMappingContexts;
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Pawn|MotionControllers")
UMotionControllerComponent* RightHand;
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Pawn|MotionControllers")
UMotionControllerComponent* LeftHand;
/* Movement */
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Pawn|Movement")
UCollisionHandlingMovement* CollisionHandlingMovement;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Pawn|Desktop Movement")
bool bMoveRightHandWithMouse = true;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Pawn|Desktop Movement")
bool bMoveLeftHandWithMouse = false;
/* CameraComponent */
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Pawn|Camera")
UCameraComponent* HeadCameraComponent;
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Pawn")
USceneComponent* SyncComponent;
// LiveLink functionality
/* Set whether nDisplay should disable LiveLink tracking*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Pawn|LiveLink")
bool bDisableLiveLink = false;
/* Set the LiveLink Subject Representation to be used by this pawn. */
UPROPERTY(BlueprintReadOnly, EditAnywhere, Category = "Pawn|LiveLink")
FLiveLinkSubjectRepresentation HeadSubjectRepresentation;
/* Set the LiveLink Subject Representation to be used by this pawn. */
UPROPERTY(BlueprintReadOnly, EditAnywhere, Category = "Pawn|LiveLink")
FLiveLinkSubjectRepresentation LeftSubjectRepresentation;
/* Set the LiveLink Subject Representation to be used by this pawn. */
UPROPERTY(BlueprintReadOnly, EditAnywhere, Category = "Pawn|LiveLink")
FLiveLinkSubjectRepresentation RightSubjectRepresentation;
/* Set the transform of the component in world space of in its local reference frame. */
UPROPERTY(BlueprintReadOnly, EditAnywhere, Category = "Pawn|LiveLink")
bool bWorldTransform = false;
protected:
virtual void SetupPlayerInputComponent(UInputComponent* PlayerInputComponent) override;
void AddInputMappingContext(const APlayerController* PC, const UInputMappingContext* Context) const;
UFUNCTION(BlueprintCallable)
UInputComponent* GetPlayerInputComponent();
/* LiveLink helper function called on tick */
void EvaluateLivelink() const;
/* Helper function that applies the LiveLink data to this component. Taken from the LiveLink Transform Controller.
*/
void ApplyLiveLinkTransform(const FTransform& Transform, const FLiveLinkTransformStaticData& StaticData) const;
/* Fixes camera rotation in desktop mode. */
void SetCameraOffset() const;
void UpdateRightHandForDesktopInteraction() const;
/* Replicated functionality */
/* Add a sync component to all instances of this pawn */
UFUNCTION(Reliable, NetMulticast)
void MulticastAddDCSyncComponent();
/* Attaches the Cluster representation to the pawn */
void AttachClustertoPawn();
/* Set device specific motion controller sources (None, L/R, Livelink) */
void SetupMotionControllerSources();
private:
UInputComponent* ActivePlayerInputComponent;
float InitialWorldToMeters;
float UniformScale;
};