int AddNodalLink(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) throw "Given Group isn't a Network"; N3DGraph* graph; param->GetValue(&graph); CK3dEntity* s = (CK3dEntity*)beh->GetInputParameterObject(1); CK3dEntity* e = (CK3dEntity*)beh->GetInputParameterObject(2); float b; beh->GetInputParameterValue(3,&b); graph->InsertEdge(s,e,b); beh->ActivateOutput(0); return CKBR_OK; }
//************************************ // Method: RegisterAttributeType // FullName: RegisterAttributeType // Access: public // Returns: int // Qualifier: // Parameter: const CKBehaviorContext& behcontext //************************************ int RegisterAttributeType(const CKBehaviorContext& behcontext) { CKBehavior* beh = behcontext.Behavior; CKContext* ctx = behcontext.Context; PhysicManager *pm = GetPMan(); CKAttributeManager* attman = ctx->GetAttributeManager(); CKParameterManager *pMan = ctx->GetParameterManager(); using namespace vtTools::BehaviorTools; if( beh->IsInputActive(0) ) { beh->ActivateInput(0,FALSE); CKSTRING name = GetInputParameterValue<CKSTRING>(beh,bbI_Name); CKSTRING category = GetInputParameterValue<CKSTRING>(beh,bbI_Category); CKSTRING defValue = GetInputParameterValue<CKSTRING>(beh,bbI_DefValue); int pType = GetInputParameterValue<int>(beh,bbI_PType); CK_CLASSID classId = GetInputParameterValue<CK_CLASSID>(beh,bbI_Class); int attFlags = 0 ; int user = GetInputParameterValue<int>(beh,bbI_User); int save = GetInputParameterValue<int>(beh,bbI_Save); if(user) attFlags|=CK_ATTRIBUT_USER; if(save) attFlags|=CK_ATTRIBUT_TOSAVE; attFlags|=CK_ATTRIBUT_CAN_DELETE; CKAttributeType aIType = attman->GetAttributeTypeByName(name); if (aIType!=-1) { beh->ActivateOutput(1); } int att = attman->RegisterNewAttributeType(name,pMan->ParameterTypeToGuid(pType),classId,(CK_ATTRIBUT_FLAGS)attFlags); if (strlen(category)) { attman->AddCategory(category); attman->SetAttributeCategory(att,category); } if (strlen(defValue)) { attman->SetAttributeDefaultValue(att,defValue); } } pm->populateAttributeFunctions(); pm->_RegisterAttributeCallbacks(); beh->ActivateOutput(0); return 0; }
int SetCIConnectionDetails(const CKBehaviorContext& behcontext) { /************************************************************************/ /* collecting data : */ /* */ CKBehavior* beh = behcontext.Behavior; CKContext* ctx = behcontext.Context; GBLConfigurationManager* cman=(GBLConfigurationManager*)ctx->GetManagerByGuid(CONFIGURATION_MAN_GUID); CGBLSyncInterface *CINetworkInterface = cman->GetSynInterface(); /************************************************************************/ /* check interface : */ /* */ if (!CINetworkInterface->isValidInterface()) { //try to init the network interface : if (!CINetworkInterface->Init(ctx)) { return CKBR_BEHAVIORERROR; } } /************************************************************************/ /* process building block events : */ /* */ if( beh->IsInputActive(0) ) { beh->ActivateInput(0,FALSE); XString message((CKSTRING) beh->GetInputParameterReadDataPtr(0)); int connectionID = -1; beh->GetInputParameterValue(1,&CINetworkInterface->connectionID); CKAttributeManager *aMan = static_cast<CKAttributeManager*>(ctx->GetAttributeManager()); ////////////////////////////////////////////////////////////////////////// //store connection details in the scipt dummies attribute : CKAttributeType gblNetworkAtt = aMan->GetAttributeTypeByName( GBL_API_ENTRY("NetworkDetails")); if (!CINetworkInterface->messageDummy->HasAttribute(gblNetworkAtt) ) { CINetworkInterface->messageDummy->SetAttribute(gblNetworkAtt); } GBLCommon::ParameterTools::SetParameterStructureValue<int>(CINetworkInterface->messageDummy->GetAttributeParameter(gblNetworkAtt),0,CINetworkInterface->connectionID); GBLCommon::ParameterTools::SetParameterStructureValue<CKSTRING>(CINetworkInterface->messageDummy->GetAttributeParameter(gblNetworkAtt),1,CINetworkInterface->messageName.Str()); ////////////////////////////////////////////////////////////////////////// //activate and execute the script : behcontext.CurrentScene->Activate(CINetworkInterface->synchronizeScript,true); behcontext.CurrentScene->Activate(CINetworkInterface->messageDummy,FALSE); CINetworkInterface->synchronizeScript->Execute(1); beh->ActivateOutput(0); } return CKBR_OK; }
int GBLCOSetID::BehaviourFunction( const CKBehaviorContext& behContext ) { CKBehavior *behaviour = behContext.Behavior; CKContext *context = behContext.Context; behaviour->ActivateInput(ECGBLCOSetLAIDBehInputs::InSetIdentity, FALSE); CKAttributeManager*attributeManager = context->GetAttributeManager(); if (attributeManager != NULL) { CKLevel *level = context->GetCurrentLevel(); if ( level != NULL ) { int attributeType = attributeManager->GetAttributeTypeByName("GBLCOLAID"); if (attributeType == -1) attributeType = attributeManager->RegisterNewAttributeType("GBLCOLAID", GUID_TGBLLAID, CKCID_BEOBJECT); else if ( level->HasAttribute(attributeType) ) level->RemoveAttribute(attributeType); attributeManager->SetAttributeCategory(attributeType,"GBL"); level->SetAttribute(attributeType); CKParameter*attribute = level->GetAttributeParameter(attributeType); if ( attribute != NULL ) { CKParameterIn*pin = behaviour->GetInputParameter(ECGBLCOSetLAIDBehInputs::InSetIdentity); CKParameter*laid = pin->GetDirectSource(); if ( laid != NULL ) { CKERROR err = attribute->CopyValue(laid); if ( err == CK_OK ) { behaviour->ActivateOutput(ECGBLCOSetLAIDBehOutputs::OutIdentitySet, TRUE); behaviour->ActivateOutput(ECGBLCOSetLAIDBehOutputs::OutError, FALSE); return CKBR_OK; } } } } } CKParameterOut *parameterOutError = behaviour->GetOutputParameter(ECGBLCOSetLAIDParamOutputs::GetError); TGBLError::SetTGBLError(parameterOutError,CGBLCOError::EGBLCOErrorType::GBLCO_LOCAL,GBLCO_ERROR_SETID_ATTRIBUTE,GBLCO_ERROR_SETID_ATTRIBUTE_DESC); behaviour->ActivateOutput(ECGBLCOSetLAIDBehOutputs::OutIdentitySet, FALSE); behaviour->ActivateOutput(ECGBLCOSetLAIDBehOutputs::OutError, TRUE); return CKBR_GENERICERROR; }
int SetCIConnectionDetails(const CKBehaviorContext& behcontext) { /************************************************************************/ /* collecting data : */ /* */ CKBehavior* beh = behcontext.Behavior; CKContext* ctx = behcontext.Context; MeasuredObjectiveControllerMgr* mman=(MeasuredObjectiveControllerMgr*)ctx->GetManagerByGuid(MeasuredObjectiveControllerMgrGUID); CGBLSyncInterface * syninterface = CGBLLOArrayHandler::Instance()->GetSynInterface(); /************************************************************************/ /* check interface : */ /* */ if (!syninterface->isValidInterface()) { Logger::ShowDebugMessage(ctx,Logger::ELOGERROR,"interface wrong"); //try to init the network interface : if (!syninterface->Init(ctx)) { Logger::ShowDebugMessage(ctx,Logger::ELOGERROR,"not loaded"); return CKBR_BEHAVIORERROR; } } /************************************************************************/ /* process building block events : */ /* */ if( beh->IsInputActive(0) ) { beh->ActivateInput(0,FALSE); XString message((CKSTRING) beh->GetInputParameterReadDataPtr(0)); int connectionID = -1; beh->GetInputParameterValue(1,&syninterface->connectionID); CKAttributeManager *aMan = static_cast<CKAttributeManager*>(ctx->GetAttributeManager()); ////////////////////////////////////////////////////////////////////////// //store connection details in the scipt dummies attribute : CKAttributeType gblNetworkAtt = aMan->GetAttributeTypeByName( GBL_API_ENTRY("NetworkDetails")); if (!syninterface->messageDummy->HasAttribute(gblNetworkAtt) ) { syninterface->messageDummy->SetAttribute(gblNetworkAtt); } GBLCommon::ParameterTools::SetParameterStructureValue<int>(syninterface->messageDummy->GetAttributeParameter(gblNetworkAtt),0,syninterface->connectionID); GBLCommon::ParameterTools::SetParameterStructureValue<CKSTRING>(syninterface->messageDummy->GetAttributeParameter(gblNetworkAtt),1,syninterface->messageName.Str()); ////////////////////////////////////////////////////////////////////////// //activate and execute the script : behcontext.CurrentScene->Activate(syninterface->synchronizeScript,true); behcontext.CurrentScene->Activate(syninterface->messageDummy,FALSE); syninterface->synchronizeScript->Execute(1); beh->ActivateOutput(0); } return CKBR_OK; }