GetVirtualObjects Help

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 07/12/2004 at 14:34, xxxxxxxx wrote:

User Information:
Cinema 4D Version:   8.200 
Platform:      Mac OSX  ; 
Language(s) :   C.O.F.F.E.E  ;  C++  ;

---------
Hi,

In trying to learn the ropes of CPP object plugin development and I realize that I don't understand how to display the child objects of the plugin in GetVirtualObjects.

For now, as a simplification of what I am really trying to do, I am essentially trying to create an object plugin that would behave as a Null Object.

From the atom.cpp I am creating instances of the children and attaching them to the plugin object, which works, but when I just try to attach the child itself to the returnObject I get a crash. As I step through the children, how do I attach them to the returnObject in GetVirtualObjects? Or, in the code below, what do I add between the comments with question marks?

  
BaseObject *MyNullObject::GetVirtualObjects(PluginObject *pluginObject, HierarchyHelp *hh)  
{  
  
  
     BaseObject*          returnObject = NULL;  
     BaseObject*      orig;  
     BaseObject*          res;  
     BaseObject           *obi        = NULL;       
     Bool                dirty;  
     BaseContainer*     data = pluginObject->GetDataInstance();  
  
  
     // request polygonized input  
     hh->AddVFlags(VFLAG_POLYGONAL);   
  
     orig = pluginObject->GetDown();  
     if (!orig) return NULL;   
       
     dirty = FALSE;  
     res = pluginObject->GetAndCheckHierarchyClone(hh,orig,HCLONE_ASPOLY,&dirty;,NULL,TRUE);   
  
     if (!dirty) {  
          return res;  
     }  
     if (!res) {  
          return NULL;  
     }   
  
  
  
     returnObject = BaseObject::Alloc(Onull);;  
       
     // STEP TRHOUGH EACH CHILD OF THE PLUGIN ONBJECT  
     while (orig) {  
            
          BaseContainer *origdata = orig->GetDataInstance();  
            
            
          // ??? WHAT SHOULD I DO HERE TO JUST DISPLAY/RETURN THE CHILDREN INSTEAD OF INSTANCING THEM?  
          obi = BaseObject::Alloc(Oinstance);  
          AutoAlloc<BaseLink> link;  
          if (link) {  
               link->SetLink(orig);  
               obi->SetParameter(DescLevel(INSTANCEOBJECT_LINK), GeData(link), 0);                 
          }  
          // ????  
            
            
          obi->InsertUnderLast(returnObject);  
  
          orig = orig->GetNext();  
       
     }  
  
     if (!returnObject) goto Error;  
     returnObject->SetName(pluginObject->GetName());  
  
  
     return returnObject;  
  
Error:  
     blDelete(returnObject);  
     return NULL;  
}  

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 08/12/2004 at 01:00, xxxxxxxx wrote:

You can't return the children themselves. That will cause a crash. You need to create clones of the children, just like the examples do.

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 08/12/2004 at 05:15, xxxxxxxx wrote:

Thanks Mikael - that worked like a charm. I have one more related question: Based on the Atom example, I was not only using instances but also GetAndCheckHeirarchyClone to test if the object was dirty. But in MophMixer, they use CheckCache. When would one use one over the other?