///////////////////////////////////////////////////// ///////////////////////////////////////////////////// // // ActivateLink // ///////////////////////////////////////////////////// ///////////////////////////////////////////////////// #include "CKAll.h" #include "N3dGraph.h" CKObjectDeclaration *FillBehaviorActivateLinkDecl(); CKERROR CreateActivateLinkProto(CKBehaviorPrototype **); int ActivateLink(const CKBehaviorContext& behcontext); CKObjectDeclaration *FillBehaviorActivateLinkDecl() { CKObjectDeclaration *od = CreateCKObjectDeclaration("Activate Link"); od->SetDescription("Activates or deactivates a link between two nodes of a Nodal Path."); /* rem: In: triggers the process.
Out: is activated when the process is completed.

Nodal Path: nodal path to which the link belongs.
Start Node: link's starting point (node).
End Node: link's ending point (node).
Activate: link will be activated if TRUE, otherwise link will be deactivated.
TwoWay: building block will be applied to both directions if TRUE and if link is two way.

More information on Nodal Paths.
See also: other Nodal related building blocks in the Nodal Path folder of 3D Transformations.
*/ /* warning: - If the two nodes aren't directly linked together, the "Activate Link" building block won't activate all the links that lead from one to another.
*/ od->SetType( CKDLL_BEHAVIORPROTOTYPE); od->SetGuid(CKGUID(0x51df79d8,0x294163a3)); od->SetAuthorGuid(VIRTOOLS_GUID); od->SetAuthorName("Virtools"); od->SetVersion(0x00010000); od->SetCreationFunction(CreateActivateLinkProto); od->SetCompatibleClassId(CKCID_BEOBJECT); od->SetCategory("3D Transformations/Nodal Path"); return od; } CKERROR CreateActivateLinkProto(CKBehaviorPrototype **pproto) { CKBehaviorPrototype *proto = NULL; proto = CreateCKBehaviorPrototype("Activate Link"); if(!proto) return CKERR_OUTOFMEMORY; proto->DeclareInput("In"); proto->DeclareOutput("Out"); proto->DeclareInParameter("Nodal Path",CKPGUID_GROUP); proto->DeclareInParameter("Start Node",CKPGUID_3DENTITY); proto->DeclareInParameter("End Node",CKPGUID_3DENTITY); proto->DeclareInParameter("Activate",CKPGUID_BOOL,"FALSE"); proto->DeclareInParameter("Two Way",CKPGUID_BOOL,"FALSE"); proto->SetFlags(CK_BEHAVIORPROTOTYPE_NORMAL); proto->SetFunction( ActivateLink ); *pproto = proto; return CK_OK; } int ActivateLink(const CKBehaviorContext& behcontext) { CKBehavior* beh = behcontext.Behavior; CKContext* ctx = behcontext.Context; CKAttributeManager* attman = ctx->GetAttributeManager(); beh->ActivateInput(0,FALSE); beh->ActivateOutput(0); CKGroup* group = (CKGroup*)beh->GetInputParameterObject(0); CKParameterOut* param = group->GetAttributeParameter(attman->GetAttributeTypeByName(Network3dName)); if(!param) VXTHROW "Given Group isn't a Network"; N3DGraph* graph; param->GetValue(&graph); CK3dEntity* s = (CK3dEntity*)beh->GetInputParameterObject(1); CK3dEntity* e = (CK3dEntity*)beh->GetInputParameterObject(2); BOOL b = FALSE; beh->GetInputParameterValue(3,&b); // the core code graph->ActivateEdge(s,e,b); BOOL tw = FALSE; beh->GetInputParameterValue(4,&tw); if(tw) graph->ActivateEdge(e,s,b); return CKBR_OK; }