[Bf-extensions-cvs] [6528492f] temp-xr-tracker: VR: Add dedicated handling for VR trackers

Peter Kim noreply at git.blender.org
Mon Apr 4 10:04:34 CEST 2022


Commit: 6528492f250ed1c9b030b480f55886667a55fdc4
Author: Peter Kim
Date:   Mon Apr 4 17:04:04 2022 +0900
Branches: temp-xr-tracker
https://developer.blender.org/rBA6528492f250ed1c9b030b480f55886667a55fdc4

VR: Add dedicated handling for VR trackers

Also refactor the "blender_default_tracker" action map to have separate
pose actions for each tracker role (instead of a single pose action with
subaction paths for each role) and add controller pose actions.

===================================================================

M	viewport_vr_preview/action_map.py
M	viewport_vr_preview/action_map_io.py
M	viewport_vr_preview/configs/default.py
M	viewport_vr_preview/defaults.py
M	viewport_vr_preview/gui.py

===================================================================

diff --git a/viewport_vr_preview/action_map.py b/viewport_vr_preview/action_map.py
index ce87873c..cbd16fc2 100644
--- a/viewport_vr_preview/action_map.py
+++ b/viewport_vr_preview/action_map.py
@@ -111,6 +111,7 @@ def vr_create_actions(context: bpy.context):
 
         controller_grip_name = ""
         controller_aim_name = ""
+        tracker_names = []
 
         for ami in am.actionmap_items:
             if len(ami.bindings) < 1:
@@ -125,6 +126,8 @@ def vr_create_actions(context: bpy.context):
                     controller_grip_name = ami.name
                 if ami.pose_is_controller_aim:
                     controller_aim_name = ami.name
+                if ami.pose_is_tracker:
+                    tracker_names.append(ami.name)
 
             for amb in ami.bindings:
                 # Check for bindings that require OpenXR extensions.
@@ -145,10 +148,13 @@ def vr_create_actions(context: bpy.context):
                 if not ok:
                     return
 
-        # Set controller pose actions.
+        # Set controller and tracker pose actions.
         if controller_grip_name and controller_aim_name:
             session_state.controller_pose_actions_set(context, am.name, controller_grip_name, controller_aim_name)
 
+        for tracker_name in tracker_names:
+            session_state.tracker_pose_action_add(context, am.name, tracker_name)
+
     # Set active action set.
     vr_actionset_active_update(context)
 
diff --git a/viewport_vr_preview/action_map_io.py b/viewport_vr_preview/action_map_io.py
index 92b5b676..bd0e6d11 100644
--- a/viewport_vr_preview/action_map_io.py
+++ b/viewport_vr_preview/action_map_io.py
@@ -63,6 +63,7 @@ def ami_args_as_data(ami):
     elif ami.type == 'POSE':
         s.append(f"\"pose_is_controller_grip\": '{ami.pose_is_controller_grip}'")
         s.append(f"\"pose_is_controller_aim\": '{ami.pose_is_controller_aim}'")
+        s.append(f"\"pose_is_tracker\": '{ami.pose_is_tracker}'")
 
     return "{" + ", ".join(s) + "}"
 
@@ -86,6 +87,7 @@ def ami_data_from_args(ami, args):
     elif ami.type == 'POSE':
         ami.pose_is_controller_grip = True if (args["pose_is_controller_grip"] == 'True') else False
         ami.pose_is_controller_aim = True if (args["pose_is_controller_aim"] == 'True') else False
+        ami.pose_is_tracker = True if (args["pose_is_tracker"] == 'True') else False
 
 
 def _ami_properties_to_lines_recursive(level, properties, lines):
diff --git a/viewport_vr_preview/configs/default.py b/viewport_vr_preview/configs/default.py
index 1b5ff7fe..fbd40c1d 100644
--- a/viewport_vr_preview/configs/default.py
+++ b/viewport_vr_preview/configs/default.py
@@ -1,10 +1,10 @@
 # SPDX-License-Identifier: GPL-2.0-or-later
 
