当前位置: 首页>>代码示例>>C++>>正文


C++ CKBehavior::GetName方法代码示例

本文整理汇总了C++中CKBehavior::GetName方法的典型用法代码示例。如果您正苦于以下问题:C++ CKBehavior::GetName方法的具体用法?C++ CKBehavior::GetName怎么用?C++ CKBehavior::GetName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CKBehavior的用法示例。


在下文中一共展示了CKBehavior::GetName方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: BGWrapperCB

/*
 *******************************************************************
 * Function: CKERROR BGWrapperCB(const CKBehaviorContext& behContext)
 *
 * Description : The Behavior Callback function is called by Virtools 
 *               when various events happen in the life of a BuildingBlock.
 *
 * Parameters :
 *    behaviourContext	      Behavior context reference, which gives access to 
 *                            frequently used global objects ( context, level, manager, etc... )
 *
 * Returns : CKERROR
 *
 *******************************************************************
 */
CKERROR GBLCOBGWrapper::BGWrapperCB(const CKBehaviorContext& behContext)
{
	CKERROR	result = CKBR_GENERICERROR; 

	// Initialize common pointers.	
	CKBehavior *behaviour   = behContext.Behavior;
	CKContext  *context   = behContext.Context;
	CKLevel    *level = behContext.CurrentLevel;
	CKBeObject *owner = behContext.Behavior->GetOwner();
	
	char*name = behaviour->GetName();
	
	if ( behaviour == NULL || context == NULL || level == NULL /*|| owner == NULL*/ )
		return CKBR_OK;
	
	//Get The BG Script Object if exists
	CKBehavior* newBG = NULL;
	CKBehavior* curBG = (CKBehavior*)behaviour->GetLocalParameterObject(EGBLCOBGWRAPPERPARAM_PARAMETER_SCRIPT);

	// Get the BG nms file path. GetStringValue doesn't work with setting...
	char fileName[_MAX_PATH+1];
	memset(fileName,0,_MAX_PATH+1);
	CKParameter* scriptPath  = behaviour->GetLocalParameter(EGBLCOBGWRAPPERPARAM_PARAMETER_NAME);
	if ( scriptPath == NULL )
		return CKBR_OK;
	
	int lenPath  = scriptPath->GetDataSize();
	if ( lenPath >= _MAX_PATH )
		return CKBR_OK;
	
	void*ptrPath = scriptPath->GetReadDataPtr(TRUE);
	if ( ptrPath == NULL )
		return CKBR_OK;
	
	memcpy(fileName,ptrPath,lenPath);

	CKDWORD message = behContext.CallbackMessage;

	switch (message)
		{
		case CKM_BEHAVIORLOAD :				// when the behavior is loaded
		case CKM_BEHAVIORRESET:				// when the behavior is reseted
		case CKM_BEHAVIORSETTINGSEDITED :	// when the settings are edited
			{
				if ( curBG != NULL )
				{
					DestroyCurrentBG(level,behaviour,curBG);
					curBG = NULL;
				}

				newBG = BGLoader( fileName, behContext );
				if ( newBG == NULL )
					return CKBR_OK;
				
				if ( message == CKM_BEHAVIORLOAD || message == CKM_BEHAVIORRESET )
				{
					//context->OutputToConsoleExBeep("%s : LOADED %s",behaviour->GetName(), fileName);
					if ( CheckIO(behaviour, newBG) == TRUE )
						result = CKBR_OK;
					else	
						context->OutputToConsoleExBeep("%s : Too many inputs/outputs changes in %s\r\nPlease reconstruct the wrapper.",behaviour->GetName(), fileName);
				}
				else if ( message == CKM_BEHAVIORSETTINGSEDITED )
				{
					if ( CheckIO(behaviour, newBG) == TRUE )
					{					
						result = CKBR_OK;
					}
					else if (DeleteIO(behaviour) == TRUE)
					{
						if ( CreateIO(behaviour, newBG ) == TRUE )
							result = CKBR_OK;
						else	
							context->OutputToConsoleExBeep("%s : Cannot Create Inputs/Outputs %s",behaviour->GetName(), fileName);
					}
					else
						context->OutputToConsoleExBeep("%s : Cannot Delete Inputs/Outputs %s",behaviour->GetName(), fileName);
				}

				if ( result == CKBR_OK && newBG != NULL )
					SetNewBG(behaviour,newBG);
			}
			break;
	
		case CKM_BEHAVIORDEACTIVATESCRIPT:
//.........这里部分代码省略.........
开发者ID:gbaumgart,项目名称:GBL_Backup,代码行数:101,代码来源:GBLCOBGWrapper.cpp

示例2:

//************************************
// Method:    vt_ActivateOut
// FullName:  vt_ActivateOut
// Access:    public static 
// Returns:   PyObject *
// Qualifier:
// Parameter: PyObject * self
// Parameter: PyObject * args
//************************************
static PyObject *vt_ActivateOut( PyObject * self, PyObject * args )
{
	int size = PyTuple_Size(args);
	int bid, index, value;
	PyArg_ParseTuple(args, "iii", &bid, &index, &value); 

    CK_ID cid = bid; 
	CKBehavior *beh = static_cast<CKBehavior*>(pym->m_Context->GetObject(cid)); 
	if (size!=3)
	{
		
		pym->m_Context->OutputToConsoleEx("PyError:%s : This function only accepts 3 arguments : \n\t bid,index,value ",beh->GetName());
		Py_RETURN_NONE;
	}

	if(beh && index < beh->GetOutputCount())
	{
		beh->ActivateOutput(index,value);
	}
    		

	Py_RETURN_NONE;

}
开发者ID:,项目名称:,代码行数:33,代码来源:

示例3: BehaviourFunction

int GBLCOBGWrapper::BehaviourFunction( const CKBehaviorContext& behContext )
{
	CKBehavior	*behaviour = behContext.Behavior;
	CKContext	*context = behContext.Context;
	int			iPin, nbPin;

	CKBehavior* script = (CKBehavior*)behaviour->GetLocalParameterObject(EGBLCOBGWRAPPERPARAM_PARAMETER_SCRIPT);

	if (script == NULL)
		return CKBR_GENERICERROR;

	// Activate the right inputs
	nbPin = behaviour->GetInputCount();
	for (iPin = 0; iPin < nbPin; iPin++)
		{
		if (behaviour->IsInputActive(iPin))
			{
			script->ActivateInput(iPin, TRUE);
			behaviour->ActivateInput(iPin, FALSE);
			}
		}
	
	// Deactivate all the outputs
	nbPin = script->GetOutputCount();
	for (iPin = 0; iPin < nbPin; iPin++)
		{
		behaviour->ActivateOutput(iPin, FALSE);
		}

	// Parameter In: Set Source
	int nbPinBB = behaviour->GetInputParameterCount();
	int nbPinBG = script->GetInputParameterCount();

	if (nbPinBB != nbPinBG)
		return CKBR_GENERICERROR;

	for (iPin = 0; iPin < nbPinBB; iPin++)
	{
		CKParameterIn *pBin = behaviour->GetInputParameter(iPin);
		CKParameter* pSource = pBin->GetDirectSource();

		CKParameterIn *pSin = script->GetInputParameter(iPin);
		pSin->SetDirectSource(pSource);
	}

	// Execute the contained script
	CKERROR result = script->Execute(behContext.DeltaTime);

	// The script loop on itself too much times
	if (result == CKBR_INFINITELOOP) 
		{
		context->OutputToConsoleExBeep("Execute Script : Script %s Executed too much times",script->GetName());
		script->Activate(FALSE,FALSE);
		return CKBR_OK;
		}

	// Activate the right outputs 
	nbPin = script->GetOutputCount();
	for (iPin = 0; iPin < nbPin; iPin++)
		{
		if (script->IsOutputActive(iPin))
			{
			behaviour->ActivateOutput(iPin);
			script->ActivateOutput(iPin, FALSE);
			}
		}

	// Update Parameters Out
	nbPin = behaviour->GetOutputParameterCount();
	for (iPin = 0; iPin < nbPin; iPin++)  
		{
		CKParameterOut *pBout = behaviour->GetOutputParameter(iPin);
		CKParameterOut *pSout = script->GetOutputParameter(iPin);
		pBout->CopyValue(pSout, TRUE);
		}

	
	// Test if there are any active sub-behaviors, restart the next frame if any
	BOOL bActivateNextFrame = FALSE;
	ActivateNextFrameSubBB(script,bActivateNextFrame);
	if (bActivateNextFrame)
		return CKBR_ACTIVATENEXTFRAME;

	// return the execute value
	return result;	
}
开发者ID:gbaumgart,项目名称:GBL_Backup,代码行数:86,代码来源:GBLCOBGWrapper.cpp

示例4: CallPythonFunc2

int CallPythonFunc2(const CKBehaviorContext& behcontext)
{
	CKBehavior* beh = behcontext.Behavior;
	CKContext* ctx = behcontext.Context;


	XString File((CKSTRING) beh->GetInputParameterReadDataPtr(0));
	XString Func((CKSTRING) beh->GetInputParameterReadDataPtr(1));
	int reload=false;  //= BehaviorTools::GetInputParameterValue<bool>(beh,2);
	
	beh->GetInputParameterValue(2,&reload);

	vt_python_man *pm = (vt_python_man*)ctx->GetManagerByGuid(INIT_MAN_GUID);
	CKParameterManager *pam = static_cast<CKParameterManager *>(ctx->GetParameterManager());

	Python *py = pm->py;
    
	if (!pm->pLoaded)
	{
		pm->m_Context->OutputToConsoleEx("You must load Python before !");
		beh->ActivateOutput(1,false);
		return CKBR_BEHAVIORERROR;

	}


	//////////////////////////////////////////////////////////////////////////
	if( beh->IsInputActive(0) )
	{
		try 
		{
			PyObject *module = pm->InsertPModule(beh->GetID(),File,reload);
			PyObject* val = PyInt_FromLong(beh->GetID());
			PyObject_SetAttrString( module , "bid", val);
            pm->CallPyModule(beh->GetID(),Func);
		
		}
		catch (Python_exception ex)
		{
			pm->m_Context->OutputToConsoleEx("PyErr : \t %s",(CKSTRING)ex.what());
			std::cout << ex.what() << "pyexeption in beh : " << beh->GetName();
			PyErr_Clear();
			beh->ActivateOutput(1,false);
		}
		beh->ActivateInput(0,false);

	}
	//////////////////////////////////////////////////////////////////////////
	else
	{
		for (int i  = 1 ; i < beh->GetOutputCount() ; i++ )
		{
			
			try 
			{
				PyObject *module = pm->GetPModule(beh->GetID());
				if(module)
					pm->CallPyModule(beh->GetID(),Func);
			}
			catch (Python_exception ex)
			{
				pm->m_Context->OutputToConsoleEx("PyErr : \t %s",(CKSTRING)ex.what());
				std::cout << ex.what() << "pyexeption in beh : " << beh->GetName();
				beh->ActivateOutput(1,TRUE);
				return CKBR_BEHAVIORERROR;
			}
			beh->ActivateInput(i,false);
		}

	}
	
	return CKBR_OK;

}
开发者ID:,项目名称:,代码行数:74,代码来源:


注:本文中的CKBehavior::GetName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。