// Copyright Epic Games, Inc. All Rights Reserved. #pragma once #include "BaseGizmos/CombinedTransformGizmo.h" #include "Components/StaticMeshComponent.h" #include "XRCreativeGizmos.generated.h" class AXRCreativeAvatar; namespace UE::GizmoUtil { struct FTransformSubGizmoCommonParams; struct FTransformSubGizmoSharedState; } /** Responsible for instantiating our UXRCreativeGizmo subclass. */ UCLASS() class UXRCreativeGizmoBuilder : public UCombinedTransformGizmoBuilder { GENERATED_BODY() public: UXRCreativeGizmoBuilder(); virtual UInteractiveGizmo* BuildGizmo(const FToolBuilderState& SceneState) const override; }; /** Implements our UpdateHoverFunction, and introduces an analogous UpdateInteractingFunction. */ UCLASS() class UXRCreativeGizmo : public UCombinedTransformGizmo { GENERATED_BODY() public: virtual void Setup() override; virtual void Tick(float DeltaTime) override; protected: using FTransformSubGizmoCommonParams = UE::GizmoUtil::FTransformSubGizmoCommonParams; using FTransformSubGizmoSharedState = UE::GizmoUtil::FTransformSubGizmoSharedState; virtual UInteractiveGizmo* AddAxisTranslationGizmo(FTransformSubGizmoCommonParams& Params, FTransformSubGizmoSharedState& SharedState) override; virtual UInteractiveGizmo* AddPlaneTranslationGizmo(FTransformSubGizmoCommonParams& Params, FTransformSubGizmoSharedState& SharedState) override; virtual UInteractiveGizmo* AddAxisRotationGizmo(FTransformSubGizmoCommonParams& Params, FTransformSubGizmoSharedState& SharedState) override; virtual UInteractiveGizmo* AddAxisScaleGizmo(FTransformSubGizmoCommonParams& Params, FTransformSubGizmoSharedState& SharedState) override; virtual UInteractiveGizmo* AddPlaneScaleGizmo(FTransformSubGizmoCommonParams& Params, FTransformSubGizmoSharedState& SharedState) override; virtual UInteractiveGizmo* AddUniformScaleGizmo(FTransformSubGizmoCommonParams& Params, FTransformSubGizmoSharedState& SharedState) override; protected: TFunction UpdateInteractingFunction; }; class UXRCreativeGizmoMeshComponent; UCLASS(Blueprintable, NonTransient) class AXRCreativeCombinedTransformGizmoActor : public ACombinedTransformGizmoActor { GENERATED_BODY() public: AXRCreativeCombinedTransformGizmoActor(); void SetEnabledElements(ETransformGizmoSubElements EnableElements); UPROPERTY(BlueprintReadOnly, Category="Gizmo") TObjectPtr WorldAligned; TWeakObjectPtr WeakGizmoManager; TWeakObjectPtr OwnerAvatar; /* Get the XRCreative Avatar that spawned this Gizmo */ UFUNCTION(BlueprintCallable, Category="XRCreative|Gizmo") AXRCreativeAvatar* GetOwnerAvatar() { return OwnerAvatar.Get(); } public: // NOTE: These properties alias ones inherited from ACombinedTransformGizmoActor // as a workaround to expose them as EditAnywhere + BlueprintReadWrite without // modifying the base class. ////////////////////////////////////////////////////////////////////////// UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Gizmo") TObjectPtr XRSceneRoot; // // Translation Components // /** X Axis Translation Component */ UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Gizmo") TObjectPtr XRTranslateX; /** Y Axis Translation Component */ UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Gizmo") TObjectPtr XRTranslateY; /** Z Axis Translation Component */ UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Gizmo") TObjectPtr XRTranslateZ; /** YZ Plane Translation Component */ UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Gizmo") TObjectPtr XRTranslateYZ; /** XZ Plane Translation Component */ UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Gizmo") TObjectPtr XRTranslateXZ; /** XY Plane Translation Component */ UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Gizmo") TObjectPtr XRTranslateXY; // // Rotation Components // /** X Axis Rotation Component */ UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Gizmo") TObjectPtr XRRotateX; /** Y Axis Rotation Component */ UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Gizmo") TObjectPtr XRRotateY; /** Z Axis Rotation Component */ UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Gizmo") TObjectPtr XRRotateZ; /** Z Axis Rotation Component */ UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Gizmo") TObjectPtr XRRotationSphere; // // Scaling Components // /** Uniform Scale Component */ UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Gizmo") TObjectPtr XRUniformScale; /** X Axis Scale Component */ UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Gizmo") TObjectPtr XRAxisScaleX; /** Y Axis Scale Component */ UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Gizmo") TObjectPtr XRAxisScaleY; /** Z Axis Scale Component */ UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Gizmo") TObjectPtr XRAxisScaleZ; /** YZ Plane Scale Component */ UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Gizmo") TObjectPtr XRPlaneScaleYZ; /** XZ Plane Scale Component */ UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Gizmo") TObjectPtr XRPlaneScaleXZ; /** XY Plane Scale Component */ UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Gizmo") TObjectPtr XRPlaneScaleXY; }; DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FXRCreativeGizmoStateChanged, UXRCreativeGizmoMeshComponent*, Component, bool, bNewState); UCLASS() class UXRCreativeGizmoMeshComponent : public UStaticMeshComponent { GENERATED_BODY() public: void Initialize(); void UpdateHoverState(bool bInHovering); void UpdateInteractingState(bool bInInteracting); UPROPERTY(BlueprintAssignable) FXRCreativeGizmoStateChanged OnHoveringChanged; UPROPERTY(BlueprintAssignable) FXRCreativeGizmoStateChanged OnInteractingChanged; FTransform CalcViewDependent(const FViewCameraState& InView, EToolContextCoordinateSystem InCoords) const; IGizmoAxisSource* AxisSource = nullptr; protected: UPROPERTY(BlueprintReadOnly, Category="Gizmo") bool bHovering; UPROPERTY(BlueprintReadOnly, Category="Gizmo") bool bInteracting; UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Gizmo") float HideAbsoluteViewDotThreshold = -1.0f; UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Gizmo") bool bReflectOnPrimaryAxis; UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Gizmo") bool bReflectOnTangentAxes; UPROPERTY(Transient) TArray> Materials; };