VR: Add "teleport" default action
Also add "scale" property to object/custom landmarks.
This commit is contained in:
parent
2458b2146b
commit
b0577f1996
|
@ -4,10 +4,17 @@ actionconfig_data = \
|
|||
{"profile": '/interaction_profiles/oculus/touch_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.8726646304130554, 0.0, 0.0)'}, None),
|
||||
("raycast_select", {"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', "op": 'wm.xr_select_raycast', "op_flag": 'MODAL'}, 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', "op": 'wm.xr_navigation_teleport', "op_flag": 'MODAL'},
|
||||
{"op_properties":
|
||||
[("color", (0.0, 1.0, 1.0, 1.0)),
|
||||
],
|
||||
},
|
||||
),
|
||||
("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', "op": 'wm.xr_select_raycast', "op_flag": 'MODAL'}, 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', "op": 'wm.xr_grab', "op_flag": 'MODAL'}, None),
|
||||
("undo", {"type": 'BUTTON', "user_path0": '/user/hand/left', "component_path0": '/input/x/click', "user_path1": '', "component_path1": '', "threshold": '0.30000001192092896', "op": 'ed.undo', "op_flag": 'PRESS'}, None),
|
||||
("redo", {"type": 'BUTTON', "user_path0": '/user/hand/right', "component_path0": '/input/a/click', "user_path1": '', "component_path1": '', "threshold": '0.30000001192092896', "op": 'ed.redo', "op_flag": 'PRESS'}, None),
|
||||
("undo", {"type": 'BUTTON', "user_path0": '/user/hand/left', "component_path0": '/input/y/click', "user_path1": '', "component_path1": '', "threshold": '0.30000001192092896', "op": 'ed.undo', "op_flag": 'PRESS'}, None),
|
||||
("redo", {"type": 'BUTTON', "user_path0": '/user/hand/right', "component_path0": '/input/b/click', "user_path1": '', "component_path1": '', "threshold": '0.30000001192092896', "op": 'ed.redo', "op_flag": 'PRESS'}, 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),
|
||||
],
|
||||
},
|
||||
|
@ -16,7 +23,14 @@ actionconfig_data = \
|
|||
{"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),
|
||||
("raycast_select", {"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', "op": 'wm.xr_select_raycast', "op_flag": 'MODAL'}, 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', "op": 'wm.xr_navigation_teleport', "op_flag": 'MODAL'},
|
||||
{"op_properties":
|
||||
[("color", (0.0, 1.0, 1.0, 1.0)),
|
||||
],
|
||||
},
|
||||
),
|
||||
("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', "op": 'wm.xr_select_raycast', "op_flag": 'MODAL'}, 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', "op": 'wm.xr_grab', "op_flag": 'MODAL'}, None),
|
||||
("undo", {"type": 'BUTTON', "user_path0": '/user/hand/left', "component_path0": '/input/menu/click', "user_path1": '', "component_path1": '', "threshold": '0.30000001192092896', "op": 'ed.undo', "op_flag": 'PRESS'}, None),
|
||||
("redo", {"type": 'BUTTON', "user_path0": '/user/hand/right', "component_path0": '/input/menu/click', "user_path1": '', "component_path1": '', "threshold": '0.30000001192092896', "op": 'ed.redo', "op_flag": 'PRESS'}, None),
|
||||
|
@ -28,7 +42,14 @@ actionconfig_data = \
|
|||
{"profile": '/interaction_profiles/htc/vive_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.0, 0.0, 0.0)'}, None),
|
||||
("raycast_select", {"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', "op": 'wm.xr_select_raycast', "op_flag": 'MODAL'}, 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', "op": 'wm.xr_navigation_teleport', "op_flag": 'MODAL'},
|
||||
{"op_properties":
|
||||
[("color", (0.0, 1.0, 1.0, 1.0)),
|
||||
],
|
||||
},
|
||||
),
|
||||
("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', "op": 'wm.xr_select_raycast', "op_flag": 'MODAL'}, 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', "op": 'wm.xr_grab', "op_flag": 'MODAL'}, None),
|
||||
("undo", {"type": 'BUTTON', "user_path0": '/user/hand/left', "component_path0": '/input/menu/click', "user_path1": '', "component_path1": '', "threshold": '0.30000001192092896', "op": 'ed.undo', "op_flag": 'PRESS'}, None),
|
||||
("redo", {"type": 'BUTTON', "user_path0": '/user/hand/right', "component_path0": '/input/menu/click', "user_path1": '', "component_path1": '', "threshold": '0.30000001192092896', "op": 'ed.redo', "op_flag": 'PRESS'}, None),
|
||||
|
@ -40,10 +61,17 @@ actionconfig_data = \
|
|||
{"profile": '/interaction_profiles/valve/index_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.0, 0.0, 0.0)'}, None),
|
||||
("raycast_select", {"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', "op": 'wm.xr_select_raycast', "op_flag": 'MODAL'}, 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', "op": 'wm.xr_navigation_teleport', "op_flag": 'MODAL'},
|
||||
{"op_properties":
|
||||
[("color", (0.0, 1.0, 1.0, 1.0)),
|
||||
],
|
||||
},
|
||||
),
|
||||
("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', "op": 'wm.xr_select_raycast', "op_flag": 'MODAL'}, 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', "op": 'wm.xr_grab', "op_flag": 'MODAL'}, None),
|
||||
("undo", {"type": 'BUTTON', "user_path0": '/user/hand/left', "component_path0": '/input/a/click', "user_path1": '', "component_path1": '', "threshold": '0.30000001192092896', "op": 'ed.undo', "op_flag": 'PRESS'}, None),
|
||||
("redo", {"type": 'BUTTON', "user_path0": '/user/hand/right', "component_path0": '/input/a/click', "user_path1": '', "component_path1": '', "threshold": '0.30000001192092896', "op": 'ed.redo', "op_flag": 'PRESS'}, None),
|
||||
("undo", {"type": 'BUTTON', "user_path0": '/user/hand/left', "component_path0": '/input/b/click', "user_path1": '', "component_path1": '', "threshold": '0.30000001192092896', "op": 'ed.undo', "op_flag": 'PRESS'}, None),
|
||||
("redo", {"type": 'BUTTON', "user_path0": '/user/hand/right', "component_path0": '/input/b/click', "user_path1": '', "component_path1": '', "threshold": '0.30000001192092896', "op": 'ed.redo', "op_flag": 'PRESS'}, 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),
|
||||
],
|
||||
},
|
||||
|
|
|
@ -41,6 +41,7 @@ class VRDefaultActionmaps(Enum):
|
|||
# Default actions.
|
||||
class VRDefaultActions(Enum):
|
||||
CONTROLLER_POSE = "controller_pose"
|
||||
TELEPORT = "teleport"
|
||||
RAYCAST_SELECT = "raycast_select"
|
||||
GRAB = "grab"
|
||||
UNDO = "undo"
|
||||
|
@ -140,14 +141,23 @@ def vr_defaults_create_oculus(ac):
|
|||
"/input/grip/pose",
|
||||
True,
|
||||
(0, 0, 0),
|
||||
(math.radians(-50), 0, 0))
|
||||
(math.radians(-50), 0, 0))
|
||||
vr_defaults_actionmap_item_add(am,
|
||||
VRDefaultActions.RAYCAST_SELECT.value,
|
||||
VRDefaultActions.TELEPORT.value,
|
||||
"/user/hand/left",
|
||||
"/input/trigger/value",
|
||||
"/user/hand/right",
|
||||
"/input/trigger/value",
|
||||
0.3,
|
||||
"wm.xr_navigation_teleport",
|
||||
'MODAL')
|
||||
vr_defaults_actionmap_item_add(am,
|
||||
VRDefaultActions.RAYCAST_SELECT.value,
|
||||
"/user/hand/left",
|
||||
"/input/x/click",
|
||||
"/user/hand/right",
|
||||
"/input/a/click",
|
||||
0.3,
|
||||
"wm.xr_select_raycast",
|
||||
'MODAL')
|
||||
vr_defaults_actionmap_item_add(am,
|
||||
|
@ -162,7 +172,7 @@ def vr_defaults_create_oculus(ac):
|
|||
vr_defaults_actionmap_item_add(am,
|
||||
VRDefaultActions.UNDO.value,
|
||||
"/user/hand/left",
|
||||
"/input/x/click",
|
||||
"/input/y/click",
|
||||
"",
|
||||
"",
|
||||
0.3,
|
||||
|
@ -171,7 +181,7 @@ def vr_defaults_create_oculus(ac):
|
|||
vr_defaults_actionmap_item_add(am,
|
||||
VRDefaultActions.REDO.value,
|
||||
"/user/hand/right",
|
||||
"/input/a/click",
|
||||
"/input/b/click",
|
||||
"",
|
||||
"",
|
||||
0.3,
|
||||
|
@ -205,14 +215,23 @@ def vr_defaults_create_wmr(ac):
|
|||
(0, 0, 0),
|
||||
(math.radians(-45), 0, 0))
|
||||
vr_defaults_actionmap_item_add(am,
|
||||
VRDefaultActions.RAYCAST_SELECT.value,
|
||||
VRDefaultActions.TELEPORT.value,
|
||||
"/user/hand/left",
|
||||
"/input/trigger/value",
|
||||
"/user/hand/right",
|
||||
"/input/trigger/value",
|
||||
0.3,
|
||||
"wm.xr_select_raycast",
|
||||
"wm.xr_navigation_teleport",
|
||||
'MODAL')
|
||||
vr_defaults_actionmap_item_add(am,
|
||||
VRDefaultActions.RAYCAST_SELECT.value,
|
||||
"/user/hand/left",
|
||||
"/input/trackpad/click",
|
||||
"/user/hand/right",
|
||||
"/input/trackpad/click",
|
||||
0.3,
|
||||
"wm.xr_select_raycast",
|
||||
'MODAL')
|
||||
vr_defaults_actionmap_item_add(am,
|
||||
VRDefaultActions.GRAB.value,
|
||||
"/user/hand/left",
|
||||
|
@ -268,14 +287,23 @@ def vr_defaults_create_vive(ac):
|
|||
(0, 0, 0),
|
||||
(0, 0, 0))
|
||||
vr_defaults_actionmap_item_add(am,
|
||||
VRDefaultActions.RAYCAST_SELECT.value,
|
||||
VRDefaultActions.TELEPORT.value,
|
||||
"/user/hand/left",
|
||||
"/input/trigger/value",
|
||||
"/user/hand/right",
|
||||
"/input/trigger/value",
|
||||
0.3,
|
||||
"wm.xr_select_raycast",
|
||||
"wm.xr_navigation_teleport",
|
||||
'MODAL')
|
||||
vr_defaults_actionmap_item_add(am,
|
||||
VRDefaultActions.RAYCAST_SELECT.value,
|
||||
"/user/hand/left",
|
||||
"/input/trackpad/click",
|
||||
"/user/hand/right",
|
||||
"/input/trackpad/click",
|
||||
0.3,
|
||||
"wm.xr_select_raycast",
|
||||
'MODAL')
|
||||
vr_defaults_actionmap_item_add(am,
|
||||
VRDefaultActions.GRAB.value,
|
||||
"/user/hand/left",
|
||||
|
@ -331,14 +359,23 @@ def vr_defaults_create_index(ac):
|
|||
(0, 0, 0),
|
||||
(0, 0, 0))
|
||||
vr_defaults_actionmap_item_add(am,
|
||||
VRDefaultActions.RAYCAST_SELECT.value,
|
||||
VRDefaultActions.TELEPORT.value,
|
||||
"/user/hand/left",
|
||||
"/input/trigger/value",
|
||||
"/user/hand/right",
|
||||
"/input/trigger/value",
|
||||
0.3,
|
||||
"wm.xr_select_raycast",
|
||||
"wm.xr_navigation_teleport",
|
||||
'MODAL')
|
||||
vr_defaults_actionmap_item_add(am,
|
||||
VRDefaultActions.RAYCAST_SELECT.value,
|
||||
"/user/hand/left",
|
||||
"/input/a/click",
|
||||
"/user/hand/right",
|
||||
"/input/a/click",
|
||||
0.3,
|
||||
"wm.xr_select_raycast",
|
||||
'MODAL')
|
||||
vr_defaults_actionmap_item_add(am,
|
||||
VRDefaultActions.GRAB.value,
|
||||
"/user/hand/left",
|
||||
|
@ -351,7 +388,7 @@ def vr_defaults_create_index(ac):
|
|||
vr_defaults_actionmap_item_add(am,
|
||||
VRDefaultActions.UNDO.value,
|
||||
"/user/hand/left",
|
||||
"/input/a/click",
|
||||
"/input/b/click",
|
||||
"",
|
||||
"",
|
||||
0.3,
|
||||
|
@ -360,7 +397,7 @@ def vr_defaults_create_index(ac):
|
|||
vr_defaults_actionmap_item_add(am,
|
||||
VRDefaultActions.REDO.value,
|
||||
"/user/hand/right",
|
||||
"/input/a/click",
|
||||
"/input/b/click",
|
||||
"",
|
||||
"",
|
||||
0.3,
|
||||
|
|
|
@ -232,7 +232,7 @@ def actionconfig_export_as_data(ac, filepath, *, all_actionmaps=True, sort=False
|
|||
fw(" # Only add keywords that are supported.\n")
|
||||
fw(" from bpy.app import version as blender_version\n")
|
||||
fw(" keywords = {}\n")
|
||||
fw(" if blender_version >= (2, 93, 0):\n")
|
||||
fw(" if blender_version >= (3, 0, 0):\n")
|
||||
fw(" keywords[\"actionconfig_version\"] = actionconfig_version\n")
|
||||
|
||||
fw(" import os\n")
|
||||
|
|
|
@ -106,7 +106,6 @@ class VIEW3D_PT_vr_session_view(Panel):
|
|||
col.prop(session_settings, "clip_end", text="End")
|
||||
|
||||
|
||||
|
||||
### Landmarks.
|
||||
@persistent
|
||||
def vr_ensure_default_landmark(context: bpy.context):
|
||||
|
@ -153,6 +152,13 @@ def vr_landmark_active_base_pose_angle_update(self, context):
|
|||
session_settings.base_pose_angle = landmark_active.base_pose_angle
|
||||
|
||||
|
||||
def vr_landmark_active_base_scale_update(self, context):
|
||||
session_settings = context.window_manager.xr_session_settings
|
||||
landmark_active = VRLandmark.get_active_landmark(context)
|
||||
|
||||
session_settings.base_scale = landmark_active.base_scale
|
||||
|
||||
|
||||
def vr_landmark_type_update(self, context):
|
||||
landmark_selected = VRLandmark.get_selected_landmark(context)
|
||||
landmark_active = VRLandmark.get_active_landmark(context)
|
||||
|
@ -193,6 +199,16 @@ def vr_landmark_base_pose_angle_update(self, context):
|
|||
vr_landmark_active_base_pose_angle_update(self, context)
|
||||
|
||||
|
||||
def vr_landmark_base_scale_update(self, context):
|
||||
landmark_selected = VRLandmark.get_selected_landmark(context)
|
||||
landmark_active = VRLandmark.get_active_landmark(context)
|
||||
|
||||
# Only update session settings data if the changed landmark is actually
|
||||
# the active one.
|
||||
if landmark_active == landmark_selected:
|
||||
vr_landmark_active_base_scale_update(self, context)
|
||||
|
||||
|
||||
def vr_landmark_active_update(self, context):
|
||||
wm = context.window_manager
|
||||
|
||||
|
@ -200,6 +216,7 @@ def vr_landmark_active_update(self, context):
|
|||
vr_landmark_active_base_pose_object_update(self, context)
|
||||
vr_landmark_active_base_pose_location_update(self, context)
|
||||
vr_landmark_active_base_pose_angle_update(self, context)
|
||||
vr_landmark_active_base_scale_update(self, context)
|
||||
|
||||
if wm.xr_session_state:
|
||||
wm.xr_session_state.reset_to_base_pose(context)
|
||||
|
@ -255,6 +272,15 @@ class VRLandmark(PropertyGroup):
|
|||
subtype='ANGLE',
|
||||
update=vr_landmark_base_pose_angle_update,
|
||||
)
|
||||
base_scale: bpy.props.FloatProperty(
|
||||
name="Base Scale",
|
||||
default=1.0,
|
||||
min=0.001,
|
||||
max=1000.0,
|
||||
soft_min=0.001,
|
||||
soft_max=1000.0,
|
||||
update=vr_landmark_base_scale_update,
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def get_selected_landmark(context):
|
||||
|
@ -327,11 +353,14 @@ class VIEW3D_PT_vr_landmarks(Panel):
|
|||
|
||||
if landmark_selected.type == 'OBJECT':
|
||||
layout.prop(landmark_selected, "base_pose_object")
|
||||
layout.prop(landmark_selected, "base_scale", text="Scale")
|
||||
elif landmark_selected.type == 'CUSTOM':
|
||||
layout.prop(landmark_selected,
|
||||
"base_pose_location", text="Location")
|
||||
layout.prop(landmark_selected,
|
||||
"base_pose_angle", text="Angle")
|
||||
layout.prop(landmark_selected,
|
||||
"base_scale", text="Scale")
|
||||
|
||||
|
||||
class VIEW3D_OT_vr_landmark_add(Operator):
|
||||
|
|
Loading…
Reference in New Issue