Download LyraStarterGame/Source/LyraGame/Camera/LyraCameraComponent.cpp from Alexhas2/unitysamples: direct link, hf CLI and curl.
- Browser
- Download file 3.93 kB
-
https://huggingface.co/datasets/Alexhas2/unitysamples/resolve/main/LyraStarterGame/Source/LyraGame/Camera/LyraCameraComponent.cpp
- Command line
-
hf download hf://datasets/Alexhas2/unitysamples/LyraStarterGame/Source/LyraGame/Camera/LyraCameraComponent.cpp
-
curl -L -o LyraCameraComponent.cpp https://huggingface.co/datasets/Alexhas2/unitysamples/resolve/main/LyraStarterGame/Source/LyraGame/Camera/LyraCameraComponent.cpp
3.93 kB
| // Copyright Epic Games, Inc. All Rights Reserved. | |
| ULyraCameraComponent::ULyraCameraComponent(const FObjectInitializer& ObjectInitializer) | |
| : Super(ObjectInitializer) | |
| { | |
| CameraModeStack = nullptr; | |
| FieldOfViewOffset = 0.0f; | |
| } | |
| void ULyraCameraComponent::OnRegister() | |
| { | |
| Super::OnRegister(); | |
| if (!CameraModeStack) | |
| { | |
| CameraModeStack = NewObject<ULyraCameraModeStack>(this); | |
| check(CameraModeStack); | |
| } | |
| } | |
| void ULyraCameraComponent::GetCameraView(float DeltaTime, FMinimalViewInfo& DesiredView) | |
| { | |
| check(CameraModeStack); | |
| UpdateCameraModes(); | |
| FLyraCameraModeView CameraModeView; | |
| CameraModeStack->EvaluateStack(DeltaTime, CameraModeView); | |
| // Keep player controller in sync with the latest view. | |
| if (APawn* TargetPawn = Cast<APawn>(GetTargetActor())) | |
| { | |
| if (APlayerController* PC = TargetPawn->GetController<APlayerController>()) | |
| { | |
| PC->SetControlRotation(CameraModeView.ControlRotation); | |
| } | |
| } | |
| // Apply any offset that was added to the field of view. | |
| CameraModeView.FieldOfView += FieldOfViewOffset; | |
| FieldOfViewOffset = 0.0f; | |
| // Keep camera component in sync with the latest view. | |
| SetWorldLocationAndRotation(CameraModeView.Location, CameraModeView.Rotation); | |
| FieldOfView = CameraModeView.FieldOfView; | |
| // Fill in desired view. | |
| DesiredView.Location = CameraModeView.Location; | |
| DesiredView.Rotation = CameraModeView.Rotation; | |
| DesiredView.FOV = CameraModeView.FieldOfView; | |
| DesiredView.OrthoWidth = OrthoWidth; | |
| DesiredView.OrthoNearClipPlane = OrthoNearClipPlane; | |
| DesiredView.OrthoFarClipPlane = OrthoFarClipPlane; | |
| DesiredView.AspectRatio = AspectRatio; | |
| DesiredView.bConstrainAspectRatio = bConstrainAspectRatio; | |
| DesiredView.bUseFieldOfViewForLOD = bUseFieldOfViewForLOD; | |
| DesiredView.ProjectionMode = ProjectionMode; | |
| // See if the CameraActor wants to override the PostProcess settings used. | |
| DesiredView.PostProcessBlendWeight = PostProcessBlendWeight; | |
| if (PostProcessBlendWeight > 0.0f) | |
| { | |
| DesiredView.PostProcessSettings = PostProcessSettings; | |
| } | |
| if (IsXRHeadTrackedCamera()) | |
| { | |
| // In XR much of the camera behavior above is irrellevant, but the post process settings are not. | |
| Super::GetCameraView(DeltaTime, DesiredView); | |
| } | |
| } | |
| void ULyraCameraComponent::UpdateCameraModes() | |
| { | |
| check(CameraModeStack); | |
| if (CameraModeStack->IsStackActivate()) | |
| { | |
| if (DetermineCameraModeDelegate.IsBound()) | |
| { | |
| if (const TSubclassOf<ULyraCameraMode> CameraMode = DetermineCameraModeDelegate.Execute()) | |
| { | |
| CameraModeStack->PushCameraMode(CameraMode); | |
| } | |
| } | |
| } | |
| } | |
| void ULyraCameraComponent::DrawDebug(UCanvas* Canvas) const | |
| { | |
| check(Canvas); | |
| FDisplayDebugManager& DisplayDebugManager = Canvas->DisplayDebugManager; | |
| DisplayDebugManager.SetFont(GEngine->GetSmallFont()); | |
| DisplayDebugManager.SetDrawColor(FColor::Yellow); | |
| DisplayDebugManager.DrawString(FString::Printf(TEXT("LyraCameraComponent: %s"), *GetNameSafe(GetTargetActor()))); | |
| DisplayDebugManager.SetDrawColor(FColor::White); | |
| DisplayDebugManager.DrawString(FString::Printf(TEXT(" Location: %s"), *GetComponentLocation().ToCompactString())); | |
| DisplayDebugManager.DrawString(FString::Printf(TEXT(" Rotation: %s"), *GetComponentRotation().ToCompactString())); | |
| DisplayDebugManager.DrawString(FString::Printf(TEXT(" FOV: %f"), FieldOfView)); | |
| check(CameraModeStack); | |
| CameraModeStack->DrawDebug(Canvas); | |
| } | |
| void ULyraCameraComponent::GetBlendInfo(float& OutWeightOfTopLayer, FGameplayTag& OutTagOfTopLayer) const | |
| { | |
| check(CameraModeStack); | |
| CameraModeStack->GetBlendInfo(/*out*/ OutWeightOfTopLayer, /*out*/ OutTagOfTopLayer); | |
| } | |