Skip to content
Snippets Groups Projects
Select Git revision
  • ddd258ca991893e35766507dc3af4c6cf4b4b4a0
  • master default protected
  • feature/refactor
  • 4.24
  • develop
  • Rendering
  • temp-optix-6
7 results

BP_MotionController.uasset

Blame
  • VAReceiverActor.h 6.92 KiB
    // Fill out your copyright notice in the Description page of Project Settings.
    
    #pragma once
    
    #include "VAEnums.h"									// EAddress
    
    #include "Templates/SharedPointer.h"
    
    #include "GameFramework/Actor.h"
    #include "AuralizationMode/VAAuralizationModeController.h"
    
    #include "Events/DisplayClusterEventWrapper.h"
    
    #include "VAReceiverActor.generated.h"
    
    
    //forward declarations to not include private header files
    class FVAPlugin;
    class AVAReflectionWall;
    class FVADirectivity;
    class FVADirectivityManager;
    class FVAHRIR;
    class FVAHRIRManager;
    
    
    UCLASS(ClassGroup = (VA))
    class VAPLUGIN_API AVAReceiverActor : public AActor
    {
    	GENERATED_BODY()
    
    	friend class UVAAbstractSourceComponent;
       friend class FVAPlugin;
    
    protected:
    
    
    	// How many units in UE equal 1m in World
    	UPROPERTY(EditAnywhere, meta = (DisplayName = "Scale", Category = "General Settings"))
    	float WorldScale = 100.0f;
    
    	// How often are position updates etc. send
    	UPROPERTY(EditAnywhere, meta = (DisplayName = "Updates per second", Category = "General Settings"))
    	int UpdateRate = 30;
    
    	// Check if should ask for debug Mode?
    	UPROPERTY(EditAnywhere, meta = (DisplayName = "Ask for Debug mode?", Category = "General Settings"))
    	bool bAskForDebugMode = false;
    
    	// Check if should try to use Python Automatic Remote star
    	UPROPERTY(EditAnywhere, meta = (DisplayName = "Use Automatic Remote VA Start via Python?", Category = "General Settings"))
    	bool bAutomaticRemoteVAStart = true;
    
    	// Choose how to connect to the Server (automatic: build with windows connect with 127.0.0.1:12340, build with linux connect to cave)
    	UPROPERTY(EditAnywhere, meta = (DisplayName = "Usecase", Category = "Connection"))
    	TEnumAsByte<EConnectionSetting::Type> AddressSetting = EConnectionSetting::Type::Automatic;
    
    	// IP Address for manual input
    	UPROPERTY(EditAnywhere, meta = (DisplayName = "IP Adress", Category = "Connection")) // CanEditChange used
    	FString ServerIPAddress = "10.0.1.240";
    
    	// Port for manual input
    	UPROPERTY(EditAnywhere, meta = (DisplayName = "Port [0, 65535]", Category = "Connection", // CanEditChange used
    		ClampMin = "0", ClampMax = "65535", UIMin = "0", UIMax = "65535"))
    	uint16 ServerPort = 12340;
    
    	// Port for manual input
    	UPROPERTY(EditAnywhere, meta = (Category = "Connection", DisplayName = "Always reconnect to VAServer when this level is started?"))
    	bool bReconnecToVAServer = true;
    
    	// Read in File? 
    	UPROPERTY(EditAnywhere, meta = (DisplayName = "Read an initial mapping file?", Category = "Directivity Manager"))
    	bool bReadInitialMappingFile = false;
    	
    	// File name of the Directivity mapping file (e.g., for chaning directivities dynamically based on phonemes)
    	// if not specified it will be ignored.
    	UPROPERTY(EditAnywhere, meta = (DisplayName = "Name of ini file for directivities", Category = "Directivity Manager"))
    	FString DirMappingFileName = "";
    
    	// Port for remote VAServer starting
    	UPROPERTY(EditAnywhere, meta = (DisplayName = "Remote VAServer Start Port [0, 65535]", Category = "Connection",
    		// CanEditChange used
    		ClampMin = "0", ClampMax = "65535", UIMin = "0", UIMax = "65535"))
    	uint16 RemoteVAStarterPort = 41578;
    
    	// Which version should be started automatically
    	UPROPERTY(EditAnywhere, meta = (DisplayName =
    		"Which VAServer version should be started, configurable in the Config of the VAServer Launcher", Category =
    		"General Settings"))
    	FString WhichVAServerVersionToStart = TEXT("2020.a");
    
    	// Controller for global auraliztion modes
    	UPROPERTY(EditAnywhere, Instanced, NoClear, meta = (DisplayName = "Auraliztion Mode Controller", Category = "Auralization Modes"))
    		UVAAuralizationModeController* AuralizationModeController;
    
    	// View point to head center offset (x forward-dir, y right-dir, z up-dir) in cm. Note that x and z most probably need to be negative!
    	UPROPERTY(EditAnywhere, meta = (Category = "General Settings"))
    	FVector ViewpointToHeadcenterOffset = FVector(0, 0, 0);
    
    	// Source for tracking data, e.g., VirtualRealityPawn, ManualData (e.g., manually passed on from Optitrack)
    	UPROPERTY(EditAnywhere, meta = (Category = "General Settings"))
    	ETrackingSource TrackingSource = ETrackingSource::VirtualRealityPawn;
    
    
    public:
    
    	// Sets default values for this actor's properties
    	AVAReceiverActor();
    	void Tick(float DeltaTime) override;
    
    	// Interface for HRIR Settings
    	UFUNCTION(BlueprintCallable)
    	void SetUpdateRate(int Rate);
    
    	// Interface for Dir Mapping
    	UFUNCTION(BlueprintCallable)
    	bool ReadDirMappingFile(FString FileName);
    
    	// Interface for HRIR Settings
    	UFUNCTION(BlueprintCallable)
    	bool SetHRIRByFileName(FString FileName);
    	
    	// Set Debug Mode to toggle global visibility of all sound Sources
    	UFUNCTION(BlueprintCallable)
    	void SetDebugMode(bool bDebugMode);
    
    	// Gets scale of virtual world compared to real world
    	UFUNCTION(BlueprintCallable)
    	float GetScale() const;
    
    	// Gets IP Address
    	UFUNCTION(BlueprintCallable)
    	FString GetIPAddress() const;
    
    	// Gets Port
    	UFUNCTION(BlueprintCallable)
    	int GetPort() const;
    
    	// Gets auralization mode controller
    	UFUNCTION(BlueprintCallable)
    	UVAAuralizationModeController* GetAuralizationModeController() const;
    
    	// Update Function for TrackingSource==ManualData case.
    	// This method has to be called in that case regularly to update the receiver's position/orientation, as this is not done automatically
    	UFUNCTION(BlueprintCallable)
    	bool SetManualReceiverData(FVector VirtualPos, FRotator VirtualRot, FVector RealWorldPos=FVector(0,0,0), FRotator RealWorldRot = FRotator(0, 0, 0));
    
    	//Returns the VA receiver ID
    	int GetReceiverID() const;
    
    
    protected:
    	// Get Walls
    	TArray<AVAReflectionWall*> GetReflectionWalls();					// SourceC
    
    	// Directivity Handling
    	TSharedPtr<FVADirectivity> GetDirectivityByMapping(FString Phoneme) const;		// SourceC
    	TSharedPtr<FVADirectivity> GetDirectivityByFileName(FString FileName);			// SourceC
    
    	
    	// Cluster Stuff
    	void RunOnAllNodes(FString Command);
    	DECLARE_DISPLAY_CLUSTER_EVENT(AVAReceiverActor, RunOnAllNodes);
    
    	// Getter Functions	
    	bool IsInitialized() const;											// SourceC
    	int GetUpdateRate() const;											// SourceC
    
    	
    	// Initialization
    	void BeginPlay() override;
    	virtual void EndPlay(const EEndPlayReason::Type EndPlayReason) override;
    
    	// Position updates
    	bool UpdateVirtualWorldPose();
    	bool UpdateRealWorldPose();
    
    	void InitializeWalls();
    
    	
    #if WITH_EDITOR
    	bool CanEditChange(const FProperty* InProperty) const override;
    #endif
    
    	
    	// Receiver Specific Data
    	int ReceiverID;
    	TSharedPtr<FVADirectivityManager> DirManager;
    	TSharedPtr<FVAHRIRManager> HRIRManager;
    
    	TSharedPtr<FVAHRIR> CurrentHRIR;
    
    	TArray<AVAReflectionWall*> ReflectionWalls;
    	
    	// State of Actor
    	bool bInitialized = false;
    	bool bWallsInitialized = false;
    
    
    	// Time stuff
    	float TimeSinceUpdate;
    	float TotalTime;
    
    	// Event Listener Delegate
    	FOnClusterEventJsonListener ClusterEventListenerDelegate;
    
    };