A Demo Project for the UnrealEngineSDK
Loading...
Searching...
No Matches
VRStereoWidgetComponent.h
Go to the documentation of this file.
1// Fill out your copyright notice in the Description page of Project Settings.
2
3#pragma once
4
5#include "CoreMinimal.h"
6#include "Engine/Engine.h"
7#include "VRBPDatatypes.h"
8#include "VRGripInterface.h"
9#include "Components/WidgetComponent.h"
10#include "Components/StereoLayerComponent.h"
11#include "Slate/WidgetRenderer.h"
12#include "Blueprint/UserWidget.h"
13#include "Components/StereoLayerComponent.h"
14#include "Engine/TextureRenderTarget2D.h"
15//#include "Animation/UMGSequencePlayer.h"
16#include "Engine/GameViewportClient.h"
17#include "StereoLayerShapes.h"
18
19#include "VRStereoWidgetComponent.generated.h"
20
24UCLASS(Blueprintable, meta = (BlueprintSpawnableComponent), ClassGroup = (VRExpansionPlugin), HideCategories = ("Stereoscopic Properties", Collision))
25class VREXPANSIONPLUGIN_API UVRStereoWidgetRenderComponent : public UStereoLayerComponent
26{
27 GENERATED_BODY()
29public:
30 UVRStereoWidgetRenderComponent(const FObjectInitializer& ObjectInitializer);
31
33 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "WidgetSettings", meta = (ExposeOnSpawn = true))
34 TSubclassOf<UUserWidget> WidgetClass;
35
37 UPROPERTY(Transient, DuplicateTransient)
38 UUserWidget* Widget;
39
41 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "WidgetSettings", meta = (ExposeOnSpawn = true))
42 bool bDrawAtDesiredSize;
43
45 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "WidgetSettings", meta = (ExposeOnSpawn = true))
46 float WidgetRenderScale;
47
49 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "WidgetSettings", meta = (ExposeOnSpawn = true))
50 float WidgetRenderGamma;
51
53 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "WidgetSettings", meta = (ExposeOnSpawn = true))
54 bool bUseGammaCorrection;
55
57 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "WidgetSettings", meta = (ExposeOnSpawn = true))
58 FLinearColor RenderTargetClearColor;
59
61 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "WidgetSettings", meta = (ExposeOnSpawn = true))
62 bool bDrawWithoutStereo;
63
65 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "WidgetSettings", meta = (ExposeOnSpawn = true))
66 float DrawRate;
67
68 // Counts how long until next draw
69 float DrawCounter;
70
72 TSharedPtr<SWidget> SlateWidget;
74 class FWidgetRenderer* WidgetRenderer;
75
77 UPROPERTY(BlueprintReadOnly, Transient, DuplicateTransient, Category = "WidgetSettings")
78 UTextureRenderTarget2D* RenderTarget;
79
81 TSharedPtr<class SVirtualWindow> SlateWindow;
82
83 virtual void TickComponent(float DeltaTime, enum ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;
84 virtual void BeginPlay() override;
85 virtual void EndPlay(const EEndPlayReason::Type EndPlayReason) override;
86 virtual void DestroyComponent(bool bPromoteChildren/*= false*/) override;
87
88 UFUNCTION(BlueprintCallable, Category = "WidgetSettings")
89 void SetWidgetAndInit(TSubclassOf<UUserWidget> NewWidgetClass);
90
91 void OnLevelRemovedFromWorld(ULevel* InLevel, UWorld* InWorld);
92 void InitWidget();
93 void RenderWidget(float DeltaTime);
94 void ReleaseResources();
95};
96
103UCLASS(Blueprintable, meta = (BlueprintSpawnableComponent), ClassGroup = (VRExpansionPlugin))
104class VREXPANSIONPLUGIN_API UVRStereoWidgetComponent : public UWidgetComponent
106 GENERATED_BODY()
107
108public:
109 UVRStereoWidgetComponent(const FObjectInitializer& ObjectInitializer);
110
111 friend class FStereoLayerComponentVisualizer;
112
114
115
117 UPROPERTY(EditAnywhere, BlueprintReadOnly, NoClear, Instanced, Category = "StereoLayer", DisplayName = "Stereo Layer Shape")
118 UStereoLayerShape* Shape;
119
120 void BeginDestroy() override;
121 void OnUnregister() override;
122 virtual void TickComponent(float DeltaTime, enum ELevelTick TickType, FActorComponentTickFunction *ThisTickFunction) override;
123 virtual void DrawWidgetToRenderTarget(float DeltaTime) override;
124 virtual TStructOnScope<FActorComponentInstanceData> GetComponentInstanceData() const override;
125 void ApplyVRComponentInstanceData(class FVRStereoWidgetComponentInstanceData* WidgetInstanceData);
126
127 virtual void UpdateRenderTarget(FIntPoint DesiredRenderTargetSize) override;
128 virtual FPrimitiveSceneProxy* CreateSceneProxy() override;
129
130
131 // If true forces the widget to render both stereo and world widgets
132 // Overriden by the console command vr.ForceNoStereoWithVRWidgets if it is set to 1
133 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "StereoLayer")
134 bool bRenderBothStereoAndWorld;
135
137 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "StereoLayer")
138 bool bDrawWithoutStereo;
139
140 // If true, use Epics world locked stereo implementation instead of my own temp solution
141 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "StereoLayer")
142 bool bUseEpicsWorldLockedStereo;
143
144 // If true, will cache and delay the transform adjustment for one frame in order to sync with the game thread better
145 // Not for use with late updated parents.
146 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "StereoLayer")
147 bool bDelayForRenderThread;
148
149 // If true will not render or update until false
150 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "StereoLayer")
151 bool bIsSleeping;
152
157 UFUNCTION(BlueprintCallable, Category = "Components|Stereo Layer")
158 void SetPriority(int32 InPriority);
159
160 // @return the render priority
161 UFUNCTION(BlueprintCallable, Category = "Components|Stereo Layer")
162 int32 GetPriority() const { return Priority; }
163
165 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "StereoLayer")
166 uint32 bSupportsDepth : 1;
167
169 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "StereoLayer")
170 uint32 bNoAlphaChannel : 1;
171
173 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "StereoLayer")
174 uint32 bQuadPreserveTextureRatio : 1;
175
176protected:
178 //UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "StereoLayer")
179 // class UTexture* Texture;
180
181 // Forget left texture implementation
183 //UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "StereoLayer | Cubemap Overlay Properties")
184 // class UTexture* LeftTexture;
185
186public:
188 //UPROPERTY(EditAnywhere, BlueprintReadOnly, export, Category = "StereoLayer | Quad Overlay Properties")
189 // FVector2D StereoLayerQuadSize;
190
192 //UPROPERTY(EditAnywhere, BlueprintReadOnly, export, Category = "StereoLayer | Quad Overlay Properties")
193 FBox2D UVRect;
196 //UPROPERTY(EditAnywhere, BlueprintReadOnly, export, Category = "StereoLayer | Cylinder Overlay Properties")
197 // float CylinderRadius;
198
200 //UPROPERTY(EditAnywhere, BlueprintReadOnly, export, Category = "StereoLayer | Cylinder Overlay Properties")
201 //float CylinderOverlayArc;
205 // int CylinderHeight;
206
208 //UPROPERTY(EditAnywhere, BlueprintReadOnly, export, Category = "StereoLayer")
209 //TEnumAsByte<enum EStereoLayerType> StereoLayerType;
211 // Forcing quad layer so that it works with the widget better
213 //UPROPERTY(EditAnywhere, BlueprintReadOnly, export, Category = "StereoLayer")
214 // TEnumAsByte<enum EStereoLayerShape> StereoLayerShape;
215
217 UPROPERTY(EditAnywhere, BlueprintReadOnly, export, Category = "StereoLayer")
218 int32 Priority;
220 bool bShouldCreateProxy;
221
222private:
224 bool bIsDirty;
225 bool bDirtyRenderTarget;
226
228 bool bTextureNeedsUpdate;
229
231 uint32 LayerId;
232
234 FTransform LastTransform;
235
237 bool bLastVisible;
238
239};
UCLASS(Blueprintable, meta = (BlueprintSpawnableComponent), ClassGroup = (VRExpansionPlugin))
bool bUseEpicsWorldLockedStereo
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "StereoLayer")
bool bIsSleeping
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "StereoLayer")
bool bDelayForRenderThread
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "StereoLayer")
bool bDrawWithoutStereo
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "StereoLayer")
UStereoLayerShape * Shape
UPROPERTY(EditAnywhere, BlueprintReadOnly, NoClear, Instanced, Category = "StereoLayer",...
int32 Priority
UPROPERTY(EditAnywhere, BlueprintReadOnly, export, Category = "StereoLayer | Cylinder Overlay Propert...
bool bRenderBothStereoAndWorld
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "StereoLayer")
uint32 bQuadPreserveTextureRatio
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "StereoLayer")
uint32 bSupportsDepth
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "StereoLayer")
int32 GetPriority() const
UFUNCTION(BlueprintCallable, Category = "Components|Stereo Layer")
uint32 bNoAlphaChannel
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "StereoLayer")
UCLASS(Blueprintable, meta = (BlueprintSpawnableComponent), ClassGroup = (VRExpansionPlugin),...
bool bDrawWithoutStereo
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "WidgetSettings", meta = (ExposeOnSpawn = true...
UUserWidget * Widget
UPROPERTY(Transient, DuplicateTransient)
UTextureRenderTarget2D * RenderTarget
UPROPERTY(BlueprintReadOnly, Transient, DuplicateTransient, Category = "WidgetSettings")
TSharedPtr< class SVirtualWindow > SlateWindow
bool bUseGammaCorrection
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "WidgetSettings", meta = (ExposeOnSpawn = true...
TSubclassOf< UUserWidget > WidgetClass
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "WidgetSettings", meta = (ExposeOnSpawn = true...
float WidgetRenderGamma
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "WidgetSettings", meta = (ExposeOnSpawn = true...
float WidgetRenderScale
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "WidgetSettings", meta = (ExposeOnSpawn = true...
float DrawRate
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "WidgetSettings", meta = (ExposeOnSpawn = true...
bool bDrawAtDesiredSize
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "WidgetSettings", meta = (ExposeOnSpawn = true...
FLinearColor RenderTargetClearColor
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "WidgetSettings", meta = (ExposeOnSpawn = true...