Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Easier way of positioning snap handles #472

Open
broehl opened this issue Aug 27, 2016 · 8 comments
Open

Easier way of positioning snap handles #472

broehl opened this issue Aug 27, 2016 · 8 comments

Comments

@broehl
Copy link

broehl commented Aug 27, 2016

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.

@HyppoNymous
Copy link

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.

@broehl
Copy link
Author

broehl commented Aug 27, 2016

That would be ideal, yes.

@thestonefox
Copy link
Member

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

@Mishkun
Copy link

Mishkun commented Aug 28, 2016

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

@dantman
Copy link

dantman commented Feb 3, 2017

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.

@JWNJWN
Copy link
Contributor

JWNJWN commented Jun 30, 2017

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;
        }
    }
}

@thestonefox
Copy link
Member

PR #1377

@thestonefox
Copy link
Member

@JWNJWN is still working on this (hopefully!)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants