integrate the virtual hand into the sgpawn

This commit is contained in:
Mamadou Babaei
2023-03-28 10:39:09 +02:00
parent 2b01327555
commit 1f5262bb81
9 changed files with 111 additions and 24 deletions
@@ -35,9 +35,10 @@
#include "SenseGlove/GameFramework/SGPawn.h" #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 struct ASGPawn::FImpl
{ {
@@ -76,8 +77,36 @@ ASGPawn::ASGPawn(const FObjectInitializer& ObjectInitializer)
{ {
PrimaryActorTick.bCanEverTick = true; PrimaryActorTick.bCanEverTick = true;
SceneRoot = CreateDefaultSubobject<USceneComponent>(TEXT("SceneRoot")); SceneRoot = ObjectInitializer.CreateDefaultSubobject<USceneComponent>(this, TEXT("SceneRoot"));
SetRootComponent(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) ASGPawn::FImpl::FImpl(ASGPawn* InOwner)
@@ -38,4 +38,9 @@
ASGPlayerController::ASGPlayerController(const FObjectInitializer& ObjectInitializer) ASGPlayerController::ASGPlayerController(const FObjectInitializer& ObjectInitializer)
: Super(ObjectInitializer) : Super(ObjectInitializer)
{ {
}
void ASGPlayerController::SetupInputComponent()
{
Super::SetupInputComponent();
} }
@@ -40,13 +40,15 @@
#include "SGPawn.generated.h" #include "SGPawn.generated.h"
class UActorComponent; class UCameraComponent;
class UMotionControllerComponent; class UMotionControllerComponent;
class USGVirtualHandComponent;
UCLASS(Config=Game, BlueprintType, Blueprintable) UCLASS(Config=Game, BlueprintType, Blueprintable)
class SENSEGLOVE_API ASGPawn : public APawn class SENSEGLOVE_API ASGPawn : public APawn
{ {
GENERATED_UCLASS_BODY() GENERATED_UCLASS_BODY()
private: private:
struct FImpl; struct FImpl;
@@ -63,6 +65,9 @@ private:
UPROPERTY(VisibleAnywhere, Category="SenseGlove", meta=(AllowPrivateAccess="false")) UPROPERTY(VisibleAnywhere, Category="SenseGlove", meta=(AllowPrivateAccess="false"))
USceneComponent* SceneRoot; USceneComponent* SceneRoot;
UPROPERTY(VisibleAnywhere, Category="SenseGlove", meta=(AllowPrivateAccess="false"))
UCameraComponent* Camera;
UPROPERTY(VisibleAnywhere, Category="SenseGlove", meta=(AllowPrivateAccess="false")) UPROPERTY(VisibleAnywhere, Category="SenseGlove", meta=(AllowPrivateAccess="false"))
UMotionControllerComponent* MotionControllerLeft; UMotionControllerComponent* MotionControllerLeft;
@@ -70,28 +75,33 @@ private:
UMotionControllerComponent* MotionControllerRight; UMotionControllerComponent* MotionControllerRight;
UPROPERTY(VisibleAnywhere, Category="SenseGlove", meta=(AllowPrivateAccess="false")) UPROPERTY(VisibleAnywhere, Category="SenseGlove", meta=(AllowPrivateAccess="false"))
UActorComponent* HandLeft; USGVirtualHandComponent* HandLeft;
UPROPERTY(VisibleAnywhere, Category="SenseGlove", meta=(AllowPrivateAccess="false")) UPROPERTY(VisibleAnywhere, Category="SenseGlove", meta=(AllowPrivateAccess="false"))
UActorComponent* HandRight; USGVirtualHandComponent* HandRight;
protected: public:
FORCEINLINE UMotionControllerComponent* GetMotionContollerLeft() const FORCEINLINE UCameraComponent* GetCamera() const
{
return Camera;
}
FORCEINLINE UMotionControllerComponent* GetMotionControllerLeft() const
{ {
return MotionControllerLeft; return MotionControllerLeft;
} }
FORCEINLINE UMotionControllerComponent* GetMotionContollerRight() const FORCEINLINE UMotionControllerComponent* GetMotionControllerRight() const
{ {
return MotionControllerRight; return MotionControllerRight;
} }
FORCEINLINE UActorComponent* GetHandLeft() const FORCEINLINE USGVirtualHandComponent* GetHandLeft() const
{ {
return HandLeft; return HandLeft;
} }
FORCEINLINE UActorComponent* GetHandRight() const FORCEINLINE USGVirtualHandComponent* GetHandRight() const
{ {
return HandRight; return HandRight;
} }
@@ -42,5 +42,8 @@
UCLASS(Config=Game, BlueprintType, Blueprintable) UCLASS(Config=Game, BlueprintType, Blueprintable)
class SENSEGLOVE_API ASGPlayerController : public APlayerController class SENSEGLOVE_API ASGPlayerController : public APlayerController
{ {
GENERATED_UCLASS_BODY() GENERATED_UCLASS_BODY()
protected:
virtual void SetupInputComponent() override;
}; };
@@ -33,4 +33,35 @@
*/ */
#include "SGKismet/SGPawnKismetLibrary.h" #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" #include "SGPawnKismetLibrary.generated.h"
class UCameraComponent;
class UMotionControllerComponent;
class ASGPawn; class ASGPawn;
class ASGVirtualHand; class USGVirtualHandComponent;
/**
* Represents data of a user's hand required for forward kinematics.
*/
UCLASS(meta=(ScriptName = "SesneGlovePawnKismetLibrary")) UCLASS(meta=(ScriptName = "SesneGlovePawnKismetLibrary"))
class SENSEGLOVEKISMET_API UPawnKismetLibrary final : public USGBlueprintFunctionLibrary class SENSEGLOVEKISMET_API UPawnKismetLibrary final : public USGBlueprintFunctionLibrary
{ {
GENERATED_BODY() GENERATED_BODY()
public: 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 ASGVirtualHandActor;
class USGVirtualHandComponent; class USGVirtualHandComponent;
/**
* Represents data of a user's hand required for forward kinematics.
*/
UCLASS(meta=(ScriptName = "SesneGloveVirtualHandActorKismetLibrary")) UCLASS(meta=(ScriptName = "SesneGloveVirtualHandActorKismetLibrary"))
class SENSEGLOVEKISMET_API UVirtualHandActorKismetLibrary final : public USGBlueprintFunctionLibrary class SENSEGLOVEKISMET_API UVirtualHandActorKismetLibrary final : public USGBlueprintFunctionLibrary
{ {
@@ -53,9 +53,6 @@ class USkeletalMeshComponent;
class USGVirtualHandComponent; class USGVirtualHandComponent;
class USGHandPose; class USGHandPose;
/**
* Represents data of a user's hand required for forward kinematics.
*/
UCLASS(meta=(ScriptName = "SesneGloveVirtualHandComponentKismetLibrary")) UCLASS(meta=(ScriptName = "SesneGloveVirtualHandComponentKismetLibrary"))
class SENSEGLOVEKISMET_API UVirtualHandComponentKismetLibrary final : public USGBlueprintFunctionLibrary class SENSEGLOVEKISMET_API UVirtualHandComponentKismetLibrary final : public USGBlueprintFunctionLibrary
{ {
@@ -54,6 +54,7 @@ public class SenseGloveKismet : ModuleRules
{ {
"CoreUObject", "CoreUObject",
"Engine", "Engine",
"HeadMountedDisplay",
"SenseGlove", "SenseGlove",
"SenseGloveCore", "SenseGloveCore",
"SenseGloveLog", "SenseGloveLog",