int GetLastFileName(const CKBehaviorContext& behcontext) { CKBehavior* beh = behcontext.Behavior; CKContext* ctx = behcontext.Context; XString Inpath (ctx->GetLastCmoLoaded()); CKParameterOut *pout = beh->GetOutputParameter(0); pout->SetStringValue(Inpath.Str()); PathRemoveFileSpec(Inpath.Str()); CKParameterOut *pout2 = beh->GetOutputParameter(1); pout2->SetStringValue(Inpath.Str()); beh->ActivateOutput(0); return 0; }
//************************************ // Method: GetDocument // FullName: vtPhysics::pFactory::GetDocument // Access: public // Returns: TiXmlDocument* // Qualifier: // Parameter: XString filename //************************************ TiXmlDocument* pFactory::getDocument(XString filename) { XString fname(filename.Str()); if ( fname.Length() ) { XString fnameTest = ResolveFileName(fname.CStr()); if ( fnameTest.Length()) { TiXmlDocument* result = new TiXmlDocument(fnameTest.Str()); result->LoadFile(fnameTest.Str()); result->Parse(fnameTest.Str()); TiXmlNode* node = result->FirstChild( "vtPhysics" ); if (!node) { GetPMan()->m_Context->OutputToConsoleEx("PFactory : Couldn't load Document : %s",filename.Str()); return NULL; }else { return result; } } } return NULL; }
void CGBLStorageManagerTestBBBase::OutputTestText( CKContext *ctx, XString &text ) { // Write to output if we can... if( ctx ) { ctx->SendInterfaceMessage(CKUIM_SENDNOTIFICATION, (CKDWORD)text.Str(),0,CUIK_NOTIFICATION_DEBUGMESSAGE); ctx->OutputToConsole(text.Str(),false); } }
/* ******************************************************************* * Function: IGBLSMLAEAccess::StoreUser * * Description: Stores a user against an LAE. Essentially allows the given user permission * to participate in the given LAE. Checks whether the given user is already related to the given LAE and if * so, doesn't add another record. * * * Parameters: * CGBLLAEID laeid * CGBLUserID user * * Returns: * CGBLCOError * ******************************************************************* */ CGBLCOError IGBLSMLAEAccess::StoreUser( CGBLLAEID laeid, CGBLUserID user ) { CGBLCOError error(CGBLCOError::EGBLCOErrorType::GBLCO_OK); // Check we're actually connected to the server first... if ( !(storageManager->IsConnected()) ) { error = CGBLCOError(CGBLCOError::EGBLCOErrorType::GBLCO_LOCAL, GBLSM_ERROR_PROFILEACCESS_NO_CONNECTION_DESC, GBLSM_ERROR_PROFILEACCESS_NO_CONNECTION ); } else { XString query; XString dbName; storageManager->GetDbName( dbName ); // First thing we need to do is query to see whether an entry for the given user already exists... query = ""; query << "SELECT UserID FROM " << dbName << ".EventUsers WHERE LAEID=" << (int)laeid << " AND UserID=" << (int)user; // Now execute this query and see if we have any results CKDataArray *results = (CKDataArray *)storageManager->m_Context->CreateObject(CKCID_DATAARRAY,"IGBLSMLAEAccess::StoreUser", CK_OBJECTCREATION_DYNAMIC); storageManager->m_Context->GetCurrentLevel()->AddObject( results ); int queryResult = storageManager->ExecuteBlockingSQL( query.Str(), results ); if( queryResult == CGBLSMStorageManager::EGBLStorageManagerExecutionStatus::Result ) { // A record already exists, we do nothing } else if( queryResult == CGBLSMStorageManager::EGBLStorageManagerExecutionStatus::NoResult ) { // We need to create a record query = ""; query << "INSERT INTO " << dbName << ".EventUsers (LAEID,UserID) VALUES(" << (int)laeid << "," << (int)user << ")"; int insertResult = storageManager->ExecuteBlockingSQL( query.Str() ); if( insertResult != CGBLSMStorageManager::EGBLStorageManagerExecutionStatus::NoResult ) { error = CGBLCOError(CGBLCOError::EGBLCOErrorType::GBLCO_LOCAL, GBLSM_ERROR_GENERAL_SQL_ERROR_DESC, GBLSM_ERROR_GENERAL_SQL_ERROR); } } else { error = CGBLCOError(CGBLCOError::EGBLCOErrorType::GBLCO_LOCAL, GBLSM_ERROR_GENERAL_SQL_ERROR_DESC, GBLSM_ERROR_GENERAL_SQL_ERROR); } storageManager->m_Context->GetCurrentLevel()->RemoveObject( results ); storageManager->m_Context->DestroyObject( results ); } return error; }
void pWheel2::setWheelContactScript(int val) { CKBehavior * beh = (CKBehavior*)GetPMan()->GetContext()->GetObject(val); if (!beh) return; XString errMessage; if (!GetPMan()->checkCallbackSignature(beh,CB_OnWheelContactModify,errMessage)) { xError(errMessage.Str()); return; } pCallbackObject::setWheelContactScript(val); wheelContactModifyCallback = new pWheelContactModify(); wheelContactModifyCallback->setWheel(this); getWheelShape()->setUserWheelContactModify((NxUserWheelContactModify*)wheelContactModifyCallback); //---------------------------------------------------------------- //track information about callback getBody()->getCallMask().set(CB_OnWheelContactModify,true); }
/* ******************************************************************* * Function:GBLCommon::ResourceTools::LoadFile() * * * Description : Loads a virtools file from a specific application handle into * a given CKContext. * * Parameters : ctx, r : the virtools context filename, r : the filepath hidden, r : add object to the current level loadflags, r : how to load. targetArray, r,w : the loaded array * Returns : CKObjectArray * = the loaded objects, otherwise NULL * ******************************************************************* */ CKBOOL GBLCommon::ResourceTools::LoadFromFile( CKContext *ctx, XString filename, CKBOOL hidden, CK_LOAD_FLAGS loadflags, CKObjectArray* targetArray) { CKBOOL result = false; CKERROR res=CK_OK; if ((res=ctx->Load(filename.Str(),targetArray,loadflags))==CK_OK) { CKLevel* currentLevel=ctx->GetCurrentLevel(); result =true; for( targetArray->Reset() ; !targetArray->EndOfList() ; ) { CKObject *tmpObj = targetArray->GetData( ctx ); if (currentLevel) { currentLevel->AddObject(tmpObj); } if (hidden) { tmpObj->ModifyObjectFlags(tmpObj->GetObjectFlags()|CK_OBJECT_PRIVATE|CK_OBJECT_NOTTOBELISTEDANDSAVED,CK_OBJECT_VISIBLE); } targetArray->Next(); } } return result; }
/* ******************************************************************* * Function: IGBLSMConfigurationAccess::RemoveCIS * * Description: Removes a CIS and all associated CIs from persistent storage. * * * Parameters: * CGBLCISID cisid * * Returns: * CGBLCOError * ******************************************************************* */ CGBLCOError IGBLSMConfigurationAccess::RemoveCIS( CGBLCISID cisid ) { CGBLCOError error(CGBLCOError::EGBLCOErrorType::GBLCO_OK); // Check we're actually connected to the server first... if ( !(storageManager->IsConnected()) ) { error = CGBLCOError(CGBLCOError::EGBLCOErrorType::GBLCO_LOCAL, GBLSM_ERROR_PROFILEACCESS_NO_CONNECTION_DESC, GBLSM_ERROR_PROFILEACCESS_NO_CONNECTION ); } else { XString query; XString dbName; storageManager->GetDbName( dbName ); query << "DELETE FROM " << dbName << ".ciss WHERE ID=" << (int)cisid; // Now execute it and check the response... int queryResult = storageManager->ExecuteBlockingSQL( query.Str() ); if( queryResult != CGBLSMStorageManager::EGBLStorageManagerExecutionStatus::NoResult ) { error = CGBLCOError(CGBLCOError::EGBLCOErrorType::GBLCO_LOCAL, GBLSM_ERROR_GENERAL_SQL_ERROR_DESC, GBLSM_ERROR_GENERAL_SQL_ERROR); } } return error; }
/* ******************************************************************* * Function: IGBLSMLAEAccess::RemoveUser * * Description: Removes the association between a user and an LAE. * * * Parameters: * CGBLLAEID laeid * CGBLUserID user * * Returns: * CGBLCOError * ******************************************************************* */ CGBLCOError IGBLSMLAEAccess::RemoveUser( CGBLLAEID laeid, CGBLUserID user ) { CGBLCOError error(CGBLCOError::EGBLCOErrorType::GBLCO_OK); // Check we're actually connected to the server first... if ( !(storageManager->IsConnected()) ) { error = CGBLCOError(CGBLCOError::EGBLCOErrorType::GBLCO_LOCAL, GBLSM_ERROR_PROFILEACCESS_NO_CONNECTION_DESC, GBLSM_ERROR_PROFILEACCESS_NO_CONNECTION ); } else { XString query; XString dbName; // Get the name of the DB we're using storageManager->GetDbName(dbName); // Now build the query query = ""; query << "DELETE FROM " << dbName << ".EventUsers WHERE LAEID=" << (int)laeid << " AND UserID=" << (int)user; // Execute the query int deleteResult = storageManager->ExecuteBlockingSQL( query.Str() ); if( deleteResult != CGBLSMStorageManager::EGBLStorageManagerExecutionStatus::NoResult ) { error = CGBLCOError(CGBLCOError::EGBLCOErrorType::GBLCO_LOCAL, GBLSM_ERROR_GENERAL_SQL_ERROR_DESC, GBLSM_ERROR_GENERAL_SQL_ERROR); } } return error; }
void GBLStorageManagerStateTestBB::RetrieveStateTest( CKContext *ctx ) { XString outputStr; XString data; outputStr.Format( "Calling RetrieveState( %d, &<data>, %d, %d )", (int)testUserID, (int)testLAEID, componentID ); OutputTestText( ctx, outputStr ); StartTimeMeasure(); CGBLCOError res = pInterface->RetrieveState( testUserID, &data, testLAEID, componentID ); StopAndOutputTimeMeasure( ctx ); outputStr.Format( "RetrieveState result: %s", (const char*)res ); OutputTestText( ctx, outputStr ); if (res == CGBLCOError::EGBLCOErrorType::GBLCO_OK) { outputStr.Format( "State data retrieved: %s", data.Str() ); OutputTestText( ctx, outputStr ); if( testData == data ) OutputTestText( ctx, XString("TEST PASSED") ); else OutputTestText( ctx, XString("Retrieved data doesn't match saved data\r\nTEST FAILED") ); } else OutputTestText( ctx, XString("TEST FAILED") ); }
CGBLCOError GBLCommon::ResourceTools::SaveObject( CKBeObject*beo, XString filename) { if (!beo) { return CGBLCOError(CGBLCOError::GBLCO_LOCAL,"Invalid Object",GBL_ERROR_ID_GBL_COMMON); } //todo : adding checks for saving ability if(!filename.Length()) { return CGBLCOError(CGBLCOError::GBLCO_LOCAL,"No path specified",GBL_ERROR_ID_GBL_COMMON); } CKERROR res = CK_OK; CKObjectArray* oa = CreateCKObjectArray(); oa->InsertAt(beo->GetID()); res = beo->GetCKContext()->Save(filename.Str(),oa,0xFFFFFFFF,NULL); DeleteCKObjectArray(oa); return CGBLCOError(CGBLCOError::EGBLCOErrorType::GBLCO_LOCAL,CKErrorToString(res),GBL_ERROR_ID_GBL_COMMON); }
CKERROR LoadCallBack(CKUICallbackStruct& loaddata,void*) { if (GetPlayer().GetPAppStyle()->UseSplash() && GetPlayer().GetPAppStyle()->ShowLoadingProcess()) { if(loaddata.Reason == CKUIM_LOADSAVEPROGRESS ){ if (loaddata.NbObjetsLoaded % 10 == 0) { float progress = (static_cast<float>(loaddata.NbObjetsLoaded) / static_cast<float>(loaddata.NbObjetsToLoad)) ; progress *=100; int out = static_cast<int>(progress); XString percStr; percStr.Format("Load... %d %s",out,"%"); if (xSplash::GetSplash()) { GetPlayer().SetSplashText(percStr.Str()); if (progress > 99.9F) { GetPlayer().HideSplash(); //Sleep(3000); } } } } } return CK_OK; }
void CGBLStorageManagerTestBBBase::StopAndShowTimeMeasure(ofstream &_trace, float &totalTime) { float executionTime = TimeDiff(); totalTime += executionTime; XString disp = ""; disp << executionTime; _trace << "Execution time: " << disp.Str() << " seconds" <<endl; }
/* ******************************************************************* * Function: CKERROR InitInstance( CKContext* theContext ) * * Description : If no manager is used in the plugin these functions * are optional and can be exported. Virtools will call * 'InitInstance' when loading the behavior library and * 'ExitInstance' when unloading it. It is a good place * to perform Attributes Types declaration, registering new * enums or new parameter types. * * Parameters : CKContext* theContext * * * Returns : CKERROR * ******************************************************************* */ CKERROR InitInstance( CKContext* theContext ) { new CGBLProfileManager( theContext ); CKParameterManager* pm = theContext->GetParameterManager(); //--- TODO: A Delete function needs to be registered, until then these will leak! CKParameterTypeDesc pProfile; pProfile.Guid = GUID_PROFILE_ID; pProfile.DerivedFrom = CKGUID(0,0); pProfile.TypeName = "TGBLProfileID"; pProfile.DefaultSize = sizeof(CGBLProfileID); pProfile.CreateDefaultFunction = CKProfileCreator; pProfile.StringFunction = CKProfileStringFunc; //pProfile.UICreatorFunction = pm->RegisterParameterType(&pProfile); CKParameterTypeDesc pTeam; pTeam.Guid = GUID_TEAM_ID; pTeam.DerivedFrom = GUID_PROFILE_ID; pTeam.TypeName = "TGBLTeamID"; pTeam.DefaultSize = sizeof(CGBLTeamID); pTeam.CreateDefaultFunction = CKTeamCreator; pTeam.StringFunction = CKProfileStringFunc; //pTeam.UICreatorFunction = pm->RegisterParameterType(&pTeam); CKParameterTypeDesc pUser; pUser.Guid = GUID_USER_ID; pUser.DerivedFrom = GUID_PROFILE_ID; pUser.TypeName = "TGBLUserID"; pUser.DefaultSize = sizeof(CGBLUserID); pUser.CreateDefaultFunction = CKUserCreator; pUser.StringFunction = CKProfileStringFunc; //pUser.UICreatorFunction = pm->RegisterParameterType(&pUser); // Prevent designer from creating a Profile ID as this is an invalid type. CKParameterTypeDesc* param_type; param_type = pm->GetParameterTypeDescription(GUID_PROFILE_ID); if (param_type) param_type->dwFlags|=CKPARAMETERTYPE_HIDDEN; CGBLTypeHandler THandler(theContext); XString typeList; THandler.GetTypesList(typeList); pm->RegisterNewEnum(EGBLProfileFieldTypeGUID, "EGBLProfileFieldType", typeList.Str()); pm->RegisterNewEnum(EGBLUserTypeGUID, "EGBLUserType", "Player=0,Facilitator=1"); return CK_OK; }
/* ******************************************************************* * Function: IGBLSMConfigurationAccess::RetrieveCI * * Description: Retrieves the CI data associated with the record identified * by the given CI ID * * * Parameters: * int *flags * XString *type * XString *realValue * XString *name * XString *description * XString *defaultValue * CGBLCIID ciid * * Returns: * CGBLCOError * ******************************************************************* */ CGBLCOError IGBLSMConfigurationAccess::RetrieveCI( int *flags, XString *type, XString *realValue, XString *name, XString *description, XString *defaultValue, CGBLCIID ciid ) { CGBLCOError error(CGBLCOError::EGBLCOErrorType::GBLCO_OK); // Check we're actually connected to the server first... if ( !(storageManager->IsConnected()) ) { error = CGBLCOError(CGBLCOError::EGBLCOErrorType::GBLCO_LOCAL, GBLSM_ERROR_PROFILEACCESS_NO_CONNECTION_DESC, GBLSM_ERROR_PROFILEACCESS_NO_CONNECTION ); } else { // Build the query we need to retrieve the LAE XString query; XString dbName; storageManager->GetDbName(dbName); query = ""; query << "SELECT DefaultValue,Description,Flags,Name,RealValue,Type FROM " << dbName << ".cis WHERE CIID=" << (int)ciid; // Create a temporary array to store the results in CKDataArray *results = (CKDataArray *)storageManager->m_Context->CreateObject(CKCID_DATAARRAY,"IGBLSMLAEAccess::RetrieveLAE", CK_OBJECTCREATION_DYNAMIC); storageManager->m_Context->GetCurrentLevel()->AddObject( results ); // Execute the query int queryResult = storageManager->ExecuteBlockingSQL( query.Str(), results ); if( queryResult == CGBLSMStorageManager::EGBLStorageManagerExecutionStatus::Result ) { // Excellent, we've got the record back. Now we need to get the various bits of data into the passed arguments CGBLSMUtils::ElementToXstring( 0, 0, results, defaultValue ); CGBLSMUtils::ElementToXstring( 0, 1, results, description ); results->GetElementValue( 0, 2, flags ); CGBLSMUtils::ElementToXstring( 0, 3, results, name ); CGBLSMUtils::ElementToXstring( 0, 4, results, realValue ); CGBLSMUtils::ElementToXstring( 0, 5, results, type ); } else if( queryResult == CGBLSMStorageManager::EGBLStorageManagerExecutionStatus::NoResult ) { // Ok, no results were returned, this must mean a bad laeid error = CGBLCOError( CGBLCOError::EGBLCOErrorType::GBLCO_LOCAL, GBLSM_ERROR_GENERAL_INCORRECT_PARAM_DESC, GBLSM_ERROR_GENERAL_INCORRECT_PARAM ); } else { // Something else went wrong error = CGBLCOError(CGBLCOError::EGBLCOErrorType::GBLCO_LOCAL, GBLSM_ERROR_GENERAL_SQL_ERROR_DESC, GBLSM_ERROR_GENERAL_SQL_ERROR); } storageManager->m_Context->GetCurrentLevel()->RemoveObject(results); storageManager->m_Context->DestroyObject(results); } return error; }
int CCustomPlayer::InitEngine(HWND iMainWindow) { m_MainWindow = iMainWindow; // start the Virtools Engine CKStartUp(); // retrieve the plugin manager ... CKPluginManager* pluginManager = CKGetPluginManager(); // ... to intialize plugins ... if (!_InitPlugins(*pluginManager)) { MessageBox(NULL,UNABLE_TO_INIT_PLUGINS,INIT_ERROR,MB_OK|MB_ICONERROR); return FALSE; } // ... and the render engine. int renderEngine = _InitRenderEngines(*pluginManager); if (renderEngine==-1) { MessageBox(NULL,UNABLE_TO_LOAD_RENDERENGINE,INIT_ERROR,MB_OK|MB_ICONERROR); return FALSE; } XString inifile = CKGetStartPath(); inifile << "CompositionPrefs_R_Hi.ini"; CKERROR res = CKCreateContext(&m_CKContext,m_MainWindow,inifile.Str()); if (res!=CK_OK) { MessageBox(NULL,UNABLE_TO_INIT_CK,INIT_ERROR,MB_OK|MB_ICONERROR); return FALSE; } // retrieve the main managers which will be used by the player m_MessageManager = m_CKContext->GetMessageManager(); m_RenderManager = m_CKContext->GetRenderManager(); m_TimeManager = m_CKContext->GetTimeManager(); m_AttributeManager = m_CKContext->GetAttributeManager(); m_InputManager = (CKInputManager*)m_CKContext->GetManagerByGuid(INPUT_MANAGER_GUID); if (!m_MessageManager || !m_RenderManager || !m_TimeManager || !m_AttributeManager || !m_InputManager) { MessageBox(NULL,UNABLE_TO_INIT_MANAGERS,INIT_ERROR,MB_OK|MB_ICONERROR); return FALSE; } // initialize the display driver using the player configuration (resolution, rasterizer, ...) if (!_InitDriver()) { MessageBox(NULL,UNABLE_TO_INIT_DRIVER,INIT_ERROR,MB_OK|MB_ICONERROR); return FALSE; } return TRUE; }
int DirToArray(const CKBehaviorContext& behcontext) { CKBehavior* beh = behcontext.Behavior; CKContext* ctx = behcontext.Context; XString filename((CKSTRING) beh->GetInputParameterReadDataPtr(0)); XString Mask((CKSTRING) beh->GetInputParameterReadDataPtr(1)); int rec; beh->GetInputParameterValue(2,&rec); if( beh->IsInputActive(0) ){ beh->ActivateInput(0,FALSE); flist.erase(flist.begin(),flist.end()); CKDirectoryParser MyParser(filename.Str(),Mask.Str(),rec); char* str = NULL; while(str = MyParser.GetNextFile()) flist.push_back(XString(str)); counter = 0; beh->ActivateInput(1,TRUE); } if( beh->IsInputActive(1) ){ beh->ActivateInput(1,FALSE); if ( counter < flist.size() ){ XString entry = flist.at(counter); CKParameterOut * pout = beh->GetOutputParameter(0); pout->SetStringValue(entry.Str() ); counter++; beh->SetOutputParameterValue(1,&counter); beh->ActivateOutput(1); }else{ beh->SetOutputParameterValue(1,&counter); counter = 0 ; beh->ActivateOutput(0); } } return 0; }
/* ******************************************************************* * Function: IGBLSMConfigurationAccess::RetrieveCIS * * Description: Retrieves the CIS data associated with the record identified * by the given CIS ID * * * Parameters: * XString *name * bool *isDefault * CGBLCISID cisid * * Returns: * CGBLCOError * ******************************************************************* */ CGBLCOError IGBLSMConfigurationAccess::RetrieveCIS( XString *name, bool *isDefault, CGBLCISID cisid ) { CGBLCOError error(CGBLCOError::EGBLCOErrorType::GBLCO_OK); // Check we're actually connected to the server first... if ( !(storageManager->IsConnected()) ) { error = CGBLCOError(CGBLCOError::EGBLCOErrorType::GBLCO_LOCAL, GBLSM_ERROR_PROFILEACCESS_NO_CONNECTION_DESC, GBLSM_ERROR_PROFILEACCESS_NO_CONNECTION ); } else { XString query; XString dbName; storageManager->GetDbName( dbName ); query << "SELECT Name, IsDefault FROM " << dbName << ".ciss WHERE ID=" << (int)cisid; // Now create a temporary array to hold the query results CKDataArray * resultsArray = (CKDataArray*)storageManager->m_Context->CreateObject( CKCID_DATAARRAY, "IGBLSMConfigurationAccess::RetrieveCISID", CK_OBJECTCREATION_DYNAMIC ); storageManager->m_Context->GetCurrentLevel()->AddObject( resultsArray ); // Execute the query int queryRes = storageManager->ExecuteBlockingSQL( query.Str(), resultsArray ); if( queryRes == CGBLSMStorageManager::EGBLStorageManagerExecutionStatus::Result ) { // Get the values out of the array CGBLSMUtils::ElementToXstring( 0, 0, resultsArray, name ); int defaultValueAsInt; resultsArray->GetElementValue( 0, 1, (void*)&defaultValueAsInt ); *isDefault = (defaultValueAsInt != 0); } else if( queryRes == CGBLSMStorageManager::EGBLStorageManagerExecutionStatus::NoResult ) { error = CGBLCOError( CGBLCOError::EGBLCOErrorType::GBLCO_LOCAL, GBLSM_ERROR_GENERAL_INCORRECT_PARAM_DESC, GBLSM_ERROR_GENERAL_INCORRECT_PARAM ); } else { error = CGBLCOError(CGBLCOError::EGBLCOErrorType::GBLCO_LOCAL, GBLSM_ERROR_GENERAL_SQL_ERROR_DESC, GBLSM_ERROR_GENERAL_SQL_ERROR); } // Remove and destory the temporary array //storageManager->m_Context->GetCurrentLevel()->RemoveObject( resultsArray ); //storageManager->m_Context->DestroyObject( resultsArray ); } return error; }
XString pFactory::_getEnumDescription(const TiXmlDocument *doc, XString identifier) { if (!doc) { return XString(""); } XString result("None=0"); int counter = 1; /************************************************************************/ /* try to load settings from xml : */ /************************************************************************/ if ( doc) { const TiXmlElement *root = getFirstDocElement(doc->RootElement()); for (const TiXmlNode *child = root->FirstChild(); child; child = child->NextSibling() ) { if ( (child->Type() == TiXmlNode::ELEMENT)) { XString name = child->Value(); if (!strcmp(child->Value(), identifier.Str() ) ) { const TiXmlElement *sube = (const TiXmlElement*)child; const char* matName = NULL; matName = sube->Attribute("name"); if (matName && strlen(matName)) { if (result.Length()) { result << ","; } result << matName; result << "=" << counter; counter ++; } } } } } return result; }
/* ******************************************************************* * Function: int CGBLBuildCommand::GetNextArgument (CKParameter* nextArgument,CKBehavior* targetBB, const CKBehaviorContext& behaviorContext) * * Description : This function sets corresponding outputs with requested argument's * name, type and if the type of arguments is TGBLFCStringFromList, it also * provides designer specified list array with GetDesignerSpecifiedList output. * * Parameters : * behaviourContext r Behavior context reference, which gives * access to frequently used global objects * ( context, level, manager, etc... ) * * nextArgument r Required argument to have parameters provided by the command * * targetBB r Target GBLWaitForCommand building block * * Returns : int, The return value is 0 if no error occured or -1 on error * ******************************************************************* */ int CGBLBuildCommand::GetNextArgument (CKParameter* nextArgument,CKBehavior* targetBB, const CKBehaviorContext& behaviorContext) { CKBehavior* behavior = behaviorContext.Behavior; CKContext* context = behaviorContext.Context; XString typeName = context->GetParameterManager()->ParameterTypeToName(nextArgument->GetType()); XString argumentName = nextArgument->GetName(); if (typeName == "TGBLFCStringFromList") { int inputs = targetBB->GetInputParameterCount(); for (int i=0; i<inputs; i++) { CKParameterIn *parameterInput = targetBB->GetInputParameter(i); if ( argumentName == parameterInput->GetName() ) { CKParameterOut *parameterOutput = behavior->GetOutputParameter(EGBLBuildCommandParamOutputs::GetDesignerSpecifiedList); context->OutputToConsole(context->GetParameterManager()->ParameterTypeToName(parameterOutput->GetType()), FALSE); context->OutputToConsole(context->GetParameterManager()->ParameterTypeToName(parameterInput->GetType()), FALSE); parameterOutput->CopyValue (parameterInput->GetDirectSource()); break; } } } behavior->SetOutputParameterValue (EGBLBuildCommandParamOutputs::GetArgumentType, typeName.Str(), strlen (typeName.Str()) + 1 ); behavior->SetOutputParameterValue (EGBLBuildCommandParamOutputs::GetArgumentName, argumentName.Str(), strlen (argumentName.Str()) + 1 ); behavior->ActivateOutput (EGBLBuildCommandBehOutputs::GetNextParameterValue); return 0; }
/* ******************************************************************* * Function: IGBLSMConfigurationAccess::RetrieveCISID * * Description: Retrieves the CIS ID of the CIS associated with either * the given LA ID or LAE ID * * * Parameters: * CGBLCISID *cisid * CGBLLAID *laid * CGBLLAEID *laeid * * Returns: * CGBLCOError * ******************************************************************* */ CGBLCOError IGBLSMConfigurationAccess::RetrieveCISID( CGBLCISID *cisid, CGBLLAID *laid, CGBLLAEID *laeid ) { CGBLCOError error(CGBLCOError::EGBLCOErrorType::GBLCO_OK); // Check we're actually connected to the server first... if ( !(storageManager->IsConnected()) ) { error = CGBLCOError(CGBLCOError::EGBLCOErrorType::GBLCO_LOCAL, GBLSM_ERROR_PROFILEACCESS_NO_CONNECTION_DESC, GBLSM_ERROR_PROFILEACCESS_NO_CONNECTION ); } else { XString query; XString dbName; storageManager->GetDbName( dbName ); // Build a query based on where the CIS ID was requested if( laid != NULL ) query << "SELECT CISID FROM " << dbName << ".LearningApplications WHERE LAID='" << laid->ToString() << "'"; else query << "SELECT CISID FROM " << dbName << ".LAEs WHERE LAEID=" << (int)(*laeid); // Now create a temporary array to hold the query results CKDataArray * resultsArray = (CKDataArray*)storageManager->m_Context->CreateObject( CKCID_DATAARRAY, "IGBLSMConfigurationAccess::RetrieveCISID", CK_OBJECTCREATION_DYNAMIC ); storageManager->m_Context->GetCurrentLevel()->AddObject( resultsArray ); // Execute the query int queryRes = storageManager->ExecuteBlockingSQL( query.Str(), resultsArray ); if( queryRes == CGBLSMStorageManager::EGBLStorageManagerExecutionStatus::Result ) { // Get the result and populate the CIS ID int returnedCISID; resultsArray->GetElementValue(0, 0, &returnedCISID); *cisid = returnedCISID; } else { error = CGBLCOError(CGBLCOError::EGBLCOErrorType::GBLCO_LOCAL, GBLSM_ERROR_GENERAL_SQL_ERROR_DESC, GBLSM_ERROR_GENERAL_SQL_ERROR); } // Remove and destory the temporary array storageManager->m_Context->GetCurrentLevel()->RemoveObject( resultsArray ); storageManager->m_Context->DestroyObject( resultsArray ); } return error; }
CKSTRING GBLCommon::ResourceTools:: GetFileNameFromFullPath(XString path) { char *pc = path.Str(); int LastBackSlash =-1; int iChar = 0; while(pc[iChar] != 0) { if(pc[iChar] == GBL_FS_PATH_SEPERATOR )LastBackSlash = iChar; iChar++; } return pc + LastBackSlash +1 ; }
/* ******************************************************************* * Function: IGBLSMConfigurationAccess::RetrieveCIList * * Description: Retrieves a list containing the IDs of all the CIs * associated with the given CIS ID * * * Parameters: * CKDataArray * ciList * CGBLCISID cisid * * Returns: * CGBLCOError * ******************************************************************* */ CGBLCOError IGBLSMConfigurationAccess::RetrieveCIList( CKDataArray * ciList, CGBLCISID cisid ) { CGBLCOError error( CGBLCOError::EGBLCOErrorType::GBLCO_OK ); // Check we're actually connected to the server first... if ( !(storageManager->IsConnected()) ) { error = CGBLCOError(CGBLCOError::EGBLCOErrorType::GBLCO_LOCAL, GBLSM_ERROR_PROFILEACCESS_NO_CONNECTION_DESC, GBLSM_ERROR_PROFILEACCESS_NO_CONNECTION ); } else { // Check the arguments that we're dependent on if( ciList == NULL ) { error = CGBLCOError( CGBLCOError::EGBLCOErrorType::GBLCO_LOCAL, GBLSM_ERROR_GENERAL_INCORRECT_PARAM_DESC, GBLSM_ERROR_GENERAL_INCORRECT_PARAM ); } else { XString query; XString dbName; storageManager->GetDbName( dbName ); // Build the query... query = ""; query << "SELECT CIID as ID FROM " << dbName << ".cis WHERE CISID=" << cisid.GetIntID(); // Clear down the array before we proceed CGBLSMUtils::ClearArray( ciList ); // Execute the query int queryResults = storageManager->ExecuteBlockingSQL( query.Str(), ciList ); if( queryResults == CGBLSMStorageManager::EGBLStorageManagerExecutionStatus::NoResult ) { error = CGBLCOError( CGBLCOError::EGBLCOErrorType::GBLCO_LOCAL, GBLSM_ERROR_GENERAL_INCORRECT_PARAM_DESC, GBLSM_ERROR_GENERAL_INCORRECT_PARAM ); } else if( queryResults != CGBLSMStorageManager::EGBLStorageManagerExecutionStatus::Result ) { error = CGBLCOError(CGBLCOError::EGBLCOErrorType::GBLCO_LOCAL, GBLSM_ERROR_GENERAL_SQL_ERROR_DESC, GBLSM_ERROR_GENERAL_SQL_ERROR); } } } return error; }
int getEnumIndex(CKParameterManager* pm,CKGUID parGuide,XString enumValue) { int pType = pm->ParameterGuidToType(parGuide); CKEnumStruct *enumStruct = pm->GetEnumDescByType(pType); if ( enumStruct ) { for (int i = 0 ; i < enumStruct->GetNumEnums() ; i ++ ) { if( !strcmp(enumStruct->GetEnumDescription(i),enumValue.Str()) ) return i; } } return 0; }
/* ******************************************************************* * Function: IGBLSMLAEAccess::RetrieveUsers * * Description: * * * Parameters: * CKDataArray *userList * CGBLLAEID laeid * * Returns: * CGBLCOError * ******************************************************************* */ CGBLCOError IGBLSMLAEAccess::RetrieveUsers( CKDataArray *userList, CGBLLAEID laeid ) { CGBLCOError error( CGBLCOError::EGBLCOErrorType::GBLCO_OK ); // Check we're actually connected to the server first... if ( !(storageManager->IsConnected()) ) { error = CGBLCOError(CGBLCOError::EGBLCOErrorType::GBLCO_LOCAL, GBLSM_ERROR_PROFILEACCESS_NO_CONNECTION_DESC, GBLSM_ERROR_PROFILEACCESS_NO_CONNECTION ); } else { // Check the passed parameters if( userList == NULL ) { error = CGBLCOError( CGBLCOError::EGBLCOErrorType::GBLCO_LOCAL, GBLSM_ERROR_GENERAL_INCORRECT_PARAM_DESC, GBLSM_ERROR_GENERAL_INCORRECT_PARAM ); } else { XString query; XString dbName; storageManager->GetDbName( dbName ); // Generate the query we need to get a list of users query = ""; query << "SELECT UserID AS ID FROM " << dbName << ".EventUsers WHERE LAEID=" << (int)laeid; CGBLSMUtils::ClearArray( userList ); int queryResults = storageManager->ExecuteBlockingSQL( query.Str(), userList ); if( queryResults == CGBLSMStorageManager::EGBLStorageManagerExecutionStatus::NoResult ) { error = CGBLCOError( CGBLCOError::EGBLCOErrorType::GBLCO_LOCAL, GBLSM_ERROR_GENERAL_NO_RESULTS_DESC, GBLSM_ERROR_GENERAL_NO_RESULTS ); } else if( queryResults != CGBLSMStorageManager::EGBLStorageManagerExecutionStatus::Result ) { error = CGBLCOError( CGBLCOError::EGBLCOErrorType::GBLCO_LOCAL, GBLSM_ERROR_GENERAL_SQL_ERROR_DESC, GBLSM_ERROR_GENERAL_SQL_ERROR ); } } } return error; }
CGBLCOError IGBLSMConfigurationAccess::RetrieveCISIDList(CGBLLAID laid, CKDataArray* resultArray) { CGBLCOError error(CGBLCOError::EGBLCOErrorType::GBLCO_OK); // Check we're actually connected to the server first... if ( !(storageManager->IsConnected()) ) { error = CGBLCOError(CGBLCOError::EGBLCOErrorType::GBLCO_LOCAL, GBLSM_ERROR_PROFILEACCESS_NO_CONNECTION_DESC, GBLSM_ERROR_PROFILEACCESS_NO_CONNECTION ); } else { XString query; XString dbName; storageManager->GetDbName( dbName ); if(resultArray) CGBLSMUtils::ClearArray(resultArray); else resultArray = (CKDataArray*)storageManager->m_Context->CreateObject( CKCID_DATAARRAY, "IGBLSMConfigurationAccess::RetrieveCISIDList", CK_OBJECTCREATION_DYNAMIC ); storageManager->m_Context->GetCurrentLevel()->AddObject( resultArray ); //build query //query << "SELECT * FROM " << dbName << ".ciss"; // WHERE LAID='" << laid.ToString() << "'"; query << "SELECT ID, Name FROM " << dbName << ".ciss WHERE LAID='" << laid.ToString() << "'"; // Execute the query int queryRes = storageManager->ExecuteBlockingSQL( query.Str(), resultArray ); if( queryRes == CGBLSMStorageManager::EGBLStorageManagerExecutionStatus::Failed ) { error = CGBLCOError(CGBLCOError::EGBLCOErrorType::GBLCO_LOCAL, GBLSM_ERROR_GENERAL_SQL_ERROR_DESC, GBLSM_ERROR_GENERAL_SQL_ERROR); } } return error; }
void bodyDefaultFunctionMerged(CKParameter*in) { CKStructHelper sHelper(in); //if ( ==0 ) //happens when dev is being opened and loads a cmo with physic objects. XString msg; msg.Format("parameter members : %d",sHelper.GetMemberCount()); if(bodyCreateFuncOld!=0 ) { bodyCreateFuncOld(in); xLogger::xLog(XL_START,ELOGERROR,E_LI_MANAGER,msg.Str()); } return; // CKParameter //CKAttributeManager::SetAttributeDefaultValue() }
/* ******************************************************************* * Function: int DecodeAndSendCommand (XString commandString, char separator, const CKBehaviorContext& behaviorContext) * * Description : Decodes the string message passed in into the separate parameters for the command and * sets the output parameter valuess of the corresponding GBLWaitForCommand BB. * * Paramters : * * commandString r command string * separator r parameter separator * behaviorContext r behavior context * * Returns : * 0 on success, otherwise error * ******************************************************************* */ int CGBLCommandController::InvokeCommand (XString commandString, const CKBehaviorContext& behaviorContext) { int returnValue = 0; // 0 indicates success int separatorPos = 0; //position for string separator char separator = CGBLCommandController::commandSeparator; if (strlen (commandString.Str()) <=0) { returnValue = -1; } else { separatorPos = commandString.Find(separator, separatorPos); int commandID = atoi ( (commandString.Substring (0, separatorPos)).Str() ); CKBehavior* targetBB = CGBLCommandController::GetTargetCommand (commandID, behaviorContext); if (targetBB == NULL ) { returnValue = -1; } else if (! (targetBB->IsInputActive(0)) ) { returnValue = -1; } else { int argumentCount = targetBB->GetOutputParameterCount(); int separatorCount = 0; for (unsigned int k=0; k < strlen (commandString.Str()); k++) { if (commandString.Str()[k] == separator) { separatorCount++; } } if ( separatorCount != (argumentCount + 1 ) ) { returnValue = -1; } else { int prevPos = separatorPos+1; for(int i = 0; i < argumentCount ; i++) { separatorPos = commandString.Find(separator, prevPos); if (separatorPos == prevPos) { CKParameterOut* targetParam = targetBB->GetOutputParameter(i); targetParam->SetStringValue (""); } else { XString insert = (commandString.Substring (prevPos, separatorPos-prevPos)).Str(); CKParameterOut* targetParam = targetBB->GetOutputParameter(i); targetParam->SetStringValue (insert.Str()); } prevPos = separatorPos+1; } targetBB->ActivateOutput(0); } } } return returnValue; }
bool pFactory::findSettings(pMaterial& dst,CKBeObject*src) { if (!src)return false; CKParameterOut *parMaterial = src->GetAttributeParameter(GetPMan()->att_surface_props); if (parMaterial){ pFactory::Instance()->copyTo(dst,(CKParameter*)parMaterial); goto EVALUATE; } CK3dEntity *ent3D = static_cast<CK3dEntity*>(src); if (ent3D) { CKMesh *mesh = ent3D->GetCurrentMesh(); if (mesh) { parMaterial = mesh->GetAttributeParameter(GetPMan()->att_surface_props); if (!parMaterial) { for (int i = 0 ; i < mesh->GetMaterialCount() ; i++) { CKMaterial *entMaterial = mesh->GetMaterial(i); parMaterial = entMaterial->GetAttributeParameter(GetPMan()->att_surface_props); if (parMaterial) { break; } } } } } if (!parMaterial) return false; ////////////////////////////////////////////////////////////////////////// //copy parameter content to c++ pFactory::Instance()->copyTo(dst,(CKParameter*)parMaterial); /////////////////////////////////////////////////////////////////////////// // // Evaluate from XML // EVALUATE: if ( dst.xmlLinkID !=0 ) { XString nodeName = vtAgeia::getEnumDescription(GetPMan()->GetContext()->GetParameterManager(),VTE_XML_MATERIAL_TYPE,dst.xmlLinkID); bool err = loadFrom(dst,nodeName.Str(),getDefaultDocument()); if (err) { copyTo(parMaterial,dst); return true; } }else{ copyTo(parMaterial,dst); return true; } return false; }
int PMaterialIterator(const CKBehaviorContext& behcontext) { CKBehavior* beh = behcontext.Behavior; CKContext* ctx = behcontext.Context; PhysicManager *pm = GetPMan(); pFactory *pf = pFactory::Instance(); if (beh->IsInputActive(0)) { beh->ActivateInput(0,FALSE); ////////////////////////////////////////////////////////////////////////// //we reset our session counter int sessionIndex=-1; beh->SetOutputParameterValue(0,&sessionIndex); LMaterials*sResults = NULL; beh->GetLocalParameterValue(0,&sResults); if (!sResults) { sResults = new LMaterials(); }else sResults->clear(); NxScene * scene = GetPMan()->getDefaultWorld()->getScene(); for(int i = 0 ; i < GetPMan()->getDefaultWorld()->getScene()->getNbMaterials() ; i ++) { NxMaterial *currentMaterial = scene->getMaterialFromIndex(i); sResults->push_back(currentMaterial); } beh->SetLocalParameterValue(0,&sResults); if (sResults->size()) { beh->ActivateInput(1); }else { beh->ActivateOutput(0); return 0; } } if( beh->IsInputActive(1) ) { beh->ActivateInput(1,FALSE); int currentIndex=0; CKParameterOut *pout = beh->GetOutputParameter(0); pout->GetValue(¤tIndex); currentIndex++; LMaterials *sResults = NULL; beh->GetLocalParameterValue(0,&sResults); if (!sResults) { beh->ActivateOutput(0); return 0; } if (currentIndex>=sResults->size()) { sResults->clear(); beh->ActivateOutput(0); return 0; } NxMaterial * material = sResults->at(currentIndex); if (material!=NULL) { int sIndex = currentIndex+1; beh->SetOutputParameterValue(0,&sIndex); //SetOutputParameterValue<int>(beh,O_XML,material->xmlLinkID); SetOutputParameterValue<float>(beh,O_DFRICTION,material->getDynamicFriction()); SetOutputParameterValue<float>(beh,O_SFRICTION,material->getStaticFriction()); SetOutputParameterValue<float>(beh,O_RES,material->getRestitution()); SetOutputParameterValue<float>(beh,O_DFRICTIONV,material->getDynamicFrictionV()); SetOutputParameterValue<float>(beh,O_SFRICTIONV,material->getStaticFrictionV()); SetOutputParameterValue<VxVector>(beh,O_ANIS,getFrom(material->getDirOfAnisotropy())); SetOutputParameterValue<int>(beh,O_FCMODE,material->getFrictionCombineMode()); SetOutputParameterValue<int>(beh,O_RCMODE,material->getFrictionCombineMode()); SetOutputParameterValue<int>(beh,O_FLAGS,material->getFlags()); } if(material->userData ) { pMaterial *bMaterial = static_cast<pMaterial*>(material->userData); if (bMaterial && bMaterial->xmlLinkID ) { int xid = bMaterial->xmlLinkID; XString nodeName = vtAgeia::getEnumDescription(GetPMan()->GetContext()->GetParameterManager(),VTE_XML_MATERIAL_TYPE,xid); CKParameterOut *nameStr = beh->GetOutputParameter(O_NAME); nameStr->SetStringValue(nodeName.Str()); } } //pFactory::Instance()->copyTo(beh->GetOutputParameter(O_MATERIAL),material); beh->ActivateOutput(0); } return 0; }
/* ******************************************************************* * Function: int BehaviourFunction( const CKBehaviorContext& behaviorContext ) * * Description : The execution function is the function that will be called * during the process loop of the behavior engine, if the behavior * is defined as using an execution function. This function is not * called if the behavior is defined as a graph. This function is the * heart of the behavior: it should compute the essence of the behavior, * in an incremental way. The minimum amount of computing should be * done at each call, to leave time for the other behaviors to run. * The function receives the delay in milliseconds that has elapsed * since the last behavioral process, and should rely on this value to * manage the amount of effect it has on its computation, if the effect * of this computation relies on time. * * Parameters : * behaviourContext r Behavior context reference, which gives access to * frequently used global objects ( context, level, manager, etc... ) * * Returns : int, If it is done, it should return CKBR_OK. If it returns * CKBR_ACTIVATENEXTFRAME, the behavior will again be called * during the next process loop. * ******************************************************************* */ int RetrieveCI(const CKBehaviorContext& behcontext) { /************************************************************************/ /* collecting data : */ /* */ CKBehavior* beh = behcontext.Behavior; CKContext* ctx = behcontext.Context; CGBLCIConfigurationController* cman=(CGBLCIConfigurationController*)ctx->GetManagerByGuid(CONFIGURATION_MAN_GUID); IGBLCIManageInterface *cisFac = cman->GetCISFactoryInterface(); IGBLCIAccessInterface * accessInterface = cman->GetCISAccessInterface(); BOOL getAsString,outputAttriubtes = false; beh->GetLocalParameterValue(BEH_SETTINGS_GET_AS_STRING,&getAsString); beh->GetLocalParameterValue(BEH_SETTINGS_GET_CUSTOM_ATTRIBUTES,&outputAttriubtes); using namespace GBLCommon::BehaviorTools; using namespace GBLCommon::ParameterTools; using namespace Customisation::typedefs; int idCI = GetInputParameterValue<int>(beh,BEH_PAR_INDEX_CI); CGBLCI *currentCI = NULL; CGBLSMStorageManager *storageManager = static_cast<CGBLSMStorageManager *>(ctx->GetManagerByGuid(GBLSMStorageManagerGUID)); IGBLSMConfigurationAccess* smCIS = storageManager->GetConfigurationInterface(); currentCI = new CGBLCI("temp",CKPGUID_INT); CGBLCOError returnValue = accessInterface->GetCI(currentCI,idCI); //get error parameter CKParameterOut *parameterOutError = beh->GetOutputParameter(BEH_PIN_OUT_INDEX_ERROR); // check results and output error if (returnValue == CGBLCOError::EGBLCOErrorType::GBLCO_OK) { ////////////////////////////////////////////////////////////////////////// // output values : CKParameterOut *pout = beh->GetOutputParameter(1); if(getAsString) { //output the value VxScratch sbuffer(currentCI->realValue->GetDataSize()); CKSTRING buffer = (CKSTRING)sbuffer.Mem(); currentCI->realValue->GetStringValue(buffer); pout->SetStringValue(buffer); }else { CKParameterManager *pm = static_cast<CKParameterManager*>(ctx->GetParameterManager()); if ( beh->GetOutputParameter(0)->GetType() == currentCI->realValue->GetType() ) { pout->CopyValue(currentCI->realValue); }else { pout->SetType(currentCI->realValue->GetType()); return CKBR_PARAMETERERROR; } } ////////////////////////////////////////////////////////////////////////// // output custom attributes : if(outputAttriubtes) { //output unique name : CKParameterOut *poutName = beh->GetOutputParameter(BEH_OUT_INDEX_UNAME); poutName->SetStringValue(currentCI->name.Str()); //output description : CKParameterOut *poutDescription = beh->GetOutputParameter(BEH_OUT_INDEX_DESCRIPTION); poutDescription->SetStringValue(currentCI->description.Str()); //output default value : CKParameterOut *poutDefaultValue = beh->GetOutputParameter(BEH_OUT_INDEX_DEFAULTVALUE); TypeCheckedParameterCopy(poutDefaultValue,currentCI->defaultValue); if(getAsString) { XString outDefValue = GBLCommon::ParameterTools::GetParameterAsString(currentCI->defaultValue); poutDefaultValue->SetStringValue( outDefValue.Str() ); }else{ poutDefaultValue->CopyValue(currentCI->defaultValue,TRUE); } //output flags : int flags = 0 ; beh->SetOutputParameterValue(BEH_OUT_INDEX_FLAGS,¤tCI->flags); //output type int type = ctx->GetParameterManager()->ParameterGuidToType(currentCI->type); beh->SetOutputParameterValue(BEH_OUT_INDEX_TYPE,&type); } TGBLError::SetTGBLError(parameterOutError,returnValue.GetType(),returnValue.GetCode(),(CKSTRING)returnValue.GetDescription()); beh->ActivateOutput(BEH_PIN_OUT_INDEX_SUCCESS, true); } else { CGBLCOError::EGBLCOErrorType tType = CGBLCOError::EGBLCOErrorType::GBLCO_OK; switch((CGBLCOError::EGBLCOErrorType)returnValue) { case 0: tType = CGBLCOError::EGBLCOErrorType::GBLCO_OK; break; case 1: tType = CGBLCOError::EGBLCOErrorType::GBLCO_FATAL; break; case 2: tType = CGBLCOError::EGBLCOErrorType::GBLCO_LOCAL; break; case 3: tType = CGBLCOError::EGBLCOErrorType::GBLCO_LOCAL; break; } TGBLError::SetTGBLError(parameterOutError,tType,returnValue.GetCode(),(CKSTRING)returnValue.GetDescription()); beh->ActivateOutput(BEH_PIN_OUT_INDEX_ERROR, true); } return CKBR_OK; }