本文整理汇总了C++中CKBehavior::GetInputParameter方法的典型用法代码示例。如果您正苦于以下问题:C++ CKBehavior::GetInputParameter方法的具体用法?C++ CKBehavior::GetInputParameter怎么用?C++ CKBehavior::GetInputParameter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CKBehavior
的用法示例。
在下文中一共展示了CKBehavior::GetInputParameter方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: MidiEventCallBack
CKERROR MidiEventCallBack(const CKBehaviorContext& behcontext){
CKBehavior *beh = behcontext.Behavior;
MidiManager *mm = (MidiManager *) behcontext.Context->GetManagerByGuid( MIDI_MANAGER_GUID );
switch( behcontext.CallbackMessage ){
case CKM_BEHAVIOREDITED:
{
int c_pin = beh->GetInputParameterCount();
char name[20];
CKParameterIn *pin;
for( int a=2 ; a<c_pin ; a++){
pin = beh->GetInputParameter(a);
sprintf( name, "Note %d", a);
pin->SetName( name );
pin->SetGUID( CKPGUID_INT );
}
} break;
case CKM_BEHAVIORATTACH:
case CKM_BEHAVIORLOAD:
{
mm->AddMidiBBref();
} break;
case CKM_BEHAVIORDETACH:
{
mm->RemoveMidiBBref();
} break;
}
return CKBR_OK;
}
示例2: BehaviourFunction
int GBLCOSetID::BehaviourFunction( const CKBehaviorContext& behContext )
{
CKBehavior *behaviour = behContext.Behavior;
CKContext *context = behContext.Context;
behaviour->ActivateInput(ECGBLCOSetLAIDBehInputs::InSetIdentity, FALSE);
CKAttributeManager*attributeManager = context->GetAttributeManager();
if (attributeManager != NULL)
{
CKLevel *level = context->GetCurrentLevel();
if ( level != NULL )
{
int attributeType = attributeManager->GetAttributeTypeByName("GBLCOLAID");
if (attributeType == -1)
attributeType = attributeManager->RegisterNewAttributeType("GBLCOLAID", GUID_TGBLLAID, CKCID_BEOBJECT);
else if ( level->HasAttribute(attributeType) )
level->RemoveAttribute(attributeType);
attributeManager->SetAttributeCategory(attributeType,"GBL");
level->SetAttribute(attributeType);
CKParameter*attribute = level->GetAttributeParameter(attributeType);
if ( attribute != NULL )
{
CKParameterIn*pin = behaviour->GetInputParameter(ECGBLCOSetLAIDBehInputs::InSetIdentity);
CKParameter*laid = pin->GetDirectSource();
if ( laid != NULL )
{
CKERROR err = attribute->CopyValue(laid);
if ( err == CK_OK )
{
behaviour->ActivateOutput(ECGBLCOSetLAIDBehOutputs::OutIdentitySet, TRUE);
behaviour->ActivateOutput(ECGBLCOSetLAIDBehOutputs::OutError, FALSE);
return CKBR_OK;
}
}
}
}
}
CKParameterOut *parameterOutError = behaviour->GetOutputParameter(ECGBLCOSetLAIDParamOutputs::GetError);
TGBLError::SetTGBLError(parameterOutError,CGBLCOError::EGBLCOErrorType::GBLCO_LOCAL,GBLCO_ERROR_SETID_ATTRIBUTE,GBLCO_ERROR_SETID_ATTRIBUTE_DESC);
behaviour->ActivateOutput(ECGBLCOSetLAIDBehOutputs::OutIdentitySet, FALSE);
behaviour->ActivateOutput(ECGBLCOSetLAIDBehOutputs::OutError, TRUE);
return CKBR_GENERICERROR;
}
示例3: BehaviourFunction
/*
*******************************************************************
* 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 CGBLLAESetLAEData::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;
int dlaeid;
beh->GetInputParameterValue(1, &dlaeid);
laeid = dlaeid;
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)
{
beh->ActivateInput(0, FALSE);
beh->ActivateOutput(0);
}
else
{
CKParameterOut *parameterOutError = beh->GetOutputParameter(0);
TGBLError::SetTGBLError(parameterOutError,CGBLCOError::EGBLCOErrorType::GBLCO_LOCAL,GBLLAE_ERROR_STORELAE,GBLLAE_ERROR_STORELAE_DESC);
beh->ActivateOutput(1);
}
return CKBR_OK;
}
示例4: BehaviourFunction
int GBLCOCreateError::BehaviourFunction( const CKBehaviorContext& behContext )
{
CKBehavior *behaviour = behContext.Behavior;
CKContext *context = behContext.Context;
if ( behaviour == NULL || context == NULL )
return CKBR_GENERICERROR;
behaviour->ActivateInput(ECGBLCOCreateErrorBehInputs::In, FALSE);
CGBLCOErrorManager *errorManager = (CGBLCOErrorManager *)context->GetManagerByGuid(CGBLCOErrorManagerGUID);
if ( errorManager == NULL )
return CKBR_GENERICERROR;
// Get Parameters Inputs Source.
CKParameterOut *poutError = behaviour->GetOutputParameter(ECGBLCOCreateErrorParamOutputs::GetError);
if ( poutError == NULL )
return CKBR_GENERICERROR;
CKParameterIn*pinCode = behaviour->GetInputParameter(ECGBLCOCreateErrorParamInputs::SetErrorCode);
CKParameterIn*pinDesc = behaviour->GetInputParameter(ECGBLCOCreateErrorParamInputs::SetErrorDescription);
CKParameterIn*pinType = behaviour->GetInputParameter(ECGBLCOCreateErrorParamInputs::SetErrorType);
if ( pinCode == NULL || pinDesc == NULL || pinType == NULL )
return CKBR_GENERICERROR;
CKParameter*paraCode = pinCode->GetRealSource();
CKParameter*paraDesc = pinDesc->GetRealSource();
CKParameter*paraType = pinType->GetRealSource();
if ( paraCode == NULL || paraDesc == NULL || paraType == NULL )
return CKBR_GENERICERROR;
// Get Parameters Inputs Values (code,desc,type).
int code = 0;
paraCode->GetValue(&code);
XString desc;
int paramsize = paraDesc->GetStringValue(NULL);
if (paramsize)
{
XAP<char> paramstring(new char[paramsize]);
paraDesc->GetStringValue(paramstring,TRUE);
desc << (char*)paramstring;
}
CGBLCOError::EGBLCOErrorType type;
paraType->GetValue(&type);
// Create the TGBLError parameter output.
TGBLError::SetTGBLError(poutError,type,code,(CKSTRING)desc.CStr());
CK_CLASSID cid = poutError->GetClassID();
//
if ( type != CGBLCOError::EGBLCOErrorType::GBLCO_FATAL )
{
behaviour->ActivateOutput(ECGBLCOCreateErrorBehOutputs::OutHandled, FALSE);
behaviour->ActivateOutput(ECGBLCOCreateErrorBehOutputs::OutUnhandled, TRUE);
return CKBR_OK;
}
errorManager->NotifyError(type,code,(CKSTRING)desc.CStr());
behaviour->ActivateOutput(ECGBLCOCreateErrorBehOutputs::OutHandled, TRUE);
behaviour->ActivateOutput(ECGBLCOCreateErrorBehOutputs::OutUnhandled, FALSE);
return CKBR_OK;
}
示例5: PVSetMotorValues
int PVSetMotorValues(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);
CK3dEntity *target = (CK3dEntity *) beh->GetTarget();
if( !target ) bbSErrorME(E_PE_REF);
pRigidBody *body = GetPMan()->getBody(target);
if (!body) bbSErrorME(E_PE_NoBody);
pVehicle *v = body->getVehicle();
if (!v) bbSErrorME(E_PE_NoVeh);
if (!v->isValidEngine())
bbErrorME("Vehicle is not complete");
pEngine *engine = v->getEngine();
if (!engine) bbErrorME("No valid engine");
CK2dCurve* pOCurve = NULL; //optional
BB_DECLARE_PIMAP;//retrieves the parameter input configuration array
BBSParameter(I_XML);//our bb settings concated as s##I_XML
BBSParameter(I_Flags);
BBSParameter(I_Clutch);
BBSParameter(I_tList);
BBSParameter(I_maxRPM);
BBSParameter(I_minRPM);
BBSParameter(I_maxTorque);
BBSParameter(I_intertia);
BBSParameter(I_engineFriction);
BBSParameter(I_breakCoeff);
BBSParameter(I_GroundForceFeedBackScale);
if (sI_XML){
int xmlLink = GetInputParameterValue<int>(beh,BB_IP_INDEX(I_XML));
}
if (sI_GroundForceFeedBackScale)
engine->setForceFeedbackScale(GetInputParameterValue<float>(beh,BB_IP_INDEX(I_GroundForceFeedBackScale)));
if (sI_Flags)
engine->setFlags(GetInputParameterValue<int>(beh,BB_IP_INDEX(I_Flags)));
if (sI_Clutch)
engine->setClutch(GetInputParameterValue<float>(beh,BB_IP_INDEX(I_Clutch)));
if (sI_maxTorque)
engine->setMaxTorque(GetInputParameterValue<float>(beh,BB_IP_INDEX(I_maxTorque)));
if (sI_maxTorque)
engine->setMaxTorque(GetInputParameterValue<float>(beh,BB_IP_INDEX(I_maxTorque)));
if (sI_maxRPM)
engine->setMaxRPM(GetInputParameterValue<float>(beh,BB_IP_INDEX(I_maxRPM)));
if (sI_minRPM)
engine->setIdleRPM(GetInputParameterValue<float>(beh,BB_IP_INDEX(I_minRPM)));
if (sI_engineFriction)
engine->setFriction(GetInputParameterValue<float>(beh,BB_IP_INDEX(I_engineFriction)));
if (sI_intertia)
engine->SetInertia(GetInputParameterValue<float>(beh,BB_IP_INDEX(I_intertia)));
if (sI_breakCoeff)
engine->setBrakingCoeff(GetInputParameterValue<float>(beh,BB_IP_INDEX(I_breakCoeff)));
if (sI_tList){
CKParameterIn *inP = beh->GetInputParameter(BB_IP_INDEX(I_tList));
CKParameter *pout= inP->GetDirectSource();
if (pout)
{
if (engine->getTorqueCurve())
{
pLinearInterpolation &curve = *engine->getTorqueCurve();
curve.clear();
IParameter::Instance()->copyTo(curve,pout);
engine->preStep();
}
}
//engine->setTorqueCurve();
}
//.........这里部分代码省略.........
示例6: PBPhysicalize
//************************************
// Method: PBPhysicalize
// FullName: PBPhysicalize
// Access: public
// Returns: int
// Qualifier:
// Parameter: const CKBehaviorContext& behcontext
//************************************
int PBPhysicalize(const CKBehaviorContext& behcontext)
{
using namespace vtTools::BehaviorTools;
using namespace vtTools;
using namespace vtTools::AttributeTools;
//////////////////////////////////////////////////////////////////////////
//basic parameters
CKBehavior* beh = behcontext.Behavior;
CKContext* ctx = behcontext.Context;
PhysicManager *pm = GetPMan();
pFactory *pf = pFactory::Instance();
//////////////////////////////////////////////////////////////////////////
//settings
int useDWorld; beh->GetLocalParameterValue(bbS_USE_DEFAULT_WORLD,&useDWorld);
// int useWorldSS; beh->GetLocalParameterValue(bbS_USE_WORLD_SLEEP_SETTINGS,&useWorldSS);
// int useWorldDS; beh->GetLocalParameterValue(bbS_USE_WORLD_DAMPING_SETTINGS,&useWorldDS);
int useWorldM; beh->GetLocalParameterValue(bbS_USE_WORLD_MATERIAL,&useWorldM);
int addAttributes; beh->GetLocalParameterValue(bbS_ADD_ATTRIBUTES,&addAttributes);
//////////////////////////////////////////////////////////////////////////
//the object :
CK3dEntity *referenceObject = (CK3dEntity *) beh->GetTarget();
if( !referenceObject ) return CKBR_OWNERERROR;
//////////////////////////////////////////////////////////////////////////
//the world :
CK3dEntity*worldRef = NULL;
if (!useDWorld)
{
worldRef = (CK3dEntity *) beh->GetInputParameterObject(bbI_TargetWorld);
}
// the world :
pWorld *world=GetPMan()->getWorld(worldRef,referenceObject);
if (!world)
{
beh->ActivateOutput(0);
return 0;
}
pRigidBody*result = world->getBody(referenceObject);
if (result)
{
beh->ActivateOutput(0);
return 0;
}
//////////////////////////////////////////////////////////////////////////
//pick up some parameters :
int flags = GetInputParameterValue<int>(beh,bbI_Flags);
int hType = GetInputParameterValue<int>(beh,bbI_HullType);
float density = GetInputParameterValue<float>(beh,bbI_Density);
float skinWidth = GetInputParameterValue<float>(beh,bbI_SkinWidth);
int hierarchy = GetInputParameterValue<int>(beh,bbI_Hierachy);
float newDensity = GetInputParameterValue<float>(beh,bbI_NewDensity);
float totalMass = GetInputParameterValue<float>(beh,bbI_TotalMass);
VxVector massOffset = GetInputParameterValue<VxVector>(beh,bbI_MassShift);
VxVector shapeOffset = GetInputParameterValue<VxVector>(beh,bbI_ShapeShift);
//////////////////////////////////////////////////////////////////////////
// we remove the old physic attribute :
if (referenceObject->HasAttribute(GetPMan()->GetPAttribute()))
{
referenceObject->RemoveAttribute(GetPMan()->GetPAttribute());
}
referenceObject->SetAttribute(GetPMan()->GetPAttribute());
SetAttributeValue<int>(referenceObject,GetPMan()->GetPAttribute(),E_PPS_HIRARCHY,&hierarchy);
SetAttributeValue<int>(referenceObject,GetPMan()->GetPAttribute(),E_PPS_HULLTYPE,&hType);
SetAttributeValue<int>(referenceObject,GetPMan()->GetPAttribute(),E_PPS_BODY_FLAGS,&flags);
SetAttributeValue<float>(referenceObject,GetPMan()->GetPAttribute(),E_PPS_DENSITY,&density);
SetAttributeValue<float>(referenceObject,GetPMan()->GetPAttribute(),E_PPS_NEW_DENSITY,&newDensity);
SetAttributeValue<float>(referenceObject,GetPMan()->GetPAttribute(),E_PPS_TOTAL_MASS,&totalMass);
SetAttributeValue<VxVector>(referenceObject,GetPMan()->GetPAttribute(),E_PPS_MASS_OFFSET,&massOffset);
//SetAttributeValue<VxVector>(referenceObject,GetPMan()->GetPAttribute(),E_PPS_MASS_OFFSET,&massOffset);
//.........这里部分代码省略.........
示例7: BehaviourFunction
/*
*******************************************************************
* 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;
}
示例8: DoHandleNextNetworkArgument
/*
*******************************************************************
* Function: int CGBLBuildCommand::DoHandleNextNetworkArgument (const CKBehaviorContext& behaviorContext)
*
* Description : Checks if there are more arguments to be specified for network command
* and takes corresponded actions
*
* Parameters :
* behaviourContext r Behavior context reference, which gives
* access to frequently used global objects
* ( context, level, manager, etc... )
*
*******************************************************************
*/
int CGBLBuildCommand::DoHandleNextNetworkArgument (const CKBehaviorContext& behaviorContext)
{
CKBehavior* behavior = behaviorContext.Behavior;
CKContext* context = behaviorContext.Context;
int gblBuildCommandState;
CKBehavior* targetBB = NULL;
CK_ID targetID;
behavior->GetLocalParameterValue (targetBBLocalPos, &targetID);
targetBB = (CKBehavior*)behaviorContext.Context->GetObject(targetID);
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;
}
int currentParameterPosition = 0;
behavior->GetLocalParameterValue (currentParameterPositionLocalPos, ¤tParameterPosition);
CKParameter* nextArgument = CGBLCommandUtil::GetCommandArgument(*targetBB, currentParameterPosition);
currentParameterPosition++;
behavior->SetLocalParameterValue (currentParameterPositionLocalPos, ¤tParameterPosition);
if (nextArgument == NULL)
{
//no arguments required, build finished
CKParameter *outputCommandString, *localCommandString;
CKParameter *outputDests;
CKParameterIn *inputDests;
ClearParameterOutputs(behaviorContext);
outputCommandString = (CKParameter*) behavior->GetOutputParameter (EGBLBuildCommandParamOutputs::GetCommandString);
localCommandString = (CKParameter*) behavior->GetLocalParameter (commandStringLocalPos);
outputCommandString->CopyValue(localCommandString);
// Copy list of recipients from input to output
outputDests = (CKParameter*) (behavior->GetOutputParameter (EGBLBuildCommandParamOutputs::GetDests));
inputDests = behavior->GetInputParameter (EGBLBuildCommandParamInputs::SetDests);
outputDests->CopyValue(inputDests->GetDirectSource());
gblBuildCommandState = EGBLBuildCommandState::Completed;
behavior->SetLocalParameterValue (gblBuildCommandStateLocalPos, &gblBuildCommandState);
behavior->ActivateOutput (EGBLBuildCommandBehOutputs::HandleTargetedCommand);
return CKBR_OK;
}
else
{
//get next argument
gblBuildCommandState = EGBLBuildCommandState::AwaitingParametersForNetwork;
behavior->SetLocalParameterValue (gblBuildCommandStateLocalPos, &gblBuildCommandState);
GetNextArgument (nextArgument, targetBB, behaviorContext);
return CKBR_OK;
}
}
示例9: PJRevolute
//************************************
// Method: PJRevolute
// FullName: PJRevolute
// Access: public
// Returns: int
// Qualifier:
// Parameter: const CKBehaviorContext& behcontext
//************************************
int PJRevolute(const CKBehaviorContext& behcontext)
{
CKBehavior* beh = behcontext.Behavior;
CKContext* ctx = behcontext.Context;
PhysicManager *pm = GetPMan();
pFactory *pf = pFactory::Instance();
using namespace vtTools::BehaviorTools;
if( beh->IsInputActive(0) )
{
beh->ActivateInput(0,FALSE);
//////////////////////////////////////////////////////////////////////////
//the object A:
CK3dEntity *target = (CK3dEntity *) beh->GetTarget();
CK3dEntity *targetB = (CK3dEntity *) beh->GetInputParameterObject(bI_ObjectB);
if (!pFactory::Instance()->jointCheckPreRequisites(target,targetB,JT_Revolute))
{
return CK_OK;
}
// the world :
pWorld *worldA=GetPMan()->getWorldByBody(target);
pWorld *worldB=GetPMan()->getWorldByBody(targetB);
if (!worldA && ! worldB )
{
return 0;
}
if (!worldA)
{
worldA = worldB;
}
if (!worldA)
{
beh->ActivateOutput(0);
return 0;
}
// the physic object A :
pRigidBody*bodyA= worldA->getBody(target);
pRigidBody*bodyB= worldA->getBody(targetB);
//anchor :
VxVector anchor = GetInputParameterValue<VxVector>(beh,bI_Anchor);
VxVector anchorOut = anchor;
CK3dEntity*anchorReference = (CK3dEntity *) beh->GetInputParameterObject(bI_AnchorRef);
if (anchorReference)
{
anchorReference->Transform(&anchorOut,&anchor);
}
//swing axis
VxVector Axis = GetInputParameterValue<VxVector>(beh,bI_Axis);
VxVector axisOut = Axis;
CK3dEntity*axisReference = (CK3dEntity *) beh->GetInputParameterObject(bI_AxisRef);
if (axisReference)
{
VxVector dir,up,right;
axisReference->GetOrientation(&dir,&up,&right);
axisReference->TransformVector(&axisOut,&up);
}
//////////////////////////////////////////////////////////////////////////
//limit high :
pJointLimit limitH;
pJointLimit limitL;
DWORD limit;
beh->GetLocalParameterValue(1,&limit);
if (limit)
{
CKParameterIn *par = beh->GetInputParameter(bbI_HighLimit);
if (par)
{
CKParameter *rPar = par->GetRealSource();
if (rPar)
{
limitH = pFactory::Instance()->createLimitFromParameter(rPar);
}
}
}
//.........这里部分代码省略.........
示例10: PBPhysicalizeEx
//************************************
// Method: PBPhysicalizeEx
// FullName: PBPhysicalizeEx
// Access: public
// Returns: int
// Qualifier:
// Parameter: const CKBehaviorContext& behcontext
//************************************
int PBPhysicalizeEx(const CKBehaviorContext& behcontext)
{
using namespace vtTools::BehaviorTools;
using namespace vtTools;
using namespace vtTools::AttributeTools;
using namespace vtTools::ParameterTools;
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
//
// objects
//
CKBehavior* beh = behcontext.Behavior;
CKContext* ctx = behcontext.Context;
PhysicManager *pm = GetPMan();
pFactory *pf = pFactory::Instance();
//the object :
CK3dEntity *target = (CK3dEntity *) beh->GetTarget();
if( !target ) bbErrorME("No Reference Object specified");
//the world reference, optional used
CK3dEntity*worldRef = NULL;
//the world object, only used when reference has been specified
pWorld *world = NULL;
//final object description
pObjectDescr *oDesc = new pObjectDescr();
pRigidBody *body = NULL;
XString errMesg;
//----------------------------------------------------------------
//
// sanity checks
//
// rigid body
GetPMan()->getBody(target);
if( body){
errMesg.Format("Object %s already registered.",target->GetName());
bbErrorME(errMesg.Str());
}
//----------------------------------------------------------------
//
//
//
if (!GetPMan()->isValid())
GetPMan()->performInitialization();
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
//
// Collecting data. Stores all settings in a pObjectDescr.
//
//get the parameter array
BB_DECLARE_PIMAP;
//----------------------------------------------------------------
//
// generic settings
//
oDesc->hullType = (HullType)GetInputParameterValue<int>(beh,bbI_HullType);
oDesc->flags = (BodyFlags)GetInputParameterValue<int>(beh,bbI_Flags);
oDesc->density = GetInputParameterValue<float>(beh,bbI_Density);
//----------------------------------------------------------------
// optional
// world
//
BBSParameterM(bbI_World,BB_SSTART);
if (sbbI_World)
{
worldRef = (CK3dEntity *) beh->GetInputParameterObject(BB_IP_INDEX(bbI_World));
if (worldRef)
{
world = GetPMan()->getWorld(worldRef,target);
if (!world)
{
xLogger::xLog(ELOGERROR,E_LI_MANAGER,"World reference has been specified but no valid world object found. Switching to default world");
goto errorFound;
}
}
}
//----------------------------------------------------------------
//.........这里部分代码省略.........
示例11: 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;
}
示例12: DoReadNextParameterValue
/*
*******************************************************************
* Function: int CGBLBuildCommand::DoReadNextParameterValue (const CKBehaviorContext& behaviorContext)
*
* Description : Read next provided argument from SetParameterString p-in and add it to command string
*
* Parameters :
* behaviourContext r Behavior context reference, which gives
* access to frequently used global objects
* ( context, level, manager, etc... )
*
*******************************************************************
*/
int CGBLBuildCommand::DoReadNextParameterValue (const CKBehaviorContext& behaviorContext)
{
CKBehavior* behavior = behaviorContext.Behavior;
CKContext* context = behaviorContext.Context;
int gblBuildCommandState;
behavior->GetLocalParameterValue (gblBuildCommandStateLocalPos, &gblBuildCommandState);
switch (gblBuildCommandState)
{
case EGBLBuildCommandState::Initial:
{
CKParameterOut *parameterOutError = behavior->GetOutputParameter(EGBLBuildCommandParamOutputs::GetError);
TGBLError::SetTGBLError(parameterOutError,CGBLCOError::EGBLCOErrorType::GBLCO_LOCAL,GBLFC_ERROR_BUILDCOMMAND_INVALID_STATE,GBLFC_ERROR_BUILDCOMMAND_INVALID_STATE_DESC);
behavior->ActivateOutput (EGBLBuildCommandBehOutputs::Error);
return CKBR_OK;
}
break;
case EGBLBuildCommandState::GetTargets:
{
//check if the array of recipients is provided
void* recipients = NULL;
recipients = behavior->GetInputParameter (EGBLBuildCommandParamInputs::SetDests)->GetDirectSource()->GetValueObject();
if (recipients == NULL)
{
CKParameterOut *parameterOutError = behavior->GetOutputParameter(EGBLBuildCommandParamOutputs::GetError);
TGBLError::SetTGBLError(parameterOutError,CGBLCOError::EGBLCOErrorType::GBLCO_LOCAL,GBLFC_ERROR_BUILDCOMMAND_NO_DESTS,GBLFC_ERROR_BUILDCOMMAND_NO_DESTS_DESC);
behavior->ActivateOutput (EGBLBuildCommandBehOutputs::Error);
return CKBR_OK;
}
int targetID = 0;
behavior->GetInputParameterValue (EGBLBuildCommandParamInputs::SetCommandID, &targetID);
XString commandString;
commandString << targetID << CGBLCommandUtil::commandSeparator;
behavior->SetLocalParameterValue(commandStringLocalPos, commandString.Str(), strlen(commandString.Str()) + 1 );
//check if there are more arguments
return DoHandleNextNetworkArgument (behaviorContext);
}
break;
case EGBLBuildCommandState::AwaitingParametersForNetwork:
case EGBLBuildCommandState::AwaitingParametersForUntargeted:
{
CKSTRING commandString = (CKSTRING) behavior->GetLocalParameter(commandStringLocalPos)->GetReadDataPtr();
CKSTRING argumentString = (CKSTRING) behavior->GetInputParameter(EGBLBuildCommandParamInputs::SetParameterString)->GetReadDataPtr();
//char commandString[512];
//char argumentString[512];
//behavior->GetLocalParameterValue(commandStringLocalPos,&commandString);
//behavior->GetInputParameterValue (EGBLBuildCommandParamInputs::SetParameterString, &argumentString);
if (strlen (argumentString) == 0)
{
behavior->ActivateOutput (EGBLBuildCommandBehOutputs::InvalidValue);
return CKBR_OK;
}
CKSTRING argumentType = (CKSTRING) behavior->GetOutputParameter(EGBLBuildCommandParamOutputs::GetArgumentType)->GetReadDataPtr();
if ( (strcmp (argumentType, "Integer") == 0) || (strcmp (argumentType, "Float") == 0))
{
bool isArgumentNumeric = CGBLCommandUtil::IsNumeric(argumentString);
if (!isArgumentNumeric)
{
behavior->ActivateOutput (EGBLBuildCommandBehOutputs::InvalidValue);
return CKBR_OK;
}
}
XString updatedCommandString;
updatedCommandString << commandString << argumentString << CGBLCommandUtil::commandSeparator;
behavior->SetLocalParameterValue(commandStringLocalPos, updatedCommandString.Str(), strlen(updatedCommandString.Str()) + 1 );
if (gblBuildCommandState == EGBLBuildCommandState::AwaitingParametersForUntargeted)
{
return DoHandleNextLocalArgument (behaviorContext);
}
return DoHandleNextNetworkArgument (behaviorContext);
//.........这里部分代码省略.........
示例13: err
//************************************
// Method: vt_GetInVal
// FullName: vt_GetInVal
// Access: public static
// Returns: PyObject *
// Qualifier:
// Parameter: PyObject * self
// Parameter: PyObject * args
//************************************
static PyObject *vt_GetInVal( PyObject * self, PyObject * args )
{
int size = PyTuple_Size(args);
int bid, index;
PyArg_ParseTuple(args, "ii", &bid, &index);
CK_ID cid = bid;
CKBehavior *beh = static_cast<CKBehavior*>(pym->m_Context->GetObject(cid));
if (size!=2)
{
pym->m_Context->OutputToConsole("PyError : This function needs 2 arguments : \n\t bid,index");
Py_RETURN_NONE;
}
using namespace vtTools;
using namespace vtTools::Enums;
CKParameterManager *pam = static_cast<CKParameterManager *>(pym->m_Context->GetParameterManager());
if (index < beh->GetInputParameterCount() )
{
CKParameterIn *ciIn = beh->GetInputParameter(index);
CKParameterType pType = ciIn->GetType();
vtTools::Enums::SuperType sType = ParameterTools::GetVirtoolsSuperType(pym->m_Context,pam->ParameterTypeToGuid(pType));
PyObject *val;
switch (sType)
{
case vtSTRING:
{
val = PyString_FromString( vtTools::BehaviorTools::GetInputParameterValue<CKSTRING>(beh,index ));
break;
}
case vtFLOAT:
{
val = PyFloat_FromDouble(static_cast<float>(vtTools::BehaviorTools::GetInputParameterValue<float>(beh,index )));
break;
}
case vtINTEGER:
{
val = PyInt_FromLong( static_cast<long>(vtTools::BehaviorTools::GetInputParameterValue<int>(beh,index )));
break;
}
default :
XString err("wrong input parameter type: ");
err << ciIn->GetName() << "Only Types derivated from Interger,Float or String are acceptable";
pym->m_Context->OutputToConsole(err.Str(),FALSE );
Py_RETURN_NONE;
}
if (!val)
{
Py_DECREF(val);
}
return val;
}
Py_RETURN_NONE;
}
示例14: PWOverlapSphere
//************************************
// Method: PWOverlapSphere
// FullName: PWOverlapSphere
// Access: public
// Returns: int
// Qualifier:
// Parameter: const CKBehaviorContext& behcontext
//************************************
int PWOverlapSphere(const CKBehaviorContext& behcontext)
{
CKBehavior* beh = behcontext.Behavior;
CKContext* ctx = behcontext.Context;
PhysicManager *pm = GetPMan();
pFactory *pf = pFactory::Instance();
using namespace vtTools::BehaviorTools;
using namespace vtTools::ParameterTools;
//////////////////////////////////////////////////////////////////////////
//the object :
CK3dEntity *target = (CK3dEntity *) beh->GetTarget();
if( !target ) return CKBR_OWNERERROR;
//////////////////////////////////////////////////////////////////////////
// the world :
pWorld *world=GetPMan()->getWorld(target->GetID());
if (!world)
{
beh->ActivateOutput(bbOT_No);
return 0;
}
NxScene *scene = world->getScene();
if (!scene)
{
beh->ActivateOutput(bbOT_No);
return 0;
}
if( beh->IsInputActive(0) )
{
beh->ActivateInput(0,FALSE);
CKGroup *carray = (CKGroup*)beh->GetLocalParameterObject(bbS_Result);
if (carray)
{
//carray->clear();
carray->Clear();
}else
{
CK_OBJECTCREATION_OPTIONS creaoptions = (CK_OBJECTCREATION_OPTIONS)(CK_OBJECTCREATION_NONAMECHECK|CK_OBJECTCREATION_DYNAMIC);
carray = (CKGroup*)ctx()->CreateObject(CKCID_GROUP,"asdasd",creaoptions);
}
beh->SetLocalParameterObject(0,carray);
int hitIndex = 0;
beh->SetLocalParameterValue(bbS_Index,&hitIndex);
int hitSize = 0;
beh->SetLocalParameterValue(bbS_Size,&hitSize);
//////////////////////////////////////////////////////////////////////////
int types = GetInputParameterValue<int>(beh,bbI_ShapesType);
int accurate = GetInputParameterValue<int>(beh,bbI_Accurate);
DWORD groupsEnabled;
DWORD groups = 0xffffffff;
beh->GetLocalParameterValue(bbS_Groups,&groupsEnabled);
if (groupsEnabled)
{
groups = GetInputParameterValue<int>(beh,bbI_Groups);
}
pGroupsMask *gmask = NULL;
DWORD mask;
beh->GetLocalParameterValue(bbS_Mask,&mask);
if (mask)
{
CKParameter *maskP = beh->GetInputParameter(bbI_Mask)->GetRealSource();
gmask->bits0 = GetValueFromParameterStruct<int>(maskP,0);
gmask->bits1 = GetValueFromParameterStruct<int>(maskP,1);
gmask->bits2 = GetValueFromParameterStruct<int>(maskP,2);
gmask->bits3 = GetValueFromParameterStruct<int>(maskP,3);
}
//.........这里部分代码省略.........
示例15: BehaviourFunction
/*
*******************************************************************
* 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 CGBLLOStopTimer::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 *pInMO = beh->GetInputParameter(eParamInputMO);
CKParameter *moParam = pInMO->GetRealSource();
// Get the details of the Measurement P-In
CKParameterIn *pInMeas= beh->GetInputParameter(eParamInputMeasurement);
CKParameter *measParam = pInMeas->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 data from the P-In
CGBLMeasurementData *measData = static_cast<CGBLMeasurementData*>(measParam->GetAppData());
if (measData)
{
// Get the measurement
XString measName = measData->GetName();
EGBLLOMeasurementType measType=measData->GetType();
CGBLMeasurement *meas=NULL;
retVal=mo->GetMeasurement(measName,meas);
// See if the MO gave us the measurement
if((retVal==CGBLCOError::EGBLCOErrorType::GBLCO_OK)&&(meas))
{
// Based on the measurement type, get the value from the P-Im
// and pass the value to the measurement.
switch (measType)
{
case eTimer:
{
CGBLLOMeasurementTimer *timeMeas=NULL;
timeMeas=static_cast<CGBLLOMeasurementTimer*>(meas);
retVal=timeMeas->StopTimer();
}
break;
default:
{
CKParameterOut *pOut = beh->GetOutputParameter(eParamOutputGetError);
TGBLError::SetTGBLError(pOut, CGBLCOError::EGBLCOErrorType::GBLCO_LOCAL,
GBLLO_ERROR_TRIED_START_TIMER_NOT,GBLLO_ERROR_TRIED_START_TIMER_NOT_DESC);
beh->ActivateOutput(eBehOutputError, TRUE);
localError = true;
}
break;
}
}
}
//.........这里部分代码省略.........