-actionconfig_version = (3, 2, 3)
+actionconfig_version = (3, 2, 8)
 actionconfig_data = \
 [("blender_default",
   {"items":
-   [("controller_grip", {"type": 'POSE', "user_paths": ['/user/hand/left', '/user/hand/right'], "pose_is_controller_grip": 'True', "pose_is_controller_aim": 'False'}, None,
+   [("controller_grip", {"type": 'POSE', "user_paths": ['/user/hand/left', '/user/hand/right'], "pose_is_controller_grip": 'True', "pose_is_controller_aim": 'False', "pose_is_tracker": 'False'}, None,
      {"bindings":
       [("huawei", {"profile": '/interaction_profiles/huawei/controller', "component_paths": ['/input/grip/pose', '/input/grip/pose'], "pose_location": '(0.0, 0.0, 0.0)', "pose_rotation": '(0.0, 0.0, 0.0)'}),
        ("index", {"profile": '/interaction_profiles/valve/index_controller', "component_paths": ['/input/grip/pose', '/input/grip/pose'], "pose_location": '(0.0, 0.0, 0.0)', "pose_rotation": '(0.0, 0.0, 0.0)'}),
@@ -18,7 +18,7 @@ actionconfig_data = \
        ],
       },
      ),
-    ("controller_aim", {"type": 'POSE', "user_paths": ['/user/hand/left', '/user/hand/right'], "pose_is_controller_grip": 'False', "pose_is_controller_aim": 'True'}, None,
+    ("controller_aim", {"type": 'POSE', "user_paths": ['/user/hand/left', '/user/hand/right'], "pose_is_controller_grip": 'False', "pose_is_controller_aim": 'True', "pose_is_tracker": 'False'}, None,
      {"bindings":
       [("huawei", {"profile": '/interaction_profiles/huawei/controller', "component_paths": ['/input/aim/pose', '/input/aim/pose'], "pose_location": '(0.0, 0.0, 0.0)', "pose_rotation": '(0.0, 0.0, 0.0)'}),
        ("index", {"profile": '/interaction_profiles/valve/index_controller', "component_paths": ['/input/aim/pose', '/input/aim/pose'], "pose_location": '(0.0, 0.0, 0.0)', "pose_rotation": '(0.0, 0.0, 0.0)'}),
@@ -479,9 +479,103 @@ 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_t [...]
+   [("controller_grip", {"type": 'POSE', "user_paths": ['/user/hand/left', '/user/hand/right'], "pose_is_controller_grip": 'True', "pose_is_controller_aim": 'False', "pose_is_tracker": 'False'}, 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)'}),
+      [("huawei", {"profile": '/interaction_profiles/huawei/controller', "component_paths": ['/input/grip/pose', '/input/grip/pose'], "pose_location": '(0.0, 0.0, 0.0)', "pose_rotation": '(0.0, 0.0, 0.0)'}),
+       ("index", {"profile": '/interaction_profiles/valve/index_controller', "component_paths": ['/input/grip/pose', '/input/grip/pose'], "pose_location": '(0.0, 0.0, 0.0)', "pose_rotation": '(0.0, 0.0, 0.0)'}),
+       ("oculus", {"profile": '/interaction_profiles/oculus/touch_controller', "component_paths": ['/input/grip/pose', '/input/grip/pose'], "pose_location": '(0.0, 0.0, 0.0)', "pose_rotation": '(0.0, 0.0, 0.0)'}),
+       ("reverb_g2", {"profile": '/interaction_profiles/hp/mixed_reality_controller', "component_paths": ['/input/grip/pose', '/input/grip/pose'], "pose_location": '(0.0, 0.0, 0.0)', "pose_rotation": '(0.0, 0.0, 0.0)'}),
+       ("simple", {"profile": '/interaction_profiles/khr/simple_controller', "component_paths": ['/input/grip/pose', '/input/grip/pose'], "pose_location": '(0.0, 0.0, 0.0)', "pose_rotation": '(0.0, 0.0, 0.0)'}),
+       ("vive", {"profile": '/interaction_profiles/htc/vive_controller', "component_paths": ['/input/grip/pose', '/input/grip/pose'], "pose_location": '(0.0, 0.0, 0.0)', "pose_rotation": '(0.0, 0.0, 0.0)'}),
+       ("vive_cosmos", {"profile": '/interaction_profiles/htc/vive_cosmos_controller', "component_paths": ['/input/grip/pose', '/input/grip/pose'], "pose_location": '(0.0, 0.0, 0.0)', "pose_rotation": '(0.0, 0.0, 0.0)'}),
+       ("vive_focus", {"profile": '/interaction_profiles/htc/vive_focus3_controller', "component_paths": ['/input/grip/pose', '/input/grip/pose'], "pose_location": '(0.0, 0.0, 0.0)', "pose_rotation": '(0.0, 0.0, 0.0)'}),
+       ("wmr", {"profile": '/interaction_profiles/microsoft/motion_controller', "component_paths": ['/input/grip/pose', '/input/grip/pose'], "pose_location": '(0.0, 0.0, 0.0)', "pose_rotation": '(0.0, 0.0, 0.0)'}),
+       ],
+      },
+     ),
+    ("controller_aim", {"type": 'POSE', "user_paths": ['/user/hand/left', '/user/hand/right'], "pose_is_controller_grip": 'False', "pose_is_controller_aim": 'True', "pose_is_tracker": 'False'}, None,
+     {"bindings":
+      [("huawei", {"profile": '/interaction_profiles/huawei/controller', "component_paths": ['/input/aim/pose', '/input/aim/pose'], "pose_location": '(0.0, 0.0, 0.0)', "pose_rotation": '(0.0, 0.0, 0.0)'}),
+       ("index", {"profile": '/interaction_profiles/valve/index_controller', "component_paths": ['/input/aim/pose', '/input/aim/pose'], "pose_location": '(0.0, 0.0, 0.0)', "pose_rotation": '(0.0, 0.0, 0.0)'}),
+       ("oculus", {"profile": '/interaction_profiles/oculus/touch_controller', "component_paths": ['/input/aim/pose', '/input/aim/pose'], "pose_location": '(0.0, 0.0, 0.0)', "pose_rotation": '(0.0, 0.0, 0.0)'}),
+       ("reverb_g2", {"profile": '/interaction_profiles/hp/mixed_reality_controller', "component_paths": ['/input/aim/pose', '/input/aim/pose'], "pose_location": '(0.0, 0.0, 0.0)', "pose_rotation": '(0.0, 0.0, 0.0)'}),
+       ("simple", {"profile": '/interaction_profiles/khr/simple_controller', "component_paths": ['/input/aim/pose', '/input/aim/pose'], "pose_location": '(0.0, 0.0, 0.0)', "pose_rotation": '(0.0, 0.0, 0.0)'}),
+       ("vive", {"profile": '/interaction_profiles/htc/vive_controller', "component_paths": ['/input/aim/pose', '/input/aim/pose'], "pose_location": '(0.0, 0.0, 0.0)', "pose_rotation": '(0.0, 0.0, 0.0)'}),
+       ("vive_cosmos", {"profile": '/interaction_profiles/htc/vive_cosmos_controller', "component_paths": ['/input/aim/pose', '/input/aim/pose'], "pose_location": '(0.0, 0.0, 0.0)', "pose_rotation": '(0.0, 0.0, 0.0)'}),
+       ("vive_focus", {"profile": '/interaction_profiles/htc/vive_focus3_controller', "component_paths": ['/input/aim/pose', '/input/aim/pose'], "pose_location": '(0.0, 0.0, 0.0)', "pose_rotation": '(0.0, 0.0, 0.0)'}),
+       ("wmr", {"profile": '/interaction_profiles/microsoft/motion_controller', "component_paths": ['/input/aim/pose', '/input/aim/pose'], "pose_location": '(0.0, 0.0, 0.0)', "pose_rotation": '(0.0, 0.0, 0.0)'}),
+       ],
+      },
+     ),
+    ("left_foot", {"type": 'POSE', "user_paths": ['/user/vive_tracker_htcx/role/left_foot'], "pose_is_controller_grip": 'False', "pose_is_controller_aim": 'False', "po

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-extensions-cvs mailing list