Exemple #1
0
int GetNextBBId(const CKBehaviorContext& behcontext)
{
	CKBehavior* beh = behcontext.Behavior;
	CKContext* ctx = behcontext.Context;
	
	beh->ActivateInput(0,FALSE);
	
	int count = beh->GetParent()->GetSubBehaviorLinkCount();
	int result = -1;
    
	for (int i=0; i<count; i++)
	{
		CKBehaviorLink *link =  beh->GetParent()->GetSubBehaviorLink(i);
		if (link->GetInBehaviorIO() == beh->GetOutput(0))
		{
			result   = link->GetOutBehaviorIO()->GetOwner()->GetID();
			beh->SetOutputParameterValue(0,&result);
			break;
		}
	}
	
	CKBehavior *script   = static_cast<CKBehavior*>(ctx->GetObject(result));
	if (script)
	{
		int bc = script->GetOutputCount();

		int bc2 = script->GetInputCount();

	}


	beh->ActivateOutput(0);
	beh->SetOutputParameterValue(0,&result);
	return CKBR_OK;
}
/*
*******************************************************************
* Function: void CGBLBuildCommand::ClearParameterOutputs(const CKBehaviorContext& behaviorContext)
*
* Description : Clears the values of parameter outputs for this building block
*
* Parameters :
*    behaviourContext    r   Behavior context reference, which gives 
*                            access to frequently used global objects 
*                            ( context, level, manager, etc... )
*
*******************************************************************
*/
void CGBLBuildCommand::ClearParameterOutputs(const CKBehaviorContext& behaviorContext)
{
	CKBehavior* behavior = behaviorContext.Behavior;
	char *emptyString = "";
	behavior->SetOutputParameterValue (EGBLBuildCommandParamOutputs::GetArgumentName, emptyString, strlen(emptyString)+1);
	behavior->SetOutputParameterValue (EGBLBuildCommandParamOutputs::GetArgumentType, emptyString, strlen(emptyString)+1);
	behavior->SetOutputParameterValue (EGBLBuildCommandParamOutputs::GetCommandString, emptyString, strlen(emptyString)+1);
}
Exemple #3
0
//************************************
// Method:    vt_SetOutVal
// FullName:  vt_SetOutVal
// Access:    public static 
// Returns:   PyObject *
// Qualifier:
// Parameter: PyObject * self
// Parameter: PyObject * args
//************************************
static PyObject *vt_SetOutVal( PyObject * self, PyObject * args )
{
	
	int size = PyTuple_Size(args);
	PyObject *val;
	int bid, index;
	PyArg_ParseTuple(args, "iiO", &bid, &index,&val); 

	CK_ID cid = bid; 
	CKBehavior *beh = static_cast<CKBehavior*>(pym->m_Context->GetObject(cid)); 
	if (size!=3)
	{

		pym->m_Context->OutputToConsole("PyError : This function only accepts 3 arguments : \n\t bid,index,value ");
		Py_RETURN_NONE;
	}
	
	using namespace vtTools;
	
	if (beh && val &&  index < beh->GetOutputParameterCount() )
	{
		if (PyInt_Check(val))
		{
			long ret = PyInt_AsLong(val);
			int retx = static_cast<int>(ret);
			beh->SetOutputParameterValue(index,&retx);
			Py_RETURN_NONE;
		}
		if (PyFloat_Check(val))
		{
			double ret = PyFloat_AsDouble(val);
			float retx  = static_cast<float>(ret);
			beh->SetOutputParameterValue(index,&retx);
			Py_RETURN_NONE;
		}
		if (PyString_Check(val))
		{
			std::string ret;
			CKParameterOut * pout = beh->GetOutputParameter(index);
			XString retx(ret.c_str());
			pout->SetStringValue(retx.Str());
			Py_RETURN_NONE;
		}
		if (PyTuple_Check(val))
		{
			std::string outList = to_string(val);
			CKParameterOut * pout = beh->GetOutputParameter(index);
			XString retx(outList.c_str());
			pout->SetStringValue(retx.Str());
			Py_RETURN_NONE;
		}

		
	}
	Py_RETURN_NONE;
}
Exemple #4
0
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;
}
Exemple #5
0
int GetFile(const CKBehaviorContext& behcontext)
{
	CKBehavior* beh = behcontext.Behavior;
  	CKContext* ctx = behcontext.Context;

	int Length=0;

	// Start by In0
	if( beh->IsInputActive(0)){
		beh->ActivateInput(0,FALSE);

		
		XString RemoteFile((CKSTRING) beh->GetInputParameterReadDataPtr(0));
		XString LocalFile((CKSTRING) beh->GetInputParameterReadDataPtr(1));
		
		char *Type = "Type_B";
		int Get = FtpRecvFile (	RemoteFile.Str(),LocalFile.Str(),*Type, FALSE,NULL,NULL);
		Length = FtpBytesToBeTransferred();

		if ( Get !=0 ){
			beh->SetOutputParameterValue(3,&Get);
			beh->ActivateOutput(2);
			return CKBR_OK;
		}

		beh->SetOutputParameterValue(0,&Length);
		beh->ActivateOutput(0);
		return CKBR_ACTIVATENEXTFRAME;
	}


	beh->GetOutputParameterValue(0,&Length);

	int down=FtpBytesTransferred(); 
	beh->SetOutputParameterValue(1,&down);
	float progress=(float)(down*100.0f/Length); // percentage of file downloaded
	progress /=100.0f;
	beh->SetOutputParameterValue(2,&progress);


	
	if ( down == Length){

			beh->ActivateOutput(1);
			return CKBR_OK;
	}

	return CKBR_ACTIVATENEXTFRAME;
	
}
Exemple #6
0
int FTPLogin(const CKBehaviorContext& behcontext)
{
	CKBehavior* beh = behcontext.Behavior;
  	CKContext* ctx = behcontext.Context;

		if( beh->IsInputActive(0)){
			beh->ActivateInput(0,FALSE);
	
			HWND win = (HWND)ctx->GetMainWindow();
			FtpInit(win);
			//HFILE hLogFile =  _lcreat (LOG_FILE, 0);
			//FtpLogTo (hLogFile);
			
			
	
			FtpSetDefaultTimeOut (30);
			FtpSetPassiveMode(TRUE);
			FtpSetAsynchronousMode();
	
			int Port;
			beh->GetInputParameterValue(3,&Port);
			


			XString Host((CKSTRING) beh->GetInputParameterReadDataPtr(0));
			XString User((CKSTRING) beh->GetInputParameterReadDataPtr(1));
			XString Pw((CKSTRING) beh->GetInputParameterReadDataPtr(2));
			
			int Login = FtpLogin(Host.Str(),User.Str(),Pw.Str(),win,0);
			beh->SetOutputParameterValue(0,&Login);
			

			if (Login == 0)beh->ActivateOutput(0);
				else{
					beh->ActivateOutput(2);
					return CKBR_OK;
				}
				return CKBR_ACTIVATENEXTFRAME;
			}

		if( beh->IsInputActive(1)){
			beh->ActivateInput(1,FALSE);

			FtpCloseConnection();
			FtpRelease ();
			beh->ActivateOutput(1);
			return CKBR_OK;
		}
	return CKBR_ACTIVATENEXTFRAME;
}
/*
*******************************************************************
* 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: int BehaviourFunction() 
 *
 * Description : Returns the number of plugins in this DLL
 *		
 * Paramters :
 *    CKBehaviorContext& r The virtools behaviour context
 *
 * Returns : One of the many virtools return values
 *
 *******************************************************************
 */
