VR: Add action bindings for Vive Trackers
Intended for use with motion capture objects. Currently only supported by the SteamVR runtime (1.21) and requires the "HTC Vive Tracker" extension to be enabled via the "Extensions" panel.
This commit is contained in:
parent
be48defed8
commit
43b98b1c5f
|
@ -100,6 +100,11 @@ def vr_create_actions(context: bpy.context):
|
|||
if len(am.actionmap_items) < 1:
|
||||
continue
|
||||
|
||||
# Check for action maps where all bindings require OpenXR extensions.
|
||||
if am.name == defaults.VRDefaultActionmaps.TRACKER.value:
|
||||
if not session_settings.enable_vive_tracker_extension: #scene.vr_actions_enable_vive_tracker:
|
||||
continue
|
||||
|
||||
ok = session_state.action_set_create(context, am)
|
||||
if not ok:
|
||||
return
|
||||
|
@ -191,6 +196,11 @@ def register():
|
|||
description="Enable bindings for the HTC Vive Focus 3 controllers. Note that this may not be supported by all OpenXR runtimes",
|
||||
default=False,
|
||||
)
|
||||
# Stored in session settings to use in session creation as a workaround for SteamVR controller/tracker compatibility issues.
|
||||
#bpy.types.Scene.vr_actions_enable_vive_tracker = bpy.props.BoolProperty(
|
||||
# description="Enable bindings for the HTC Vive Trackers. Note that this may not be supported by all OpenXR runtimes",
|
||||
# default=False,
|
||||
#)
|
||||
|
||||
bpy.app.handlers.xr_session_start_pre.append(vr_create_actions)
|
||||
|
||||
|
@ -201,5 +211,6 @@ def unregister():
|
|||
del bpy.types.Scene.vr_actions_enable_reverb_g2
|
||||
del bpy.types.Scene.vr_actions_enable_vive_cosmos
|
||||
del bpy.types.Scene.vr_actions_enable_vive_focus
|
||||
#del bpy.types.Scene.vr_actions_enable_vive_tracker
|
||||
|
||||
bpy.app.handlers.xr_session_start_pre.remove(vr_create_actions)
|
||||
|
|
|
@ -477,6 +477,17 @@ actionconfig_data = \
|
|||
],
|
||||
},
|
||||
),
|
||||
("blender_default_tracker",
|
||||
{"items":
|
||||
[("tracker_pose", {"type": 'POSE', "user_paths": ['/user/vive_tracker_htcx/role/left_foot', '/user/vive_tracker_htcx/role/right_foot', '/user/vive_tracker_htcx/role/left_shoulder', '/user/vive_tracker_htcx/role/right_shoulder', '/user/vive_tracker_htcx/role/left_elbow', '/user/vive_tracker_htcx/role/right_elbow', '/user/vive_tracker_htcx/role/left_knee', '/user/vive_tracker_htcx/role/right_knee', '/user/vive_tracker_htcx/role/waist', '/user/vive_tracker_htcx/role/chest', '/user/vive_tracker_htcx/role/camera', '/user/vive_tracker_htcx/role/keyboard'], "pose_is_controller_grip": 'True', "pose_is_controller_aim": 'True'}, None,
|
||||
{"bindings":
|
||||
[("vive_tracker", {"profile": '/interaction_profiles/htc/vive_tracker_htcx', "component_paths": ['/input/grip/pose', '/input/grip/pose', '/input/grip/pose', '/input/grip/pose', '/input/grip/pose', '/input/grip/pose', '/input/grip/pose', '/input/grip/pose', '/input/grip/pose', '/input/grip/pose', '/input/grip/pose', '/input/grip/pose'], "pose_location": '(0.0, 0.0, 0.0)', "pose_rotation": '(0.0, 0.0, 0.0)'}),
|
||||
],
|
||||
},
|
||||
),
|
||||
],
|
||||
},
|
||||
),
|
||||
]
|
||||
|
||||
|
||||
|
|
|
@ -18,12 +18,14 @@ import os.path
|
|||
class VRDefaultActionmaps(Enum):
|
||||
DEFAULT = "blender_default"
|
||||
GAMEPAD = "blender_default_gamepad"
|
||||
TRACKER = "blender_default_tracker"
|
||||
|
||||
|
||||
# Default actions.
|
||||
class VRDefaultActions(Enum):
|
||||
CONTROLLER_GRIP = "controller_grip"
|
||||
CONTROLLER_AIM = "controller_aim"
|
||||
TRACKER_POSE = "tracker_pose"
|
||||
TELEPORT = "teleport"
|
||||
NAV_GRAB = "nav_grab"
|
||||
FLY = "fly"
|
||||
|
@ -58,6 +60,7 @@ class VRDefaultActionbindings(Enum):
|
|||
VIVE = "vive"
|
||||
VIVE_COSMOS = "vive_cosmos"
|
||||
VIVE_FOCUS = "vive_focus"
|
||||
VIVE_TRACKER = "vive_tracker"
|
||||
WMR = "wmr"
|
||||
|
||||
|
||||
|
@ -71,6 +74,7 @@ class VRDefaultActionprofiles(Enum):
|
|||
VIVE = "/interaction_profiles/htc/vive_controller"
|
||||
VIVE_COSMOS = "/interaction_profiles/htc/vive_cosmos_controller"
|
||||
VIVE_FOCUS = "/interaction_profiles/htc/vive_focus3_controller"
|
||||
VIVE_TRACKER = "/interaction_profiles/htc/vive_tracker_htcx"
|
||||
WMR = "/interaction_profiles/microsoft/motion_controller"
|
||||
|
||||
|
||||
|
@ -1809,6 +1813,50 @@ def vr_defaults_create_default_gamepad(session_settings):
|
|||
["/output/haptic_right_trigger"])
|
||||
|
||||
|
||||
def vr_defaults_create_default_tracker(session_settings):
|
||||
am = vr_defaults_actionmap_add(session_settings,
|
||||
VRDefaultActionmaps.TRACKER.value)
|
||||
if not am:
|
||||
return
|
||||
|
||||
ami = vr_defaults_pose_action_add(am,
|
||||
VRDefaultActions.TRACKER_POSE.value,
|
||||
[#"/user/vive_tracker_htcx/role/handheld_object", # SteamVR (1.21) fails to assign interaction profile.
|
||||
"/user/vive_tracker_htcx/role/left_foot",
|
||||
"/user/vive_tracker_htcx/role/right_foot",
|
||||
"/user/vive_tracker_htcx/role/left_shoulder",
|
||||
"/user/vive_tracker_htcx/role/right_shoulder",
|
||||
"/user/vive_tracker_htcx/role/left_elbow",
|
||||
"/user/vive_tracker_htcx/role/right_elbow",
|
||||
"/user/vive_tracker_htcx/role/left_knee",
|
||||
"/user/vive_tracker_htcx/role/right_knee",
|
||||
"/user/vive_tracker_htcx/role/waist",
|
||||
"/user/vive_tracker_htcx/role/chest",
|
||||
"/user/vive_tracker_htcx/role/camera",
|
||||
"/user/vive_tracker_htcx/role/keyboard"],
|
||||
True,
|
||||
True)
|
||||
if ami:
|
||||
vr_defaults_pose_actionbinding_add(ami,
|
||||
VRDefaultActionbindings.VIVE_TRACKER.value,
|
||||
VRDefaultActionprofiles.VIVE_TRACKER.value,
|
||||
[#"/input/grip/pose",
|
||||
"/input/grip/pose",
|
||||
"/input/grip/pose",
|
||||
"/input/grip/pose",
|
||||
"/input/grip/pose",
|
||||
"/input/grip/pose",
|
||||
"/input/grip/pose",
|
||||
"/input/grip/pose",
|
||||
"/input/grip/pose",
|
||||
"/input/grip/pose",
|
||||
"/input/grip/pose",
|
||||
"/input/grip/pose",
|
||||
"/input/grip/pose"],
|
||||
(0, 0, 0),
|
||||
(0, 0, 0))
|
||||
|
||||
|
||||
def vr_get_default_config_path():
|
||||
filepath = os.path.join(os.path.dirname(os.path.abspath(__file__)), "configs")
|
||||
return os.path.join(filepath, "default.py")
|
||||
|
@ -1832,6 +1880,7 @@ def vr_ensure_default_actionmaps(session_settings):
|
|||
# Create and save default action maps.
|
||||
vr_defaults_create_default(session_settings)
|
||||
vr_defaults_create_default_gamepad(session_settings)
|
||||
vr_defaults_create_default_tracker(session_settings)
|
||||
|
||||
action_map.vr_save_actionmaps(session_settings, filepath, sort=False)
|
||||
|
||||
|
|
|
@ -536,6 +536,7 @@ class VIEW3D_PT_vr_actions_extensions(VRActionsPanel, Panel):
|
|||
|
||||
def draw(self, context):
|
||||
scene = context.scene
|
||||
session_settings = context.window_manager.xr_session_settings
|
||||
|
||||
layout = self.layout
|
||||
layout.use_property_split = True
|
||||
|
@ -545,6 +546,8 @@ class VIEW3D_PT_vr_actions_extensions(VRActionsPanel, Panel):
|
|||
col.prop(scene, "vr_actions_enable_reverb_g2", text="HP Reverb G2")
|
||||
col.prop(scene, "vr_actions_enable_vive_cosmos", text="HTC Vive Cosmos")
|
||||
col.prop(scene, "vr_actions_enable_vive_focus", text="HTC Vive Focus")
|
||||
col.prop(session_settings, "enable_vive_tracker_extension", text="HTC Vive Tracker")
|
||||
#col.prop(scene, "vr_actions_enable_vive_tracker", text="HTC Vive Tracker")
|
||||
col.prop(scene, "vr_actions_enable_huawei", text="Huawei")
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue