Add EditorCameraUtils (#6469)
* Add EditorCamera utility class. * Rename and reparent UEditorCameraUtils to AEditorCameraUtils (AActor). * Add copyright and fix indentation. * Fix copyright.
This commit is contained in:
parent
14f6ea1f79
commit
78476f6b37
|
@ -0,0 +1,25 @@
|
|||
// Copyright (c) 2023 Computer Vision Center (CVC) at the Universitat Autonoma
|
||||
// de Barcelona (UAB).
|
||||
//
|
||||
// This work is licensed under the terms of the MIT license.
|
||||
// For a copy, see <https://opensource.org/licenses/MIT>.
|
||||
|
||||
#include "EditorCamera.h"
|
||||
#include "UnrealClient.h"
|
||||
#include "Editor/EditorEngine.h"
|
||||
#include "EditorViewportClient.h"
|
||||
|
||||
void AEditorCameraUtils::Get()
|
||||
{
|
||||
auto ViewportClient = dynamic_cast<FEditorViewportClient*>(GEditor->GetActiveViewport()->GetClient());
|
||||
CameraTransform = FTransform();
|
||||
CameraTransform.SetLocation(ViewportClient->GetViewLocation());
|
||||
CameraTransform.SetRotation(FQuat(ViewportClient->GetViewRotation()));
|
||||
}
|
||||
|
||||
void AEditorCameraUtils::Set()
|
||||
{
|
||||
auto ViewportClient = dynamic_cast<FEditorViewportClient*>(GEditor->GetActiveViewport()->GetClient());
|
||||
ViewportClient->SetViewLocation(CameraTransform.GetLocation());
|
||||
ViewportClient->SetViewRotation(FRotator(CameraTransform.GetRotation()));
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
// Copyright (c) 2023 Computer Vision Center (CVC) at the Universitat Autonoma
|
||||
// de Barcelona (UAB).
|
||||
//
|
||||
// This work is licensed under the terms of the MIT license.
|
||||
// For a copy, see <https://opensource.org/licenses/MIT>.
|
||||
|
||||
#pragma once
|
||||
#include "CoreMinimal.h"
|
||||
#include "EditorCamera.generated.h"
|
||||
|
||||
|
||||
|
||||
|
||||
UCLASS(BlueprintType)
|
||||
class CARLATOOLS_API AEditorCameraUtils :
|
||||
public AActor
|
||||
{
|
||||
GENERATED_BODY()
|
||||
public:
|
||||
|
||||
UFUNCTION(BlueprintCallable, CallInEditor)
|
||||
void Get();
|
||||
|
||||
UFUNCTION(BlueprintCallable, CallInEditor)
|
||||
void Set();
|
||||
|
||||
|
||||
|
||||
UPROPERTY(BlueprintReadWrite, EditAnywhere)
|
||||
FTransform CameraTransform;
|
||||
|
||||
};
|
Loading…
Reference in New Issue