I am trying to get familiar with the modal operators in blender and want to create some kind of custom trackball rotation. When I set the rotation euler values to the mouse_x and mouse_y event values, blender adds the absolute mouse position to the rotation values. Is there a possibility to start with 0 when I click the operator button?
def execute(self, context):
bpy.data.objects["Cube"].rotation_euler[0] = math.radians(self.value_z)
bpy.data.objects["Cube"].rotation_euler[2] = math.radians(self.value_x)
return {'FINISHED'}
def modal(self, context, event):
if event.type == 'MOUSEMOVE': # Apply
self.value_x = event.mouse_region_x
self.value_z = event.mouse_region_y
self.execute(context)