1
2
3 """
4 The Blender.Lamp submodule.
5
6 B{New}: L{Lamp.clearScriptLinks} accepts a parameter now.
7
8 Lamp Data
9 =========
10
11 This module provides control over B{Lamp Data} objects in Blender.
12
13 Example::
14
15 from Blender import Lamp, Scene
16 l = Lamp.New('Spot') # create new 'Spot' lamp data
17 l.setMode('Square', 'Shadow') # set these two lamp mode flags
18 scn = Scene.GetCurrent()
19 ob = scn.objects.new(l)
20
21 @type Types: read-only dictionary
22 @var Types: The lamp types.
23 - 'Lamp': 0
24 - 'Sun' : 1
25 - 'Spot': 2
26 - 'Hemi': 3
27 - 'Area': 4
28 - 'Photon': 5
29 @type Falloffs: read-only dictionary
30 @var Falloffs: The lamp falloff types.
31 - CONSTANT - Constant falloff
32 - INVLINEAR - Inverse linear
33 - INVSQUARE - Inverse square
34 - CUSTOM - Custom curve
35 - LINQUAD - Lin/Quad weighted
36 @type Modes: read-only dictionary
37 @var Modes: The lamp modes. Modes may be ORed together.
38 - 'Shadows'
39 - 'Halo'
40 - 'Layer'
41 - 'Quad'
42 - 'Negative'
43 - 'OnlyShadow'
44 - 'Sphere'
45 - 'Square'
46 - 'NoDiffuse'
47 - 'NoSpecular'
48 - 'RayShadow'
49
50 Example::
51 from Blender import Lamp, Object
52 # Change the mode of selected lamp objects.
53 for ob in Object.GetSelected(): # Loop through the current selection
54 if ob.getType() == "Lamp": # if this is a lamp.
55 lamp = ob.getData() # get the lamp data.
56 if lamp.type == Lamp.Types["Spot"]: # Lamp type is not a flag
57 lamp.mode &= ~Lamp.Modes["RayShadow"] # Disable RayShadow.
58 lamp.mode |= Lamp.Modes["Shadows"] # Enable Shadowbuffer shadows
59 """
60
61 -def New (type = 'Lamp', name = 'LampData'):
62 """
63 Create a new Lamp Data object.
64 @type type: string
65 @param type: The Lamp type: 'Lamp', 'Sun', 'Spot', 'Hemi', 'Area', or 'Photon'.
66 @type name: string
67 @param name: The Lamp Data name.
68 @rtype: Blender Lamp
69 @return: The created Lamp Data object.
70 """
71
72 -def Get (name = None):
73 """
74 Get the Lamp Data object(s) from Blender.
75 @type name: string
76 @param name: The name of the Lamp Data.
77 @rtype: Blender Lamp or a list of Blender Lamps
78 @return: It depends on the I{name} parameter:
79 - (name): The Lamp Data object with the given I{name};
80 - (): A list with all Lamp Data objects in the current scene.
81 """
82
84 """
85 The Lamp Data object
86 ====================
87 This object gives access to Lamp-specific data in Blender.
88
89 @ivar B: Lamp color blue component.
90 Value is clamped to the range [0.0,1.0].
91 @type B: float
92 @ivar G: Lamp color green component.
93 Value is clamped to the range [0.0,1.0].
94 @type G: float
95 @ivar R: Lamp color red component.
96 Value is clamped to the range [0.0,1.0].
97 @type R: float
98 @ivar bias: Lamp shadow map sampling bias.
99 Value is clamped to the range [0.01,5.0].
100 @type bias: float
101 @ivar bufferSize: Lamp shadow buffer size.
102 Value is clamped to the range [512,5120].
103 @type bufferSize: int
104 @ivar clipEnd: Lamp shadow map clip end.
105 Value is clamped to the range [1.0,5000.0].
106 @type clipEnd: float
107 @ivar clipStart: Lamp shadow map clip start.
108 Value is clamped to the range [0.1,1000.0].
109 @type clipStart: float
110 @ivar col: Lamp RGB color triplet.
111 Components are clamped to the range [0.0,1.0].
112 @type col: RGB tuple
113 @ivar dist: Lamp clipping distance.
114 Value is clamped to the range [0.1,5000.0].
115 @type dist: float
116 @ivar energy: Lamp light intensity.
117 Value is clamped to the range [0.0,10.0].
118 @type energy: float
119 @ivar haloInt: Lamp spotlight halo intensity.
120 Value is clamped to the range [0.0,5.0].
121 @type haloInt: float
122 @ivar haloStep: Lamp volumetric halo sampling frequency.
123 Value is clamped to the range [0,12].
124 @type haloStep: int
125 @ivar ipo: Lamp Ipo.
126 Contains the Ipo if one is assigned to the object, B{None} otherwise. Setting to B{None} clears the current Ipo..
127 @type ipo: Blender Ipo
128 @ivar mode: Lamp mode bitfield. See L{Modes} for values.
129 @type mode: int
130 @ivar quad1: Quad lamp linear distance attenuation.
131 Value is clamped to the range [0.0,1.0].
132 @type quad1: float
133 @ivar quad2: Quad lamp quadratic distance attenuation.
134 Value is clamped to the range [0.0,1.0].
135 @type quad2: float
136 @ivar samples: Lamp shadow map samples.
137 Value is clamped to the range [1,16].
138 @type samples: int
139 @ivar raySamplesX: Lamp raytracing X samples (X is used for the Y axis with square area lamps).
140 Value is clamped to the range [1,16].
141 @type raySamplesX: int
142 @ivar raySamplesY: Lamp raytracing Y samples (Y is only used for rectangle area lamps).
143 Value is clamped to the range [1,16].
144 @type raySamplesY: int
145 @ivar areaSizeX: Lamp X size (X is used for the Y axis with square area lamps)
146 Value is clamped to the range [0.01,100.0].
147 @type areaSizeX: float
148 @ivar areaSizeY: Lamp Y size (Y is only used for rectangle area lamps).
149 Value is clamped to the range [0.01,100.0].
150 @type areaSizeY: float
151 @ivar softness: Lamp shadow sample area size.
152 Value is clamped to the range [1.0,100.0].
153 @type softness: float
154 @ivar spotBlend: Lamp spotlight edge softness.
155 Value is clamped to the range [0.0,1.0].
156 @type spotBlend: float
157 @ivar spotSize: Lamp spotlight beam angle (in degrees).
158 Value is clamped to the range [1.0,180.0].
159 @type spotSize: float
160 @ivar type: Lamp type. See L{Types} for values.
161 @type type: int
162 @ivar falloffType: Lamp falloff type. See L{Falloffs} for values.
163 @type falloffType: int
164 @type textures: a tuple of Blender MTex objects.
165 @ivar textures: The Lamp's texture list. Empty texture channels contains None.
166
167 @warning: Most member variables assume values in some [Min, Max] interval.
168 When trying to set them, the given parameter will be clamped to lie in
169 that range: if val < Min, then val = Min, if val > Max, then val = Max.
170 """
171
173 """
174 Get the name of this Lamp Data object.
175 @rtype: string
176 """
177
179 """
180 Set the name of this Lamp Data object.
181 @type name: string
182 @param name: The new name.
183 """
184
186 """
187 Get this Lamp's type.
188 @rtype: int
189 """
190
192 """
193 Set this Lamp's type.
194 @type type: string
195 @param type: The Lamp type: 'Lamp', 'Sun', 'Spot', 'Hemi', 'Area', or 'Photon'
196 """
197
199 """
200 Get this Lamp's mode flags.
201 @rtype: int
202 @return: B{OR'ed value}. Use the Modes dictionary to check which flags
203 are 'on'.
204
205 Example::
206 flags = mylamp.getMode()
207 if flags & mylamp.Modes['Shadows']:
208 print "This lamp produces shadows"
209 else:
210 print "The 'Shadows' flag is off"
211 """
212
213 - def setMode(m = None, m2 = None, m3 = None, m4 = None,
214 m5 = None, m6 = None, m7 = None, m8 = None):
215 """
216 Set this Lamp's mode flags. Mode strings given are turned 'on'.
217 Those not provided are turned 'off', so lamp.setMode() -- without
218 arguments -- turns off all mode flags for Lamp lamp.
219 @type m: string
220 @param m: A mode flag. From 1 to 8 can be set at the same time.
221 """
222
224 """
225 Get this lamp's samples value.
226 @rtype: int
227 """
228
230 """
231 Set the samples value.
232 @type samples: int
233 @param samples: The new samples value.
234 """
235
237 """
238 Get this lamp's raytracing sample value on the X axis.
239 This value is only used for area lamps.
240 @rtype: int
241 """
242
244 """
245 Set the lamp's raytracing sample value on the X axis, between 1 and 16.
246 This value is only used for area lamps.
247 @rtype: int
248 """
249
251 """
252 Get this lamp's raytracing sample value on the Y axis.
253 This value is only used for rectangle area lamps.
254 @rtype: int
255 """
256
258 """
259 Set the lamp's raytracing sample value on the Y axis, between 1 and 16.
260 This value is only used for rectangle area lamps.
261 @rtype: int
262 """
263
265 """
266 Get this lamp's size on the X axis.
267 This value is only used for area lamps.
268 @rtype: int
269 """
270
272 """
273 Set this lamp's size on the X axis.
274 This value is only used for area lamps.
275 @rtype: int
276 """
277
279 """
280 Get this lamp's size on the Y axis.
281 This value is only used for rectangle area lamps.
282 @rtype: int
283 """
284
286 """
287 Set this lamp's size on the Y axis.
288 This value is only used for rectangle area lamps.
289 @rtype: int
290 """
291
293 """
294 Get this lamp's buffer size.
295 @rtype: int
296 """
297
299 """
300 Set the buffer size value.
301 @type bufsize: int
302 @param bufsize: The new buffer size value.
303 """
304
306 """
307 Get this lamp's halo step value.
308 @rtype: int
309 """
310
312 """
313 Set the halo step value.
314 @type hastep: int
315 @param hastep: The new halo step value.
316 """
317
319 """
320 Get this lamp's energy intensity value.
321 @rtype: float
322 """
323
325 """
326 Set the energy intensity value.
327 @type energy: float
328 @param energy: The new energy value.
329 """
330
332 """
333 Get this lamp's distance value.
334 @rtype: float
335 """
336
338 """
339 Set the distance value.
340 @type distance: float
341 @param distance: The new distance value.
342 """
343
345 """
346 Get this lamp's spot size value.
347 @rtype: float
348 """
349
351 """
352 Set the spot size value.
353 @type spotsize: float
354 @param spotsize: The new spot size value.
355 """
356
358 """
359 Get this lamp's spot blend value.
360 @rtype: float
361 """
362
364 """
365 Set the spot blend value.
366 @type spotblend: float
367 @param spotblend: The new spot blend value.
368 """
369
371 """
372 Get this lamp's clip start value.
373 @rtype: float
374 """
375
377 """
378 Set the clip start value.
379 @type clipstart: float
380 @param clipstart: The new clip start value.
381 """
382
384 """
385 Get this lamp's clip end value.
386 @rtype: float
387 """
388
390 """
391 Set the clip end value.
392 @type clipend: float
393 @param clipend: The new clip end value.
394 """
395
397 """
398 Get this lamp's bias value.
399 @rtype: float
400 """
401
403 """
404 Set the bias value.
405 @type bias: float
406 @param bias: The new bias value.
407 """
408
410 """
411 Get this lamp's softness value.
412 @rtype: float
413 """
414
416 """
417 Set the softness value.
418 @type softness: float
419 @param softness: The new softness value.
420 """
421
423 """
424 Get this lamp's halo intensity value.
425 @rtype: float
426 """
427
429 """
430 Set the halo intensity value.
431 @type haloint: float
432 @param haloint: The new halo intensity value.
433 """
434
436 """
437 Get this lamp's quad 1 value.
438 @rtype: float
439 @warning: this only applies to Lamps with the 'Quad' flag on.
440 """
441
443 """
444 Set the quad 1 value.
445 @type quad1: float
446 @warning: this only applies to Lamps with the 'Quad' flag on.
447 """
448
450 """
451 Get this lamp's quad 2 value.
452 @rtype: float
453 @warning: this only applies to Lamps with the 'Quad' flag on.
454 """
455
457 """
458 Set the quad 2 value.
459 @type quad2: float
460 @param quad2: The new quad 2 value.
461 @warning: this only applies to Lamps with the 'Quad' flag on.
462 """
463
465 """
466 Get a list with this Lamp's script links of type 'event'.
467 @type event: string
468 @param event: "FrameChanged", "Redraw" or "Render".
469 @rtype: list
470 @return: a list with Blender L{Text} names (the script links of the given
471 'event' type) or None if there are no script links at all.
472 """
473
475 """
476 Delete script links from this Lamp. If no list is specified, all
477 script links are deleted.
478 @type links: list of strings
479 @param links: None (default) or a list of Blender L{Text} names.
480 """
481
483 """
484 Add a new script link to this Lamp.
485 @type text: string
486 @param text: the name of an existing Blender L{Text}.
487 @type event: string
488 @param event: "FrameChanged", "Redraw" or "Render".
489 """
490
492 """
493 Get the Ipo associated with this Lamp object, if any.
494 @rtype: Ipo
495 @return: the wrapped ipo or None.
496 """
497
499 """
500 Link an ipo to this Lamp object.
501 @type ipo: Blender Ipo
502 @param ipo: a "lamp data" ipo.
503 """
504
506 """
507 Unlink the ipo from this Lamp object.
508 @return: True if there was an ipo linked or False otherwise.
509 """
510
512 """
513 Inserts keytype values in lamp ipo at curframe. Uses module constants.
514 @type keytype: Integer
515 @param keytype:
516 -RGB
517 -ENERGY
518 -SPOTSIZE
519 -OFFSET
520 -SIZE
521 @return: None
522 """
523
525 """
526 Make a copy of this lamp
527 @rtype: Lamp
528 @return: a copy of this lamp
529 """
530
531 import id_generics
532 Lamp.__doc__ += id_generics.attributes
533