359 lines
13 KiB
C++
359 lines
13 KiB
C++
/**
|
|
* @file
|
|
*
|
|
* @author Mamadou Babaei <mamadou@senseglove.com>
|
|
*
|
|
* @section LICENSE
|
|
*
|
|
* (The MIT License)
|
|
*
|
|
* Copyright (c) 2020 - 2022 SenseGlove
|
|
*
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
* of this software and associated documentation files (the "Software"), to deal
|
|
* in the Software without restriction, including without limitation the rights
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
* copies of the Software, and to permit persons to whom the Software is
|
|
* furnished to do so, subject to the following conditions:
|
|
*
|
|
* The above copyright notice and this permission notice shall be included in all
|
|
* copies or substantial portions of the Software.
|
|
*
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
* SOFTWARE.
|
|
*
|
|
* @section DESCRIPTION
|
|
*
|
|
*
|
|
*/
|
|
|
|
|
|
#pragma once
|
|
|
|
#include "Containers/Array.h"
|
|
#include "Math/Quat.h"
|
|
#include "Math/Rotator.h"
|
|
#include "Math/Vector.h"
|
|
|
|
#include "SGKismet/SGBlueprintFunctionLibrary.h"
|
|
#include "SGTypes/SGCoreTypes.h"
|
|
|
|
#include "SGTrackingKismetLibrary.generated.h"
|
|
|
|
/**
|
|
*
|
|
*/
|
|
UCLASS(meta=(ScriptName = "SesneGloveTrackingKismetLibrary"))
|
|
class SENSEGLOVECOREKISMET_API USGTrackingKismetLibrary final : public USGBlueprintFunctionLibrary
|
|
{
|
|
GENERATED_BODY()
|
|
|
|
public:
|
|
/**
|
|
* Knowing a position & rotation in 3D space, calculate a relative location based on offsets.
|
|
*/
|
|
UFUNCTION(BlueprintCallable, DisplayName="Calculate Location", Category="SenseGlove | Core | Tracking")
|
|
static void CalculateLocation_TP_FQuat_TR_PO_FQuat_RO_OutNP_FQuat_OutNR(
|
|
const FVector& TrackedPosition, const FQuat& TrackedRotation,
|
|
const FVector& PositionOffset, const FQuat& RotationOffset,
|
|
FVector& OutNewPosition, FQuat& OutNewRotation);
|
|
|
|
/**
|
|
* Knowing a position & rotation in 3D space, calculate a relative location based on offsets.
|
|
*/
|
|
UFUNCTION(BlueprintCallable, DisplayName="Calculate Location", Category="SenseGlove | Core | Tracking")
|
|
static void CalculateLocation_TP_FRotator_TR_PO_FRotator_RO_OutNP_FRotator_OutNR(
|
|
const FVector& TrackedPosition, const FRotator& TrackedRotation,
|
|
const FVector& PositionOffset, const FRotator& RotationOffset,
|
|
FVector& OutNewPosition, FRotator& OutNewRotation);
|
|
|
|
/**
|
|
* Positional offset from each finger to the glove origin.
|
|
*/
|
|
UFUNCTION(BlueprintCallable, Category="SenseGlove | Core | Tracking")
|
|
static TArray<FVector> GetSenseGloveFingerToGlovePositionOrigin();
|
|
|
|
/**
|
|
*
|
|
*/
|
|
UFUNCTION(BlueprintCallable, DisplayName="Get SenseGlove Finger To Glove Rotation Origin",
|
|
Category="SenseGlove | Core | Tracking")
|
|
static TArray<FQuat> GetSenseGloveFingerToGloveRotationOrigin_TArrayFQuat();
|
|
|
|
/**
|
|
*
|
|
*/
|
|
UFUNCTION(BlueprintCallable, DisplayName="Get SenseGlove Finger To Glove Rotation Origin",
|
|
Category="SenseGlove | Core | Tracking")
|
|
static TArray<FRotator> GetSenseGloveFingerToGloveRotationOrigin_TArrayFRotator();
|
|
|
|
/**
|
|
* Default position offset from glove origin to wrist location, in cm.
|
|
*/
|
|
UFUNCTION(BlueprintCallable, Category="SenseGlove | Core | Tracking")
|
|
static FVector GetSenseGloveWristPositionOffset();
|
|
|
|
/**
|
|
* Default rotation offset from glove origin to wrist location.
|
|
*/
|
|
UFUNCTION(BlueprintCallable, DisplayName="Get SenseGlove Wrist Rotation Offset",
|
|
Category="SenseGlove | Core | Tracking")
|
|
static FQuat GetSenseGloveWristRotationOffset_FQuat();
|
|
|
|
/**
|
|
* Default rotation offset from glove origin to wrist location.
|
|
*/
|
|
UFUNCTION(BlueprintCallable, DisplayName="Get SenseGlove Wrist Rotation Offset",
|
|
Category="SenseGlove | Core | Tracking")
|
|
static FRotator GetSenseGloveWristRotationOffset_FRotator();
|
|
|
|
/**
|
|
* Get the position and rotation offsets to go from the glove origin to the mounted position.
|
|
* @remarks Based on CAD. needs to be inverted when going from tracker to glove origin.
|
|
*/
|
|
UFUNCTION(BlueprintCallable, DisplayName="Get SenseGlove Mount Offset", Category="SenseGlove | Core | Tracking")
|
|
static void GetSenseGloveMountOffset_bRH_TF_OutIP_FQuat_OutIR(
|
|
bool bRightHanded, ESGFinger ToFinger, FVector& OutIPosition, FQuat& OutIRotation);
|
|
|
|
/**
|
|
* Get the position and rotation offsets to go from the glove origin to the mounted position.
|
|
* @remarks Based on CAD. needs to be inverted when going from tracker to glove origin.
|
|
*/
|
|
UFUNCTION(BlueprintCallable, DisplayName="Get SenseGlove Mount Offset", Category="SenseGlove | Core | Tracking")
|
|
static void GetSenseGloveMountOffset_bRH_TF_OutIP_FRotator_OutIR(
|
|
bool bRightHanded, ESGFinger ToFinger, FVector& OutIPosition, FRotator& OutIRotation);
|
|
|
|
/**
|
|
* Get the offset to get from the TrackedHardware to a SenseGlove mounting location. Combined with Glove-Mount offset to get the glove location.
|
|
*/
|
|
UFUNCTION(BlueprintCallable, DisplayName="Get SenseGlove Tracker Mouunt Offset",
|
|
Category="SenseGlove | Core | Tracking")
|
|
static void GetSenseGloveTrackerMountOffset_H_bRH_OutPO_FQuat_OutRO(
|
|
ESGPositionalTrackingHardware Hardware, bool bRightHanded,
|
|
FVector& OutPositionOffset, FQuat& OutRotationOffset);
|
|
|
|
/**
|
|
* Get the offset to get from the TrackedHardware to a SenseGlove mounting location. Combined with Glove-Mount offset to get the glove location.
|
|
*/
|
|
UFUNCTION(BlueprintCallable, DisplayName="Get SenseGlove Tracker Mouunt Offset",
|
|
Category="SenseGlove | Core | Tracking")
|
|
static void GetSenseGloveTrackerMountOffset_H_bRH_OutPO_FRotator_OutRO(
|
|
ESGPositionalTrackingHardware Hardware, bool bRightHanded,
|
|
FVector& OutPositionOffset, FRotator& OutRotationOffset);
|
|
|
|
/**
|
|
* Vive Tracker origin to Finger rotational offset.
|
|
*/
|
|
UFUNCTION(BlueprintCallable, Category="SenseGlove | Core | Tracking")
|
|
static FVector GetSenseGloveViveToAttachPosition();
|
|
|
|
/**
|
|
* Vive Tracker origin to Finger rotational offset.
|
|
*/
|
|
UFUNCTION(BlueprintCallable, DisplayName="Get SenseGlove Vive To Attach Rotation",
|
|
Category="SenseGlove | Core | Tracking")
|
|
static FQuat GetSenseGloveViveToAttachRotation_FQuat();
|
|
|
|
/**
|
|
* Vive Tracker origin to Finger rotational offset.
|
|
*/
|
|
UFUNCTION(BlueprintCallable, DisplayName="Get SenseGlove Vive To Attach Rotation",
|
|
Category="SenseGlove | Core | Tracking")
|
|
static FRotator GetSenseGloveViveToAttachRotation_FRotator();
|
|
|
|
/**
|
|
* Oculus Touch origin to Finger rotational offset.
|
|
*/
|
|
UFUNCTION(BlueprintCallable, Category="SenseGlove | Core | Tracking")
|
|
static FVector GetSenseGloveOculusTouchToAttachPosition();
|
|
|
|
/**
|
|
* Oculus Touch origin to Finger rotational offset.
|
|
*/
|
|
UFUNCTION(BlueprintCallable, DisplayName="Get SenseGlove Oculus Touch To Attach Rotation",
|
|
Category="SenseGlove | Core | Tracking")
|
|
static FQuat GetSenseGloveOculusTouchToAttachRotation_FQuat();
|
|
|
|
/**
|
|
* Oculus Touch origin to Finger rotational offset.
|
|
*/
|
|
UFUNCTION(BlueprintCallable, DisplayName="Get SenseGlove Oculus Touch To Attach Rotation",
|
|
Category="SenseGlove | Core | Tracking")
|
|
static FRotator GetSenseGloveOculusTouchToAttachRotation_FRotator();
|
|
|
|
/**
|
|
* Positional offset between Nova Glove Origin and Wrist.
|
|
*/
|
|
UFUNCTION(BlueprintCallable, Category="SenseGlove | Core | Tracking")
|
|
static FVector GetNovaToWristPositionOffset();
|
|
|
|
/**
|
|
* Rotational offset between Nova Glove Origin and Wrist.
|
|
*/
|
|
UFUNCTION(BlueprintCallable, DisplayName="Get Nove To Wrist Rotation Offset",
|
|
Category="SenseGlove | Core | Tracking")
|
|
static FQuat GetNovaToWristRotationOffset_FQuat();
|
|
|
|
/**
|
|
* Rotational offset between Nova Glove Origin and Wrist.
|
|
*/
|
|
UFUNCTION(BlueprintCallable, DisplayName="Get Nove To Wrist Rotation Offset",
|
|
Category="SenseGlove | Core | Tracking")
|
|
static FRotator GetNovaToWristRotationOffset_FRotator();
|
|
|
|
/**
|
|
* Returns the Offsets that will bring us from the Nova origin to the wrist position.
|
|
*/
|
|
UFUNCTION(BlueprintCallable, DisplayName="Get Nova Glove Wrist Offset", Category="SenseGlove | Core | Tracking")
|
|
static void GetNovaGloveWristOffset_bRH_OutPO_FQuat_OutRO(
|
|
bool bRightHanded, FVector& OutPositionOffset, FQuat& OutRotationOffset);
|
|
|
|
/**
|
|
* Returns the Offsets that will bring us from the Nova origin to the wrist position.
|
|
*/
|
|
UFUNCTION(BlueprintCallable, DisplayName="Get Nova Glove Wrist Offset", Category="SenseGlove | Core | Tracking")
|
|
static void GetNovaGloveWristOffset_bRH_OutPO_FRotator_OutRO(
|
|
bool bRightHanded, FVector& OutPositionOffset, FRotator& OutRotationOffset);
|
|
|
|
/**
|
|
*
|
|
*/
|
|
UFUNCTION(BlueprintCallable, Category="SenseGlove | Core | Tracking")
|
|
static FVector GetRightNovaViveToAttachPosition();
|
|
|
|
/**
|
|
*
|
|
*/
|
|
UFUNCTION(BlueprintCallable, DisplayName="Get Right Nova Vive To Attach Rotation",
|
|
Category="SenseGlove | Core | Tracking")
|
|
static FQuat GetRightNovaViveToAttachRotation_FQuat();
|
|
|
|
/**
|
|
*
|
|
*/
|
|
UFUNCTION(BlueprintCallable, DisplayName="Get Right Nova Vive To Attach Rotation",
|
|
Category="SenseGlove | Core | Tracking")
|
|
static FRotator GetRightNovaViveToAttachRotation_FRotator();
|
|
|
|
/**
|
|
*
|
|
*/
|
|
UFUNCTION(BlueprintCallable, Category="SenseGlove | Core | Tracking")
|
|
static FVector GetLeftNovaViveToAttachPosition();
|
|
|
|
/**
|
|
*
|
|
*/
|
|
UFUNCTION(BlueprintCallable, DisplayName="Get Left Nova Vive To Attach Rotation",
|
|
Category="SenseGlove | Core | Tracking")
|
|
static FQuat GetLeftNovaViveToAttachRotation_FQuat();
|
|
|
|
/**
|
|
*
|
|
*/
|
|
UFUNCTION(BlueprintCallable, DisplayName="Get Left Nova Vive To Attach Rotation",
|
|
Category="SenseGlove | Core | Tracking")
|
|
static FRotator GetLeftNovaViveToAttachRotation_FRotator();
|
|
|
|
/**
|
|
*
|
|
*/
|
|
UFUNCTION(BlueprintCallable, Category="SenseGlove | Core | Tracking")
|
|
static FVector GetRightNovaQuest2ToAttachPosition();
|
|
|
|
/**
|
|
*
|
|
*/
|
|
UFUNCTION(BlueprintCallable, DisplayName="Get Right Nova Quest 2 To Attach Rotation",
|
|
Category="SenseGlove | Core | Tracking")
|
|
static FQuat GetRightNovaQuest2ToAttachRotation_FQuat();
|
|
|
|
/**
|
|
*
|
|
*/
|
|
UFUNCTION(BlueprintCallable, DisplayName="Get Right Nova Quest 2 To Attach Rotation",
|
|
Category="SenseGlove | Core | Tracking")
|
|
static FRotator GetRightNovaQuest2ToAttachRotation_FRotator();
|
|
|
|
/**
|
|
*
|
|
*/
|
|
UFUNCTION(BlueprintCallable, Category="SenseGlove | Core | Tracking")
|
|
static FVector GetLeftNovaQuest2ToAttachPosition();
|
|
|
|
/**
|
|
*
|
|
*/
|
|
UFUNCTION(BlueprintCallable, DisplayName="Get Left Nova Quest 2 To Attach Rotation",
|
|
Category="SenseGlove | Core | Tracking")
|
|
static FQuat GetLeftNovaQuest2ToAttachRotation_FQuat();
|
|
|
|
/**
|
|
*
|
|
*/
|
|
UFUNCTION(BlueprintCallable, DisplayName="Get Left Nova Quest 2 To Attach Rotation",
|
|
Category="SenseGlove | Core | Tracking")
|
|
static FRotator GetLeftNovaQuest2ToAttachRotation_FRotator();
|
|
|
|
/**
|
|
* @remarks Left is a mirror, so we only need R pos.
|
|
*/
|
|
UFUNCTION(BlueprintCallable, Category="SenseGlove | Core | Tracking")
|
|
static FVector GetRightNovaPico2ToAttachPosition();
|
|
|
|
/**
|
|
*
|
|
*/
|
|
UFUNCTION(BlueprintCallable, DisplayName="Get Right Nova Pico 2 To Attach Rotation",
|
|
Category="SenseGlove | Core | Tracking")
|
|
static FQuat GetRightNovaPico2ToAttachRotation_FQuat();
|
|
|
|
/**
|
|
*
|
|
*/
|
|
UFUNCTION(BlueprintCallable, DisplayName="Get Right Nova Pico 2 To Attach Rotation",
|
|
Category="SenseGlove | Core | Tracking")
|
|
static FRotator GetRightNovaPico2ToAttachRotation_FRotator();
|
|
|
|
/**
|
|
*
|
|
*/
|
|
UFUNCTION(BlueprintCallable, DisplayName="Get Left Nova Pico 2 To Attach Rotation",
|
|
Category="SenseGlove | Core | Tracking")
|
|
static FQuat GetLeftNovaPico2ToAttachRotation_FQuat();
|
|
|
|
/**
|
|
*
|
|
*/
|
|
UFUNCTION(BlueprintCallable, DisplayName="Get Left Nova Pico 2 To Attach Rotation",
|
|
Category="SenseGlove | Core | Tracking")
|
|
static FRotator GetLeftNovaPico2ToAttachRotation_FRotator();
|
|
|
|
/**
|
|
* Retrieves Offsets for a particular device.
|
|
*/
|
|
UFUNCTION(BlueprintCallable, DisplayName="Get Nova Glove Tracker Offset", Category="SenseGlove | Core | Tracking")
|
|
static void GetNovaGloveTrackerOffset_H_bRH_OutPO_FQuat_OutRO(
|
|
ESGPositionalTrackingHardware Hardware, bool bRightHanded,
|
|
FVector& OutPositionOffset, FQuat& OutRotationOffset);
|
|
|
|
/**
|
|
* Retrieves Offsets for a particular device.
|
|
*/
|
|
UFUNCTION(BlueprintCallable, DisplayName="Get Nova Glove Tracker Offset", Category="SenseGlove | Core | Tracking")
|
|
static void GetNovaGloveTrackerOffset_H_bRH_OutPO_FRotator_OutRO(
|
|
ESGPositionalTrackingHardware Hardware, bool bRightHanded,
|
|
FVector& OutPositionOffset, FRotator& OutRotationOffset);
|
|
|
|
/**
|
|
*
|
|
*/
|
|
UFUNCTION(BlueprintCallable, Category="SenseGlove | Core | Tracking")
|
|
static FString ToString(ESGPositionalTrackingHardware Hardware);
|
|
};
|