2018-07-14 21:55:20 +00:00
|
|
|
# Example of a gizmo that activates an operator
|
|
|
|
# using the predefined dial gizmo to change the camera roll.
|
2017-06-26 05:57:14 +00:00
|
|
|
#
|
|
|
|
# Usage: Run this script and select a camera in the 3D view.
|
|
|
|
#
|
|
|
|
import bpy
|
|
|
|
from bpy.types import (
|
2018-07-14 21:55:20 +00:00
|
|
|
GizmoGroup,
|
2017-06-26 05:57:14 +00:00
|
|
|
)
|
|
|
|
|
2018-06-26 20:56:39 +00:00
|
|
|
|
2018-07-14 21:55:20 +00:00
|
|
|
class MyCameraWidgetGroup(GizmoGroup):
|
2018-07-15 12:24:10 +00:00
|
|
|
bl_idname = "OBJECT_GGT_test_camera"
|
2017-06-26 05:57:14 +00:00
|
|
|
bl_label = "Object Camera Test Widget"
|
|
|
|
bl_space_type = 'VIEW_3D'
|
|
|
|
bl_region_type = 'WINDOW'
|
|
|
|
bl_options = {'3D', 'PERSISTENT'}
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def poll(cls, context):
|
|
|
|
ob = context.object
|
|
|
|
return (ob and ob.type == 'CAMERA')
|
|
|
|
|
|
|
|
def setup(self, context):
|
2018-07-14 21:55:20 +00:00
|
|
|
# Run an operator using the dial gizmo
|
2017-06-26 05:57:14 +00:00
|
|
|
ob = context.object
|
2021-01-29 00:33:54 +00:00
|
|
|
gz = self.gizmos.new("GIZMO_GT_dial_3d")
|
|
|
|
props = gz.target_set_operator("transform.rotate")
|
2017-06-26 05:57:14 +00:00
|
|
|
props.constraint_axis = False, False, True
|
2019-02-28 01:30:06 +00:00
|
|
|
props.orient_type = 'LOCAL'
|
2017-06-26 05:57:14 +00:00
|
|
|
props.release_confirm = True
|
|
|
|
|
2021-01-29 00:33:54 +00:00
|
|
|
gz.matrix_basis = ob.matrix_world.normalized()
|
|
|
|
gz.line_width = 3
|
2017-06-26 05:57:14 +00:00
|
|
|
|
2021-01-29 00:33:54 +00:00
|
|
|
gz.color = 0.8, 0.8, 0.8
|
|
|
|
gz.alpha = 0.5
|
2017-07-17 05:06:18 +00:00
|
|
|
|
2021-01-29 00:33:54 +00:00
|
|
|
gz.color_highlight = 1.0, 1.0, 1.0
|
|
|
|
gz.alpha_highlight = 1.0
|
2017-06-26 05:57:14 +00:00
|
|
|
|
2021-01-29 00:33:54 +00:00
|
|
|
self.roll_gizmo = gz
|
2017-06-26 05:57:14 +00:00
|
|
|
|
|
|
|
def refresh(self, context):
|
|
|
|
ob = context.object
|
2021-01-29 00:33:54 +00:00
|
|
|
gz = self.roll_gizmo
|
|
|
|
gz.matrix_basis = ob.matrix_world.normalized()
|
2017-06-26 05:57:14 +00:00
|
|
|
|
2018-06-26 20:56:39 +00:00
|
|
|
|
2017-06-26 05:57:14 +00:00
|
|
|
bpy.utils.register_class(MyCameraWidgetGroup)
|