Module Effect

Source Code for Module Effect

  1  # Blender.Effect module and the Effect PyType effect 
  2   
  3  """ 
  4  The Blender.Effect submodule 
  5   
  6  B{Deprecated}: 
  7  This module is now maintained but not actively developed. 
  8   
  9  Effect 
 10  ====== 
 11   
 12  INTRODUCTION 
 13   
 14  The Effect module allows you to access all the data of particle effects. 
 15  An effect can modify a mesh object using particles, where vertex of 
 16  the mesh emits particles, which can themselves emit new particles. 
 17   
 18  In the Blender internals, the effect object is just a placeholder for 
 19  the particle effect.  Prior to v2.39 build and wave effects were also 
 20  supported by Blender, and the Python API supported all three types of 
 21  effects.  They were removed in v2.39 when the build and wave modifiers 
 22  were implemented. 
 23   
 24   
 25  Example:: 
 26    import Blender 
 27      listffects = Blender.Effect.Get() 
 28      print listeffects 
 29      eff = listeffects[0] 
 30      #we suppose the first effect is a build effect 
 31      print eff.getLen() 
 32      eff.setLen(500)      
 33   
 34  @type Flags: read-only dictionary 
 35  @var Flags: The particle effect flags.  Values can be ORed. 
 36    - SELECTED: The particle effect is selected in the UI. (Read-only) 
 37    - BSPLINE: Use a B-spline formula for particle interpolation 
 38    - STATIC: Make static particles 
 39    - ANIMATED: Recalculate static particles for each rendered frame 
 40    - VERTS: Emit particles from vertices 
 41    - FACES: Emit particles from faces 
 42    - EVENDIST: Use even distribution based on face area (requires FACES) 
 43    - TRUERAND: Use true random distribution based on face area (requires FACES) 
 44    - UNBORN: Make particles appear before they are emitted 
 45    - DIED: Make particles appear after they have died 
 46    - EMESH: Render emitter mesh 
 47   
 48  @type SpeedTypes: read-only dictionary 
 49  @var SpeedTypes: The available settings for selecting particle speed vectors. 
 50  Only one setting is active at a time. 
 51    - INTENSITY: Use texture intensity 
 52    - RGB: Use RGB values 
 53    - GRADIENT: Use texture gradient 
 54  """ 
 55   
