23
23
24
24
import bpy
25
25
from bpy .app .handlers import persistent
26
- from bpy .props import BoolProperty , IntProperty , StringProperty
26
+ from bpy .props import BoolProperty , IntProperty , StringProperty , EnumProperty
27
27
28
28
from .src .artnet_socket import ArtNetSocket
29
29
from .src .universe_store import UniverseStore , ALL_UNIVERSES
36
36
GLOBAL_DATA = {
37
37
ArtNetSocket : ArtNetSocket ,
38
38
BlenderSynchroniser : BlenderSynchroniser ,
39
- FixtureStore : FixtureStore
39
+ FixtureStore : FixtureStore ,
40
40
}
41
41
42
+ PAN_TILT_TARGETS = [
43
+ ('lx' , 'Light x' , 'tilt around light x axis' , 0 ),
44
+ ('ly' , 'Light y' , 'tilt around light y axis' , 1 ),
45
+ ('lz' , 'Light z' , 'tilt around light z axis' , 2 ),
46
+ None ,
47
+ ('px' , 'Parent x' , 'tilt around parent x axis' , 3 ),
48
+ ('py' , 'Parent y' , 'tilt around parent y axis' , 4 ),
49
+ ('pz' , 'Parent z' , 'tilt around parent z axis' , 5 ),
50
+ None ,
51
+ ('gpx' , 'Grandparent x' , 'tilt around grandparent x axis' , 6 ),
52
+ ('gpy' , 'Grandparent y' , 'tilt around grandparent y axis' , 7 ),
53
+ ('gpz' , 'Grandparent z' , 'tilt around grandparent z axis' , 8 ),
54
+ None ,
55
+ ('none' , 'Ignore' , 'ignore tilt from Artnet' , 9 )
56
+ ]
57
+
42
58
bl_info = {
43
59
"name" : "ArtNet Lighting Controller" ,
44
60
"description" : "Combine with Evee to get a real "
@@ -87,24 +103,70 @@ def register():
87
103
bpy .app .handlers .load_post .append (_on_file_loaded )
88
104
# add light properties
89
105
bpy .types .Light .artnet_enabled = BoolProperty (
90
- name = "artnet_enabled " ,
106
+ name = "Enabled " ,
91
107
update = _light_data_change
92
108
)
93
109
bpy .types .Light .artnet_universe = IntProperty (
94
- name = "artnet_universe " ,
110
+ name = "Universe " ,
95
111
update = _light_data_change
96
112
)
97
113
bpy .types .Light .artnet_fixture_type = StringProperty (
98
- name = "artnet_fixture_type " ,
114
+ name = "Fixture Type " ,
99
115
update = _light_data_change
100
116
)
101
117
bpy .types .Light .artnet_base_address = IntProperty (
102
- name = "artnet_base_address " ,
118
+ name = "Base DMX Address " ,
103
119
update = _light_data_change
104
120
)
121
+ bpy .types .Light .artnet_pan_target = EnumProperty (
122
+ name = "Pan Target" ,
123
+ items = PAN_TILT_TARGETS ,
124
+ default = "lx" ,
125
+ update = _light_data_change ,
126
+ get = get_pan_target ,
127
+ set = set_pan_target
128
+ )
129
+ bpy .types .Light .artnet_tilt_target = EnumProperty (
130
+ name = "Tilt Target" ,
131
+ items = PAN_TILT_TARGETS ,
132
+ default = "lz" ,
133
+ update = _light_data_change ,
134
+ get = get_tilt_target ,
135
+ set = set_tilt_target
136
+ )
137
+ bpy .types .Light .artnet_old_pan_target = EnumProperty (
138
+ name = "Old Pan Target" ,
139
+ items = PAN_TILT_TARGETS ,
140
+ default = "none"
141
+ )
142
+ bpy .types .Light .artnet_old_tilt_target = EnumProperty (
143
+ name = "Old Tilt Target" ,
144
+ items = PAN_TILT_TARGETS ,
145
+ default = "none"
146
+ )
105
147
# register UI Panel
106
148
bpy .utils .register_class (LightArtNetPanel )
107
149
150
+ def get_pan_target (self ):
151
+ return self .get ("artnet_pan_target" , "lz" )
152
+
153
+ def set_pan_target (self , value ):
154
+ self .artnet_old_pan_target = get_pan_tilt_target_from_int (self .get ("artnet_pan_target" , 9 ))
155
+ self ["artnet_pan_target" ] = value
156
+
157
+ def get_pan_tilt_target_from_int (value ):
158
+ for target in PAN_TILT_TARGETS :
159
+ if target is not None :
160
+ if target [3 ] == value :
161
+ return target [0 ]
162
+
163
+ def get_tilt_target (self ):
164
+ return self .get ("artnet_tilt_target" , "lx" )
165
+
166
+ def set_tilt_target (self , value ):
167
+ self .artnet_old_tilt_target = get_pan_tilt_target_from_int (self .get ("artnet_tilt_target" , 9 ))
168
+ self ["artnet_tilt_target" ] = value
169
+
108
170
def unregister ():
109
171
"""Called from Blender"""
110
172
if GLOBAL_DATA ["ArtNetSocket" ] is not None :
@@ -119,6 +181,8 @@ def unregister():
119
181
del bpy .types .Light .artnet_fixture_type
120
182
del bpy .types .Light .artnet_universe
121
183
del bpy .types .Light .artnet_base_address
184
+ del bpy .types .Light .artnet_pan_target
185
+ del bpy .types .Light .artnet_tilt_target
122
186
123
187
def _light_data_change (data , context ):
124
188
"""One of the lights changed in the scene - update our internal data"""
0 commit comments