[Bf-extensions-cvs] [823910c5] master: VR: Default Actions, Controller Visualization

Peter Kim noreply at git.blender.org
Tue Oct 26 06:45:34 CEST 2021


Commit: 823910c50d1c4814c4aa1962a31b91e4dc1c183b
Author: Peter Kim
Date:   Tue Oct 26 13:45:00 2021 +0900
Branches: master
https://developer.blender.org/rBA823910c50d1c4814c4aa1962a31b91e4dc1c183b

VR: Default Actions, Controller Visualization

This updates the VR Scene Inspection add-on with functionality for
loading and using default controller actions, including controller
poses and haptics, and visualizing VR controllers both in-headset and
in the regular 3D viewport.

In other words, users can finally view their VR controllers and use
them to navigate their scene in VR.

Controller actions (enabled by default) are available as an option in
the "VR Session" panel. For controller bindings that require OpenXR
extensions (Reverb G2, Vive Cosmos, Huawei), there is a new
"Action Maps" panel where users can toggle these bindings. Bindings
that require extensions are disabled by default since not all OpenXR
runtimes may support them, which will lead to an error during action
creation at session start.

There is also an option in the "Action Maps" panel to use a
gamepad (Xbox Controller) instead of motion controllers for VR
actions/viewport navigation.

In addition to default actions, this update adds new options for VR
controller visualization. For in-headset (VR) visualization, controller
visibility as well as style (dark/light, ray/no ray) can be set via the
"View" panel. For visualization in the regular 3D viewport, there is a
new option in the "Viewport Feedback" panel to draw controllers as
gizmos, similar to the existing option for the VR camera (headset).

Finally, this update also changes the VR Landmark "Custom Camera" type
to "Custom Object", so users can specify any object (not just cameras)
as a base pose reference, and adds a base scale option for custom
object and custom pose-type landmarks.

Reviewed By: Severin

Differential Revision: https://developer.blender.org/D11271

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

D	viewport_vr_preview.py
A	viewport_vr_preview/__init__.py
A	viewport_vr_preview/action_map.py
A	viewport_vr_preview/action_map_io.py
A	viewport_vr_preview/configs/default.py
A	viewport_vr_preview/defaults.py
A	viewport_vr_preview/gui.py
A	viewport_vr_preview/operators.py
A	viewport_vr_preview/properties.py
A	viewport_vr_preview/versioning.py

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

