GetVirtualObjects() Question



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

    On 25/05/2010 at 19:20, xxxxxxxx wrote:

    User Information:
    Cinema 4D Version:   11.5 
    Platform:   Windows  ;   
    Language(s) :     C++  ;

    ---------
    I am creating a plane using GetVirtualObjects().   however, the plane does not show up in the viewport.  It does, however show up when I render the scene.  Does anyone know why this would be happening?   Here is the code I use to draw the plane.

      
      
    BaseObject *TestClass::GetVirtualObjects(BaseObject* op, HierarchyHelp* hh)  
    {  
        PolygonObject *polyObj = PolygonObject::Alloc(16,9);  
        if (!polyObj) goto Error;  
      
        Vector *padr=NULL;  
      
        CPolygon *vadr=NULL;  
      
        padr = polyObj->GetPointW();  
      
        vadr = polyObj->GetPolygonW();  
      
        padr[0] = Vector(0,150,-150);  
        padr[1] = Vector(0,150,-50);  
        padr[2] = Vector(0,150,50);  
        padr[3] = Vector(0,150,150);  
        padr[4] = Vector(0,50,-150);  
        padr[5] = Vector(0,50,-50);  
        padr[6] = Vector(0,50,50);  
        padr[7] = Vector(0,50,150);  
        padr[8] = Vector(0,-50,-150);  
        padr[9] = Vector(0,-50,-50);  
        padr[10] = Vector(0,-50,50);  
        padr[11] = Vector(0,-50,150);  
        padr[12] = Vector(0,-150,-150);  
        padr[13] = Vector(0,-150,-50);  
        padr[14] = Vector(0,-150,50);  
        padr[15] = Vector(0,-150,150);  
      
        vadr[0] = CPolygon(0,1,5,4);  
        vadr[1] = CPolygon(1,2,6,5);  
        vadr[2] = CPolygon(2,3,7,6);  
        vadr[3] = CPolygon(4,5,9,8);  
        vadr[4] = CPolygon(5,6,10,9);  
        vadr[5] = CPolygon(6,7,11,10);  
        vadr[6] = CPolygon(8,9,13,12);  
        vadr[7] = CPolygon(9,10,14,13);  
        vadr[8] = CPolygon(10,11,15,14);  
      
        return polyObj;  
      
    Error:  
        return NULL;  
      
    }  
      
      
    

    Any help would be greatly appreciated.

    Thanks,

    Shawn



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

    On 26/05/2010 at 02:57, xxxxxxxx wrote:

    It looks like the error is outside of GetVirtualObjects().

    cheers,
    Matthias



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

    On 28/05/2010 at 10:18, xxxxxxxx wrote:

    Hmmm...  I have put this code in to a completely empty object plugin and it still does not show up in the viewport.   It does render..  but there is nothing in the viewport.   Any thoughts?

    Here's the who code of my empty plugin.

      
    #include "c4d.h"
    #include "c4d_symbols.h"
    #include "ospacerock.h"
    #include "c4d_basetag.h"
    #include "c4d_basematerial.h" 
      
    // be sure to use a unique ID obtained from www.plugincafe.com
    #define ID_SPACEROCK_OBJECT 1025336  
      
    class SpaceRock : public ObjectData
    {
    	public:
    		virtual Bool Init(GeListNode *node);
    		virtual Bool Message(GeListNode *node, LONG type, void *t_data);
    		static	NodeData *Alloc(void) { return gNew SpaceRock; }
    		virtual Bool GetDEnabling(GeListNode *node, const DescID &id,GeData &t_data,LONG flags,const BaseContainer *itemdesc);
    		virtual Bool Draw(BaseObject* op, LONG drawpass, BaseDraw* bd, BaseDrawHelp* bh);	
    		virtual BaseObject *GetVirtualObjects(BaseObject* op, HierarchyHelp* hh);
    				void Free(GeListNode* node);
      
    		
    		
    };
      
    void SpaceRock::Free(GeListNode* node)
    {
      
    }
      
    // initialize settings
    Bool SpaceRock::Init(GeListNode *node)
    {	//Called when a new instance of the node plugin has been allocated. You can use this function to for example fill the BaseContainer of the connected node with default values:
    	
    	
    	return TRUE;	
      
    }
      
    Bool SpaceRock::Draw(BaseObject* op, LONG drawpass, BaseDraw* bd, BaseDrawHelp* bh)
    {
    	return TRUE;
    }
      
    BaseObject *SpaceRock::GetVirtualObjects(BaseObject* op, HierarchyHelp* hh)
      
    {
      
        PolygonObject *polyObj = PolygonObject::Alloc(16,9);
      
        if (!polyObj) goto Error;
      
      
      
        Vector *padr=NULL;
      
      
      
        CPolygon *vadr=NULL;
      
      
      
        padr = polyObj->GetPointW();
      
      
      
        vadr = polyObj->GetPolygonW();
      
      
      
        padr[0] = Vector(0,150,-150);
      
        padr[1] = Vector(0,150,-50);
      
        padr[2] = Vector(0,150,50);
      
        padr[3] = Vector(0,150,150);
      
        padr[4] = Vector(0,50,-150);
      
        padr[5] = Vector(0,50,-50);
      
        padr[6] = Vector(0,50,50);
      
        padr[7] = Vector(0,50,150);
      
        padr[8] = Vector(0,-50,-150);
      
        padr[9] = Vector(0,-50,-50);
      
        padr[10] = Vector(0,-50,50);
      
        padr[11] = Vector(0,-50,150);
      
        padr[12] = Vector(0,-150,-150);
      
        padr[13] = Vector(0,-150,-50);
      
        padr[14] = Vector(0,-150,50);
      
        padr[15] = Vector(0,-150,150);
      
      
      
        vadr[0] = CPolygon(0,1,5,4);
      
        vadr[1] = CPolygon(1,2,6,5);
      
        vadr[2] = CPolygon(2,3,7,6);
      
        vadr[3] = CPolygon(4,5,9,8);
      
        vadr[4] = CPolygon(5,6,10,9);
      
        vadr[5] = CPolygon(6,7,11,10);
      
        vadr[6] = CPolygon(8,9,13,12);
      
        vadr[7] = CPolygon(9,10,14,13);
      
        vadr[8] = CPolygon(10,11,15,14);
      
      
      
        return polyObj;
      
      
      
    Error:
      
        return NULL;
      
      
      
    }
      
      
    Bool SpaceRock::GetDEnabling(GeListNode *node, const DescID &id,GeData &t_data,LONG flags,const BaseContainer *itemdesc)
    {
    	
    	return TRUE;
    }
    Bool SpaceRock::Message(GeListNode *node, LONG type, void *t_data)
    {	
    	
    BaseObject* op = static_cast<BaseTag*>(node)->GetObject();
      
    	if (!node) return FALSE;
      
    	return TRUE;
    }
      
      
      
    Bool RegisterSpaceRock(void)
    {
    	// decide by name if the plugin shall be registered - just for user convenience
    	String name=GeLoadString(IDS_SPACEROCK); if (!name.Content()) return TRUE;
    	return RegisterObjectPlugin(ID_SPACEROCK_OBJECT,name,OBJECT_GENERATOR|OBJECT_INPUT,SpaceRock::Alloc,"OSpaceRock","spacerock.tif",0);
    }
      
    
    


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

    On 31/05/2010 at 02:46, xxxxxxxx wrote:

    You have to send a MSG_UPDATE message to the internal polygon object after you made some changes to it. Below is the modified source of the GetVirtualObjects() method. I also added two lines at the beginning to only create the polyogn object if the cache is dirty. You should always check the cache in your generators, otherwise your plugin will do unnecessary calculations.

      
    BaseObject* SpaceRock::GetVirtualObjects(BaseObject *op, HierarchyHelp *hh)  
    {  
      Bool dirty = op->CheckCache(hh) || op->IsDirty(DIRTY_DATA);  
      if (!dirty) return op->GetCache(hh);  
      
      PolygonObject *polyObj = PolygonObject::Alloc(16,9);  
      if (!polyObj) goto Error;  
      
      Vector *padr=NULL;  
      
      CPolygon *vadr=NULL;  
      
      padr = polyObj->GetPointW();  
      
      vadr = polyObj->GetPolygonW();  
      
      padr[0] = Vector(0,150,-150);  
      padr[1] = Vector(0,150,-50);  
      padr[2] = Vector(0,150,50);  
      padr[3] = Vector(0,150,150);  
      padr[4] = Vector(0,50,-150);  
      padr[5] = Vector(0,50,-50);  
      padr[6] = Vector(0,50,50);  
      padr[7] = Vector(0,50,150);  
      padr[8] = Vector(0,-50,-150);  
      padr[9] = Vector(0,-50,-50);  
      padr[10] = Vector(0,-50,50);  
      padr[11] = Vector(0,-50,150);  
      padr[12] = Vector(0,-150,-150);  
      padr[13] = Vector(0,-150,-50);  
      padr[14] = Vector(0,-150,50);  
      padr[15] = Vector(0,-150,150);  
      
      vadr[0] = CPolygon(0,1,5,4);  
      vadr[1] = CPolygon(1,2,6,5);  
      vadr[2] = CPolygon(2,3,7,6);  
      vadr[3] = CPolygon(4,5,9,8);  
      vadr[4] = CPolygon(5,6,10,9);  
      vadr[5] = CPolygon(6,7,11,10);  
      vadr[6] = CPolygon(8,9,13,12);  
      vadr[7] = CPolygon(9,10,14,13);  
      vadr[8] = CPolygon(10,11,15,14);  
      
      polyObj->Message(MSG_UPDATE);  
      
      return polyObj;  
      
      Error:  
      return NULL;  
    }  
    

    cheers,
    Matthias



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

    On 31/05/2010 at 05:13, xxxxxxxx wrote:

    Thanks Matthias..   That helps alot.

    ~Shawn


Log in to reply