Retrieving several Inport Data?

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

On 07/01/2003 at 07:08, xxxxxxxx wrote:

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

---------
Hi,
I tried to get the inport data of my plugin node but I can only retrieve the data of the first port. The second one is NULL. I tried two ways:

    
    
    GvPort* ipt = bn->GetInPort(1);  
       GeData iptdata = GvGetPortGeData(bn, ipt, run);  
       Vector pos = iptdata.GetVector();  
    
    
    
    
       GvPort* inport = vinport->GetPort();   
       GeData inportdata = GvGetPortGeData(bn, inport, run);  
       Vector normale = inportdata.GetVector();

the second one does give me the data of the first inport correctly. The first one doesn´t give me the data, though the port is correct and I can also get the name of the port. How can I get the data of several ports then?
Thanks
Samir

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

On 08/01/2003 at 02:32, xxxxxxxx wrote:

The ports must be calculated correctly. The easiest way is to always use the convenience functions for value tables. Please refer to this example: (And just add more ports to input_ids.)

    
    
    static LONG input_ids[] = { INPORT_LINK, 0 }; // Use this for the input ports!  
    enum { INPORT_LINK_INDEX };
    
    
    
    
    class Node: public GvOperatorData  
    {  
    // Defines super  
    INSTANCEOF(Node, GvOperatorData)  
    public:  
       
      virtual Bool iCreateOperator(GvNode *bn)  
      {  
        BaseContainer* data = bn->GetOpContainerInstance();   
        if (!data) return FALSE;
    
    
    
    
        data->SetLong(STEPS, 3);
    
    
    
    
        return SUPER::iCreateOperator(bn);  
      }  
        
        
      Bool InitCalculation(GvNode *bn, GvCalc *c, GvRun *r)  
      {  
        return GvBuildInValuesTable(bn, ports, c, r, input_ids);      
      }  
        
        
      void FreeCalculation(GvNode *bn, GvCalc *c)  
      {  
        GvFreeValuesTable(bn, ports);  
      }  
        
      Bool Calculate(GvNode *bn, GvPort *port, GvRun *run, GvCalc *calc)  
      {  
        if (!port) return FALSE;  
          
        BaseContainer *data = bn->GetOpContainerInstance();  
        if (!data) return FALSE;
    
    
    
    
        LONG steps = data->GetLong(STEPS);  
        LONG mode = data->GetLong(MODE_ID);
    
    
    
    
        GvValue* vinport = ports.in_values[INPORT_LINK_INDEX];  
        if (!vinport) return FALSE; 
    
    
    
    
        if (!vinport->Calculate(bn, GV_PORT_INPUT, run, calc, 0)) return FALSE;  
          
        GvPort* inport = vinport->GetPort();  
        GeData inportdata = GvGetPortGeData(bn, inport, run);
    
    
    
    
        BaseDocument* doc = bn->GetNodeMaster()->GetDocument();  
        if (!doc) return FALSE;
    
    
    
    
        BaseLink* link = inportdata.GetBaseLink();  
        if (!link) return FALSE;
    
    
    
    
        BaseList2D* list = link->GetLink(doc);  
        if (!list) return FALSE;  
          
        switch(port->GetMainID())   
        {  
        case OUTPORT_LINK:  
          {  
            BaseObject* obj = static_cast<BaseObject*>(list);  
            for (LONG i = 0; list && i < steps; ++i)  
            {  
              switch(mode)  
              {  
              case GETDOWN: obj = obj->GetDown(); break;  
              case GETUP: obj = obj->GetUp(); break;  
              case GETPRED: obj = obj->GetPred(); break;  
              case GETNEXT: obj = obj->GetNext(); break;  
              }       
            } 
    
    
    
    
            AutoAlloc<BaseLink> bl;  
            if (!bl) return FALSE;  
            bl->SetLink(obj);
    
    
    
    
            return GvSetPortGeData(GeData(bl), bn, port, run);  
          }  
        }  
          
        return FALSE;  
      }  
          
      static NodeData* Alloc(void) { return gNew Node; }
    
    
    
    
    private:  
      GvValuesInfo ports;  
    };

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

On 08/01/2003 at 02:41, xxxxxxxx wrote:

The ports must be calculated correctly. The easiest way is to always use the convenience functions for value tables. Please refer to this example: (And just add more ports to input_ids.)

    
    
    static LONG input_ids[] = { INPORT_LINK, 0 }; // Use this for the input ports!  
    enum { INPORT_LINK_INDEX };
Hi,


I am already doing this.


static LONG input_ids[] = { NORMAL,0,LEAVECOUNT,1}; // Use this for the input ports!  
enum { INPORT_LINK_INDEX };


and then the same procedure as shown in your example above.


here is some code then in my calculate method
    
    
    Bool Calculate(GvNode *bn, GvPort *port, GvRun *run, GvCalc *calc)    
      {      
         
       if (!port) return FALSE;          
       BaseContainer *data = bn->GetOpContainerInstance();    if (!data) return FALSE;  
       LONG offsetseed = data->GetLong(OFFSET_SEED);      
       LONG offset = data->GetLong(OFFSET);  
         
       Random rnd;  
       rnd.Init(offsetseed);
    
    
       GvValue* vinport = ports.in_values[INPORT_LINK_INDEX];    if (!vinport) return FALSE;      
       if (!vinport->Calculate(bn, GV_PORT_INPUT_OR_GEDATA, run, calc, 0)) return FALSE;   
         
       /*LONG portcnt = bn->GetInPortCount();  
       GvPort* ipt = bn->GetInPort(1);  
       GeData iptdata = GvGetPortGeData(bn, ipt, run);  
       Vector pos = iptdata.GetVector();  */
    
    
       GvPort* inport = vinport->GetPort();   
       GeData inportdata = GvGetPortGeData(bn, inport, run);  
       Vector normale = inportdata.GetVector();  
    
    
    [...]
The problem is that I cannot get the second port with vinport->GetPort().


This only returns the first inport. GetPort() should take a SubID parameter for the inport afaik


but that doesn´t work either.


Am I missing something? :\

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

On 10/01/2003 at 02:03, xxxxxxxx wrote:

Any conclusions yet?

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

On 11/01/2003 at 07:03, xxxxxxxx wrote:

Uhm, input_ids is supposed to be zero terminated. So you should have:

    
    
    static LONG input_ids[] = { NORMAL,LEAVECOUNT,0};   
    enum { INPORT_NORMAL_INDEX, INPORT_LEAVECOUNT_INDEX };

Then you repeat the whole ports.in_values part for each port.

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

On 11/01/2003 at 07:46, xxxxxxxx wrote:

oh, ok. Works just fine now.
Thanks
P.s.: Mikael works at the weekend? :)