THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 05/06/2010 at 15:18, xxxxxxxx wrote:
Hi, i did a quick test on subdividing and it works here.. dont ask me why it needs to create the dependency list twice, but if i dont do it, the plugin is updating everytime something changes in the editor even if you turn the camera and such.. if someone can tell my why, i'd be happy.
anyways, here is what is working for me:
#define pluginID 1000001
#define pluginName "testObject"
#include "c4d.h"
#include "c4d_symbols.h"
class testObject : public ObjectData
{
INSTANCEOF(testObject,ObjectData);
private:
public:
virtual BaseObject* GetVirtualObjects(PluginObject *op, HierarchyHelp *hh);
static NodeData *Alloc(void) { return gNew testObject; }
};
BaseObject *testObject::GetVirtualObjects(PluginObject *op, HierarchyHelp *hh)
{
BaseDocument* doc = op->GetDocument();
ModelingCommandData cd;
Bool dirty;
BaseObject* main = BaseObject::Alloc(Onull);
if (!main) goto Error;
BaseObject* child = op->GetDown();
if (!child) goto Error;
op->NewDependenceList();
op->AddDependence(hh,child);
dirty = op->CheckCache(hh) || op->IsDirty(DIRTY_MATRIX|DIRTY_DATA|DIRTY_CHILDREN);
dirty = dirty || !op->CompareDependenceList();
if (!dirty)
{
blDelete(main);
op->TouchDependenceList();
return op->GetCache(hh);
}
BaseObject* clone = op->GetAndCheckHierarchyClone(hh,child,HCLONE_ASPOLY,&dirty,0,false);//static_cast<PolygonObject*>(child->GetClone(0,0));
if (clone)
{
GePrint ("cloned");
if (clone->GetType()==Opolygon)
{
GePrint("polygonobject detected");
cd.doc = doc;
cd.op = clone;
BaseContainer bc;
bc.SetBool(MDATA_SUBDIVIDE_HYPER, true);
bc.SetReal(MDATA_SUBDIVIDE_ANGLE, 90);
bc.SetLong(MDATA_SUBDIVIDE_SUB, 2);
cd.bc = &bc;
if(SendModelingCommand(MCOMMAND_SUBDIVIDE, cd))
{
GePrint("modeling command sent: MCOMMAND_SUBDIVIDE");
}
else
{
GePrint("failed");
}
clone->InsertUnderLast(main);
}
else
{
blDelete(clone);
}
}
op->NewDependenceList();
op->AddDependence(hh,child);
op->TouchDependenceList();
return main;
Error:
if (main) blDelete(main);
return NULL;
}
// be sure to use a unique ID obtained from www.plugincafe.com
Bool Register_testObject(void)
{
GePrint("- testObject");
return RegisterObjectPlugin(pluginID,pluginName,OBJECT_GENERATOR|OBJECT_INPUT,testObject::Alloc,"OtestObject","orgaLine.tif",0);
}
hope this helps