Programmatically doing Set Driven Keys
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 31/03/2006 at 02:26, xxxxxxxx wrote:
Anything?
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 31/03/2006 at 05:21, xxxxxxxx wrote:
I can confirm that the naive attempt of node->AddPort(GV_PORT_OUTPUT, GV_OUTPUT_FIRST_ID); doesn't work for me either. I'm investigating if there's a proper way to do it.
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 31/03/2006 at 12:01, xxxxxxxx wrote:
I've already confirmed it, Mikael, and have found the solution (so that you can stop investigating this aspect anyway). Here it is:
// PortList for finding available ports on node AutoAlloc<GvPortList> portList; if (!portList) return ErrorException::Throw("error"); GvPortListEntry* portLE; GvPortDescription portDesc; GvNode* snode; // filled using GvNodeMaster::CreateNode() GvPort* sport; // - Add Ports // -- Source (Master) Node portList->FlushAll(); snode->GetPortList(GV_PORT_OUTPUT, *portList); LONG portCount = portList->GetCount(); for (LONG i = 0; i < portCount; i++) { portLE = portList->GetIndex(i); snode->GetPortDescription(GV_PORT_OUTPUT, portLE->id, &portDesc;); // I'm using the port name to find the port to be added if (portDesc.name == md->dialName) break; } // -- No matching port if (i == portCount) return ErrorException::Throw("Master Node Port not found!"); if (!snode->AddPortIsOK(GV_PORT_OUTPUT, portLE->id)) return ErrorException::Throw("error"); sport = snode->AddPort(GV_PORT_OUTPUT, portLE->id); if (!sport) return ErrorException::Throw("error");
Adding the ports and connecting/configuring them, though, are two differnt things. Have had no luck connecting the ports and it seems that they (or the nodes) are not configured correctly. No idea on how to go about doing that.
Thanks,
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 31/03/2006 at 12:33, xxxxxxxx wrote:
Almost forgot that I wanted to mention that after some experimenting with the XPresso nodes manually, the desired interaction isn't exactly like 'Set Driven Keys', but instead would be better modeled using something like this:
Master(out) ---> (in0)|Math::Multiply(out) -> (in)Slave
Constant(out) -> (in1)|The Constant node specifies a proportional multiplier of the Master's value that is used to set the Slave.
So, one more node to contend with.
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 31/03/2006 at 14:29, xxxxxxxx wrote:
As a continuation of the issues with GraphView here, I'm not having any luck getting a GvRun from the GvNodeMaster. This is sort of catch-22 isn't it? It cannot be instantiated and there is no method (to be found in the docs) to force it or that says that this needs to be done to instantiate it (and yet everything seems to require it). But GvNodeMaster::GetRun() always returns NULL. So, how can one use GvSetPortGeData() (as shown in the docs and repeatedly here) if one does not know how to get the GvRun 'instantiated' in the GvNodeMaster?
I'm finding it odd that it appears easier to create your own custom XPresso nodes than it is to just use the built-in ones. There is no intention for my code to control these blasted things once (if ever) they get setup properly. Once added, Cinema 4D should be doing the calculations and so on - as if the user added them manually.
The reason that GvSetPortGeData() seems to be needed is that the Constant Node's data, for instance, is GvDynamic. So, this means that it needs to do all of that magical stuff in that method to set the Real value (since no other approach seems to work).
One singular example of adding a couple of nodes, connecting one outport to one inport, and configuring it to work would probably cause thousands of SDK developers to actually use GraphView...
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 02/04/2006 at 08:44, xxxxxxxx wrote:
Here's a piece of code that seems to work:
#include "c4d_graphview.h" #include "c4d_operatorplugin.h" #include "......\resource\modules\gv\expressiontag\res\description\gvobject.h" #define GvCall(op,fnc) (((GvOperatorData* )op)->*((OPERATORPLUGIN* )C4DOS.Bl->RetrieveTableX((NodeData* )op,1))->fnc) Bool MenuTest::Execute(BaseDocument *doc) { BaseObject* cube = doc->GetFirstObject(); BaseObject* sphere = cube->GetNext(); DescID cubeid = DescID(DescLevel(ID_BASEOBJECT_POSITION), DescLevel(VECTOR_X)); DescID sphereid = DescID(DescLevel(ID_BASEOBJECT_POSITION), DescLevel(VECTOR_Y)); XPressoTag* x = static_cast<XPressoTag*>(sphere->GetTag(Texpresso, 0)); if (!x) x = static_cast<XPressoTag*>(sphere->MakeTag(Texpresso, NULL)); GvNodeMaster* m = x->GetNodeMaster(); GvNode* n1 = m->CreateNode(m->GetRoot(), ID_OPERATOR_OBJECT, NULL, 8, 8); n1->OperatorSetData(GV_ATOM, cube, GV_OP_DROP_IN_BODY); GvOperatorData* op1 = n1->GetOperatorData(); LONG s1 = GvCall(op1, GetMainID)(n1, GV_PORT_OUTPUT, cubeid); GvPort* p1 = n1->AddPort(GV_PORT_OUTPUT, s1, GV_PORT_FLAG_IS_VISIBLE, TRUE); GvNode* n2 = m->CreateNode(m->GetRoot(), ID_OPERATOR_OBJECT, NULL, 208, 8); n2->OperatorSetData(GV_ATOM, sphere, GV_OP_DROP_IN_BODY); GvOperatorData* op2 = n2->GetOperatorData(); LONG s2 = GvCall(op2, GetMainID)(n2, GV_PORT_INPUT, sphereid); GvPort* p2 = n2->AddPort(GV_PORT_INPUT, s2, GV_PORT_FLAG_IS_VISIBLE, TRUE); if (p1 && p2) { GvNode* n1u = NULL; GvNode* n2u = NULL; GvPort* p1u = NULL; GvPort* p2u = NULL; if (m->IsConnectionValid(n1, p1, n2, p2, n1u, p1u, n2u, p2u)) { n2->AddConnection(n1u, p1u, n2u, p2u); } } EventAdd(); return TRUE; }
Som points:
- The Object node is initialized by simulating a drag-and-drop action.
- The ports can then be added by asking the Object node directly about which ID to use.
- The AddConnection() only works in one way, i.e. you need to call it for the destination node otherwise it silently fails.
I hope this helps!
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 02/04/2006 at 19:33, xxxxxxxx wrote:
Hi Mikael,
Ah, would have never thought about drag-and-drop. I had tried to find ways to simulate that basic idea though with no success. And that information about AddConnection() is invaluable!
Nearly everything worked! The last difficulty now seems to be with setting the Constant Node's value. I tried this:
constNode->OperatorSetData(GV_REAL, &(md->deltaAddDelta), GV_OP_SET);
but there was no change. Now, the docs state that for GV_OP_SET: (The constant node uses this.). Okay. But since GV_CONST_VALUE is a GvDynamic type, I'm still not certain about how to set it even with OperatorSetData(). Maybe it wants a GvDynamic in the void* argument?
Again, there is no GvRun returning from GvNodeMaster so use of GvSetPortGeData() seems to be out (for now).
Thank you very much for taking the time to research this and provide working code!
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 03/04/2006 at 19:07, xxxxxxxx wrote:
Still no luck setting constNode's GV_CONST_VALUE. I've tried everything! And I mean everything:
opbc- >SetData()
opbc->SetReal() - good for crashing C4D
constNode->SetParameter() - also can be coaxed into crashing C4D
constNode->OperatorSetData()
assorted GvSetPortData()-like setupsI've printed the OperatorBaseContainer (which does point to the DA_REAL value, but will not set). I've printed the entire GvDynamicData struct (include GvDataInfo). Nothing of use there. ConvertGeDataToGv() never succeeds when attempting to use that, unless I use the ConstNode OutPort - but the data cannot be set without GvRun. And I cannot get a GvRun. Even tried InitCalculate/Calculate/FreeCalculate on the nodeMaster to see if it came into existence - nope.
The fact that some setting attempts literally crash C4D says that there is some deep, hidden stuff to which I am not being privy. The last thing that may be attempted is to go through the Descriptions and see if I can get some sort of DescID set that may work (or continue crashing C4D).
Thanks,
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 04/04/2006 at 17:16, xxxxxxxx wrote:
To continue, it seems that it may not happen until some other area is set or initialized or something. Using OperatorIsSetDataAllowed() on the Constant Node returns FALSE. So no GvRun for setting the GvPort (not that this is the solution) and no way to set the GvOperatorData even if the code is correct.
This is getting very frustrating - I donot like this DYNAMIC stuff at all, not without much more information than is given. Three days of pounding this Dynamic GV_CONST_VALUE description with 1000 lb bombs, mortar fire, strafing, and nuclear warheads - nothin'...it won't budge. ;0)
-
On 02/06/2015 at 05:34, xxxxxxxx wrote:
Hi,
I recently had the same problem, but I had it fixed.
First of all, you have to include the gvconst.h file (you have to do this for every type of node you want to use, apparentally.
So:#include "gvconst.h"
Then, inside your method:
GvNode* constantNode = myNodeMaster->CreateNode(myNodeMaster->GetRoot(), ID_OPERATOR_CONST); if (!constantNode) return false; constantNode->SetParameter(GV_DYNAMIC_DATATYPE, ID_GV_DATA_TYPE_REAL, DESCFLAGS_SET_0); constantNode->SetParameter(GV_CONST_VALUE, Int32(-1), DESCFLAGS_SET_0); GvPort* constantOutPort = constantNode->GetOutPort(0);
This worked for me.
I hope my answer isn't too late.
Greetings,Casimir Smets