diff --git a/viewport_vr_preview.py b/viewport_vr_preview.py
deleted file mode 100644
index 07f34756..00000000
--- a/viewport_vr_preview.py
+++ /dev/null
@@ -1,840 +0,0 @@
-# ##### BEGIN GPL LICENSE BLOCK #####
-#
-#  This program is free software; you can redistribute it and/or
-#  modify it under the terms of the GNU General Public License
-#  as published by the Free Software Foundation; either version 2
-#  of the License, or (at your option) any later version.
-#
-#  This program is distributed in the hope that it will be useful,
-#  but WITHOUT ANY WARRANTY; without even the implied warranty of
-#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-#  GNU General Public License for more details.
-#
-#  You should have received a copy of the GNU General Public License
-#  along with this program; if not, write to the Free Software Foundation,
-#  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
-# ##### END GPL LICENSE BLOCK #####
-
-# <pep8 compliant>
-
-import bpy
-from bpy.types import (
-    Gizmo,
-    GizmoGroup,
-    PropertyGroup,
-    UIList,
-    Menu,
-    Panel,
-    Operator,
-)
-from bpy.props import (
-    CollectionProperty,
-    IntProperty,
-    BoolProperty,
-)
-from bpy.app.handlers import persistent
-
-bl_info = {
-    "name": "VR Scene Inspection",
-    "author": "Julian Eisel (Severin), Sebastian Koenig",
-    "version": (0, 9, 0),
-    "blender": (2, 90, 0),
-    "location": "3D View > Sidebar > VR",
-    "description": ("View the viewport with virtual reality glasses "
-                    "(head-mounted displays)"),
-    "support": "OFFICIAL",
-    "warning": "This is an early, limited preview of in development "
-               "VR support for Blender.",
-    "doc_url": "{BLENDER_MANUAL_URL}/addons/3d_view/vr_scene_inspection.html",
-    "category": "3D View",
-}
-
-
- at persistent
-def ensure_default_vr_landmark(context: bpy.context):
-    # Ensure there's a default landmark (scene camera by default).
-    landmarks = bpy.context.scene.vr_landmarks
-    if not landmarks:
-        landmarks.add()
-        landmarks[0].type = 'SCENE_CAMERA'
-
-
-def xr_landmark_active_type_update(self, context):
-    wm = context.window_manager
-    session_settings = wm.xr_session_settings
-    landmark_active = VRLandmark.get_active_landmark(context)
-
-    # Update session's base pose type to the matching type.
-    if landmark_active.type == 'SCENE_CAMERA':
-        session_settings.base_pose_type = 'SCENE_CAMERA'
-    elif landmark_active.type == 'USER_CAMERA':
-        session_settings.base_pose_type = 'OBJECT'
-    elif landmark_active.type == 'CUSTOM':
-        session_settings.base_pose_type = 'CUSTOM'
-
-
-def xr_landmark_active_camera_update(self, context):
-    session_settings = context.window_manager.xr_session_settings
-    landmark_active = VRLandmark.get_active_landmark(context)
-
-    # Update the anchor object to the (new) camera of this landmark.
-    session_settings.base_pose_object = landmark_active.base_pose_camera
-
-
-def xr_landmark_active_base_pose_location_update(self, context):
-    session_settings = context.window_manager.xr_session_settings
-    landmark_active = VRLandmark.get_active_landmark(context)
-
-    session_settings.base_pose_location = landmark_active.base_pose_location
-
-
-def xr_landmark_active_base_pose_angle_update(self, context):
-    session_settings = context.window_manager.xr_session_settings
-    landmark_active = VRLandmark.get_active_landmark(context)
-
-    session_settings.base_pose_angle = landmark_active.base_pose_angle
-
-
-def xr_landmark_type_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:
-        xr_landmark_active_type_update(self, context)
-
-
-def xr_landmark_camera_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:
-        xr_landmark_active_camera_update(self, context)
-
-
-def xr_landmark_base_pose_location_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:
-        xr_landmark_active_base_pose_location_update(self, context)
-
-
-def xr_landmark_base_pose_angle_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:
-        xr_landmark_active_base_pose_angle_update(self, context)
-
-
-def xr_landmark_camera_object_poll(self, object):
-    return object.type == 'CAMERA'
-
-
-def xr_landmark_active_update(self, context):
-    wm = context.window_manager
-
-    xr_landmark_active_type_update(self, context)
-    xr_landmark_active_camera_update(self, context)
-    xr_landmark_active_base_pose_location_update(self, context)
-    xr_landmark_active_base_pose_angle_update(self, context)
-
-    if wm.xr_session_state:
-        wm.xr_session_state.reset_to_base_pose(context)
-
-
-class VIEW3D_MT_landmark_menu(Menu):
-    bl_label = "Landmark Controls"
-
-    def draw(self, _context):
-        layout = self.layout
-
-        layout.operator("view3d.vr_landmark_from_camera")
-        layout.operator("view3d.update_vr_landmark")
-        layout.separator()
-        layout.operator("view3d.cursor_to_vr_landmark")
-        layout.operator("view3d.camera_to_vr_landmark")
-        layout.operator("view3d.add_camera_from_vr_landmark")
-
-
-class VRLandmark(PropertyGroup):
-    name: bpy.props.StringProperty(
-        name="VR Landmark",
-        default="Landmark"
-    )
-    type: bpy.props.EnumProperty(
-        name="Type",
-        items=[
-            ('SCENE_CAMERA', "Scene Camera",
-             "Use scene's currently active camera to define the VR view base "
-             "location and rotation"),
-            ('USER_CAMERA', "Custom Camera",
-             "Use an existing camera to define the VR view base location and "
-             "rotation"),
-            ('CUSTOM', "Custom Pose",
-             "Allow a manually defined position and rotation to be used as "
-             "the VR view base pose"),
-        ],
-        default='SCENE_CAMERA',
-        update=xr_landmark_type_update,
-    )
-    base_pose_camera: bpy.props.PointerProperty(
-        name="Camera",
-        type=bpy.types.Object,
-        poll=xr_landmark_camera_object_poll,
-        update=xr_landmark_camera_update,
-    )
-    base_pose_location: bpy.props.FloatVectorProperty(
-        name="Base Pose Location",
-        subtype='TRANSLATION',
-        update=xr_landmark_base_pose_location_update,
-    )
-
-    base_pose_angle: bpy.props.FloatProperty(
-        name="Base Pose Angle",
-        subtype='ANGLE',
-        update=xr_landmark_base_pose_angle_update,
-    )
-
-    @staticmethod
-    def get_selected_landmark(context):
-        scene = context.scene
-        landmarks = scene.vr_landmarks
-
-        return (
-            None if (len(landmarks) <
-                     1) else landmarks[scene.vr_landmarks_selected]
-        )
-
-    @staticmethod
-    def get_active_landmark(context):
-        scene = context.scene
-        landmarks = scene.vr_landmarks
-
-        return (
-            None if (len(landmarks) <
-                     1) else landmarks[scene.vr_landmarks_active]
-        )
-
-
-class VIEW3D_UL_vr_landmarks(UIList):
-    def draw_item(self, context, layout, _data, item, icon, _active_data,
-                  _active_propname, index):
-        landmark = item
-        landmark_active_idx = context.scene.vr_landmarks_active
-
-        layout.emboss = 'NONE'
-
-        layout.prop(landmark, "name", text="")
-
-        icon = (
-            'RADIOBUT_ON' if (index == landmark_active_idx) else 'RADIOBUT_OFF'
-        )
-        props = layout.operator(
-            "view3d.vr_landmark_activate", text="", icon=icon)
-        props.index = index
-
-
-class VIEW3D_PT_vr_landmarks(Panel):
-    bl_space_type = 'VIEW_3D'
-    bl_region_type = 'UI'
-    bl_category = "VR"
-    bl_label = "Landmarks"
-    bl_options = {'DEFAULT_CLOSED'}
-
-    def draw(self, context):
-        layout = self.layout
-        scene = context.scene
-        landmark_selected = VRLandmark.get_selected_landmark(context)
-
-        layout.use_property_split = True
-        layout.use_property_decorate = False  # No animation.
-
-        row = layout.row()
-
-        row.template_list("VIEW3D_UL_vr_landmarks", "", scene, "vr_landmarks",
-                          scene, "vr_landmarks_selected", rows=3)
-
-        col = row.column(align=True)
-        col.operator("view3d.vr_landmark_add", icon='ADD', text="")
-        col.operator("view3d.vr_landmark_remove", icon='REMOVE', text="")
-        col.operator("view3d.vr_landmark_from_session", icon='PLUS', text="")
-
-        col.menu("VIEW3D_MT_landmark_menu", icon='DOWNARROW_HLT', text="")
-
-        if landmark_selected:
-            layout.prop(landmark_selected, "type")
-
-            if landmark_selected.type == 'USER_CAMERA':
-                layout.prop(landmark_selected, "base_pose_camera")
-            elif landmark_selected.type == 'CUSTOM':
-                layout.prop(landmark_selected,
-                            "base_pose_location", text="Location")
-                layout.prop(landmark_selected,
-                            "base_pose_angle", text="Angle")
-
-
-class VIEW3D_PT_vr_session_view(Panel):
-    bl_space_type = 'VIEW_3D'
-    bl_region_type = 'UI'
-    bl_category = "VR"
-    bl_label = "View"
-
-    def draw(self, context):
-    

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-extensions-cvs mailing list