int CGBLFileSystem::BehaviourFunction(const CKBehaviorContext& behContext)
{
	BOOL error = FALSE;

	// Quick bit of error checking
	CKBehavior* beh = behContext.Behavior;
	CKBeObject* beObject = beh->GetTarget();
	int fileSystemBrowseMode = 0;

    if (!beObject)
	{
       error = TRUE;
	}

	if (!error)
	{
		// Reset On input, if active
		if (beh->IsInputActive(eBehInputOn)) 
		{
			beh->ActivateInput(eBehInputOn, FALSE);

			// Clear error message output
			beh->SetOutputParameterValue(eParamOutputErrorMsg, EMPTY_STRING);
		}

		// see which mode we are in
		beh->GetInputParameterValue(eParamInputMode, &fileSystemBrowseMode);
	}

	if (!error)
	{
		// See if we have the special case
		char *currentFolder = NULL;
		currentFolder = (char*)(beh->GetInputParameterReadDataPtr(eParamInputCurrentFolder));

		XString scannedFolder = currentFolder;

		if (currentFolder) 
		{
			// special case takes priority over FILES / FOLDER mode
			if (strcmp(currentFolder,SPECIAL_CASE)==0)
			{
				beh->SetOutputParameterValue(eParamOutputScannedFolder, scannedFolder.CStr(),scannedFolder.Length()+1 );
				if (fileSystemBrowseMode == eFolder)
				{			
					if (GetLogicalDrives(beh))
					{
						// Everythings gone ok we have a list of the logical drives
						beh->ActivateOutput(eBehOutputDone, TRUE);
					}
					else
					{
						// Something went wrong
						beh->SetOutputParameterValue(eParamOutputErrorMsg, "Failed To Scan The Logical Drives");
						beh->ActivateOutput(eBehOutputError, TRUE);
					}
				}
				else
				{
					//  Cant scan for files in the SPECIAL_CASE
					// Get the destination data array and clear it out
					CKDataArray* dataArray = static_cast<CKDataArray*>(beh->GetInputParameterObject(eParamInputDataArray));
					if (!dataArray)
					{
						CGBLWidget::OutputBBErrorMsg(beh, "Please attatch an array to the BB");
					}
					else
					{
						dataArray->Clear();
						dataArray->AddRow();
						int currentRow = dataArray->GetRowCount()-1; // 0 index
						dataArray->SetElementStringValue(currentRow,NAME_COLUMN,NOT_FOUND);
						beh->ActivateOutput(eBehOutputDone, TRUE);
					}
					
				}
			}
			else
			{
				// add a "\" to the end, it makes the ouput consistent.
				int len = strlen (scannedFolder.CStr());
				if ((scannedFolder[len-1])!=SINGLE_SEPERATOR)
				{
					scannedFolder << SINGLE_SEPERATOR;
				}

				// Try to scan the passed folder
				if (GetData(beh,fileSystemBrowseMode)==FALSE)
				{
					// Error Handling we can handle errors here
					// We most likely got here because the user doesnt have access to the folder.
					if (fileSystemBrowseMode == eFile)
					{
						beh->SetOutputParameterValue(eParamOutputErrorMsg, "Failed To Scan Files");
					}
					else
					{
						beh->SetOutputParameterValue(eParamOutputErrorMsg, "Failed To Scan Folders");
					}
					
					beh->ActivateOutput(eBehOutputDone, TRUE);
					// Handleable, recoverable errors, so dont set the error flag
					//beh->ActivateOutput(eBehOutputError, TRUE);
				}
				else
				{
					// No errors
					beh->SetOutputParameterValue(eParamOutputScannedFolder, scannedFolder.CStr(), scannedFolder.Length() + 1);
					beh->ActivateOutput(eBehOutputDone, TRUE);
				}
			}
		}	
		else
		{
			// Dont think we can ever get here becuase "" is a valid folder.
			// Just in case though.
			beh->SetOutputParameterValue(eParamOutputErrorMsg, "Please Supply a Folder To Scan");
			beh->ActivateOutput(eBehOutputError, TRUE);
		}
	}

	return CKBR_OK;
}
Exemple #9
0
/*
 *******************************************************************
 * Function: BehaviourFunction() 
 *
 * Description : Is called every frame from Virtools. Executes the behaviour of the BB.
 *		
 * Parameters :
 *    behContext, r: Passed in from Virtools
 *
 * Returns : A CKBR_... return value
 *
 *******************************************************************
 */
