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

ViveRole -> BodyRole -> Foots #36

Open
ziiCz opened this issue Mar 26, 2018 · 5 comments
Open

ViveRole -> BodyRole -> Foots #36

ziiCz opened this issue Mar 26, 2018 · 5 comments

Comments

@ziiCz
Copy link

ziiCz commented Mar 26, 2018

Hello!

I try to use the left foot and the right foot with Vive Trackers, but they are never assigned as foot.
I use the BodyRole on them and assign the left and right foot on their GameObject.

This feature is operational or I forgot something?

Thank you in advance.

@lawwong
Copy link
Contributor

lawwong commented Mar 27, 2018

Without bindings, BodyRole will only roughly mapping tracking devices according to their tracking position (related to hmd) whenever a controller or tracker is connected.

So either make sure your hmd and trackers are connected and in right position before game started playing, or call HTC.UnityPlugin.Vive.ViveRole.DefaultBodyRoleHandler.Refresh() manually to remapping BodyRole on demend.

But we recommended to use bindings anyway, is more convenience to setup tracking devices along with gears.
Also see Binding Interface Release Note.

If you are using in product, you may not want to include our VIU style binding interface and binding config file, then you can design your own binding process for your user and apply those bindings manually by calling the following API:

HTC.UnityPlugin.Vive.ViveRole.GetMap<BodyRole>().BindDeviceToRole(string deviceSN, BodyRole role)

@ziiCz
Copy link
Author

ziiCz commented Mar 27, 2018

Yeah, I'm sure that my hmd and trackers are connected before game start.

I think the problem comes from the IsFoot() function from the BodyRole class. This function already returns false.

I don't want to use bindings. I need the configuration to be done automatically at startup.

This is why I want to use the BodyRole class without default bindings.

I have called the HTC.UnityPlugin.Vive.ViveRole.DefaultBodyRoleHandler.Refresh() function but there was no change.

@lawwong
Copy link
Contributor

lawwong commented Mar 27, 2018

I see.

You can customize auto-mapping logic by implementing ViveRoleHandler<EnumType> and replace the default handler by calling ViveRole.AssignMapHandler().
For Example:

using UnityEngine;
using HTC.UnityPlugin.Vive;

public class CustomBodyRoleHandler : ViveRole.MapHandler<BodyRole>
{
    // called when handler is assigned
    public override void OnInitialize() { RemapAll(); }
    // called when device connected or disconnected
    public override void OnConnectedDeviceChanged(uint deviceIndex, ETrackedDeviceClass deviceClass, string deviceSN, bool connected) { RemapAll(); }
    // called when binding changed (Ex. when ViveRole.GetMap<BodyRole>().BindRole called)
    public override void OnBindingChanged(MyEquipRole role, string deviceSN, bool bound) { RemapAll(); }
    // called when OpenVR TrackedDeviceRoleChanged event emitted
    public override void OnTrackedDeviceRoleChanged() { RemapAll(); }

    public void RemapAll()
    {
        // some auto mapping algorithm...
        // call protected function here to map/unmap relations
        // this.UnmappingAll() to unmap all relations
        // this.MappingRole(MyEquipRole role, uint deviceIndex) to map the role to the device
    }
}

public class BodyRoleHandlerReplacer : MonoBehaviour
{
    public readonly CustomBodyRoleHandler handler = new CustomBodyRoleHandler();

    public void Awake()
    {
        // Replacing DefaultBodyRoleHandler
        ViveRole.AssignMapHandler<BodyRole>(handler);
    }
}

@lawwong
Copy link
Contributor

lawwong commented Mar 27, 2018

BTW, VIU only have roughly mapped BodyRole, may not work on certain cases. It will be very grateful if you share your BodyRoleHandler implementation to public.

@ziiCz
Copy link
Author

ziiCz commented Mar 28, 2018

We agree that the BodyRole does not work completely. No problem, if I find a good implementation I will share it.
Thank you for your answers.

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

No branches or pull requests

2 participants