VR: Add grab navigation to default actions

Remaps grab transform action to different inputs.
This commit is contained in:
Peter Kim 2021-06-19 18:15:42 +09:00
parent 6b89bd9a21
commit 3012fffba6
2 changed files with 138 additions and 78 deletions

View File

@ -7,14 +7,23 @@ actionconfig_data = \
("teleport",
{"type": 'BUTTON', "user_path0": '/user/hand/left', "component_path0": '/input/trigger/value', "user_path1": '/user/hand/right', "component_path1": '/input/trigger/value', "threshold": '0.30000001192092896', "axis_flag": 'ANY', "op": 'wm.xr_navigation_teleport', "op_flag": 'MODAL', "bimanual": 'False'},
{"op_properties":
[("color", (0.0, 1.0, 1.0, 1.0)),
[("interpolation", 0.9),
("color", (0.0, 1.0, 1.0, 1.0)),
],
},
),
("navigate",
{"type": 'BUTTON', "user_path0": '/user/hand/left', "component_path0": '/input/squeeze/value', "user_path1": '/user/hand/right', "component_path1": '/input/squeeze/value', "threshold": '0.30000001192092896', "axis_flag": 'ANY', "op": 'wm.xr_navigation_grab', "op_flag": 'MODAL', "bimanual": 'True'},
{"op_properties":
[("lock_rotation", True),
("lock_scale", True),
],
},
),
("raycast_select", {"type": 'BUTTON', "user_path0": '/user/hand/left', "component_path0": '/input/x/click', "user_path1": '/user/hand/right', "component_path1": '/input/a/click', "threshold": '0.30000001192092896', "axis_flag": 'ANY', "op": 'wm.xr_select_raycast', "op_flag": 'MODAL', "bimanual": 'False'}, None),
("grab", {"type": 'BUTTON', "user_path0": '/user/hand/left', "component_path0": '/input/squeeze/value', "user_path1": '/user/hand/right', "component_path1": '/input/squeeze/value', "threshold": '0.30000001192092896', "axis_flag": 'ANY', "op": 'wm.xr_transform_grab', "op_flag": 'MODAL', "bimanual": 'True'}, None),
("undo", {"type": 'BUTTON', "user_path0": '/user/hand/left', "component_path0": '/input/y/click', "user_path1": '', "component_path1": '', "threshold": '0.30000001192092896', "axis_flag": 'ANY', "op": 'ed.undo', "op_flag": 'PRESS', "bimanual": 'False'}, None),
("redo", {"type": 'BUTTON', "user_path0": '/user/hand/right', "component_path0": '/input/b/click', "user_path1": '', "component_path1": '', "threshold": '0.30000001192092896', "axis_flag": 'ANY', "op": 'ed.redo', "op_flag": 'PRESS', "bimanual": 'False'}, None),
("grab", {"type": 'BUTTON', "user_path0": '/user/hand/left', "component_path0": '/input/y/click', "user_path1": '/user/hand/right', "component_path1": '/input/b/click', "threshold": '0.30000001192092896', "axis_flag": 'ANY', "op": 'wm.xr_transform_grab', "op_flag": 'MODAL', "bimanual": 'True'}, None),
("undo", {"type": 'BUTTON', "user_path0": '/user/hand/left', "component_path0": '/input/thumbstick/x', "user_path1": '/user/hand/right', "component_path1": '/input/thumbstick/x', "threshold": '0.30000001192092896', "axis_flag": 'NEGATIVE', "op": 'ed.undo', "op_flag": 'PRESS', "bimanual": 'False'}, None),
("redo", {"type": 'BUTTON', "user_path0": '/user/hand/left', "component_path0": '/input/thumbstick/x', "user_path1": '/user/hand/right', "component_path1": '/input/thumbstick/x', "threshold": '0.30000001192092896', "axis_flag": 'POSITIVE', "op": 'ed.redo', "op_flag": 'PRESS', "bimanual": 'False'}, None),
("haptic", {"type": 'HAPTIC', "user_path0": '/user/hand/left', "component_path0": '/output/haptic', "user_path1": '/user/hand/right', "component_path1": '/output/haptic', "haptic_duration": '0.30000001192092896', "haptic_frequency": '3000.0', "haptic_amplitude": '0.5'}, None),
],
},
@ -22,18 +31,27 @@ actionconfig_data = \
("blender_wmr",
{"profile": '/interaction_profiles/microsoft/motion_controller'},
{"items":
[("controller_pose", {"type": 'POSE', "user_path0": '/user/hand/left', "component_path0": '/input/grip/pose', "user_path1": '/user/hand/right', "component_path1": '/input/grip/pose', "pose_is_controller": 'True', "pose_location": '(0.0, 0.0, 0.0)', "pose_rotation": '(-0.7853981852531433, 0.0, 0.0)'}, None),
[("controller_pose", {"type": 'POSE', "user_path0": '/user/hand/left', "component_path0": '/input/grip/pose', "user_path1": '/user/hand/right', "component_path1": '/input/grip/pose', "pose_is_controller": 'True', "pose_location": '(0.0, 0.0, 0.0)', "pose_rotation": '(-0.8726646304130554, 0.0, 0.0)'}, None),
("teleport",
{"type": 'BUTTON', "user_path0": '/user/hand/left', "component_path0": '/input/trigger/value', "user_path1": '/user/hand/right', "component_path1": '/input/trigger/value', "threshold": '0.30000001192092896', "axis_flag": 'ANY', "op": 'wm.xr_navigation_teleport', "op_flag": 'MODAL', "bimanual": 'False'},
{"op_properties":
[("color", (0.0, 1.0, 1.0, 1.0)),
[("interpolation", 0.9),
("color", (0.0, 1.0, 1.0, 1.0)),
],
},
),
("navigate",
{"type": 'BUTTON', "user_path0": '/user/hand/left', "component_path0": '/input/squeeze/click', "user_path1": '/user/hand/right', "component_path1": '/input/squeeze/click', "threshold": '0.30000001192092896', "axis_flag": 'ANY', "op": 'wm.xr_navigation_grab', "op_flag": 'MODAL', "bimanual": 'True'},
{"op_properties":
[("lock_rotation", True),
("lock_scale", True),
],
},
),
("raycast_select", {"type": 'BUTTON', "user_path0": '/user/hand/left', "component_path0": '/input/trackpad/click', "user_path1": '/user/hand/right', "component_path1": '/input/trackpad/click', "threshold": '0.30000001192092896', "axis_flag": 'ANY', "op": 'wm.xr_select_raycast', "op_flag": 'MODAL', "bimanual": 'False'}, None),
("grab", {"type": 'BUTTON', "user_path0": '/user/hand/left', "component_path0": '/input/squeeze/click', "user_path1": '/user/hand/right', "component_path1": '/input/squeeze/click', "threshold": '0.30000001192092896', "axis_flag": 'ANY', "op": 'wm.xr_transform_grab', "op_flag": 'MODAL', "bimanual": 'True'}, None),
("undo", {"type": 'BUTTON', "user_path0": '/user/hand/left', "component_path0": '/input/menu/click', "user_path1": '', "component_path1": '', "threshold": '0.30000001192092896', "axis_flag": 'ANY', "op": 'ed.undo', "op_flag": 'PRESS', "bimanual": 'False'}, None),
("redo", {"type": 'BUTTON', "user_path0": '/user/hand/right', "component_path0": '/input/menu/click', "user_path1": '', "component_path1": '', "threshold": '0.30000001192092896', "axis_flag": 'ANY', "op": 'ed.redo', "op_flag": 'PRESS', "bimanual": 'False'}, None),
("grab", {"type": 'BUTTON', "user_path0": '/user/hand/left', "component_path0": '/input/menu/click', "user_path1": '/user/hand/right', "component_path1": '/input/menu/click', "threshold": '0.30000001192092896', "axis_flag": 'ANY', "op": 'wm.xr_transform_grab', "op_flag": 'MODAL', "bimanual": 'True'}, None),
("undo", {"type": 'BUTTON', "user_path0": '/user/hand/left', "component_path0": '/input/thumbstick/x', "user_path1": '/user/hand/right', "component_path1": '/input/thumbstick/x', "threshold": '0.30000001192092896', "axis_flag": 'NEGATIVE', "op": 'ed.undo', "op_flag": 'PRESS', "bimanual": 'False'}, None),
("redo", {"type": 'BUTTON', "user_path0": '/user/hand/left', "component_path0": '/input/thumbstick/x', "user_path1": '/user/hand/right', "component_path1": '/input/thumbstick/x', "threshold": '0.30000001192092896', "axis_flag": 'POSITIVE', "op": 'ed.redo', "op_flag": 'PRESS', "bimanual": 'False'}, None),
("haptic", {"type": 'HAPTIC', "user_path0": '/user/hand/left', "component_path0": '/output/haptic', "user_path1": '/user/hand/right', "component_path1": '/output/haptic', "haptic_duration": '0.30000001192092896', "haptic_frequency": '3000.0', "haptic_amplitude": '0.5'}, None),
],
},
@ -45,14 +63,21 @@ actionconfig_data = \
("teleport",
{"type": 'BUTTON', "user_path0": '/user/hand/left', "component_path0": '/input/trigger/value', "user_path1": '/user/hand/right', "component_path1": '/input/trigger/value', "threshold": '0.30000001192092896', "axis_flag": 'ANY', "op": 'wm.xr_navigation_teleport', "op_flag": 'MODAL', "bimanual": 'False'},
{"op_properties":
[("color", (0.0, 1.0, 1.0, 1.0)),
[("interpolation", 0.9),
("color", (0.0, 1.0, 1.0, 1.0)),
],
},
),
("navigate",
{"type": 'BUTTON', "user_path0": '/user/hand/left', "component_path0": '/input/squeeze/click', "user_path1": '/user/hand/right', "component_path1": '/input/squeeze/click', "threshold": '0.30000001192092896', "axis_flag": 'ANY', "op": 'wm.xr_navigation_grab', "op_flag": 'MODAL', "bimanual": 'True'},
{"op_properties":
[("lock_rotation", True),
("lock_scale", True),
],
},
),
("raycast_select", {"type": 'BUTTON', "user_path0": '/user/hand/left', "component_path0": '/input/trackpad/click', "user_path1": '/user/hand/right', "component_path1": '/input/trackpad/click', "threshold": '0.30000001192092896', "axis_flag": 'ANY', "op": 'wm.xr_select_raycast', "op_flag": 'MODAL', "bimanual": 'False'}, None),
("grab", {"type": 'BUTTON', "user_path0": '/user/hand/left', "component_path0": '/input/squeeze/click', "user_path1": '/user/hand/right', "component_path1": '/input/squeeze/click', "threshold": '0.30000001192092896', "axis_flag": 'ANY', "op": 'wm.xr_transform_grab', "op_flag": 'MODAL', "bimanual": 'True'}, None),
("undo", {"type": 'BUTTON', "user_path0": '/user/hand/left', "component_path0": '/input/menu/click', "user_path1": '', "component_path1": '', "threshold": '0.30000001192092896', "axis_flag": 'ANY', "op": 'ed.undo', "op_flag": 'PRESS', "bimanual": 'False'}, None),
("redo", {"type": 'BUTTON', "user_path0": '/user/hand/right', "component_path0": '/input/menu/click', "user_path1": '', "component_path1": '', "threshold": '0.30000001192092896', "axis_flag": 'ANY', "op": 'ed.redo', "op_flag": 'PRESS', "bimanual": 'False'}, None),
("grab", {"type": 'BUTTON', "user_path0": '/user/hand/left', "component_path0": '/input/menu/click', "user_path1": '/user/hand/right', "component_path1": '/input/menu/click', "threshold": '0.30000001192092896', "axis_flag": 'ANY', "op": 'wm.xr_transform_grab', "op_flag": 'MODAL', "bimanual": 'True'}, None),
("haptic", {"type": 'HAPTIC', "user_path0": '/user/hand/left', "component_path0": '/output/haptic', "user_path1": '/user/hand/right', "component_path1": '/output/haptic', "haptic_duration": '0.30000001192092896', "haptic_frequency": '3000.0', "haptic_amplitude": '0.5'}, None),
],
},
@ -64,14 +89,23 @@ actionconfig_data = \
("teleport",
{"type": 'BUTTON', "user_path0": '/user/hand/left', "component_path0": '/input/trigger/value', "user_path1": '/user/hand/right', "component_path1": '/input/trigger/value', "threshold": '0.30000001192092896', "axis_flag": 'ANY', "op": 'wm.xr_navigation_teleport', "op_flag": 'MODAL', "bimanual": 'False'},
{"op_properties":
[("color", (0.0, 1.0, 1.0, 1.0)),
[("interpolation", 0.9),
("color", (0.0, 1.0, 1.0, 1.0)),
],
},
),
("navigate",
{"type": 'BUTTON', "user_path0": '/user/hand/left', "component_path0": '/input/squeeze/value', "user_path1": '/user/hand/right', "component_path1": '/input/squeeze/value', "threshold": '0.30000001192092896', "axis_flag": 'ANY', "op": 'wm.xr_navigation_grab', "op_flag": 'MODAL', "bimanual": 'True'},
{"op_properties":
[("lock_rotation", True),
("lock_scale", True),
],
},
),
("raycast_select", {"type": 'BUTTON', "user_path0": '/user/hand/left', "component_path0": '/input/a/click', "user_path1": '/user/hand/right', "component_path1": '/input/a/click', "threshold": '0.30000001192092896', "axis_flag": 'ANY', "op": 'wm.xr_select_raycast', "op_flag": 'MODAL', "bimanual": 'False'}, None),
("grab", {"type": 'BUTTON', "user_path0": '/user/hand/left', "component_path0": '/input/squeeze/value', "user_path1": '/user/hand/right', "component_path1": '/input/squeeze/value', "threshold": '0.30000001192092896', "axis_flag": 'ANY', "op": 'wm.xr_transform_grab', "op_flag": 'MODAL', "bimanual": 'True'}, None),
("undo", {"type": 'BUTTON', "user_path0": '/user/hand/left', "component_path0": '/input/b/click', "user_path1": '', "component_path1": '', "threshold": '0.30000001192092896', "axis_flag": 'ANY', "op": 'ed.undo', "op_flag": 'PRESS', "bimanual": 'False'}, None),
("redo", {"type": 'BUTTON', "user_path0": '/user/hand/right', "component_path0": '/input/b/click', "user_path1": '', "component_path1": '', "threshold": '0.30000001192092896', "axis_flag": 'ANY', "op": 'ed.redo', "op_flag": 'PRESS', "bimanual": 'False'}, None),
("grab", {"type": 'BUTTON', "user_path0": '/user/hand/left', "component_path0": '/input/b/click', "user_path1": '/user/hand/right', "component_path1": '/input/b/click', "threshold": '0.30000001192092896', "axis_flag": 'ANY', "op": 'wm.xr_transform_grab', "op_flag": 'MODAL', "bimanual": 'True'}, None),
("undo", {"type": 'BUTTON', "user_path0": '/user/hand/left', "component_path0": '/input/thumbstick/x', "user_path1": '/user/hand/right', "component_path1": '/input/thumbstick/x', "threshold": '0.30000001192092896', "axis_flag": 'NEGATIVE', "op": 'ed.undo', "op_flag": 'PRESS', "bimanual": 'False'}, None),
("redo", {"type": 'BUTTON', "user_path0": '/user/hand/left', "component_path0": '/input/thumbstick/x', "user_path1": '/user/hand/right', "component_path1": '/input/thumbstick/x', "threshold": '0.30000001192092896', "axis_flag": 'POSITIVE', "op": 'ed.redo', "op_flag": 'PRESS', "bimanual": 'False'}, None),
("haptic", {"type": 'HAPTIC', "user_path0": '/user/hand/left', "component_path0": '/output/haptic', "user_path1": '/user/hand/right', "component_path1": '/output/haptic', "haptic_duration": '0.30000001192092896', "haptic_frequency": '3000.0', "haptic_amplitude": '0.5'}, None),
],
},

View File

@ -42,12 +42,14 @@ class VRDefaultActionmaps(Enum):
class VRDefaultActions(Enum):
CONTROLLER_POSE = "controller_pose"
TELEPORT = "teleport"
NAVIGATE = "navigate"
RAYCAST_SELECT = "raycast_select"
GRAB = "grab"
UNDO = "undo"
REDO = "redo"
HAPTIC = "haptic"
def vr_defaults_actionmap_add(ac, name, profile):
am = ac.actionmaps.new(name, True)
if am:
@ -159,7 +161,19 @@ def vr_defaults_create_oculus(ac):
'ANY',
"wm.xr_navigation_teleport",
'MODAL',
False)
False)
vr_defaults_actionmap_item_add(am,
VRDefaultActions.NAVIGATE.value,
"/user/hand/left",
"/input/squeeze/value",
"/user/hand/right",
"/input/squeeze/value",
0.3,
'ANY',
'ANY',
"wm.xr_navigation_grab",
'MODAL',
True)
vr_defaults_actionmap_item_add(am,
VRDefaultActions.RAYCAST_SELECT.value,
"/user/hand/left",
@ -171,13 +185,13 @@ def vr_defaults_create_oculus(ac):
'ANY',
"wm.xr_select_raycast",
'MODAL',
False)
False)
vr_defaults_actionmap_item_add(am,
VRDefaultActions.GRAB.value,
"/user/hand/left",
"/input/squeeze/value",
"/input/y/click",
"/user/hand/right",
"/input/squeeze/value",
"/input/b/click",
0.3,
'ANY',
'ANY',
@ -187,23 +201,23 @@ def vr_defaults_create_oculus(ac):
vr_defaults_actionmap_item_add(am,
VRDefaultActions.UNDO.value,
"/user/hand/left",
"/input/y/click",
"",
"",
"/input/thumbstick/x",
"/user/hand/right",
"/input/thumbstick/x",
0.3,
'ANY',
'NEGATIVE',
'ANY',
"ed.undo",
'PRESS',
False)
vr_defaults_actionmap_item_add(am,
VRDefaultActions.REDO.value,
"/user/hand/left",
"/input/thumbstick/x",
"/user/hand/right",
"/input/b/click",
"",
"",
"/input/thumbstick/x",
0.3,
'ANY',
'POSITIVE',
'ANY',
"ed.redo",
'PRESS',
@ -247,6 +261,18 @@ def vr_defaults_create_wmr(ac):
"wm.xr_navigation_teleport",
'MODAL',
False)
vr_defaults_actionmap_item_add(am,
VRDefaultActions.NAVIGATE.value,
"/user/hand/left",
"/input/squeeze/click",
"/user/hand/right",
"/input/squeeze/click",
0.3,
'ANY',
'ANY',
"wm.xr_navigation_grab",
'MODAL',
True)
vr_defaults_actionmap_item_add(am,
VRDefaultActions.RAYCAST_SELECT.value,
"/user/hand/left",
@ -262,9 +288,9 @@ def vr_defaults_create_wmr(ac):
vr_defaults_actionmap_item_add(am,
VRDefaultActions.GRAB.value,
"/user/hand/left",
"/input/squeeze/click",
"/input/menu/click",
"/user/hand/right",
"/input/squeeze/click",
"/input/menu/click",
0.3,
'ANY',
'ANY',
@ -274,23 +300,23 @@ def vr_defaults_create_wmr(ac):
vr_defaults_actionmap_item_add(am,
VRDefaultActions.UNDO.value,
"/user/hand/left",
"/input/menu/click",
"",
"",
"/input/thumbstick/x",
"/user/hand/right",
"/input/thumbstick/x",
0.3,
'ANY',
'NEGATIVE',
'ANY',
"ed.undo",
'PRESS',
False)
vr_defaults_actionmap_item_add(am,
VRDefaultActions.REDO.value,
"/user/hand/left",
"/input/thumbstick/x",
"/user/hand/right",
"/input/menu/click",
"",
"",
"/input/thumbstick/x",
0.3,
'ANY',
'POSITIVE',
'ANY',
"ed.redo",
'PRESS',
@ -333,7 +359,19 @@ def vr_defaults_create_vive(ac):
'ANY',
"wm.xr_navigation_teleport",
'MODAL',
False)
False)
vr_defaults_actionmap_item_add(am,
VRDefaultActions.NAVIGATE.value,
"/user/hand/left",
"/input/squeeze/click",
"/user/hand/right",
"/input/squeeze/click",
0.3,
'ANY',
'ANY',
"wm.xr_navigation_grab",
'MODAL',
True)
vr_defaults_actionmap_item_add(am,
VRDefaultActions.RAYCAST_SELECT.value,
"/user/hand/left",
@ -345,43 +383,19 @@ def vr_defaults_create_vive(ac):
'ANY',
"wm.xr_select_raycast",
'MODAL',
False)
False)
vr_defaults_actionmap_item_add(am,
VRDefaultActions.GRAB.value,
"/user/hand/left",
"/input/squeeze/click",
"/input/menu/click",
"/user/hand/right",
"/input/squeeze/click",
"/input/menu/click",
0.3,
'ANY',
'ANY',
"wm.xr_transform_grab",
'MODAL',
True)
vr_defaults_actionmap_item_add(am,
VRDefaultActions.UNDO.value,
"/user/hand/left",
"/input/menu/click",
"",
"",
0.3,
'ANY',
'ANY',
"ed.undo",
'PRESS',
False)
vr_defaults_actionmap_item_add(am,
VRDefaultActions.REDO.value,
"/user/hand/right",
"/input/menu/click",
"",
"",
0.3,
'ANY',
'ANY',
"ed.redo",
'PRESS',
False)
True)
vr_defaults_haptic_actionmap_item_add(am,
VRDefaultActions.HAPTIC.value,
"/user/hand/left",
@ -421,6 +435,18 @@ def vr_defaults_create_index(ac):
"wm.xr_navigation_teleport",
'MODAL',
False)
vr_defaults_actionmap_item_add(am,
VRDefaultActions.NAVIGATE.value,
"/user/hand/left",
"/input/squeeze/value",
"/user/hand/right",
"/input/squeeze/value",
0.3,
'ANY',
'ANY',
"wm.xr_navigation_grab",
'MODAL',
True)
vr_defaults_actionmap_item_add(am,
VRDefaultActions.RAYCAST_SELECT.value,
"/user/hand/left",
@ -436,9 +462,9 @@ def vr_defaults_create_index(ac):
vr_defaults_actionmap_item_add(am,
VRDefaultActions.GRAB.value,
"/user/hand/left",
"/input/squeeze/value",
"/input/b/click",
"/user/hand/right",
"/input/squeeze/value",
"/input/b/click",
0.3,
'ANY',
'ANY',
@ -448,23 +474,23 @@ def vr_defaults_create_index(ac):
vr_defaults_actionmap_item_add(am,
VRDefaultActions.UNDO.value,
"/user/hand/left",
"/input/b/click",
"",
"",
"/input/thumbstick/x",
"/user/hand/right",
"/input/thumbstick/x",
0.3,
'ANY',
'NEGATIVE',
'ANY',
"ed.undo",
'PRESS',
False)
vr_defaults_actionmap_item_add(am,
VRDefaultActions.REDO.value,
"/user/hand/left",
"/input/thumbstick/x",
"/user/hand/right",
"/input/b/click",
"",
"",
"/input/thumbstick/x",
0.3,
'ANY',
'POSITIVE',
'ANY',
"ed.redo",
'PRESS',