int CGBLListBox::BehaviourFunction(const CKBehaviorContext& behContext)
{
	static VxRect fullUVRect(0.0f, 0.0f, 1.0f, 1.0f);

    // The default return code is CKBR_ACTIVATENEXTFRAME which forces BehaviourFunction() to be called next frame 
	CK_BEHAVIOR_RETURN behReturn = CKBR_ACTIVATENEXTFRAME;

    CKBehavior* beh = behContext.Behavior;

	// Call the helper class to implement our base class functionality
	// If it returns FALSE, we must return the error code and not perform any behavioural functionality
	CKBOOL isFocussed = FALSE;
	if (!CGBLWidget::ExecuteBaseBehaviour(behContext, &isFocussed, &behReturn)) 
    {
		return behReturn;
	}

    // Check for mouse and keyboard inputs
	CKInputManager* inputManager = (CKInputManager*)behContext.Context->GetManagerByGuid(INPUT_MANAGER_GUID);
    if (!inputManager) 
    {
	    assert(NULL);
        return CKBR_OK;
    }

    // Get material
    CKMaterial* material = (CKMaterial*)beh->GetInputParameterObject(eParamInputMaterial);
    if (!material) 
    {
        // Output an error - we need a material
        CGBLWidget::OutputBBErrorMsg(beh, "Please attach a material to the building block");
        return CKBR_OK;
    }

    // Get font
    VirtoolsSource::CKTextureFont* font = CGBLWidget::GetFont(behContext.Context, beh);
    if (!font) 
    {
        // Output an error - we need a font attached
        CGBLWidget::OutputBBErrorMsg(beh, "Please attach a font to the building block");
        return CKBR_OK;
    }
    // Are we using proportional scaling?
    CKBOOL isPropScaling = CGBLWidget::IsProportionalScaling(beh);

    // Get the font height
    CKRenderContext* renderContext = behContext.Context->GetPlayerRenderContext();
    float fontHeight = CGBLWidget::GetFontHeight(font, renderContext, isPropScaling);

    // Get columns array, doesn't matter if we can't get it
    CKDataArray* columnsArray = static_cast<CKDataArray*>(beh->GetInputParameterObject(eParamInputColumnsArray));
    int numColumns = columnsArray ? columnsArray->GetRowCount() : 1;

    CKSTRING errMsg = ValidateColumnsArray(columnsArray);
    if (errMsg) 
    {
        CGBLWidget::OutputBBErrorMsg(beh, errMsg);
        return CKBR_OK;
    }

    // Get the string list array and check it's of the right type
    CKDataArray* stringListArray = static_cast<CKDataArray*>(beh->GetInputParameterObject(eParamInputStringListArray));
    errMsg = CGBLWidget::ValidateStringListArray(stringListArray, numColumns - 1);
    if (errMsg) 
    {
        CGBLWidget::OutputBBErrorMsg(beh, errMsg);
        return CKBR_OK;
    }

    CKBeObject* beObject = beh->GetTarget();
	CKRenderObject* renderObject = CKRenderObject::Cast(beObject);

    // Add a render callback to allow our widget to render itself next frame
	renderObject->AddPostRenderCallBack(RenderCallback, (void *)behContext.Behavior->GetID(), TRUE);

   	CK2dEntity* ent = CK2dEntity::Cast(renderObject);
    VxRect clientRect;
    ent->GetExtents(fullUVRect, clientRect);

    // Check for Select b-in
    if (beh->IsInputActive(eBehInputSelect)) 
    {
        // Reset b-in
        beh->ActivateInput(eBehInputSelect, FALSE);

        int select = 0;
        beh->GetInputParameterValue(eParamInputSelectedItem, &select);

        // Check we are in single selection mode
        int selectionType = 0;
        beh->GetLocalParameterValue(eLocalParamSelectionType, &selectionType);
        if (selectionType == eSelectionTypeSingleSelection)
        {
            // Is this row selectable?
            CKBOOL selectable = FALSE;
            stringListArray->GetElementValue(select, CGBLWidget::eStringListArrayColumnSelectable, &selectable);
            if (selectable || (select < 0) || (select >= stringListArray->GetRowCount()) ) 
            {
                // Select only this row
                for (int selRow = 0;selRow < stringListArray->GetRowCount();selRow++) 
                {
                    CKBOOL bSelect = (selRow == select);
                    stringListArray->SetElementValue(selRow, CGBLWidget::eStringListArrayColumnSelected, &bSelect);
                }

                // Set focus to this item too
                if (selectable) 
                    beh->SetLocalParameterValue(eLocalParamFocussedItem, &select);

                // Update selected item p-out
                beh->SetOutputParameterValue(eParamOutputSelectedItem, &select);

                // Activate new selection b-out
                beh->ActivateOutput(eBehOutputNewSelection);

                // Do we need to scroll?
                int scrollOffset;
                beh->GetLocalParameterValue(eLocalParamScrollOffset, &scrollOffset);

                VxRect stringListRect = GetRectStringList(clientRect, fontHeight, columnsArray);
                if (!CGBLWidget::GetListRowRect(stringListRect, select, scrollOffset, stringListArray->GetRowCount(),
                    fontHeight, NULL)) 
                {
                        
                    // Set the scroll offset to the focussed item
                    scrollOffset = select;
                    beh->SetLocalParameterValue(eLocalParamScrollOffset, &scrollOffset);
                }
            }
        }
    }

    // Check for Focus b-in
    if (beh->IsInputActive(eBehInputFocus)) 
    {
        // Reset b-in
        beh->ActivateInput(eBehInputFocus, FALSE);

        // Set focus
        int nFocus = 0;
        beh->GetInputParameterValue(eParamInputFocusItem, &nFocus);

        // Copy to focus item and scroll offset
        beh->SetLocalParameterValue(eLocalParamFocussedItem, &nFocus);

        // Do we need to scroll?
        int scrollOffset;
        beh->GetLocalParameterValue(eLocalParamScrollOffset, &scrollOffset);

        VxRect stringListRect = GetRectStringList(clientRect, fontHeight, columnsArray);
        if (!CGBLWidget::GetListRowRect(stringListRect, nFocus, scrollOffset, stringListArray->GetRowCount(),
            fontHeight, NULL)) 
        {
                
            // Set the scroll offset to the focussed item
            scrollOffset = nFocus;
            beh->SetLocalParameterValue(eLocalParamScrollOffset, &scrollOffset);
        }
    }

    // Only handle mouse clicks and keyboard input when enabled
    if (CGBLWidget::IsWidgetEnabled(beh)) 
    {

        // Handle the clicking of the scroll buttons
        HandleScrollButtonClicks(beh, inputManager, ent, clientRect, fontHeight, behContext.DeltaTime);

        // Get the string list area
        VxRect stringListRect = GetRectStringList(clientRect, fontHeight, columnsArray);

        if (isFocussed) 
        {
            // Handle the pressing of the arrow keys
            HandleArrowKeyPresses(beh, inputManager, behContext.DeltaTime, stringListRect, fontHeight, stringListArray);

            // Handle the pressing of the space bar to select
            HandleSpaceBarPress(beh, inputManager, stringListArray);
        }

        // Handle clicking on the rows
        HandleListItemClicks(beh, inputManager, ent, stringListRect, stringListArray, fontHeight);
    }

	return behReturn;
}
Exemple #10
0
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(&currentIndex);
		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;
}
int ARTPlusPatternTransformation(const CKBehaviorContext& BehContext)
{
	CKBehavior* beh = BehContext.Behavior;
	CKBOOL detected = FALSE;
	int patternID = -1;
	int markerId = -1;
	float buffer[16];
	float patternWidth = 8.0f;
	CK3dEntity* Object = NULL;
	VxQuaternion quat = VxQuaternion();
	VxVector pos = VxVector();
	VxVector scale = VxVector();

	float gl_para[4][4] = { {1.0f, 0.0f, 0.0f, 0.0f},
							{0.0f, 1.0f, 0.0f, 0.0f},
							{0.0f, 0.0f, 1.0f, 0.0f},
							{0.0f, 0.0f, 0.0f, 1.0f} };

	float gl_tmp[4][4] =  { {0.0f, 0.0f, 0.0f, 0.0f},
							{0.0f, 0.0f, 0.0f, 0.0f},
							{0.0f, 0.0f, 0.0f, 0.0f},
							{0.0f, 0.0f, 0.0f, 0.0f} };

	float koordSys[4][4] = { {1.0f, 0.0f, 0.0f, 0.0f},
							 {0.0f, 0.0f, 1.0f, 0.0f},
							 {0.0f, 1.0f, 0.0f, 0.0f},
							 {0.0f, 0.0f, 0.0f, 1.0f} };
 
	float koordSys2[4][4] = { {1.0f, 0.0f, 0.0f, 0.0f},
							  {0.0f, -1.0f, 0.0f, 0.0f},
							  {0.0f, 0.0f, 1.0f, 0.0f},
							  {0.0f, 0.0f, 0.0f, 1.0f} };

	beh->ActivateInput(0, FALSE);
	beh->ActivateOutput(0);

	if(ARTPlusInitialized == true)
	{
		// get object
		Object = CK3dEntity::Cast(beh->GetInputParameterObject(IN_OBJECT));
		if(Object==NULL)  return CKBR_BEHAVIORERROR;

		if(markerInfo!=NULL && numMarkers>0)
		{
			// Get pattern id
			beh->GetInputParameterValue(IN_PATTERN_NUMBER, &patternID);

			// Get pattern width
			beh->GetInputParameterValue(IN_PATTERN_WIDTH, &patternWidth);

			// define size of the marker
			tracker->setPatternWidth(patternWidth);

			markerId = findMarker(patternID);
			if(	markerId>=0 && markerInfo[markerId].id==patternID)
			{
				ARFloat	patt_center[2] = {0.0f, 0.0f};
				tracker->calcOpenGLMatrixFromMarker(&markerInfo[markerId], patt_center, patternWidth, (float *)buffer);

				detected = TRUE;

				for( int j = 0; j < 4; j++ )
				{
					for( int i = 0; i < 4; i++ )
					{
						gl_para[j][i] = buffer[j*4+i];
					}
				}

				for( int j = 0; j < 4; j++ )
				{
					for( int i = 0; i < 4; i++ )
					{
						gl_tmp[j][i] = 0.0;
						for(int k=0 ; k<4 ; k++)
						{
							gl_tmp[j][i] += koordSys[j][k]*gl_para[k][i];
						}
					}
				}

				for( int j = 0; j < 4; j++ )
				{
					for( int i = 0; i < 4; i++ )
					{
						gl_para[j][i] = 0.0;
						for(int k=0 ; k<4 ; k++)
						{
							gl_para[j][i] += gl_tmp[j][k]*koordSys2[k][i];
						}
					}
				}
			}
		}

		VxMatrix mat = VxMatrix(gl_para);
		Vx3DDecomposeMatrix(mat, quat, pos, scale);

		// Set true, if marker is detected
		beh->SetOutputParameterValue(OUT_DETECTED, &detected, 0);

		// Set marker id
		beh->SetOutputParameterValue(OUT_MARKERID, &patternID, 0);

		// Set Position
		beh->SetOutputParameterValue(OUT_POSITION, &pos, 0);

		// Set quaternion
		beh->SetOutputParameterValue(OUT_QUATERNION, &quat, 0);

		// Set matrix
		beh->SetOutputParameterValue(OUT_TRANSFORM_MATRIX, &mat, 0);

		//Check object visibility
		if(detected==TRUE)
		{
			// Transform object
			Object->SetPosition(&pos, NULL, FALSE);
			Object->SetQuaternion(&quat, NULL, FALSE, FALSE);
			Object->Show(CKSHOW);
		}
		else
		{
			Object->Show(CKHIERARCHICALHIDE);
		}
	}

	return CKBR_OK;
}
/*
*******************************************************************
* Function: int CGBLBuildCommand::DoBuildCommand(const CKBehaviorContext& behaviorContext)
*
* Description : Starts building the command. Find required GBLWaitForCommand BB,
*				determine its target (GBLTarget) and take corresponded actions.
*
* Parameters :
*    behaviourContext    r   Behavior context reference, which gives 
*                            access to frequently used global objects 
*                            ( context, level, manager, etc... )
*
*******************************************************************
*/
int CGBLBuildCommand::DoBuildCommand(const CKBehaviorContext& behaviorContext)
{
	CKBehavior* behavior = behaviorContext.Behavior;
  	CKContext* context = behaviorContext.Context;

	//set to initial state
	int stateValue = EGBLBuildCommandState::Initial;
	behavior->SetLocalParameterValue (gblBuildCommandStateLocalPos, &stateValue);

	int initialParameterPosition = 0;
	behavior->SetLocalParameterValue (currentParameterPositionLocalPos, &initialParameterPosition);

	char *emptyString = "";
	behavior->SetLocalParameterValue(commandStringLocalPos, emptyString, strlen(emptyString)+1);

	ClearParameterOutputs(behaviorContext);


	int targetID = 0;
	behavior->GetInputParameterValue (EGBLBuildCommandParamInputs::SetCommandID, &targetID);


	CKBehavior* targetBB = CGBLCommandUtil::GetTargetCommand (targetID, behaviorContext);

	if (targetBB == NULL)
	{
		CKParameterOut *parameterOutError = behavior->GetOutputParameter(EGBLBuildCommandParamOutputs::GetError);
		TGBLError::SetTGBLError(parameterOutError,CGBLCOError::EGBLCOErrorType::GBLCO_LOCAL,GBLFC_ERROR_BUILDCOMMAND_TARGET_NOT_FOUND,GBLFC_ERROR_BUILDCOMMAND_TARGET_NOT_FOUND_DESC);

		behavior->ActivateOutput (EGBLBuildCommandBehOutputs::Error);
		return CKBR_OK;
	}
	CK_ID targetBBID = targetBB->GetID();
	behavior->SetLocalParameterValue (targetBBLocalPos, &targetBBID);

	int gblTatgetType = -1;
	targetBB->GetLocalParameterValue (CGBLWaitForCommand::EGBLWaitForCommandLocalVariables::EGBLFCTarget, &gblTatgetType);

	switch (gblTatgetType)
	{
	case CGBLWaitForCommand::EGBLFCTarget::Untargeted:
		{
			XString commandString;
			commandString << targetID << CGBLCommandUtil::commandSeparator;

			behavior->SetLocalParameterValue(commandStringLocalPos, commandString.Str(), strlen(commandString.Str()) + 1 );

			return DoHandleNextLocalArgument (behaviorContext);
		}
		break;

		case CGBLWaitForCommand::EGBLFCTarget::Player:
		case CGBLWaitForCommand::EGBLFCTarget::Team:
		{
			//set state to GetTargets
			int stateValue = EGBLBuildCommandState::GetTargets;
			behavior->SetLocalParameterValue (gblBuildCommandStateLocalPos,&stateValue);

			//get list of recipients
			behavior->SetOutputParameterValue (EGBLBuildCommandParamOutputs::GetTarget, &gblTatgetType); 
			behavior->ActivateOutput (EGBLBuildCommandBehOutputs::ListRecipients);
			return CKBR_OK;
		}
		break;

		default:
			CKParameterOut *parameterOutError = behavior->GetOutputParameter(EGBLBuildCommandParamOutputs::GetError);
			TGBLError::SetTGBLError(parameterOutError,CGBLCOError::EGBLCOErrorType::GBLCO_LOCAL,GBLFC_ERROR_BUILDCOMMAND_UNSPECIFIED_RECIPIENT,GBLFC_ERROR_BUILDCOMMAND_UNSPECIFIED_RECIPIENT_DESC);

			behavior->ActivateOutput (EGBLBuildCommandBehOutputs::Error);
		break;
	}
	return CKBR_OK;
}
/*
 *******************************************************************
 * 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,&currentCI->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;

}
Exemple #14
0
int DOOwnerChanged(const CKBehaviorContext& behcontext)
{
    CKBehavior* beh = behcontext.Behavior;
    CKMessageManager* mm = behcontext.MessageManager;
    CKContext* ctx = behcontext.Context;

    //////////////////////////////////////////////////////////////////////////
    //connection id :
    int connectionID = vtTools::BehaviorTools::GetInputParameterValue<int>(beh,0);

    //////////////////////////////////////////////////////////////////////////
    //we come in by input 0 :
    if (beh->IsInputActive(0))
    {
        beh->ActivateOutput(0);
        beh->ActivateInput(0,FALSE);
    }

    if (beh->IsInputActive(1))
    {
        beh->ActivateOutput(1);
        beh->ActivateInput(1,FALSE);
        return 0;
    }

    //////////////////////////////////////////////////////////////////////////
    //the object :
    CK3dEntity *obj= (CK3dEntity*)beh->GetInputParameterObject(1);
    if (!obj)
    {
        beh->ActivateOutput(4);
        return CKBR_ACTIVATENEXTFRAME;
    }

    //////////////////////////////////////////////////////////////////////////
    //network ok  ?
    xNetInterface *cin  = GetNM()->GetClientNetInterface();
    if (!cin)
    {
        CKParameterOut *pout = beh->GetOutputParameter(1);
        XString errorMesg("distributed object creation failed,no network connection !");
        pout->SetStringValue(errorMesg.Str());
        beh->ActivateOutput(4);
        return CKBR_ACTIVATENEXTFRAME;
    }


    IDistributedObjects*doInterface  = cin->getDistObjectInterface();
    //////////////////////////////////////////////////////////////////////////
    //we come in by input 0 :
    xDistributedObject *dobj = doInterface->getByEntityID(obj->GetID());
    if (!dobj)
    {
        CKParameterOut *pout = beh->GetOutputParameter(1);
        XString errorMesg("There is no such an object");
        pout->SetStringValue(errorMesg.Str());
        beh->ActivateOutput(4);
    } else
    {
        if (dobj->getOwnershipState().test(1 << E_DO_OS_RELEASED) && dobj->getOwnershipState().test( 1 << E_DO_OS_OWNERCHANGED) )
        {
            beh->ActivateOutput(3);
        }

        if (dobj->getOwnershipState().testStrict(1 << E_DO_OS_OWNERCHANGED))
        {
            dobj->getOwnershipState().set( 1<<E_DO_OS_OWNERCHANGED ,false );
            int newCLientID   = dobj->getUserID();
            beh->SetOutputParameterValue(0,&newCLientID);
            beh->ActivateOutput(2);
        }
    }
    return CKBR_ACTIVATENEXTFRAME;
}
/*
 *******************************************************************
 * Function: int BehaviourFunction() 
 *
 * Description : Returns the number of plugins in this DLL
 *		
 * Paramters :
 *    CKBehaviorContext& r The virtools behaviour context
 *
 * Returns : One of the many virtools return values
 *
 *******************************************************************
 */
int CGBLLOGetMOStatus::BehaviourFunction(const CKBehaviorContext& behContext)
{
	CKBehavior* beh = behContext.Behavior; 
	CKBOOL localError = false;
	CGBLCOError retVal(CGBLCOError::EGBLCOErrorType::GBLCO_OK);

	MeasuredObjectiveControllerMgr* MOMngr = 
        static_cast<MeasuredObjectiveControllerMgr*>(behContext.Context->GetManagerByGuid(MeasuredObjectiveControllerMgrGUID));

	// Check to see if we got the manager ok
	if (!MOMngr) 
	{
		assert(NULL);
		return CKBR_OK;
	} 

	if (beh->IsInputActive(eBehInputStart)) 
	{
		// Get the details of the MO P-In
		CKParameterIn *pIn = beh->GetInputParameter(eParamInputMO);
		CKParameter *moParam = pIn->GetRealSource();
		// Ensure we read the P-In ok
		if (!moParam)
		{
			// Report the error
			CKParameterOut *pOut = beh->GetOutputParameter(eParamOutputGetError);
			TGBLError::SetTGBLError(pOut, CGBLCOError::EGBLCOErrorType::GBLCO_LOCAL,
					GBLLO_ERROR_NO_PARAM_FROM_BB,GBLLO_ERROR_NO_DATA_FROM_BB_DESC);
			beh->ActivateOutput(eBehOutputError, TRUE);
			localError = true;
		}
		if (!localError)
		{
			// Get the data from the P-In
			CGBLMOData *moData = static_cast<CGBLMOData*>(moParam->GetAppData());
			if (moData)
			{
				// Get the name from the MO and use this to get the
				// runtime MO from the controller
				XString moName = moData->GetName();
				CGBLLOMeasuredObjective *mo=NULL;
				retVal=MOMngr->GetRunTimeMO(moName,mo);
				// See if the controller gave us the MO
				if((retVal==CGBLCOError::EGBLCOErrorType::GBLCO_OK)&&(mo))
				{
					// Get the status of the MO
					bool moStatus=mo->GetMOStatus();
					// return the status of the MO back to Virtools Dev
					beh->SetOutputParameterValue(eParamOutputGetStatus, &moStatus);
				}
			}
			else
			{
				// Report the fact that we couldnt create a runtime MO from the param
				CKParameterOut *pOut = beh->GetOutputParameter(eParamOutputGetError);
				TGBLError::SetTGBLError(pOut, CGBLCOError::EGBLCOErrorType::GBLCO_LOCAL,
						GBLLO_ERROR_NO_DATA_FROM_BB,GBLLO_ERROR_NO_DATA_FROM_BB_DESC);
				beh->ActivateOutput(eBehOutputError, TRUE);
				localError = true;
			}
		}
	}

	if (localError)
	{
		// error allready dealt with
	}
	else if (retVal!=CGBLCOError::EGBLCOErrorType::GBLCO_OK)
	{	
		// Report the error back to Virtools dev
		CKParameterOut *pOut = beh->GetOutputParameter(eParamOutputGetError);
		const char* errorString = retVal;
        TGBLError::SetTGBLError(pOut, retVal,retVal,(CKSTRING)errorString);
		beh->ActivateOutput(eBehOutputError, TRUE);
	}
	else
	{
		// We are ok
		beh->ActivateOutput(eBehOutputDone, TRUE);
	}

	return CKBR_OK;
}
/*
 *******************************************************************
 * Function: int CISIteratorBB( 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 CISIteratorBB(const CKBehaviorContext& behcontext)
{
	
	/************************************************************************/
	/* collecting data :													*/
	/*  																	*/
	
	CKBehavior* beh = behcontext.Behavior;
  	CKContext* ctx = behcontext.Context;
	CGBLCIConfigurationController* cman=(CGBLCIConfigurationController*)ctx->GetManagerByGuid(CONFIGURATION_MAN_GUID);
	

    	
	/*get the last index */
	int index = 0;
	beh->GetLocalParameterValue(BEH_LOCAL_PAR_INDEX_INDEX, &index);

	BOOL getFromDB = false;
	beh->GetLocalParameterValue(BEH_LOCAL_PAR_INDEX_DB_MODE,&getFromDB);
    
	using namespace GBLCommon::BehaviorTools;
	using namespace GBLCommon::ParameterTools;

	using namespace Customisation::typedefs;


	/************************************************************************/
	/*   behavior trigger event processing  :							    */
	/*																		*/
	/*																		*/
    


	/* Reset/On : sets the index to zero and save it  */
	if( beh->IsInputActive(0) )
	{
		beh->ActivateInput(0,FALSE);
		

		if (getFromDB)
		{
			CKDataArray * resultArray = NULL; 
			beh->GetLocalParameterValue(BEH_LOCAL_PAR_INDEX_CIID_LIST,&resultArray);
			if (resultArray)
			{
				resultArray->Clear();
				while ( resultArray->GetColumnCount() )
					resultArray->RemoveColumn(0);
			}
			else
			{
				resultArray  = static_cast<CKDataArray*>(ctx->CreateObject( CKCID_DATAARRAY, "IGBLSMConfigurationAccess::CIS_IDLIST", CK_OBJECTCREATION_DYNAMIC ));
			}
			ctx->GetCurrentLevel()->AddObject( resultArray );
			
			////////////////////////////////////////////////////////////////////////// retrieve list of CI ID's  :
			CGBLSMStorageManager *storageManager = static_cast<CGBLSMStorageManager *>(ctx->GetManagerByGuid(GBLSMStorageManagerGUID));
			IGBLSMConfigurationAccess* smCIS = storageManager->GetConfigurationInterface();

			int idCIS = GetInputParameterValue<int>(beh,BEH_IN_PAR_CIS_ID);
			smCIS->RetrieveCIList(resultArray,CGBLCISID(idCIS));
			
			beh->SetLocalParameterValue(BEH_LOCAL_PAR_INDEX_CIID_LIST,&resultArray,sizeof(CKDataArray*));
			
			int cis_size = resultArray->GetRowCount();
			beh->SetLocalParameterValue(BEH_LOCAL_PAR_INDEX_CIS_SIZE,&cis_size);
		}else
		{
			Customisation::typedefs::CIS* currentCIS = cman->GetCIS();
			if(!currentCIS)
				Logger::ShowDebugMessage(ctx,Logger::ELOGERROR,"CISIterator : couldn't find CIS");	

		}
		//reset counter : 
		index = 0 ;
		beh->SetLocalParameterValue(BEH_LOCAL_PAR_INDEX_INDEX,&index);
		beh->ActivateInput(1,TRUE);
	}

	//get LA_ID :

	
	
	int cisSize;
	beh->GetLocalParameterValue(BEH_LOCAL_PAR_INDEX_CIS_SIZE,&cisSize);
	    

	/* bounding check for the index: if out of range, set to zero and save it.*/ 
	if(index > cisSize -1  )
	{
		index = 0;
		beh->SetLocalParameterValue(BEH_LOCAL_PAR_INDEX_INDEX,&index);
		beh->ActivateOutput(0);
		return CKBR_OK;
	}


	/* Loop In :  */
	if( beh->IsInputActive(1)  ) 
	{ 
		 beh->ActivateInput(1,FALSE);


		 CGBLCI *currentCI = NULL;
		 //ctx->OutputToConsole("asfasdf");

		 if (getFromDB)
		 {
			 CKDataArray * resultArray = NULL;
			 beh->GetLocalParameterValue(BEH_LOCAL_PAR_INDEX_CIID_LIST,&resultArray);
			 if (resultArray)
			 {
				 CGBLSMStorageManager *storageManager = static_cast<CGBLSMStorageManager *>(ctx->GetManagerByGuid(GBLSMStorageManagerGUID));
				 IGBLSMConfigurationAccess* smCIS = storageManager->GetConfigurationInterface();

				 CGBLCIConfigurationController* cman=static_cast<CGBLCIConfigurationController*>(ctx->GetManagerByGuid(CONFIGURATION_MAN_GUID));
				 IGBLCIAccessInterface * accessInterface  = cman->GetCISAccessInterface(); 
				 
				 currentCI = new CGBLCI("temp",CKPGUID_INT);
                 
				 int idCI;
				 resultArray->GetElementValue(index,0,&idCI);
				 accessInterface->GetCI(currentCI,idCI);
				 beh->SetOutputParameterValue(BEH_OUT_PAR_INDEX_DB_INDEX,&idCI);

			 }else
			 {
				 ctx->OutputToConsole("wrong array");
			 }
		 }else
		 {
			 Customisation::typedefs::CISIterator it = cman->GetCIS()->GetIteratorByIndex(index);
			 currentCI = (CGBLCI *)*it;
		 }
        if (currentCI)
        {
			//output name : 
			CKParameterOut *outName = beh->GetOutputParameter(BEH_OUT_PAR_INDEX_UNAME);
			outName->SetStringValue(currentCI->name.Str());
			
			//output description:
			CKParameterOut *outDescr = beh->GetOutputParameter(BEH_OUT_PAR_INDEX_DESCRIPTION);
			outDescr->SetStringValue(currentCI->description.Str());
			
			//output type 
			int type = ctx->GetParameterManager()->ParameterGuidToType(currentCI->type);
			beh->SetOutputParameterValue(BEH_OUT_PAR_INDEX_TYPE,&type);
			
			//output  value: 
			CKParameterOut *outStrValue = beh->GetOutputParameter(BEH_OUT_PAR_INDEX_VALUE);
			outStrValue->SetStringValue(GetParameterAsString(currentCI->realValue));

			//output default value: 
			CKParameterOut *outDefaultStrValue = beh->GetOutputParameter(BEH_OUT_PAR_INDEX_DEFAULTVALUE);
			outDefaultStrValue->SetStringValue(GetParameterAsString(currentCI->defaultValue));
                            
			//output flags : 
			beh->SetOutputParameterValue(BEH_OUT_PAR_INDEX_FLAGS,&currentCI->flags);

		}else
		{            
			Logger::ShowDebugMessage(ctx,Logger::ELOGERROR,"CISIterator : couldn't find CI Parameter");	
		}

		//increase counter :
		index++;
		beh->SetLocalParameterValue(BEH_LOCAL_PAR_INDEX_INDEX,&index);
		beh->ActivateOutput(1);
	}
	return CKBR_OK;
}
/*
 *******************************************************************
 * 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.
 *
 * Paramters :
 *    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 CGBLLAECreateLAE::BehaviourFunction( const CKBehaviorContext& behaviorContext )
{
	CKBehavior* beh = behaviorContext.Behavior;
  	CKContext* ctx = behaviorContext.Context;

	IGBLSMProfileAccess* pin = NULL;
    CGBLSMStorageManager *storageManager = (CGBLSMStorageManager *)ctx->GetManagerByGuid(GBLSMStorageManagerGUID);
	IGBLSMLAEAccess *laeInterface = storageManager->GetLAEInterface();

	int cisid;
	CGBLLAID laid;
	XString xlaid;
	XString laeName;
	int laeState = 0;

	CKDataArray *userIDList = NULL;


	CGBLLAEID laeid = 0;

	GBLLAEDataType::GetGBLLAEData(beh->GetInputParameter(0)->GetRealSource(), cisid, laeName, laeState, xlaid, &userIDList );

	laid.FromString(xlaid);
	

	CGBLCOError res = laeInterface->StoreLAE (laeState, cisid, laid, laeName, &laeid);
	if ( res == CGBLCOError::EGBLCOErrorType::GBLCO_OK)
	{

		int dlaeid = laeid;

		beh->SetOutputParameterValue(0, &dlaeid);



		//add users to lae
		if (userIDList)
		{
			CGBLCOError res = CGBLLAEAddUser::AddUsers (behaviorContext, laeid, userIDList);
			if(CGBLCOError::GBLCO_OK != res)
			{
				CKParameterOut *parameterOutError = beh->GetOutputParameter(1);
				TGBLError::SetTGBLError(parameterOutError,CGBLCOError::EGBLCOErrorType::GBLCO_LOCAL,GBLLAE_ERROR_ADDUSER,GBLLAE_ERROR_ADDUSER_DESC);
				beh->ActivateOutput(1);
			}
			else
			{
				beh->ActivateInput(0, FALSE);
				beh->ActivateOutput(0);
			}
		}
		else
		{
			beh->ActivateInput(0, FALSE);
			beh->ActivateOutput(0);
		}
	}
	else
	{
		CKParameterOut *parameterOutError = beh->GetOutputParameter(1);
		TGBLError::SetTGBLError(parameterOutError,CGBLCOError::EGBLCOErrorType::GBLCO_LOCAL,GBLLAE_ERROR_STORELAE,GBLLAE_ERROR_STORELAE_DESC);
		beh->ActivateOutput(1);
		
	}

    return CKBR_OK;
}
Exemple #18
0
int DOUserValueModified(const CKBehaviorContext& behcontext)
{
	CKBehavior* beh = behcontext.Behavior;
	CKMessageManager* mm = behcontext.MessageManager;
	CKContext* ctx = behcontext.Context;

	//////////////////////////////////////////////////////////////////////////
	//connection id : 
	int connectionID = vtTools::BehaviorTools::GetInputParameterValue<int>(beh,0);





	if (beh->IsInputActive(1))
	{
		beh->ActivateInput(1,FALSE);
		beh->ActivateOutput(1);
		return 0;
	}



	//////////////////////////////////////////////////////////////////////////
	//the object :
	CK3dEntity *obj= (CK3dEntity*)beh->GetInputParameterObject(1);
	if (!obj)
	{
		beh->ActivateOutput(3);
		return CKBR_ACTIVATENEXTFRAME;
	}

	//////////////////////////////////////////////////////////////////////////
	//network ok  ? 
	xNetInterface *cin  = GetNM()->GetClientNetInterface();
	if (!cin)
	{
		CKParameterOut *pout = beh->GetOutputParameter(2);
		XString errorMesg("distributed object creation failed,no network connection !");
		pout->SetStringValue(errorMesg.Str());
		beh->ActivateOutput(3);
		return CKBR_ACTIVATENEXTFRAME;
	}

	//use objects name, if not specified : 
	CKSTRING name= obj->GetName();
	
	IDistributedObjects*doInterface  = cin->getDistObjectInterface();
	IDistributedClasses*cInterface = cin->getDistributedClassInterface();
    
	XString className((CKSTRING) beh->GetLocalParameterReadDataPtr(0));
	XString parameterName((CKSTRING) beh->GetLocalParameterReadDataPtr(1));

	xDistributedClass *_class = cInterface->get(className.CStr());
	
	
	//////////////////////////////////////////////////////////////////////////
	//dist class ok  ? 
	if (_class==NULL)
	{
		beh->ActivateOutput(3);
		ctx->OutputToConsoleEx("Distributed Class doesn't exists : %s",className.CStr());
		return CKBR_ACTIVATENEXTFRAME;
	}
	const char * cNAme  = _class->getClassName().getString();

	int classType  = _class->getEnitityType();
	int bcount = beh->GetInputParameterCount();

	//////////////////////////////////////////////////////////////////////////
	//we come in by input 0 : 

	

	xDistributedObject *dobjDummy = NULL;
	xDistributedObject *dobj = doInterface->getByEntityID(obj->GetID());
	if (!dobj)
	{
		beh->ActivateOutput(3);
		return CKBR_ACTIVATENEXTFRAME;
	}

	if (dobj)
	{
		xDistributedProperty * prop  = dobj->getUserProperty(parameterName.CStr());
		if (prop)
		{
			if ( dobj->getGhostUpdateBits().testStrict(1 << prop->getBlockIndex()))
			{
				CKParameterManager *pam = static_cast<CKParameterManager *>(ctx->GetParameterManager());
				CKParameterOut *ciIn = beh->GetOutputParameter(1);
				CKParameterType pType  = ciIn->GetType();

				int sType = vtTools::ParameterTools::GetVirtoolsSuperType(ctx,pam->ParameterTypeToGuid(pType));	
				int userType = xDistTools::ValueTypeToSuperType(prop->getPropertyInfo()->mValueType);
				if ( userType ==sType )
				{
					beh->ActivateOutput(2);
					dobj->getGhostUpdateBits().set(1 << prop->getBlockIndex(),false);
					switch(xDistTools::ValueTypeToSuperType(prop->getPropertyInfo()->mValueType))
					{
						case vtFLOAT:
						{
							xDistributedPoint1F *propValue  = static_cast<xDistributedPoint1F*>(prop);
							if (propValue)
							{
								float ovalue = propValue->mLastServerValue;
								beh->SetOutputParameterValue(1,&ovalue);
								break;
							}
						}

						case vtVECTOR2D:
						{
							xDistributedPoint2F *propValue  = static_cast<xDistributedPoint2F*>(prop);
							if (propValue)
							{
								Point2F ovalue = propValue->mLastServerValue;
								Vx2DVector ovaluex(ovalue.x,ovalue.y);
								beh->SetOutputParameterValue(1,&ovaluex);
								break;
							}
						}
						case vtVECTOR:
						{
							xDistributedPoint3F *propValue  = static_cast<xDistributedPoint3F*>(prop);
							if (propValue)
							{
								Point3F ovalue = propValue->mLastServerValue;
								VxVector ovaluex(ovalue.x,ovalue.y,ovalue.z);
								beh->SetOutputParameterValue(1,&ovaluex);
								break;
							}
						}
						case vtQUATERNION:
						{
							xDistributedQuatF*propValue  = static_cast<xDistributedQuatF*>(prop);
							if (propValue)
							{
								QuatF ovalue = propValue->mLastServerValue;
								VxQuaternion ovaluex(ovalue.x,ovalue.y,ovalue.z,ovalue.w);
								beh->SetOutputParameterValue(1,&ovaluex);
								break;
							}
						}
						case vtSTRING:
						{
							xDistributedString*propValue  = static_cast<xDistributedString*>(prop);
							if (propValue)
							{
								TNL::StringPtr ovalue = propValue->mCurrentValue;
								CKParameterOut *pout = beh->GetOutputParameter(1);
								XString errorMesg(ovalue.getString());
								pout->SetStringValue(errorMesg.Str());
								break;
							}
						}
						case vtINTEGER:
						{
							xDistributedInteger*propValue  = static_cast<xDistributedInteger*>(prop);
							if (propValue)
							{
								int ovalue = propValue->mLastServerValue;
								beh->SetOutputParameterValue(1,&ovalue);
								break;
							}
						}
					}
				}
			}
		}
	}

	return CKBR_ACTIVATENEXTFRAME;
	if (beh->IsInputActive(0))
	{
		beh->ActivateOutput(0);
	}



	/*
	//////////////////////////////////////////////////////////////////////////
	//we come in by input 0 : 
	if (beh->IsInputActive(0))
	{
		beh->ActivateOutput(0);

	
		for (int i = BEH_IN_INDEX_MIN_COUNT  ; i < beh->GetInputParameterCount() ; i++ )
		{
			beh->ActivateInput(0,FALSE);

			xDistributedObject *dobj = doInterface->get(name);
			if (!dobj)
			{
				beh->ActivateOutput(0);
				return 0;
			}

			CKParameterIn *ciIn = beh->GetInputParameter(i);
			CKParameterType pType  = ciIn->GetType();
			int sType = vtTools::ParameterTools::GetVirtoolsSuperType(ctx,pam->ParameterTypeToGuid(pType));	
			xDistributedPropertyArrayType &props = *dobj->getDistributedPorperties();
			
			int propID = _class->getInternalUserFieldIndex(i - BEH_IN_INDEX_MIN_COUNT);
			if (propID==-1 ||  propID > props.size() )
			{
				beh->ActivateOutput(1);
				return 0;
			}
			
			xDistributedProperty *prop  = props[propID];
			if (prop)
			{
				xDistributedPropertyInfo*propInfo  = prop->getPropertyInfo();
				if (propInfo)
				{
					
					if (xDistTools::ValueTypeToSuperType(propInfo->mValueType) ==sType )
					{
						TNL::U32 currentTime = TNL::Platform::getRealMilliseconds();

						switch(propInfo->mValueType)
						{
							case E_DC_PTYPE_3DVECTOR:
							{

								xDistributedPoint3F * dpoint3F  = (xDistributedPoint3F*)prop;
								if (dpoint3F)
								{
									VxVector vvalue;
									beh->GetInputParameterValue(i,&vvalue);
									bool update = dpoint3F->updateValue(xMath::getFrom(vvalue),currentTime);
								}
                                break;
							}

							case E_DC_PTYPE_FLOAT:
								{

									xDistributedPoint1F * dpoint3F  = (xDistributedPoint1F*)prop;
									if (dpoint3F)
									{
										float vvalue;
										beh->GetInputParameterValue(i,&vvalue);
										bool update = dpoint3F->updateValue(vvalue,currentTime);
									}
									break;
								}
						}
					}
				}
			}
		}
			
		beh->ActivateOutput(0);
	}

	
	*/
	//////////////////////////////////////////////////////////////////////////
	//we come in by loop : 
	return 0;
}
/*
 *******************************************************************
 * Function: int BehaviourFunction() 
 *
 * Description :
 *		
 * Paramters :
 *    CKBehaviorContext& r The virtools behaviour context
 *
 * Returns : One of the many virtools return values
 *
 *******************************************************************
 */
