Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Copyright (c) Niklas Rosenstein 2011
- # Example of a gravitiy modifier for Cinema 4Ds
- # Thinking Particles
- import c4d
- import c4d.documents as docs
- import c4d.modules.thinkingparticles as c4dtp
- # constants
- GRAVITY = 9.81 # m / (s ^ 2)
- STORAGE = type('', (), {}) () # Stores important data
- STORAGE.frame = 0
- # functions
- def main():
- doc = docs.GetActiveDocument()
- fps = doc.GetFps()
- frame = doc.GetTime().GetFrame( fps )
- # check if the frame has changed
- try:
- if STORAGE.frame == frame:
- return
- finally:
- STORAGE.frame = frame
- direct = op.GetMg().v3 * GRAVITY * 10 / fps
- tp = doc.GetParticleSystem()
- for i in xrange( tp.NumParticles() ):
- vel = tp.Velocity( i )
- vel = vel + direct
- tp.SetVelocity(i, vel)
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement