On 13/05/2013 at 13:39, xxxxxxxx wrote:
I'm still confused about the cache stuff.
I have following code, creating a cloner with a sphere as a child.
I then set the p.x (c4d.MG_LINEAR_OBJECT_POSITION,c4d.VECTOR_X]) to the frame number to have some animation.
In the editor it works perfectly, but when i render out to the picture viewer, there is no animation.
Just the current frame animation is rendered. All frames are the same.
import c4d, os, sys
from c4d import bitmaps, documents, gui, modules, plugins
from c4d.modules import mograph
RADIUS = 1002
HALFTONESETTINGS = 1000
XNUMBER = 1005
ENABLE = 1007
DUMMY = 1010
class halftone(plugins.ObjectData) :
def __init__(self) :
self.lastframe = None
def Init(self, op) :
op[XNUMBER] = 3
op[RADIUS] = 10.0
op[ENABLE] = False
return True
def GetVirtualObjects(self, node, hierarchyhelp) :
doc = documents.GetActiveDocument()
frame = doc.GetTime().GetFrame(doc.GetFps())
node[DUMMY] = frame
if (not frame == self.lastframe) :
node.SetDirty(c4d.DIRTY_DATA)
self.lastframe = frame
#if (not c4d.CheckIsRunning(c4d.CHECKISRUNNING_EXTERNALRENDERING)) :
dirty = node.CheckCache(hierarchyhelp) or node.IsDirty(c4d.DIRTY_DATA)
if dirty is False:
print "return"
return node.GetCache(hierarchyhelp)
if (not node[ENABLE]) : return None
null = c4d.BaseObject(c4d.Onull) #hulp null
null[c4d.ID_BASELIST_NAME] = "HNull"
#doc.InsertObject(null)
cloner2 = c4d.BaseObject(1018544) #insert cloner
cloner2[c4d.ID_BASELIST_NAME] = "cloner2"
cloner2[c4d.MG_LINEAR_COUNT] = node[XNUMBER]
cloner2[c4d.MG_LINEAR_OBJECT_POSITION,c4d.VECTOR_X] = frame
cloner2.InsertUnder(null)
sphere = c4d.BaseObject(c4d.Osphere) #Sphere
sphere[c4d.PRIM_SPHERE_RAD] = node[RADIUS]
sphere[c4d.PRIM_SPHERE_SUB] = 4
sphere.InsertUnder(cloner2)
return null
if __name__ == "__main__":
pluginstr = "Htest v043"
path, file = os.path.split(__file__)
bmp = bitmaps.BaseBitmap()
bmp.InitWith(os.path.join(path, "res", "halftone.png"))
okyn = plugins.RegisterObjectPlugin(id = 10297362,
str = pluginstr,
g = halftone,
description = "halftone",
icon = bmp,
info = c4d.OBJECT_GENERATOR)
if (okyn) :
print pluginstr + " initialized."
else: print "Error initializing " + pluginstr
Adding a check whether the external renderer is working (CHECKISRUNNING_EXTERNALRENDERING) does not help.
So, is the cache handled differently when rendering?
Note: I do not use self.SetOptimizeCache(True), because I want to detect is the frame has changed.