56 -def New (name):
57 """ 58 Creates a new particle effect and attaches to an object. 59 @type name: string 60 @param name: The name of object to associate with the effect. Only mesh 61 objects are supported. 62 @rtype: Blender Effect 63 @return: the new effect 64 """
65
66 -def Get (name = None, position = None):
67 """ 68 Get an Effect from Blender. 69 @type name: string 70 @param name: The name of object linked to the effect. 71 @type position: int 72 @param position: The position of the effect in the list of effects linked to the object. 73 @rtype: Blender Effect or a list of Blender Effects 74 @return: It depends on the 'objname, position' parameters: 75 - (): A list with all Effects in the current scene; 76 - (name): A list with all Effects linked to the given object; 77 - (name, position): The Effect linked to the given object at the given position 78 """
79
80 -class Effect:
81 """ 82 The Effect object 83 ================= 84 This object gives access to particle effect data in Blender. 85 86 @ivar child: The number of children a particle may have. 87 Values are clamped to the range [1,600]. 88 @type child: tuple of 4 ints 89 @ivar childMat: The materials used by the 4 generation particles. 90 Values are clamped to the range [1,16]. 91 @type childMat: tuple of 4 ints 92 @ivar damping: The particle damping factor. This controls the rate at 93 which particles decelerate. 94 Values are clamped to the range [0.0,1.0]. 95 @type damping: float 96 @ivar defvec: The x, y and z axis of the force defined by the texture. 97 Values are clamped to the range [-1.0,1.0]. 98 @type defvec: tuple of 3 floats 99 @ivar disp: The percentage of particles displayed. 100 Value is clamped to the range [0,100]. 101 @type disp: int 102 @ivar dispMat: The material used for the particles. 103 Value is clamped to the range [1,16]. 104 @type dispMat: int 105 @ivar emissionTex: The texture used for texture emission. 106 Value is clamped to the range [1,10]. 107 @type emissionTex: int 108 @ivar end: The end time of the effect. 109 Value is clamped to the range [1.0,30000.0]. 110 @type end: float 111 @ivar flag: The flag bitfield. See L{Flags} for values. 112 @type flag: int 113 @ivar force: The constant force applied to the parts. 114 Values are clamped to the range [-1.0,1.0]. 115 @type force: tuple of 3 floats 116 @ivar forceTex: The texture used for force. 117 Value is clamped to the range [1,10]. 118 @type forceTex: int 119 @ivar jitter: Jitter table distribution: maximum particles per face. 120 Values are clamped to the range [0,200]. 121 @type jitter: int 122 @ivar life: The lifetime of of the next generation of particles. 123 Values are clamped to the range [1.0,30000.0]. 124 @type life: tuple of 4 floats 125 @ivar lifetime: The lifetime of the effect. 126 Value is clamped to the range [1.0,30000.0]. 127 @type lifetime: float 128 @ivar mult: The probabilities of a particle having a child. 129 Values are clamped to the range [0.0,1.0]. 130 @type mult: tuple of 4 floats 131 @ivar nabla: The nabla value. 132 Value is clamped to the range [0.0001,1.0]. 133 @type nabla: float 134 @ivar normfac: The normal strength of the particles relative to mesh. 135 Value is clamped to the range [-2.0,2.0]. 136 @type normfac: float 137 @ivar obfac: The strength of the particles relative to objects. 138 Value is clamped to the range [-1.0,1.0]. 139 @type obfac: float 140 @ivar randfac: The initial random speed of the particles. 141 Value is clamped to the range [0.0,2.0]. 142 @type randfac: float 143 @ivar randlife: The variability of the life of the particles. 144 Value is clamped to the range [0.0,2.0]. 145 @type randlife: float 146 @ivar seed: The seed of the random number generator. 147 Value is clamped to the range [0,255]. 148 @type seed: int 149 @ivar speedType: Controls which texture property affects particle speeds. 150 See L{SpeedTypes} for values and their meanings. 151 @type speedType: int 152 @ivar speedVGroup: The name of the vertex group used for speed control. 153 @type speedVGroup: str 154 @ivar sta: The start time of the effect. 155 Value is clamped to the range [-250.0,30000.0]. 156 @type sta: float 157 @ivar staticStep: percentage of skipped particles in static display. 158 Value is clamped to the range [1,100]. 159 @type staticStep: int 160 @ivar stype: The bitfield for vector. 161 @type stype: int 162 @ivar texfac: The initial speed of the particles caused by the texture. 163 Value is clamped to the range [0.0,2.0]. 164 @type texfac: float 165 @ivar totpart: The total number of particles. 166 Value is clamped to the range [1,100000]. 167 @type totpart: int 168 @ivar totkey: The total number of key positions. 169 Value is clamped to the range [1,100]. 170 @type totkey: int 171 @ivar type: The type of the effect. Deprecated. 172 @type type: int 173 @ivar vectsize: The size of vectors associated to the particles (if any). 174 Value is clamped to the range [0.0,1.0]. 175 @type vectsize: float 176 @ivar vGroup: The name of the vertex group used for emitted particles. 177 @type vGroup: str 178 """ 179
180 - def getType():
181 """ 182 Retrieves the type of an effect object. 183 Deprecated, since only particle effects are supported. 184 @rtype: int 185 @return: the type of an effect object : should always return 1 186 (particle effect) 187 """
188
189 - def setType(name):
190 """ 191 Deprecated, since only particle effects are supported. 192 @type name: int 193 @param name : the new type. 194 @rtype: None 195 @return: None 196 """
197
198 - def getFlag():
199 """ 200 Retrieves the flag of an effect object. The flag is a bit-mask. 201 @rtype: int 202 @return: The flag of the effect is a combination of parameters. See 203 L{Flags} for values. 204 205 """
206
207 - def setFlag(newflag):
208 """ 209 Sets the flag of an effect object. See L{Flags} for values. 210 @type newflag: int 211 @param newflag: the new flag. 212 @rtype: None 213 @return: None 214 """
215
216 - def getStartTime():
217 """ 218 Retrieves the starting time of a particle effect object 219 @rtype: float 220 @return: the starting time of the effect. 221 """
222
223 - def setSta(newstart):
224 """ 225 Sets the starting time of an particle effect object 226 @type newstart: float 227 @param newstart: the new starting time. 228 @rtype: None 229 @return: None 230 """
231
232 - def getEndTime():
233 """ 234 Retrieves the end time of a particle effect object 235 @rtype: float 236 @return: the end time of the effect. 237 """
238
239 - def setEnd(newendrt):
240 """ 241 Sets the end time of an particle effect object 242 @type newendrt: float 243 @param newendrt: the new end time. 244 @rtype: None 245 @return: None 246 """
247
248 - def getLifetime():
249 """ 250 Retrieves the lifetime of a particle effect object 251 @rtype: float 252 @return: the lifetime of the effect. 253 """
254 255
256 - def setLifetime(newlifetime):
257 """ 258 Sets the lifetime of a particle effect object 259 @type newlifetime: float 260 @param newlifetime: the new lifetime. 261 @rtype: None 262 @return: None 263 """
264
265 - def getNormfac():
266 """ 267 Retrieves the normal strength of the particles (relatively to mesh). 268 @rtype: float 269 @return: normal strength of the particles (relatively to mesh). 270 """
271
272 - def setNormfac(newnormfac):
273 """ 274 Sets the normal strength of the particles (relatively to mesh). 275 @type newnormfac: float 276 @param newnormfac: the normal strength of the particles (relatively to mesh). 277 @rtype: None 278 @return: None 279 """
280
281 - def getObfac():
282 """ 283 Retrieves the initial strength of the particles relatively to objects. 284 @rtype: float 285 @return: initial strength of the particles (relatively to mesh). 286 """
287
288 - def setObfac(newobfac):
289 """ 290 Sets the initial strength of the particles relatively to objects. 291 @type newobfac: float 292 @param newobfac: the initial strength of the particles relatively to objects. 293 @rtype: None 294 @return: None 295 """
296
297 - def getRandfac():
298 """ 299 Retrieves the random strength applied to the particles. 300 @rtype: float 301 @return: random strength applied to the particles. 302 """
303
304 - def setRandfac(newrandfac):
305 """ 306 Sets the random strength applied to the particles. 307 @type newrandfac: float 308 @param newrandfac: the random strength applied to the particles. 309 @rtype: None 310 @return: None 311 """
312
313 - def getStype():
314 """ 315 Retrieves the vect state of an effect object. 316 @rtype: int 317 @return: the Stype (Vect) of an effect object : 0 , Vect is not enabled, 1, Vect is enabled 318 (particle effect) 319 """
320
321 - def setStype(int):
322 """ 323 @type int : int 324 @param int : state of the Stype : 0 not enabled, 1 enabled. 325 @rtype: None 326 @return: None 327 """
328
329 - def getTexfac():
330 """ 331 Retrieves the strength applied to the particles from the texture of the object. 332 @rtype: float 333 @return: strength applied to the particles from the texture of the object. 334 """
335
336 - def setTexfac(newtexfac):
337 """ 338 Sets the strength applied to the particles from the texture of the object. 339 @type newtexfac: float 340 @param newtexfac: the strength applied to the particles from the texture of the object. 341 @rtype: None 342 @return: None 343 """
344
345 - def getRandlife():
346 """ 347 Retrieves the variability of the life of the particles. 348 @rtype: float 349 @return: variability of the life of the particles. 350 """
351
352 - def setRandlife(newrandlife):
353 """ 354 Sets the variability of the life of the particles. 355 @type newrandlife: float 356 @param newrandlife: the variability of the life of the particles. 357 @rtype: None 358 @return: None 359 """
360
361 - def getNabla():
362 """ 363 Retrieves the sensibility of the particles to the variations of the texture. 364 @rtype: float 365 @return: sensibility of the particles to the variations of the texture. 366 """
367 368
369 - def setNabla(newnabla):
370 """ 371 Sets the sensibility of the particles to the variations of the texture. 372 @type newnabla: float 373 @param newnabla: the sensibility of the particles to the variations of the texture. 374 @rtype: None 375 @return: None 376 """
377
378 - def getVectsize():
379 """ 380 Retrieves the size of the vector which is associated to the particles. 381 @rtype: float 382 @return: size of the vector which is associated to the particles. 383 """
384 385
386 - def setVectsize(newvectsize):
387 """ 388 Sets the size of the vector which is associated to the particles. 389 @type newvectsize: float 390 @param newvectsize: the size of the vector which is associated to the particles. 391 @rtype: None 392 @return: None 393 """
394
395 - def getTotpart():
396 """ 397 Retrieves the total number of particles. 398 @rtype: int 399 @return: the total number of particles. 400 """
401 402
403 - def setTotpart(newtotpart):
404 """ 405 Sets the the total number of particles. 406 @type newtotpart: int 407 @param newtotpart: the the total number of particles. 408 @rtype: None 409 @return: None 410 """
411
412 - def getTotkey():
413 """ 414 Retrieves the number of keys associated to the particles (kind of degree of freedom) 415 @rtype: int 416 @return: number of keys associated to the particles. 417 """
418
419 - def setTotkey(newtotkey):
420 """ 421 Sets the number of keys associated to the particles. 422 @type newtotkey: int 423 @param newtotkey: number of keys associated to the particles. 424 @rtype: None 425 @return: None 426 """
427
428 - def getSeed():
429 """ 430 Retrieves the random number generator seed. 431 @rtype: int 432 @return: current seed value. 433 """
434
435 - def setSeed(newseed):
436 """ 437 Sets the random number generator seed. 438 @type newseed: int 439 @param newseed: new seed value. 440 @rtype: None 441 @return: None 442 """
443
444 - def getForce():
445 """ 446 Retrieves the force applied to the particles. 447 @rtype: tuple of three floats 448 @return: force applied to the particles. 449 """
450
451 - def setForce(newforce):
452 """ 453 Sets the force applied to the particles. 454 @type newforce: tuple of 3 floats 455 @param newforce: force applied to the particles. 456 @rtype: None 457 @return: None 458 """
459
460 - def getMult():
461 """ 462 Retrieves the probabilities of a particle having a child. 463 @rtype: tuple of 4 floats 464 @return: probabilities of a particle having a child. 465 """
466
467 - def setMult(newmult):
468 """ 469 Sets the probabilities of a particle having a child. 470 @type newmult: tuple of 4 floats 471 @param newmult: probabilities of a particle having a child. 472 @rtype: None 473 @return: None 474 """
475
476 - def getLife():
477 """ 478 Retrieves the average life of the particles (4 generations) 479 @rtype: tuple of 4 floats 480 @return: average life of the particles (4 generations) 481 """
482
483 - def setLife(newlife):
484 """ 485 Sets the average life of the particles (4 generations). 486 @type newlife: tuple of 4 floats 487 @param newlife: average life of the particles (4 generations). 488 @rtype: None 489 @return: None 490 """
491
492 - def getChild():
493 """ 494 Retrieves the average number of children of the particles (4 generations). 495 @rtype: tuple of 4 ints 496 @return: average number of children of the particles (4 generations). 497 """
498
499 - def setChild(newchild):
500 """ 501 Sets the average number of children of the particles (4 generations). 502 @type newchild: tuple of 4 ints 503 @param newchild: average number of children of the particles (4 generations). 504 @rtype: None 505 @return: None 506 """
507
508 - def getMat():
509 """ 510 Retrieves the indexes of the materials associated to the particles (4 generations). 511 @rtype: tuple of 4 ints 512 @return: indexes of the materials associated to the particles (4 generations). 513 """
514
515 - def setMat(newmat):
516 """ 517 Sets the indexes of the materials associated to the particles (4 generations). 518 @type newmat: tuple of 4 ints 519 @param newmat: the indexes of the materials associated to the particles (4 generations). 520 @rtype: None 521 @return: None 522 """
523
524 - def getDefvec():
525 """ 526 Retrieves the x, y and z components of the force defined by the texture. 527 @rtype: tuple of 3 floats 528 @return: x, y and z components of the force defined by the texture. 529 """
530
531 - def setDefvec(newdefvec):
532 """ 533 Sets the x, y and z components of the force defined by the texture. 534 @type newdefvec: tuple of 3 floats 535 @param newdefvec: the x, y and z components of the force defined by the 536 texture. 537 @rtype: None 538 @return: None 539 """
540
541 - def getParticlesLoc():
542 """ 543 Gets the location of each particle at the current time in worldspace. 544 @rtype: A list of vector or a list of vector lists. 545 @return: The coordinates of each particle at the current time. 546 If the "Vect" option is enabled a list Vector pairs will be returned with a start and end point for each particle. 547 When static particles are enabled, a list of lists will be returned, each item a strand of particles. 548 549 Example:: 550 551 import Blender 552 from Blender import Effect, Object 553 scn= Blender.Scene.GetCurrent() 554 ob= scn.getActiveObject() 555 effect= ob.effects[0] 556 particles= effect.getParticlesLoc() 557 558 # Check that particles are points only (not static and not vectors) 559 if not effect.getFlag() & Effect.Flags.STATIC or not effect.getStype(): 560 for pt in particles: 561 ob_empty= scn.objects.new('Empty') 562 ob_empty.setLocation(pt) 563 564 else: # Particles will be a list 565 for pt in particles: 566 for pt_item in pt: 567 ob_empty= scn.objects.new('Empty') 568 ob_empty.setLocation(pt_item) 569 570 Example:: 571 # Converts particles into a mesh with edges for strands 572 from Blender import Scene, Mathutils, Effect, Mesh, Object 573 scn= Scene.GetCurrent() 574 ob= scn.getActiveObject() 575 me= Mesh.New() 576 577 effects= Effect.Get() 578 for eff in effects: 579 for p in eff.getParticlesLoc(): 580 # p is either a vector or a list of vectors. me.verts.extend() will deal with either 581 print p 582 me.verts.extend(p) 583 584 if type(p)==list: # Are we a strand or a pair, then add edges. 585 if len(p)>1: 586 edges= [(i, i+1) for i in range(len(me.verts)-len(p), len(me.verts)-1)] 587 me.edges.extend( edges ) 588 589 print len(me.verts) 590 ob= scn.objects.new(me) 591 """
592