THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 13/03/2012 at 05:35, xxxxxxxx wrote:
I still don't understand how caching in Cinema 4D works. I can obtain the virtual object hierarchy using c4d.BaseObject.GetCache(). The returned hierarchy is exactly the same as the object keeps a reference to. That means, modifieng the hierarchy returned by ~.GetCache() takes immidiate effect on the generator object, as I'm modifieng it directly.
For example, when I create a standart Cloner object and execute this script in the Script Manager
import c4d def main() : cache = op.GetCache() for child in cache.GetChildren() : pos = child.GetAbsPos() child.SetAbsPos(pos * 2) c4d.EventAdd()
This will immidiately double the clones positions. However, this will only last until the Cloner's cache is being rebuilt again.
So far, so good. Let's say I'd like to modify the points of a primitive cube continiously. I'd create a PythonTag, get the cache in it and modify that cache. As the PythonTag is executed even has not been rebuilt, I need to check if the cache has changed the last time I modified it.
import c4d prevDirty = 0 def main() : global prevDirty og = op.GetOrigin() dirty = og.GetDirty(c4d.DIRTY_CACHE) if prevDirty < dirty: cache = og.GetCache() for i, p in enumerate(cache.GetAllPoints()) : cache.SetPoint(i, p * 2) cache.Message(c4d.MSG_UPDATE) prevDirty = dirty
This works pretty fine. But when you hit Render To Picture Viewer, you can see that the cube has still it's original size in the first frame but was affected correctly in all other frames. (Don't forget to set the Tags priority to Generators, Thanks to Lennart [tcastudios]).
I also noticed that this seems to work most time in the Physical renderer, but not in the Advanced, Software or Hardware renderer.
How can I modify the cache so it does have effect to the rendered object?**
Thanks very much,
PS: Here is another example scene with a tag modifieng a cloner's cache.