01-13-2017 02:57 PM
01-14-2017 11:24 PM
UFUNCTION(BlueprintCallable, Category = "Custom Tracking")
bool GetTouchPositionClean(int32 sensorIndex, FVector &HandOnePosition, FRotator &HandOneRotator, FVector &HandTwoPosition, FRotator &HandTwoRotator)
{
IOculusRiftPlugin& OculusRiftPlugin = IOculusRiftPlugin::Get();
ovrTrackingState OvrTrackingState;
const bool bOvrGCTRes = OculusRiftPlugin.GetCurrentTrackingState(&OvrTrackingState);
if (GEngine != nullptr)
{
float notNeeded = 0;
FQuat sensorQ;
FVector sensorPosition;
bool foundSensor = GEngine->HMDDevice->GetTrackingSensorProperties(sensorIndex, sensorPosition, sensorQ, notNeeded, notNeeded, notNeeded, notNeeded, notNeeded, notNeeded, notNeeded);
FRotator sensorRotation = sensorQ.Rotator();
sensorRotation.Pitch = 0.0f;
sensorRotation.Roll = 0.0f;
FQuat hand1Quat;
FQuat hand2Quat;
//left touch controller
OculusRiftPlugin.PoseToOrientationAndPosition(OvrTrackingState.HandPoses[0].ThePose, hand1Quat, HandOnePosition);
//right touch controller
OculusRiftPlugin.PoseToOrientationAndPosition(OvrTrackingState.HandPoses[1].ThePose, hand2Quat, HandTwoPosition);
HandOneRotator = hand1Quat.Rotator();
HandTwoRotator = hand2Quat.Rotator();
HandOnePosition -= sensorPosition;
HandTwoPosition -= sensorPosition;
HandOnePosition = sensorRotation.UnrotateVector(HandOnePosition);
HandTwoPosition = sensorRotation.UnrotateVector(HandTwoPosition);
HandOneRotator = HandOneRotator + sensorRotation.GetInverse();
HandTwoRotator = HandTwoRotator + sensorRotation.GetInverse();
}
return true;
}
07-26-2017 01:06 PM