Skip to content
Snippets Groups Projects
Select Git revision
  • 5fff5b7ee76a2026588cec9439674a21de7840e3
  • 5.4 default protected
  • 5.5
  • dev/5.5
  • dev/5.4
  • dev/5.3_downgrade
  • feature/experimenttime_hack
  • 5.3 protected
  • _IntenSelect5.3
  • IntenSelect5.3
  • 4.27 protected
  • 4.26 protected
  • 5.0 protected
  • 4.22 protected
  • 4.21 protected
  • UE5.4-2024.1
  • UE5.4-2024.1-rc1
  • UE5.3-2023.1-rc3
  • UE5.3-2023.1-rc2
  • UE5.3-2023.1-rc
20 results

RWTHVRPawn.h

Blame
  • 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;
    };