/////////////////////////////////////////////////////
/////////////////////////////////////////////////////
//
// ActivateNode
//
/////////////////////////////////////////////////////
/////////////////////////////////////////////////////
#include "CKAll.h"
#include "N3dGraph.h"
CKObjectDeclaration *FillBehaviorActivateNodeDecl();
CKERROR CreateActivateNodeProto(CKBehaviorPrototype **);
int ActivateNode(const CKBehaviorContext& behcontext);
CKObjectDeclaration *FillBehaviorActivateNodeDecl()
{
CKObjectDeclaration *od = CreateCKObjectDeclaration("Activate Node");
od->SetDescription("Activates or deactivates a node in a Nodal Path.");
/* rem:
In: triggers the process.
Out: is activated when the process is completed.
Nodal Path: nodal path to which the node belongs.
Node: object representing the node to activate or deactivate.
Activate: node will be activated if TRUE, otherwise node will be deactivated.
If a node is deactivated, then all links leading to or from the node will also be deactivated.
More information on Nodal Paths.
See also: other Nodal related building blocks in the Nodal Path folder of 3D Transformations.
*/
od->SetType( CKDLL_BEHAVIORPROTOTYPE);
od->SetGuid(CKGUID(0x92a4e59,0x4009769c));
od->SetAuthorGuid(VIRTOOLS_GUID);
od->SetAuthorName("Virtools");
od->SetVersion(0x00010000);
od->SetCreationFunction(CreateActivateNodeProto);
od->SetCompatibleClassId(CKCID_BEOBJECT);
od->SetCategory("3D Transformations/Nodal Path");
return od;
}
CKERROR CreateActivateNodeProto(CKBehaviorPrototype **pproto)
{
CKBehaviorPrototype *proto = NULL;
proto = CreateCKBehaviorPrototype("Activate Node");
if(!proto) return CKERR_OUTOFMEMORY;
proto->DeclareInput("In");
proto->DeclareOutput("Out");
proto->DeclareInParameter("Nodal Path",CKPGUID_GROUP);
proto->DeclareInParameter("Node",CKPGUID_3DENTITY);
proto->DeclareInParameter("Activate",CKPGUID_BOOL,"FALSE");
proto->SetFlags(CK_BEHAVIORPROTOTYPE_NORMAL);
proto->SetFunction( ActivateNode );
*pproto = proto;
return CK_OK;
}
int ActivateNode(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);
BOOL b = FALSE;
beh->GetInputParameterValue(2,&b);
// the core code
graph->ActivateState(s,b);
return CKBR_OK;
}