int CGBLLOStringBuilder::BehaviourFunction(const CKBehaviorContext& behContext)
{
	CKBehavior* beh = behContext.Behavior;
	CKBeObject* beObject = beh->GetTarget();
	CKBOOL error = FALSE;
	XString outString = NULL;

    // error check to ensure virtools is working ok
	if (!beObject)
	{
		error = TRUE;
		CKParameterOut *parameterOutError = beh->GetOutputParameter(EGBLStringBuilderParamOutputs::eParamGetError);
		TGBLError::SetTGBLError(parameterOutError,CGBLCOError::EGBLCOErrorType::GBLCO_FATAL,LOI_ERROR_NO_BEHAVIOUR_STATE,LOI_ERROR_NO_BEHAVIOUR_DESC);
		beh->SetOutputParameterValue(eParamGetError, parameterOutError);
		beh->ActivateOutput(eBehOutputError, TRUE);
	}

	int lengthOfSource = 0;
	int lengthOfInsert = 0;
	int insertPosition = 0;
	if (!error)
	{
		// Reset On input, if active
		if (beh->IsInputActive(eBehInputOn)) 
		{
			beh->ActivateInput(eBehInputOn, FALSE);
		}

		// get the BB params into variables to work with
		XString sourceString = NULL;
		sourceString = (CKSTRING)(beh->GetInputParameterReadDataPtr(eParamSetSourceString));

		XString insertString = NULL;
		insertString = (CKSTRING)(beh->GetInputParameterReadDataPtr(eParamSetInsertString));

		
		beh->GetInputParameterValue(eParamSetInsertPosition,&insertPosition);

		

		lengthOfSource = strlen(sourceString.Str());
		lengthOfInsert = strlen(insertString.Str());

		// Simple bounds checking and error recovery
		if (insertPosition<0)
		{
			insertPosition=0;
		}
		if (insertPosition>lengthOfSource)
		{
			outString = sourceString;
			outString += insertString;
		}
		else
		{
			// a little more error checking and simple recovery
			// deal with the special cases first
			if (lengthOfSource<=0)
			{
				// an empty source
				outString = insertString;
			}
			else if (insertPosition == 0)
			{
				outString = insertString;
				outString += sourceString;
			}
			else
			{
				//  build up the new string
				XString start = NULL;
				XString end = NULL;
				start = sourceString.Substring(0,insertPosition);
				end = sourceString.Substring(insertPosition,lengthOfSource);
				outString  = start ;
				outString += insertString;
				outString += end;
			}
		}
	}

	if (!error)
	{
		int newCartPos = insertPosition+lengthOfInsert;
		beh->SetOutputParameterValue(eParamGetCarretPosition,&newCartPos);
		beh->SetOutputParameterValue(eParamGetNewText, outString.CStr(), outString.Length() + 1);
		beh->ActivateOutput(eBehOutputDone, TRUE);
	}

	return CKBR_OK;
}
/*
*******************************************************************
* 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 GBLLDGetSetup::BehaviourFunction( const CKBehaviorContext& behaviorContext )
{
    CKBehavior    *beh;
    CKContext     *context;
    GBLLDManager  *GBLLDMan;
    XString       DBName;
    CKBOOL        logging;
    XString       ODBCName;
    XString       proxyLogin;
    XString       proxyPassword;
    XString       serverAddress;
    XString       serverLogin;
    XString       serverPassword;
    CKBOOL        serverMode;
    XString       userName;
    int           virtoolsUserID;
    CKBOOL        webPlayerMode;
    int           ConnectionID;

    if ( (beh      = behaviorContext.Behavior)                                   == NULL ) return CKBR_BEHAVIORERROR;
    if ( (context  = behaviorContext.Context)                                    == NULL ) return CKBR_BEHAVIORERROR;
    if ( (GBLLDMan = (GBLLDManager*)context->GetManagerByGuid(GBLLDManagerGUID)) == NULL ) return CKBR_BEHAVIORERROR;

    beh->ActivateInput( POS_I_IN, FALSE );

    // Force the reading of the attributes
    GBLLDMan->ReadSetup();

    ConnectionID     = GBLLDMan->GetConnectionID();
    DBName           = GBLLDMan->GetDBName();
    logging          = GBLLDMan->IsLogging();
    ODBCName         = GBLLDMan->GetODBCName();
    proxyLogin       = GBLLDMan->GetProxyLogin();
    proxyPassword    = GBLLDMan->GetProxyPassword();
    serverAddress    = GBLLDMan->GetServerAddress();
    serverLogin      = GBLLDMan->GetServerLogin();
    serverPassword   = GBLLDMan->GetServerPassword();
    serverMode       = GBLLDMan->GetServerMode();
    userName         = GBLLDMan->GetUserName();
    webPlayerMode    = GBLLDMan->IsWebplayerMode();
    virtoolsUserID   = GBLLDMan->GetVirtoolsUserID();

    beh->SetOutputParameterValue( POS_OP_CONNECTIONID,   &ConnectionID );
    beh->SetOutputParameterValue( POS_OP_DBNAME,         DBName.CStr(),         DBName.Length() );
    beh->SetOutputParameterValue( POS_OP_LOGGING,        &logging );
    beh->SetOutputParameterValue( POS_OP_ODBCNAME,       ODBCName.CStr(),       ODBCName.Length() );
    beh->SetOutputParameterValue( POS_OP_PROXYLOGIN,     proxyLogin.CStr(),     proxyLogin.Length() );
    beh->SetOutputParameterValue( POS_OP_PROXYPASSWORD,  proxyPassword.CStr(),  proxyPassword.Length() );
    beh->SetOutputParameterValue( POS_OP_SERVERADDRESS,  serverAddress.CStr(),  serverAddress.Length() );
    beh->SetOutputParameterValue( POS_OP_SERVERLOGIN,    serverLogin.CStr(),    serverLogin.Length() );
    beh->SetOutputParameterValue( POS_OP_SERVERMODE,     &serverMode );
    beh->SetOutputParameterValue( POS_OP_SERVERPASSWORD, serverPassword.CStr(), serverPassword.Length() );
    beh->SetOutputParameterValue( POS_OP_USERNAME,       userName.CStr(),       userName.Length() );
    beh->SetOutputParameterValue( POS_OP_WEBPLAYERMODE,  &webPlayerMode );
    beh->SetOutputParameterValue( POS_OP_VIRTOOLSUSERID, &virtoolsUserID );

    beh->ActivateOutput( POS_O_OUT, TRUE );
    return CKBR_OK;
}
Exemple #21
0
/*
 *******************************************************************
 * Function: int GetCIValue( 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 GetCIValue(const CKBehaviorContext& behcontext)
{
	/************************************************************************/
	/*  collecting data :													*/
	/*  																	*/
	CKBehavior* beh = behcontext.Behavior;
  	CKContext* ctx = behcontext.Context;
	CGBLCIConfigurationController* cman=(CGBLCIConfigurationController*)ctx->GetManagerByGuid(CONFIGURATION_MAN_GUID);

	BOOL getByName,getAsString,outputAttriubtes,outputOnChange = false;
	beh->GetLocalParameterValue(BEH_SETTINGS_GET_BY_NAME,&getByName);
	beh->GetLocalParameterValue(BEH_SETTINGS_GET_AS_STRING,&getAsString);
	beh->GetLocalParameterValue(BEH_SETTINGS_GET_CUSTOM_ATTRIBUTES,&outputAttriubtes);
	beh->GetLocalParameterValue(BEH_SETTINGS_OUTPUT_ON_CHANGE,&outputOnChange);


	// Beh Input 1 activated : switch of on event mode /////////////////////////////////////////////////
	if( outputOnChange && beh->IsInputActive(1) )
	{
		beh->ActivateInput(1,FALSE);
		return CKBR_OK;
	}

	using namespace GBLCommon::BehaviorTools;
	using namespace Customisation::typedefs;

	Customisation::typedefs::CIS* currentCIS = cman->GetCIS();

	if( !currentCIS)
	{
		return CKBR_PARAMETERERROR;
	}
	
	CGBLCI *currentCI = NULL;
	
	//get  by uniquie name mode  ? 
	if( getByName )
	{
		CISIterator it = currentCIS->Find( new CGBLCIID (GetInputParameterValue<CKSTRING>(beh,0) , 0  ) );
		if (it  == currentCIS->End() )
		{
			return CKBR_PARAMETERERROR;
		}else
		{
			currentCI = *it;
		}
		//////// then get the custom parameter : 
	}else
	{
		CKParameter *ciPar = beh->GetInputParameter(0)->GetRealSource();
		currentCI = static_cast<CGBLCI *>(ciPar->GetAppData());
		if (!currentCI)
		{
			return CKBR_PARAMETERERROR;
		}
	}
	//////////////////////////////////////////////////////////////////////////
	// output values :
	CKParameterOut *pout = beh->GetOutputParameter(0);
	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;
		}
	}

	using namespace GBLCommon::ParameterTools;
	
	//////////////////////////////////////////////////////////////////////////
	// 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,&currentCI->flags);

		//output type 
		int type = ctx->GetParameterManager()->ParameterGuidToType(currentCI->type);
		beh->SetOutputParameterValue(BEH_OUT_INDEX_TYPE,&type);

	}
	
	if (outputOnChange && (currentCI->ciState & CGBLCI::GBL_CI_STATE::GBL_CI_CHANGED) )
	{
		//reset state :
		currentCI->ciState = 0L;
		beh->ActivateOutput(0);
	}


	if (!outputOnChange)
	{
		beh->ActivateOutput(0);
	}

	return outputOnChange ?  CKBR_ACTIVATENEXTFRAME : CKBR_OK;

}