Your browser does not seem to support JavaScript. As a result, your viewing experience will be diminished, and you have been placed in read-only mode.
Please download a browser that supports JavaScript, or enable it if it's disabled (i.e. NoScript).
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.
On 13/05/2013 at 15:09, xxxxxxxx wrote:
i am not 100% sure, but i think the culprit is doc = documents.GetActiveDocument(). for rendering the document is being cloned, which will mess up your frame based dirty calculations as the current frame in the active document won't change while rendering. use the passed node to get your document. you should also overwrite NodeData.CheckDirty() instead of fiddling with the dirty flag from GVO. it does work from GVO, but under certain circumstances things can go wrong.
def GetVirtualObjects(self, node, hh) : doc = node.GetDocument()
you also do not need to redefine your description symbols. you can use them directly.
node[c4d.XNUMBER] = someValue
On 13/05/2013 at 23:31, xxxxxxxx wrote:
Yes, it works now (doc = node.GetDocument()) Thanks for the solution and the explanation.
Do you have an example of overwriting NodeData.CheckDirty()?
Regards, Pim
On 14/05/2013 at 04:16, xxxxxxxx wrote:
hi,
I have to correct myself. CheckDirty() is not a member of NodeData, but of ObjectData. Here is the example from the docs.
def CheckDirty(self, op, doc) : frame = doc.GetTime().GetFrame(doc.GetFps()) if frame != lastFrame: lastFrame = frame op.SetDirty(c4d.DIRTYFLAGS_DATA)