integrate the virtual hand into the sgpawn

This commit is contained in:
Mamadou Babaei
2023-03-13 14:19:32 +01:00
parent 054f6182b5
commit 529e69ea34
9 changed files with 111 additions and 24 deletions
@@ -35,9 +35,10 @@
#include "SenseGlove/GameFramework/SGPawn.h"
#include "Components/ActorComponent.h"
#include "Camera/CameraComponent.h"
#include "MotionControllerComponent.h"
#include "SenseGlove/GameFramework/SGPawn.h"
#include "SenseGlove/Components/SGVirtualHandComponent.h"
struct ASGPawn::FImpl
{
@@ -76,8 +77,36 @@ ASGPawn::ASGPawn(const FObjectInitializer& ObjectInitializer)
{
PrimaryActorTick.bCanEverTick = true;
SceneRoot = CreateDefaultSubobject<USceneComponent>(TEXT("SceneRoot"));
SceneRoot = ObjectInitializer.CreateDefaultSubobject<USceneComponent>(this, TEXT("SceneRoot"));
SetRootComponent(SceneRoot);
Camera = ObjectInitializer.CreateDefaultSubobject<UCameraComponent>(this, TEXT("Camera"));
Camera->SetupAttachment(GetRootComponent());
Camera->SetCanEverAffectNavigation(false);
MotionControllerLeft = ObjectInitializer.CreateDefaultSubobject<UMotionControllerComponent>(
this, TEXT("MotionControllerLeft"));
MotionControllerLeft->SetupAttachment(GetRootComponent());
MotionControllerLeft->SetCanEverAffectNavigation(false);
MotionControllerLeft->SetWorldLocation(FVector{30.0f, -20.0f, -10.0f},
false, nullptr, ETeleportType::None);
HandLeft = ObjectInitializer.CreateDefaultSubobject<USGVirtualHandComponent>(this, TEXT("HandLeft"));
HandLeft->SetupAttachment(MotionControllerLeft);
HandLeft->SetCanEverAffectNavigation(false);
HandLeft->SetRight(false);
MotionControllerRight = ObjectInitializer.CreateDefaultSubobject<UMotionControllerComponent>(
this, TEXT("MotionControllerRight"));
MotionControllerRight->SetupAttachment(GetRootComponent());
MotionControllerRight->SetCanEverAffectNavigation(false);
MotionControllerRight->SetWorldLocation(FVector{30.0f, 20.0f, -10.0f},
false, nullptr, ETeleportType::None);
HandRight = ObjectInitializer.CreateDefaultSubobject<USGVirtualHandComponent>(this, TEXT("HandRight"));
HandRight->SetupAttachment(MotionControllerRight);
HandRight->SetCanEverAffectNavigation(false);
HandRight->SetRight(true);
}
ASGPawn::FImpl::FImpl(ASGPawn* InOwner)
@@ -39,3 +39,8 @@ ASGPlayerController::ASGPlayerController(const FObjectInitializer& ObjectInitial
: Super(ObjectInitializer)
{
}
void ASGPlayerController::SetupInputComponent()
{
Super::SetupInputComponent();
}
@@ -40,9 +40,11 @@
#include "SGPawn.generated.h"
class UActorComponent;
class UCameraComponent;
class UMotionControllerComponent;
class USGVirtualHandComponent;
UCLASS(Config=Game, BlueprintType, Blueprintable)
class SENSEGLOVE_API ASGPawn : public APawn
{
@@ -63,6 +65,9 @@ private:
UPROPERTY(VisibleAnywhere, Category="SenseGlove", meta=(AllowPrivateAccess="false"))
USceneComponent* SceneRoot;
UPROPERTY(VisibleAnywhere, Category="SenseGlove", meta=(AllowPrivateAccess="false"))
UCameraComponent* Camera;
UPROPERTY(VisibleAnywhere, Category="SenseGlove", meta=(AllowPrivateAccess="false"))
UMotionControllerComponent* MotionControllerLeft;
@@ -70,28 +75,33 @@ private:
UMotionControllerComponent* MotionControllerRight;
UPROPERTY(VisibleAnywhere, Category="SenseGlove", meta=(AllowPrivateAccess="false"))
UActorComponent* HandLeft;
USGVirtualHandComponent* HandLeft;
UPROPERTY(VisibleAnywhere, Category="SenseGlove", meta=(AllowPrivateAccess="false"))
UActorComponent* HandRight;
USGVirtualHandComponent* HandRight;
protected:
FORCEINLINE UMotionControllerComponent* GetMotionContollerLeft() const
public:
FORCEINLINE UCameraComponent* GetCamera() const
{
return Camera;
}
FORCEINLINE UMotionControllerComponent* GetMotionControllerLeft() const
{
return MotionControllerLeft;
}
FORCEINLINE UMotionControllerComponent* GetMotionContollerRight() const
FORCEINLINE UMotionControllerComponent* GetMotionControllerRight() const
{
return MotionControllerRight;
}
FORCEINLINE UActorComponent* GetHandLeft() const
FORCEINLINE USGVirtualHandComponent* GetHandLeft() const
{
return HandLeft;
}
FORCEINLINE UActorComponent* GetHandRight() const
FORCEINLINE USGVirtualHandComponent* GetHandRight() const
{
return HandRight;
}
@@ -43,4 +43,7 @@ UCLASS(Config=Game, BlueprintType, Blueprintable)
class SENSEGLOVE_API ASGPlayerController : public APlayerController
{
GENERATED_UCLASS_BODY()
protected:
virtual void SetupInputComponent() override;
};
@@ -34,3 +34,34 @@
#include "SGKismet/SGPawnKismetLibrary.h"
#include "Camera/CameraComponent.h"
#include "MotionControllerComponent.h"
#include "SenseGlove/Components/SGVirtualHandComponent.h"
#include "SenseGlove/GameFramework/SGPawn.h"
UCameraComponent* UPawnKismetLibrary::GetCamera(const ASGPawn* Pawn)
{
return Pawn->GetCamera();
}
UMotionControllerComponent* UPawnKismetLibrary::GetMotionControllerLeft(const ASGPawn* Pawn)
{
return Pawn->GetMotionControllerLeft();
}
UMotionControllerComponent* UPawnKismetLibrary::GetMotionControllerRight(const ASGPawn* Pawn)
{
return Pawn->GetMotionControllerRight();
}
USGVirtualHandComponent* UPawnKismetLibrary::GetHandLeft(const ASGPawn* Pawn)
{
return Pawn->GetHandLeft();
}
USGVirtualHandComponent* UPawnKismetLibrary::GetHandRight(const ASGPawn* Pawn)
{
return Pawn->GetHandRight();
}
@@ -49,16 +49,30 @@
#include "SGPawnKismetLibrary.generated.h"
class UCameraComponent;
class UMotionControllerComponent;
class ASGPawn;
class ASGVirtualHand;
class USGVirtualHandComponent;
/**
* Represents data of a user's hand required for forward kinematics.
*/
UCLASS(meta=(ScriptName = "SesneGlovePawnKismetLibrary"))
class SENSEGLOVEKISMET_API UPawnKismetLibrary final : public USGBlueprintFunctionLibrary
{
GENERATED_BODY()
public:
UFUNCTION(BlueprintPure, Category="SenseGlove | Game Framework | Pawn")
static UCameraComponent* GetCamera(const ASGPawn* Pawn);
UFUNCTION(BlueprintPure, Category="SenseGlove | Game Framework | Pawn")
static UMotionControllerComponent* GetMotionControllerLeft(const ASGPawn* Pawn);
UFUNCTION(BlueprintPure, Category="SenseGlove | Game Framework | Pawn")
static UMotionControllerComponent* GetMotionControllerRight(const ASGPawn* Pawn);
UFUNCTION(BlueprintPure, Category="SenseGlove | Game Framework | Pawn")
static USGVirtualHandComponent* GetHandLeft(const ASGPawn* Pawn);
UFUNCTION(BlueprintPure, Category="SenseGlove | Game Framework | Pawn")
static USGVirtualHandComponent* GetHandRight(const ASGPawn* Pawn);
};
@@ -44,9 +44,6 @@
class ASGVirtualHandActor;
class USGVirtualHandComponent;
/**
* Represents data of a user's hand required for forward kinematics.
*/
UCLASS(meta=(ScriptName = "SesneGloveVirtualHandActorKismetLibrary"))
class SENSEGLOVEKISMET_API UVirtualHandActorKismetLibrary final : public USGBlueprintFunctionLibrary
{
@@ -53,9 +53,6 @@ class USkeletalMeshComponent;
class USGVirtualHandComponent;
class USGHandPose;
/**
* Represents data of a user's hand required for forward kinematics.
*/
UCLASS(meta=(ScriptName = "SesneGloveVirtualHandComponentKismetLibrary"))
class SENSEGLOVEKISMET_API UVirtualHandComponentKismetLibrary final : public USGBlueprintFunctionLibrary
{
@@ -54,6 +54,7 @@ public class SenseGloveKismet : ModuleRules
{
"CoreUObject",
"Engine",
"HeadMountedDisplay",
"SenseGlove",
"SenseGloveCore",
"SenseGloveLog",