Module Lamp

Source Code for Module Lamp

  1  # Blender.Lamp module and the Lamp PyType object 
  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
83 -class Lamp:
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 165 @warning: Most member variables assume values in some [Min, Max] interval. 166 When trying to set them, the given parameter will be clamped to lie in 167 that range: if val < Min, then val = Min, if val > Max, then val = Max. 168 """ 169
170 - def getName():
171 """ 172 Get the name of this Lamp Data object. 173 @rtype: string 174 """
175
176 - def setName(name):
177 """ 178 Set the name of this Lamp Data object. 179 @type name: string 180 @param name: The new name. 181 """
182
183 - def getType():
184 """ 185 Get this Lamp's type. 186 @rtype: int 187 """
188
189 - def setType(type):
190 """ 191 Set this Lamp's type. 192 @type type: string 193 @param type: The Lamp type: 'Lamp', 'Sun', 'Spot', 'Hemi', 'Area', or 'Photon' 194 """
195
196 - def getMode():
197 """ 198 Get this Lamp's mode flags. 199 @rtype: int 200 @return: B{OR'ed value}. Use the Modes dictionary to check which flags 201 are 'on'. 202 203 Example:: 204 flags = mylamp.getMode() 205 if flags & mylamp.Modes['Shadows']: 206 print "This lamp produces shadows" 207 else: 208 print "The 'Shadows' flag is off" 209 """
210
211 - def setMode(m = None, m2 = None, m3 = None, m4 = None, 212 m5 = None, m6 = None, m7 = None, m8 = None):
213 """ 214 Set this Lamp's mode flags. Mode strings given are turned 'on'. 215 Those not provided are turned 'off', so lamp.setMode() -- without 216 arguments -- turns off all mode flags for Lamp lamp. 217 @type m: string 218 @param m: A mode flag. From 1 to 8 can be set at the same time. 219 """
220
221 - def getSamples():
222 """ 223 Get this lamp's samples value. 224 @rtype: int 225 """
226
227 - def setSamples(samples):
228 """ 229 Set the samples value. 230 @type samples: int 231 @param samples: The new samples value. 232 """
233
234 - def getRaySamplesX():
235 """ 236 Get this lamp's raytracing sample value on the X axis. 237 This value is only used for area lamps. 238 @rtype: int 239 """
240
241 - def setRaySamplesX():
242 """ 243 Set the lamp's raytracing sample value on the X axis, between 1 and 16. 244 This value is only used for area lamps. 245 @rtype: int 246 """
247
248 - def getRaySamplesY():
249 """ 250 Get this lamp's raytracing sample value on the Y axis. 251 This value is only used for rectangle area lamps. 252 @rtype: int 253 """
254
255 - def setRaySamplesY():
256 """ 257 Set the lamp's raytracing sample value on the Y axis, between 1 and 16. 258 This value is only used for rectangle area lamps. 259 @rtype: int 260 """
261
262 - def getAreaSizeX():
263 """ 264 Get this lamp's size on the X axis. 265 This value is only used for area lamps. 266 @rtype: int 267 """
268
269 - def setAreaSizeX():
270 """ 271 Set this lamp's size on the X axis. 272 This value is only used for area lamps. 273 @rtype: int 274 """
275
276 - def getAreaSizeY():
277 """ 278 Get this lamp's size on the Y axis. 279 This value is only used for rectangle area lamps. 280 @rtype: int 281 """
282
283 - def setAreaSizeY():
284 """ 285 Set this lamp's size on the Y axis. 286 This value is only used for rectangle area lamps. 287 @rtype: int 288 """
289
290 - def getBufferSize():
291 """ 292 Get this lamp's buffer size. 293 @rtype: int 294 """
295
296 - def setBufferSize(bufsize):
297 """ 298 Set the buffer size value. 299 @type bufsize: int 300 @param bufsize: The new buffer size value. 301 """
302
303 - def getHaloStep():
304 """ 305 Get this lamp's halo step value. 306 @rtype: int 307 """
308
309 - def setHaloStep(hastep):
310 """ 311 Set the halo step value. 312 @type hastep: int 313 @param hastep: The new halo step value. 314 """
315
316 - def getEnergy():
317 """ 318 Get this lamp's energy intensity value. 319 @rtype: float 320 """
321
322 - def setEnergy(energy):
323 """ 324 Set the energy intensity value. 325 @type energy: float 326 @param energy: The new energy value. 327 """
328
329 - def getDist():
330 """ 331 Get this lamp's distance value. 332 @rtype: float 333 """
334
335 - def setDist(distance):
336 """ 337 Set the distance value. 338 @type distance: float 339 @param distance: The new distance value. 340 """
341
342 - def getSpotSize():
343 """ 344 Get this lamp's spot size value. 345 @rtype: float 346 """
347
348 - def setSpotSize(spotsize):
349 """ 350 Set the spot size value. 351 @type spotsize: float 352 @param spotsize: The new spot size value. 353 """
354
355 - def getSpotBlend():
356 """ 357 Get this lamp's spot blend value. 358 @rtype: float 359 """
360
361 - def setSpotBlend(spotblend):
362 """ 363 Set the spot blend value. 364 @type spotblend: float 365 @param spotblend: The new spot blend value. 366 """
367
368 - def getClipStart():
369 """ 370 Get this lamp's clip start value. 371 @rtype: float 372 """
373
374 - def setClipStart(clipstart):
375 """ 376 Set the clip start value. 377 @type clipstart: float 378 @param clipstart: The new clip start value. 379 """
380
381 - def getClipEnd():
382 """ 383 Get this lamp's clip end value. 384 @rtype: float 385 """
386
387 - def setClipEnd(clipend):
388 """ 389 Set the clip end value. 390 @type clipend: float 391 @param clipend: The new clip end value. 392 """
393
394 - def getBias():
395 """ 396 Get this lamp's bias value. 397 @rtype: float 398 """
399
400 - def setBias(bias):
401 """ 402 Set the bias value. 403 @type bias: float 404 @param bias: The new bias value. 405 """
406
407 - def getSoftness():
408 """ 409 Get this lamp's softness value. 410 @rtype: float 411 """
412
413 - def setSoftness(softness):
414 """ 415 Set the softness value. 416 @type softness: float 417 @param softness: The new softness value. 418 """
419
420 - def getHaloInt():
421 """ 422 Get this lamp's halo intensity value. 423 @rtype: float 424 """
425
426 - def setHaloInt(haloint):
427 """ 428 Set the halo intensity value. 429 @type haloint: float 430 @param haloint: The new halo intensity value. 431 """
432
433 - def getQuad1():
434 """ 435 Get this lamp's quad 1 value. 436 @rtype: float 437 @warning: this only applies to Lamps with the 'Quad' flag on. 438 """
439
440 - def setQuad1(quad1):
441 """ 442 Set the quad 1 value. 443 @type quad1: float 444 @warning: this only applies to Lamps with the 'Quad' flag on. 445 """
446
447 - def getQuad2():
448 """ 449 Get this lamp's quad 2 value. 450 @rtype: float 451 @warning: this only applies to Lamps with the 'Quad' flag on. 452 """
453
454 - def setQuad2(quad2):
455 """ 456 Set the quad 2 value. 457 @type quad2: float 458 @param quad2: The new quad 2 value. 459 @warning: this only applies to Lamps with the 'Quad' flag on. 460 """
461 471 479 488
489 - def getIpo():
490 """ 491 Get the Ipo associated with this Lamp object, if any. 492 @rtype: Ipo 493 @return: the wrapped ipo or None. 494 """
495
496 - def setIpo(ipo):
497 """ 498 Link an ipo to this Lamp object. 499 @type ipo: Blender Ipo 500 @param ipo: a "lamp data" ipo. 501 """
502
503 - def clearIpo():
504 """ 505 Unlink the ipo from this Lamp object. 506 @return: True if there was an ipo linked or False otherwise. 507 """
508
509 - def insertIpoKey(keytype):
510 """ 511 Inserts keytype values in lamp ipo at curframe. Uses module constants. 512 @type keytype: Integer 513 @param keytype: 514 -RGB 515 -ENERGY 516 -SPOTSIZE 517 -OFFSET 518 -SIZE 519 @return: None 520 """
521
522 - def __copy__ ():
523 """ 524 Make a copy of this lamp 525 @rtype: Lamp 526 @return: a copy of this lamp 527 """
528 529 import id_generics 530 Lamp.__doc__ += id_generics.attributes 531