forked from LeenkxTeam/LNXSDK
added Mouse Look node for FSP style movement of object like camera...
This commit is contained in:
101
leenkx/blender/lnx/logicnode/input/LN_mouse_look.py
Normal file
101
leenkx/blender/lnx/logicnode/input/LN_mouse_look.py
Normal file
@ -0,0 +1,101 @@
|
||||
from lnx.logicnode.lnx_nodes import *
|
||||
|
||||
|
||||
class MouseLookNode(LnxLogicTreeNode):
|
||||
"""Controls object rotation based on mouse movement for FPS-style camera control.
|
||||
|
||||
Features:
|
||||
- Sub-pixel interpolation (always enabled) for optimal precision and smooth low-sensitivity movement
|
||||
- Resolution-adaptive scaling for consistent feel across different screen resolutions
|
||||
"""
|
||||
bl_idname = 'LNMouseLookNode'
|
||||
bl_label = 'Mouse Look'
|
||||
lnx_section = 'mouse'
|
||||
lnx_version = 1
|
||||
|
||||
# Front axis property
|
||||
property0: HaxeEnumProperty(
|
||||
'property0',
|
||||
items=[('X', 'X Axis', 'X Axis as front'),
|
||||
('Y', 'Y Axis', 'Y Axis as front'),
|
||||
('Z', 'Z Axis', 'Z Axis as front')],
|
||||
name='Front', default='Y')
|
||||
|
||||
# Hide Locked property
|
||||
property1: HaxeBoolProperty(
|
||||
'property1',
|
||||
name='Hide Locked',
|
||||
description='Automatically center and lock the mouse cursor',
|
||||
default=True)
|
||||
|
||||
# Invert X property
|
||||
property2: HaxeBoolProperty(
|
||||
'property2',
|
||||
name='Invert X',
|
||||
description='Invert horizontal mouse movement',
|
||||
default=False)
|
||||
|
||||
# Invert Y property
|
||||
property3: HaxeBoolProperty(
|
||||
'property3',
|
||||
name='Invert Y',
|
||||
description='Invert vertical mouse movement',
|
||||
default=False)
|
||||
|
||||
# Cap Left/Right property
|
||||
property4: HaxeBoolProperty(
|
||||
'property4',
|
||||
name='Cap Left / Right',
|
||||
description='Limit horizontal rotation',
|
||||
default=False)
|
||||
|
||||
# Cap Up/Down property
|
||||
property5: HaxeBoolProperty(
|
||||
'property5',
|
||||
name='Cap Up / Down',
|
||||
description='Limit vertical rotation',
|
||||
default=True)
|
||||
|
||||
# Strategy toggles
|
||||
property6: HaxeBoolProperty(
|
||||
'property6',
|
||||
name='Resolution Adaptive',
|
||||
description='Scale sensitivity based on screen resolution',
|
||||
default=False)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
def lnx_init(self, context):
|
||||
self.add_input('LnxNodeSocketAction', 'In')
|
||||
self.add_input('LnxNodeSocketObject', 'Body')
|
||||
self.add_input('LnxNodeSocketObject', 'Head')
|
||||
self.add_input('LnxFloatSocket', 'Sensitivity', default_value=0.5)
|
||||
self.add_input('LnxFloatSocket', 'Smoothing', default_value=0.0)
|
||||
|
||||
self.add_output('LnxNodeSocketAction', 'Out')
|
||||
|
||||
def draw_buttons(self, context, layout):
|
||||
layout.prop(self, 'property0', text='Front')
|
||||
layout.prop(self, 'property1', text='Hide Locked')
|
||||
|
||||
# Invert XY section
|
||||
col = layout.column(align=True)
|
||||
col.label(text="Invert XY:")
|
||||
row = col.row(align=True)
|
||||
row.prop(self, 'property2', text='X', toggle=True)
|
||||
row.prop(self, 'property3', text='Y', toggle=True)
|
||||
|
||||
# Cap rotations section
|
||||
col = layout.column(align=True)
|
||||
col.prop(self, 'property4', text='Cap Left / Right')
|
||||
col.prop(self, 'property5', text='Cap Up / Down')
|
||||
|
||||
# Separator
|
||||
layout.separator()
|
||||
|
||||
# Enhancement strategies section
|
||||
col = layout.column(align=True)
|
||||
col.label(text="Enhancement Strategies:")
|
||||
col.prop(self, 'property6', text='Resolution Adaptive')
|
Reference in New Issue
Block a user