On 29/10/2014 at 06:24, xxxxxxxx wrote:
Hi - I still need a bit of help. I've worked out creating an ObjectData plugin - but not sure where to place my code within it. I have a method which creates random geometry to the scene each frame 'updateScene' - you can see where I've put it below - but not sure where to call it from, and how it connects to getvirtualobjects to update.
> import c4d
>
> from c4d import gui, plugins, bitmaps
>
> import time, sys, os, subprocess
>
> import logging, logging.handlers
>
> import math, random
>
> from c4d.utils.noise import C4DNoise
>
> from c4d.utils import SinCos
>
> import c4d.utils
>
>
>
>
>
>
>
> PLUGIN_ID = 100000
>
>
>
>
> class Test(c4d.plugins.ObjectData) :
>
>
>
>
> def GetVirtualObjects(self, op, hierarchyhelp) :
>
> dirty = op.CheckCache(hierarchyhelp) or op.IsDirty(c4d.DIRTY_DATA)
>
> if dirty is False:
>
> return op.GetCache(hierarchyhelp)
>
>
>
>
> def __init__(self) :
>
> self.SetOptimizeCache(True)
>
>
>
>
>
>
>
> def Execute(self, op, doc, bt, priority, flags) :
>
> return True
>
>
>
>
> def Message(self, node, type, data) :
>
>
>
>
> return True
>
>
>
>
> def Draw(self, op, drawpass, bd, bh) :
>
>
>
>
> return c4d.DRAWRESULT_OK
>
>
>
>
> def updateScene(self) :
>
>
>
> """
>
> CREATE RANDOM GEOMETRY EVERY FRAME
>
>
>
>
> """
>
> return True
>
>
>
>
>
>
>
> if __name__ == '__main__':
>
> #main()
>
> bmp = c4d.bitmaps.BaseBitmap()
>
> dir, file = os.path.split(__file__)
>
> fn = os.path.join(dir, "res", "Icon.tif")
>
> bmp.InitWith(fn)
>
> result = plugins.RegisterObjectPlugin(
>
> id=PLUGIN_ID,
>
> str="Controller",
>
> g=Test,
>
> description="Otest",
>
> info=c4d.OBJECT_GENERATOR,
>
> icon=bmp
>
> )