Setting up Xpresso Nodes [SOLVED]
-
On 29/04/2015 at 11:20, xxxxxxxx wrote:
User Information:
Cinema 4D Version: R16
Platform: Windows ; Mac OSX ;
Language(s) : C++ ; XPRESSO ;---------
I have this code I wrote in Python that links up two nodes...newObj = c4d.BaseObject(c4d.Onull) newObj.SetName("Offset Null") offsetXpressoTag = newObj.MakeTag(c4d.Texpresso) doc.InsertObject(newObj) jntCnstTag = op.MakeTag(TCNST_TAG) jntCnstTag[c4d.ID_CA_CONSTRAINT_TAG_PSR] = True # set a PSR constraint masterNode = offsetXpressoTag.GetNodeMaster() cnstObjectNode = masterNode.CreateNode(masterNode.GetRoot(), c4d.ID_OPERATOR_OBJECT) nullObjectNode = masterNode.CreateNode(masterNode.GetRoot(), c4d.ID_OPERATOR_OBJECT) cnstObjectNode[c4d.GV_OBJECT_OBJECT_ID] = jntCnstTag nullObjectNode[c4d.GV_OBJECT_OBJECT_ID] = newObj sourcePort = nullObjectNode.AddPort(c4d.GV_PORT_OUTPUT, c4d.ID_BASEOBJECT_GLOBAL_POSITION) targetPort = cnstObjectNode.AddPort(c4d.GV_PORT_INPUT, c4d.ID_CA_CONSTRAINT_TAG_PSR_P_OFFSET) sourcePort.Connect(targetPort) sourcePort = nullObjectNode.AddPort(c4d.GV_PORT_OUTPUT, c4d.ID_BASEOBJECT_GLOBAL_ROTATION) targetPort = cnstObjectNode.AddPort(c4d.GV_PORT_INPUT, c4d.ID_CA_CONSTRAINT_TAG_PSR_R_OFFSET) sourcePort.Connect(targetPort)
...as a test of functionality, and it works great, I have this same snippet in C++ after going through the docs and the forum for a bit, but the ports never get added and I can't make any connections:
BaseObject* controller = doc->SearchObject(command->sourceComponent); //Get the controller BaseTag* sourceCnstTag = controller->MakeTag(TCNST_TAG); sourceCnstTag->SetParameter(DescID(ID_CA_CONSTRAINT_TAG_PSR), GeData(true), DESCFLAGS_SET_0); sourceCnstTag->SetParameter(DescID(TCNST_TAG_TARGET), GeData(targetJnt), DESCFLAGS_SET_0); sourceCnstTag->SetParameter(DescID(ID_CA_CONSTRAINT_TAG_PSR_MAINTAIN), GeData(true), DESCFLAGS_SET_0); BaseObject* offsetNull = BaseObject::Alloc(Onull); offsetNull->SetName(controller->GetName() + "_mocap_offset"); doc->InsertObject(offsetNull, nullptr, nullptr); XPressoTag* offsetXpressoTag = (XPressoTag* )offsetNull->MakeTag(Texpresso); GvNodeMaster* masterNode = offsetXpressoTag->GetNodeMaster(); GvNode* cnstObjectNode = masterNode->CreateNode(masterNode->GetRoot(), ID_OPERATOR_OBJECT); cnstObjectNode->SetParameter(DescID(GV_OBJECT_OBJECT_ID), GeData(sourceCnstTag), DESCFLAGS_SET_0); GvNode* nullObjectNode = masterNode->CreateNode(masterNode->GetRoot(), ID_OPERATOR_OBJECT); nullObjectNode->SetParameter(DescID(GV_OBJECT_OBJECT_ID), GeData(offsetNull), DESCFLAGS_SET_0); GvPort* sourcePort = nullObjectNode->AddPort(GV_PORT_OUTPUT, ID_BASEOBJECT_GLOBAL_POSITION, GV_PORT_FLAG_IS_VISIBLE, TRUE); GvPort* targetPort = cnstObjectNode->AddPort(GV_PORT_INPUT, ID_CA_CONSTRAINT_TAG_PSR_P_OFFSET, GV_PORT_FLAG_IS_VISIBLE, TRUE); cnstObjectNode->AddConnection(nullObjectNode, sourcePort, cnstObjectNode, targetPort); sourcePort = nullObjectNode->AddPort(GV_PORT_OUTPUT, ID_BASEOBJECT_GLOBAL_ROTATION, GV_PORT_FLAG_IS_VISIBLE, TRUE); targetPort = cnstObjectNode->AddPort(GV_PORT_INPUT, ID_CA_CONSTRAINT_TAG_PSR_R_OFFSET, GV_PORT_FLAG_IS_VISIBLE, TRUE); cnstObjectNode->AddConnection(nullObjectNode, sourcePort, cnstObjectNode, targetPort);
-
On 30/04/2015 at 08:18, xxxxxxxx wrote:
Hello,
in Python some things are happening internally to make the life easier for developers. In C++ you have to do these things yourself.
In this case you cannot simply use the parameter ID with AddPort(). Unfortunately the needed functionality was never properly implemented so it needs some special treatment.
First you have to add a define:
#define GvCall(op,fnc) (((GvOperatorData* )op)->*((OPERATORPLUGIN* )C4DOS.Bl->RetrieveTableX((NodeData* )op,1))->fnc)
With that you can calculate the proper ID:
GvOperatorData* op2 = newNode->GetOperatorData(); DescID parameterDescID = DescID(DescLevel(ID_BASEOBJECT_GLOBAL_POSITION)); Int32 xpressoID = GvCall(op2, GetMainID)(newNode, GV_PORT_INPUT, parameterDescID); newNode->AddPort(GV_PORT_INPUT,xpressoID, GV_PORT_FLAG_IS_VISIBLE,TRUE);
This solution was original posted in this thread.
Best wishes,
Sebastian -
On 01/05/2015 at 18:59, xxxxxxxx wrote:
That worked out. Thanks.