Advertisement
nux95

Untitled

Oct 26th, 2011
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.88 KB | None | 0 0
  1. # Copyright (c) Niklas Rosenstein 2011
  2. # Example of a gravitiy modifier for Cinema 4Ds
  3. # Thinking Particles
  4.  
  5. import  c4d
  6. import  c4d.documents                   as docs
  7. import  c4d.modules.thinkingparticles   as c4dtp
  8.  
  9. # constants
  10. GRAVITY         = 9.81      # m / (s ^ 2)
  11. STORAGE         = type('', (), {}) () # Stores important data
  12. STORAGE.frame   = 0
  13.  
  14. # functions
  15. def main():
  16.  
  17.     doc     = docs.GetActiveDocument()
  18.     fps     = doc.GetFps()
  19.     frame   = doc.GetTime().GetFrame( fps )
  20.  
  21.     # check if the frame has changed
  22.     try:
  23.         if STORAGE.frame == frame:
  24.             return
  25.     finally:
  26.         STORAGE.frame = frame
  27.  
  28.     direct  = op.GetMg().v3 * GRAVITY * 10 / fps
  29.     tp      = doc.GetParticleSystem()
  30.  
  31.     for i in xrange( tp.NumParticles() ):
  32.         vel = tp.Velocity( i )
  33.         vel = vel + direct
  34.         tp.SetVelocity(i, vel)
  35.        
  36. main()
  37.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement