本文整理汇总了C++中CKBehavior::Execute方法的典型用法代码示例。如果您正苦于以下问题:C++ CKBehavior::Execute方法的具体用法?C++ CKBehavior::Execute怎么用?C++ CKBehavior::Execute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CKBehavior
的用法示例。
在下文中一共展示了CKBehavior::Execute方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: getVehicle
bool pWheel2::onWheelContactModify(int& changeFlags,pWheelContactModifyData* contact)
{
bool result = true;
//----------------------------------------------------------------
//
// sanity checks
//
if (!contact)
return true;
//----------------------------------------------------------------
//
// keep some informationens for our self
//
if( getProcessOptions() & pVPO_Wheel_UsePHYSX_Load &&
getProcessOptions() & pVPO_Wheel_UsePHYSX_CONTACT_DATA && getVehicle()
)
{
load = contact->contactNormal.y;
if (load > 1500)
load = 1500;
if (load <= 0)
load = 1000;
}
CKBehavior * beh = (CKBehavior*)GetPMan()->GetContext()->GetObject(getWheelContactScript());
if (beh && CKGetObject(ctx(),getEntID()))
{
SetInputParameterValue<CK_ID>(beh,bbIWC_SrcObject,getEntID());
SetInputParameterValue<VxVector>(beh,bbIWC_Point,contact->contactPoint);
SetInputParameterValue<VxVector>(beh,bbIWC_Normal,contact->contactNormal);
SetInputParameterValue<float>(beh,bbIWC_Position,contact->contactPosition);
SetInputParameterValue<float>(beh,bbIWC_NormalForce,contact->normalForce);
SetInputParameterValue<int>(beh,bbIWC_OtherMaterialIndex,contact->otherMaterialIndex);
//----------------------------------------------------------------
//
// execute:
//
beh->Execute(lastStepTimeSec);
//----------------------------------------------------------------
//
// refuse contact
//
result = GetOutputParameterValue<int>(beh,bbOWC_CreateContact);
if (!result)
return false;
//----------------------------------------------------------------
//
// nothing changed, return true
//
changeFlags = GetOutputParameterValue<int>(beh,bbOWC_ModificationFlags);
if (changeFlags == 0 )
{
return true;
}
//----------------------------------------------------------------
//
// pickup data, according to change flags
//
if (changeFlags & CWCM_ContactPoint )
contact->contactPoint = GetOutputParameterValue<VxVector>(beh,bbOWC_Point);
if (changeFlags & CWCM_ContactNormal)
contact->contactNormal= GetOutputParameterValue<VxVector>(beh,bbOWC_Normal);
if (changeFlags & CWCM_ContactPosition )
contact->contactPosition= GetOutputParameterValue<float>(beh,bbOWC_Position);
if (changeFlags & CWCM_NormalForce )
contact->normalForce = GetOutputParameterValue<float>(beh,bbOWC_NormalForce);
}
return true;
}