Skip to content
Snippets Groups Projects
Commit 35f14cfd authored by Jonathan Ehret's avatar Jonathan Ehret
Browse files

Merge branch 'feature/dynamic_spawning_of_overlay' into 'develop'

Feature/dynamic spawning of overlay

See merge request VR-Group/unreal-development/unreal-cave-overlay!12
parents 6418ac3a b63fcbf0
Branches develop
No related tags found
2 merge requests!13Develop,!12Feature/dynamic spawning of overlay
// Copyright 1998-2019 Epic Games, Inc. All Rights Reserved.
#include "CAVEOverlay.h"
#include "CAVEOverlaySettings.h"
#include "CAVEOverlayController.h"
#include "Kismet/GameplayStatics.h"
#define LOCTEXT_NAMESPACE "FCAVEOverlayModule"
void FCAVEOverlayModule::StartupModule()
{
// This code will execute after your module is loaded into memory; the exact timing is specified in the .uplugin file per-module
On_Post_World_Initialization_Delegate.BindRaw(this, &FCAVEOverlayModule::OnSessionStart);
FWorldDelegates::OnPostWorldInitialization.Add(On_Post_World_Initialization_Delegate);
}
void FCAVEOverlayModule::OnSessionStart(UWorld* World, const UWorld::InitializationValues)
{
if (!World->IsGameWorld())
return;
const UCAVEOverlaySettings* Settings = GetDefault<UCAVEOverlaySettings>();
//Test if already in
TArray<AActor*> Actors;
UGameplayStatics::GetAllActorsOfClass(World, ACAVEOverlayController::StaticClass(), Actors);
if((Settings->DefaultActivationType == DefaultActivationType_ON
!= Settings->excludedMaps.ContainsByPredicate(
[World](const FSoftObjectPath& Map) {return Map.GetAssetName() == World->GetName();}
)) && Actors.Num() == 0){
World->SpawnActor(ACAVEOverlayController::StaticClass());
}
}
void FCAVEOverlayModule::ShutdownModule()
{
// This function may be called during shutdown to clean up your module. For modules that support dynamic reloading,
......
......@@ -21,8 +21,7 @@
DEFINE_LOG_CATEGORY(LogCAVEOverlay);
template <std::size_t S>
bool ContainsFString(const std::array<FString, S>& Array, const FString& Entry)
bool ContainsFString(const TArray<FString>& Array, const FString& Entry)
{
for (FString Current_Entry : Array)
{
......@@ -279,7 +278,7 @@ bool ACAVEOverlayController::PositionInDoorOpening(FVector Position)
void ACAVEOverlayController::RefreshPawnComponents()
{
Cave_Origin = Player_Pawn->GetTrackingOriginComponent();
Shutter_Glasses = Player_Pawn->GetHeadComponent();
Head = Player_Pawn->GetHeadComponent();
}
// Called every frame
......@@ -289,7 +288,7 @@ void ACAVEOverlayController::Tick(float DeltaTime)
if (!bCAVE_Mode) return; // Not our business
if (!Cave_Origin || !Shutter_Glasses)
if (!Cave_Origin || !Head)
{
RefreshPawnComponents();
}
......@@ -313,10 +312,10 @@ void ACAVEOverlayController::Tick(float DeltaTime)
}
}
if (!Shutter_Glasses) return; //Display Cluster not initialized
if (!Head || !Cave_Origin) return; //Display Cluster not initialized
//Tape Logic
FVector Shutter_Position = Shutter_Glasses->GetRelativeTransform().GetLocation();
FVector Shutter_Position = Head->GetComponentLocation() - Cave_Origin->GetComponentLocation();
bool bOverlay_Visible = FMath::IsWithinInclusive(Shutter_Position.GetAbsMax(), Wall_Distance - Wall_Close_Distance, Wall_Distance);
if (bOverlay_Visible && !PositionInDoorOpening(Shutter_Position))
......
......@@ -4,6 +4,7 @@
#include "CoreMinimal.h"
#include "Modules/ModuleManager.h"
#include "Engine/World.h"
class FCAVEOverlayModule : public IModuleInterface
{
......@@ -12,4 +13,7 @@ public:
/** IModuleInterface implementation */
virtual void StartupModule() override;
virtual void ShutdownModule() override;
private:
TBaseDelegate<void, UWorld*, const UWorld::InitializationValues> On_Post_World_Initialization_Delegate;
void OnSessionStart(UWorld* World, UWorld::InitializationValues);
};
......@@ -6,7 +6,6 @@
#include "GameFramework/Actor.h"
#include "DoorOverlayData.h"
#include "Engine/Engine.h"
#include <array>
#include "Components/StaticMeshComponent.h"
#include "Materials/Material.h"
#include "Materials/MaterialInstanceDynamic.h"
......@@ -39,9 +38,9 @@ private:
enum EScreen_Type { SCREEN_MASTER, SCREEN_NORMAL, SCREEN_DOOR_PARTIAL, SCREEN_DOOR };
EScreen_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 std::array<FString, 5> Screens_FPS = {"node_rur_left_eye", "node_rur_right_eye", "node_lur_left_eye", "node_lur_right_eye", "node_main"};
const TArray<FString> Screens_Door = {"node_bul_left_eye", "node_bul_right_eye", "node_bll_left_eye", "node_bll_right_eye"};
const TArray<FString> Screens_Door_Partial = {"node_bur_left_eye", "node_bur_right_eye", "node_blr_left_eye", "node_blr_right_eye"};
const TArray<FString> Screens_FPS = {"node_rur_left_eye", "node_rur_right_eye", "node_lur_left_eye", "node_lur_right_eye", "node_main"};
const FString Screen_Main = "node_main";
//Door Mode
......@@ -73,7 +72,7 @@ private:
void RefreshPawnComponents();
AVirtualRealityPawn* Player_Pawn;
USceneComponent* Cave_Origin;
USceneComponent* Shutter_Glasses;
USceneComponent* Head;
//Cluster Events
FOnClusterEventListener ClusterEventListenerDelegate;
......
#pragma once
#include "CoreMinimal.h"
#include "Engine/EngineTypes.h"
#include "Engine/DeveloperSettings.h"
#include "CAVEOverlaySettings.generated.h"
UENUM(BlueprintType)
enum DefaultActivationType
{
DefaultActivationType_OFF UMETA(DisplayName = "Off by default"),
DefaultActivationType_ON UMETA(DisplayName = "On by default")
};
UCLASS(config=Game, defaultconfig, meta=(DisplayName="CAVE Overlay"))
class UCAVEOverlaySettings : public UDeveloperSettings
{
GENERATED_BODY()
public:
UPROPERTY(EditAnywhere, config, Category = "General", meta = (DisplayName = "Default Activation Type"))
TEnumAsByte<DefaultActivationType> DefaultActivationType = DefaultActivationType_ON;
UPROPERTY(EditAnywhere, config, Category = Maps, meta=(AllowedClasses="World"))
TArray<FSoftObjectPath> excludedMaps;
};
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment