Select Git revision
CAVEOverlayController.h
-
Sebastian Pape authored
Changed moving to attachment. Fixed attachment and forced door position to be in the correct side. Rebound function to Action1 instead of DisplayClusterAction1
Sebastian Pape authoredChanged moving to attachment. Fixed attachment and forced door position to be in the correct side. Rebound function to Action1 instead of DisplayClusterAction1
CAVEOverlayController.h 5.15 KiB
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "DoorOverlayData.h"
#include "HeadMountedDisplayFunctionLibrary.h"
#include "IDisplayCluster.h"
#include "Engine/Engine.h"
#include "IXRTrackingSystem.h"
#include "Components/InputComponent.h"
#include "Cluster/IDisplayClusterClusterManager.h"
#include "IDisplayClusterGameManager.h"
#include "InputCoreTypes.h"
#include "UObject/ConstructorHelpers.h"
#include <array>
#include "Components/StaticMeshComponent.h"
#include "Engine/Engine.h"
#include "Materials/Material.h"
#include "Materials/MaterialInstanceDynamic.h"
#include "DisplayClusterExtensions/Public/VirtualRealityPawn.h"
#include "DisplayCluster/Public/DisplayClusterSceneComponent.h"
#include "CAVEOverlayController.generated.h"
DECLARE_LOG_CATEGORY_EXTERN(CAVEOverlayLog, Log, All);
UCLASS()
class CAVEOVERLAY_API ACAVEOverlayController : public AActor
{
GENERATED_BODY()
public:
ACAVEOverlayController();
protected:
// Called when the game starts or when spawned
virtual void BeginPlay() override;
virtual void PostInitializeComponents() override;
private:
//Execution Modes
bool hmd_mode_ = false;
bool display_cluster_mode_ = false;
//Screen Types
enum SCREEEN_TYPE { SCREEN_MASTER, SCREEN_NORMAL, SCREEN_DOOR_PARTIAL, SCREEN_DOOR };
SCREEEN_TYPE screen_type_ = SCREEN_NORMAL;
const std::array<FString, 4> screens_door_ = {"node_bul_left_eye", "node_bul_right_eye", "node_bll_left_eye", "node_bll_right_eye"};
const std::array<FString, 4> screens_door_partial_ = {"node_bur_left_eye", "node_bur_right_eye", "node_blr_left_eye", "node_blr_right_eye"};
const FString screen_main = "node_main";
//Door Mode
enum DOOR_MODE { DOOR_CLOSED = 0, DOOR_OPEN = 1, DOOR_PARTIAL_OPEN = 2, DOOR_NUM_MODES = 3};
const FString door_mode_names_[DOOR_NUM_MODES] = {"Partial Open", "Closed", "Open" };
DOOR_MODE door_current_mode_ = DOOR_PARTIAL_OPEN;
const float door_opening_width_relative_ = 0.522; //%, used for the overlay width on the screen
const float door_opening_width_absolute_ = 165; //cm, used for the non tape part at the door
const float wall_distance_ = 262.5; //cm, distance from center to a wall, *2 = wall width
const float wall_close_distance_ = 75; //cm, the distance considered to be too close to the walls
const float wall_fade_distance_ = 35; //cm, the distance over which the tape is faded
const float wall_warning_distance_ = 40; //cm, distance on which the tape turns red, measurred from wall
float door_current_opening_width_absolute_ = 0;
//Overlay
TSubclassOf<class UDoorOverlayData> overlay_class_;
UDoorOverlayData* overlay_;
//Geometry and Material
UStaticMeshComponent* createMeshComponent(const FName &name, UStaticMesh* mesh, USceneComponent* parent);
UMaterial* tape_material_ = nullptr;
UMaterial* sign_material_ = nullptr;
float calculateOpacityFromPosition(FVector position);
bool positionInDoorOpening(FVector position);
//Pawn Components
bool attached_ = false;
void refreshPawnComponents();
AVirtualRealityPawn* player_pawn_;
UDisplayClusterSceneComponent* cave_origin_;
UDisplayClusterSceneComponent* shutter_glasses_;
public:
// Called every frame
virtual void Tick(float DeltaTime) override;
void CycleDoorType();
void SetDoorMode(DOOR_MODE m);
//Signs and Banners
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "CAVEOverlay", meta = (AllowPrivateAccess = "true")) USceneComponent* root = nullptr;
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "CAVEOverlay", meta = (AllowPrivateAccess = "true")) USceneComponent* tape_root = nullptr;
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "CAVEOverlay", meta = (AllowPrivateAccess = "true")) USceneComponent* sign_root = nullptr;
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "CAVEOverlay", meta = (AllowPrivateAccess = "true")) UStaticMeshComponent* tape_negative_y = nullptr;
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "CAVEOverlay", meta = (AllowPrivateAccess = "true")) UStaticMeshComponent* tape_negative_x = nullptr;
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "CAVEOverlay", meta = (AllowPrivateAccess = "true")) UStaticMeshComponent* tape_positive_y = nullptr;
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "CAVEOverlay", meta = (AllowPrivateAccess = "true")) UStaticMeshComponent* tape_positive_x = nullptr;
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "CAVEOverlay", meta = (AllowPrivateAccess = "true")) UStaticMeshComponent* sign_negative_y = nullptr;
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "CAVEOverlay", meta = (AllowPrivateAccess = "true")) UStaticMeshComponent* sign_negative_x = nullptr;
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "CAVEOverlay", meta = (AllowPrivateAccess = "true")) UStaticMeshComponent* sign_positive_y = nullptr;
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "CAVEOverlay", meta = (AllowPrivateAccess = "true")) UStaticMeshComponent* sign_positive_x = nullptr;
UMaterialInstanceDynamic* tape_material_dynamic_ = nullptr;
UMaterialInstanceDynamic* sign_material_dynamic_ = nullptr;
UStaticMesh* plane_mesh_ = nullptr;
};