VRTK icon indicating copy to clipboard operation
VRTK copied to clipboard

Easier way of positioning snap handles

Open broehl opened this issue 7 years ago • 8 comments

I have virtual hands in place of my controllers models, and they can take on a variety of poses.

I want to be able to precisely position the snap handles on an object so that it appears in the correct location (e.g. a key would be between the fingertips of a hand in a "pinch" pose).

Accurately positioning the snap handles to put the object in the right place is kind of tedious right now, involving a lot of trial and error, and of course it has to be done for each object and for each hand.

It would be great if there were some sort of tool (or tutorial) to simplify the process.

broehl avatar Aug 27 '16 03:08 broehl

Perhaps some grabbing preview plugin that would allow real time preview , allowing you to move the handle and see in real time the result of grabbing the object.

HyppoNymous avatar Aug 27 '16 08:08 HyppoNymous

That would be ideal, yes.

broehl avatar Aug 27 '16 13:08 broehl

The plan is to have an editor gizmo that makes it easier to understand the current position and rotation in comparison to the controller.

It's not scheduled to be done soon though, so if anyone wants to have a go at doing one, that would be great

thestonefox avatar Aug 27 '16 13:08 thestonefox

Maybe provide an optional field for transform in VRTK_Interact? That will be great customizable solution

Mishkun avatar Aug 28 '16 09:08 Mishkun

I think gizmos in the editor would be a helpful addition. However in #876 we ended up talking about arbitrary "mount points" on the controller that can be used for varying purposes.

These might actually at least make the process of snapping in this situation a little less tedious.

For example. Instead of adjusting the snap handle of a pinched object relative to the controller origin so the object's handle is positioned within the fingers:

  • Create a mount point relative to the origin with a transform so it is positioned between the fingers in a pinch pose
  • On pinchable objects place their snap handles where they will be pinched (eg: at the center of the key bow) and (not sure how yet, but) mark them to use the "pinch" mount point you created

Then a key's snap point will be relative to where the fingers will pinch it and you only need to make minor adjustments to make it look good.

dantman avatar Feb 03 '17 05:02 dantman

I created a semi-solution to this issue, I don't have a rift&touch so I haven't gotten the offsets for those correct, so sorry for anyone using a rift, maybe you can figure them out for yourself. Just in case, I got the offset by taking the position and rotation values of the attach point compared to the body object of the controller.

To use this drag the script onto the object you're using as the snap attach handle in your grab attach mechanic, then drag the corresponding controller model into the slot and change controller/hand variables in the inspector to be which one you need. Again, as I do not have a rift & touch I haven't gotten the correct offsets for those.

using UnityEngine;
using VRTK;

public class VRTK_HandleHelper : MonoBehaviour
{

    public SDK_BaseController.ControllerType Controller = SDK_BaseController.ControllerType.SteamVR_ViveWand;
    public SDK_BaseController.ControllerHand Hand = SDK_BaseController.ControllerHand.Left;

    public Mesh viveMesh;
    public Mesh occMeshL;
    public Mesh occMeshR;

    private void OnDrawGizmosSelected()
    {
        switch(Controller)
        {
            case SDK_BaseController.ControllerType.SteamVR_ViveWand:
                Gizmos.DrawMesh(viveMesh, transform.position + transform.TransformDirection(new Vector3(0, 0.003f, -0.01f)), transform.rotation * Quaternion.Euler(-5.037f, 180, 0));
                break;
                
            case SDK_BaseController.ControllerType.SteamVR_OculusTouch:
                switch(Hand)
                {
                    case SDK_BaseController.ControllerHand.Left:
                        Gizmos.DrawMesh(occMeshL, transform.position + transform.TransformDirection(new Vector3(0.00554f, 0.00735f, -0.139f)), transform.rotation * Quaternion.Euler(0.4f, 180, 0));
                        break;
                    case SDK_BaseController.ControllerHand.Right:
                        Gizmos.DrawMesh(occMeshR, transform.position + transform.TransformDirection(new Vector3(-0.00554f, -0.00735f, -0.139f)), transform.rotation * Quaternion.Euler(0.4f, 180, 0));
                        break;
                }
                break;
        }
    }
}

JWNJWN avatar Jun 30 '17 20:06 JWNJWN

PR https://github.com/thestonefox/VRTK/pull/1377

thestonefox avatar Aug 02 '17 19:08 thestonefox

@JWNJWN is still working on this (hopefully!)

thestonefox avatar Sep 27 '17 11:09 thestonefox