psmoveservice / psmove-ue4

Plugin for using PSMove as input into Unreal Engine 4. Currently obsolete. Please use PSMoveService.
GNU General Public License v2.0
59 stars 28 forks source link

Reset Orientation and Position #2

Closed ifero closed 9 years ago

ifero commented 9 years ago

Hey,

I was curiose to know if did you thought about a function that reset orientation and position in blueprint instead of only getting the data.

Thanks

Andrea

cboulay commented 9 years ago

This is something generally interesting so it should end up in code in the plugin. But first I'm working on coregistration with the Oculus Rift DK2 HMD.

In the meantime, you can try something like the following:

If you do try this out, I'd like to know what worked for you. It'll make it faster for me to put it into the plugin. (Edited to use yaw only)

ifero commented 9 years ago

Ok, it was my idea from the beginning. I was just curiose to know if you had already implemented it.

Tomorrow I'll work on it and I'll let you know

Thanks man

cboulay commented 9 years ago

I should add that you probably don't really want to reset the full orientation. You probably just want to reset the Yaw. I edited the above description to use Yaws. Breaking a Rotator out into Euler angles will lead to singularities, so really this should be done in code with the quaternions. In fact, I think I will implement this in the psmoveapi.

ifero commented 9 years ago

I've created a UFUNCTION in my character c++ class, It work like a charm for resetting FRotator.Yaw

FRotator setPSMoveRotationWithOffset (FRotator PSMoveRotation, float yawOffset) { if (yawOffset > 0) { if (PSMoveRotation.Yaw >= (-180 + yawOffset)) { PSMoveRotation.Yaw -= yawOffset; } else { PSMoveRotation.Yaw = 360 - yawOffset + PSMoveRotation.Yaw; } } else { if (PSMoveRotation.Yaw <= (180 + yawOffset)) { PSMoveRotation.Yaw -= yawOffset; } else { PSMoveRotation.Yaw = -360 - yawOffset + PSMoveRotation.Yaw; } } return PSMoveRotation; }

screenshot 2015-05-07 16 12 52

However it could be nice to receive also the data of the quaternion and not only the rotator.

I would like to help you improving the code, I'll contact you by mail one of this days

cboulay commented 9 years ago

From my searches through AnswerHub and the Unreal Engine forums, it seems Epic purposely does not want Quaternions exposed to Blueprints. I agree I would like access to the Quaternions in Blueprints too. It would have made it much easier to figure out commit 683bf04b218e14e2657bc71564c8dadb5407d51d.

cboulay commented 9 years ago

This was addressed in ad55b9814e6c2a20a0087da2294fec488ac4d7a5

See the image at the bottom of the wiki page.