本文整理汇总了C++中CKBehavior::ActivateInput方法的典型用法代码示例。如果您正苦于以下问题:C++ CKBehavior::ActivateInput方法的具体用法?C++ CKBehavior::ActivateInput怎么用?C++ CKBehavior::ActivateInput使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CKBehavior
的用法示例。
在下文中一共展示了CKBehavior::ActivateInput方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PBGet2
//************************************
// Method: PBGet2
// FullName: PBGet2
// Access: public
// Returns: int
// Qualifier:
// Parameter: const CKBehaviorContext& behcontext
//************************************
int PBGet2(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) )
{
//////////////////////////////////////////////////////////////////////////
//the object :
CK3dEntity *target = (CK3dEntity *) beh->GetTarget();
if( !target ) return CKBR_OWNERERROR;
//////////////////////////////////////////////////////////////////////////
// the world :
pWorld *world=GetPMan()->getWorldByBody(target);
if (!world)
{
beh->ActivateOutput(0);
return 0;
}
// body exists already ? clean and delete it :
pRigidBody*result = world->getBody(target);
if(result)
{
//////////////////////////////////////////////////////////////////////////
//linear damp :
DWORD cGroup;
beh->GetLocalParameterValue(bbI_CollisionGroup,&cGroup);
if (cGroup)
{
int val = result->getCollisionsGroup();
SetOutputParameterValue<int>(beh,bbI_CollisionGroup,val);
}
DWORD kine;
beh->GetLocalParameterValue(bbI_Kinematic,&kine);
if (kine)
{
int val = result->isKinematic();
SetOutputParameterValue<int>(beh,bbI_Kinematic,val);
}
DWORD gravity;
beh->GetLocalParameterValue(bbI_Gravity,&gravity);
if (gravity)
{
int val = result->getActor()->readBodyFlag(NX_BF_DISABLE_GRAVITY);
SetOutputParameterValue<int>(beh,bbI_Gravity,!val);
}
DWORD col;
beh->GetLocalParameterValue(bbI_Collision,&col);
if (col)
{
int val = result->isCollisionEnabled();
SetOutputParameterValue<int>(beh,bbI_Collision,val);
}
DWORD mass;
beh->GetLocalParameterValue(bbI_MassOffset,&mass);
if (mass)
{
VxVector val = result->getMassOffset();
SetOutputParameterValue<VxVector>(beh,bbI_MassOffset,val);
}
DWORD pivot;
beh->GetLocalParameterValue(bbI_ShapeOffset,&pivot);
if (mass)
{
// VxVector val = result->getPivotOffset();
// SetOutputParameterValue<VxVector>(beh,bbI_ShapeOffset,val);
}
}
beh->ActivateInput(0,FALSE);
beh->ActivateOutput(0);
}
return 0;
}
示例2: PBSetHard
//************************************
// Method: PBSetHard
// FullName: PBSetHard
// Access: public
// Returns: int
// Qualifier:
// Parameter: const CKBehaviorContext& behcontext
//************************************
int PBSetHard(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 :
CK3dEntity *target = (CK3dEntity *) beh->GetTarget();
if( !target ) bbErrorME("No Reference Object specified");
pRigidBody *body = NULL;
//////////////////////////////////////////////////////////////////////////
// the world :
pWorld *world=GetPMan()->getWorldByBody(target);
if (!world)
{
if (!body) bbErrorME("No valid world object found");
}
body = GetPMan()->getBody(target);
if (!body) bbErrorME("No Reference Object specified");
BB_DECLARE_PIMAP;
/************************************************************************/
/* retrieve settings state */
/************************************************************************/
BBSParameter(bbI_Vel);
BBSParameter(bbI_AVel);
BBSParameter(bbI_Torque);
BBSParameter(bbI_Momentum);
BBSParameter(bbI_Pos);
BBSParameter(bbI_Rotation);
if (sbbI_Vel)
{
VxVector velocity= GetInputParameterValue<VxVector>(beh,BB_IP_INDEX(bbI_Vel));
body->setLinearVelocity(velocity);
}
if (sbbI_AVel)
{
VxVector aVelocity= GetInputParameterValue<VxVector>(beh,BB_IP_INDEX(bbI_AVel));
body->setAngularVelocity(aVelocity);
}
if (sbbI_Torque)
{
VxVector torque= GetInputParameterValue<VxVector>(beh,BB_IP_INDEX(bbI_Torque));
body->setAngularMomentum(torque);
}
if (sbbI_Momentum)
{
VxVector momentum= GetInputParameterValue<VxVector>(beh,BB_IP_INDEX(bbI_Momentum));
body->setLinearMomentum(momentum);
}
if (sbbI_Pos)
{
VxVector pos= GetInputParameterValue<VxVector>(beh,BB_IP_INDEX(bbI_Pos));
body->setPosition(pos,target);
}
if (sbbI_Rotation)
{
VxQuaternion rot= GetInputParameterValue<VxQuaternion>(beh,BB_IP_INDEX(bbI_Rotation));
body->setRotation(rot,target);
}
}
beh->ActivateOutput(0);
return 0;
}
示例3: 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 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
//.........这里部分代码省略.........
示例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: ARTPlusPatternTransformation
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);
//.........这里部分代码省略.........
示例6: NSUnlockObject
/*
*******************************************************************
* Function:
*
* Description:
*
* Parameters:
*
* Returns:
*
*******************************************************************
*/
int NSUnlockObject(const CKBehaviorContext& behcontext)
{
using namespace vtTools::BehaviorTools;
CKBehavior* beh = behcontext.Behavior;
CKMessageManager* mm = behcontext.MessageManager;
CKContext* ctx = behcontext.Context;
bbNoError(E_NWE_OK);
//network ok ?
xNetInterface *cin = GetNM()->GetClientNetInterface();
if (!cin)
{
bbError(E_NWE_NO_CONNECTION);
return 0;
}
if (!cin->getMyClient())
{
bbError(E_NWE_INTERN);
return 0;
}
ISession *sInterface = cin->getSessionInterface();
int connectionID = GetInputParameterValue<int>(beh,BB_IP_CONNECTION_ID);
//////////////////////////////////////////////////////////////////////////
//
// Check states :
//
xDistributedClient *myClient = cin->getMyClient();
if (!myClient)
{
bbError(E_NWE_INTERN);
return 0;
}
if (!myClient->getClientFlags().test(1 << E_CF_SESSION_JOINED))
{
bbError(E_NWE_NO_SESSION);
return 0;
}
xDistributedSession *session = cin->getCurrentSession();
if (!session)
{
bbError(E_NWE_NO_SUCH_SESSION);
return 0;
}
if (beh->IsInputActive(0))
{
beh->ActivateInput(0,FALSE);
if (myClient->getUserID() != session->getUserID())
{
bbError(E_NWE_NOT_SESSION_MASTER);
return 0;
}
beh->ActivateInput(0,FALSE);
sInterface->unlockSession(myClient->getUserID(),session->getSessionID());
}
if (session->isLocked())
{
beh->ActivateOutput(BB_O_UNLOCKED);
return 0;
}else
{
beh->ActivateOutput(BB_O_WAITING);
}
return CKBR_ACTIVATENEXTFRAME;
}
示例7: NSRemoveUser
/*
*******************************************************************
* Function:
*
* Description:
*
* Parameters:
*
* Returns:
*
*******************************************************************
*/
int NSRemoveUser(const CKBehaviorContext& behcontext)
{
using namespace vtTools::BehaviorTools;
CKBehavior* beh = behcontext.Behavior;
CKMessageManager* mm = behcontext.MessageManager;
CKContext* ctx = behcontext.Context;
//network ok ?
xNetInterface *cin = GetNM()->GetClientNetInterface();
if (!cin)
{
Error(beh,"No connection at the moment",BB_OP_SESSION_ERROR,TRUE,BB_O_ERROR);
return 0;
}
IDistributedObjects *oInterface = cin->getDistObjectInterface();
ISession *sInterface = cin->getSessionInterface();
int connectionID = GetInputParameterValue<int>(beh,BB_IP_CONNECTION_ID);
int userID = GetInputParameterValue<int>(beh,BB_IP_USER_ID);
//////////////////////////////////////////////////////////////////////////
//
// Check states :
//
xDistributedClient *myClient = cin->getMyClient();
xDistributedClient *client = (xDistributedClient*)oInterface->getByUserID(userID,E_DC_BTYPE_CLIENT);
xDistributedSession *session = cin->getCurrentSession();
if (!session)
{
Error(beh,"There doesn't exist such session",BB_OP_SESSION_ERROR,TRUE,BB_O_ERROR);
xLogger::xLog(ELOGERROR,E_LI_SESSION,"There doesn't exist such session!");
XL_BB_SIGNATURE;
return 0;
}
if (!client)
{
Error(beh,"There doesn't exist such client object",BB_OP_SESSION_ERROR,TRUE,BB_O_ERROR);
xLogger::xLog(ELOGERROR,E_LI_SESSION,"There doesn't exist such client object :%d",userID);
XL_BB_SIGNATURE;
return 0;
}
if (!session->isClientJoined(userID))
{
Error(beh,"Client not joint on this session!",BB_OP_SESSION_ERROR,TRUE,BB_O_ERROR);
xLogger::xLog(ELOGERROR,E_LI_SESSION,"Client not joint on this session! %d",userID);
XL_BB_SIGNATURE;
return 0;
}
if (beh->IsInputActive(0))
{
beh->ActivateInput(0,FALSE);
sInterface->removeClient(client,session->getSessionID(),false);
beh->ActivateOutput(0);
}
return 0;
}
示例8: BehaviourFunction
/*
*******************************************************************
* 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);
//.........这里部分代码省略.........
示例9: PCGroupTriggerEvent
//************************************
// Method: PCGroupTriggerEvent
// FullName: PCGroupTriggerEvent
// Access: public
// Returns: int
// Qualifier:
// Parameter: const CKBehaviorContext& behcontext
//************************************
int PCGroupTriggerEvent(const CKBehaviorContext& behcontext)
{
CKBehavior* beh = behcontext.Behavior;
CKContext* ctx = behcontext.Context;
PhysicManager *pm = GetPMan();
pFactory *pf = pFactory::Instance();
using namespace vtTools::BehaviorTools;
//////////////////////////////////////////////////////////////////////////
//the object :
CKGroup *target = (CKGroup *) beh->GetTarget();
if( !target ) return CKBR_OWNERERROR;
//int extraFilter = GetInputParameterValue<int>(beh,0);
//int remove = GetInputParameterValue<int>(beh,1);
int nbOfEvents = getEventCount();
if (!nbOfEvents)
{
beh->ActivateOutput(bbO_None);
return 0;
}
/************************************************************************/
/* handle init */
/************************************************************************/
if( beh->IsInputActive(bbI_Init) )
{
beh->ActivateInput(bbI_Init,FALSE);
int index = 0;beh->SetLocalParameterValue(0,&index);
//we have some, forward to in 1:next
if (nbOfEvents)
{
beh->ActivateInput(bbI_Next,TRUE);
beh->ActivateOutput(bbO_HasMore);
}
}
/************************************************************************/
/* handle trigger 'next' */
/************************************************************************/
if( beh->IsInputActive(bbI_Next) )
{
beh->ActivateInput(bbI_Next,FALSE);
int index = 0;beh->GetLocalParameterValue(0,&index);
for (int i = index ; i < GetPMan()->getTriggers().Size(); i++ )
{
pTriggerEntry &entry = *GetPMan()->getTriggers().At(i);
if (!entry.triggered)
{
if (isInGroup(target,entry.triggerShapeEnt))
{
beh->SetOutputParameterObject(0,entry.triggerShapeEnt);
beh->SetOutputParameterObject(1,entry.otherObject);
SetOutputParameterValue<int>(beh,2,entry.triggerEvent);
entry.triggered = true;
//trigger out
if(entry.triggerEvent == NX_TRIGGER_ON_ENTER)
{
beh->ActivateOutput(bbO_Enter);
}
if(entry.triggerEvent == NX_TRIGGER_ON_STAY)
{
beh->ActivateOutput(bbO_Stay);
}
if(entry.triggerEvent == NX_TRIGGER_ON_LEAVE)
{
beh->ActivateOutput(bbO_Leave);
}
//store index
beh->SetLocalParameterValue(1,&index);
int nbOfLeftEvents = getEventCount();
if (nbOfLeftEvents)
{
beh->ActivateOutput(bbO_HasMore);
return 0;
}else
{
beh->ActivateOutput(bbO_None);
return 0;
}
}
}
//.........这里部分代码省略.........
示例10: GetCIValue
/*
*******************************************************************
* 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
//.........这里部分代码省略.........
示例11: 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;
}
示例12: PlayFFEffect
int PlayFFEffect(const CKBehaviorContext& behcontext)
{
CKBehavior* beh = behcontext.Behavior;
CKContext* ctx2 = behcontext.Context;
ctx = ctx2;
HWND mWin = (HWND )ctx->GetMainWindow();
//init and load effect
if( beh->IsInputActive(0) ){
beh->ActivateInput(0,FALSE);
HRESULT result = InitDirectInput(mWin);
HRESULT sa = S_OK;
if (InitDirectInput(mWin) == S_OK)
{
XString filename((CKSTRING) beh->GetInputParameterReadDataPtr(0));
OnReadFile(mWin,filename.Str());
beh->ActivateOutput(0);
return CKBR_OK;
}else{
beh->ActivateOutput(4);
return CKBR_OK;
}
}
//play
if( beh->IsInputActive(1) ){
beh->ActivateInput(1,FALSE);
if (OnPlayEffects2(NULL) != S_OK ){
beh->ActivateOutput(4);
return CKBR_OK;
}
beh->ActivateOutput(1);
return CKBR_OK;
}
//stop the effect
if( beh->IsInputActive(2) ){
beh->ActivateInput(2,FALSE);
// Stop all previous forces
g_pFFDevice->SendForceFeedbackCommand( DISFFC_STOPALL );
beh->ActivateOutput(2);
return CKBR_OK;
}
// [11/7/2004]
//save device release
if( beh->IsInputActive(3) ){
beh->ActivateInput(3,FALSE);
if ( g_pFFDevice)
g_pFFDevice->SendForceFeedbackCommand( DISFFC_STOPALL );
FreeDirectInput2();
beh->ActivateOutput(3);
return CKBR_OK;
}
return CKBR_OK;
}
示例13: 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 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;
}
示例14: PacketIterator
/*
*******************************************************************
* Function: int PacketIterator( 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 PacketIterator(const CKBehaviorContext& behcontext)
{
/************************************************************************/
/* collecting data : */
/* */
CKBehavior* beh = behcontext.Behavior;
CKContext* ctx = behcontext.Context;
CGBLCIConfigurationController* cman=(CGBLCIConfigurationController*)ctx->GetManagerByGuid(CONFIGURATION_MAN_GUID);
CGBLCONetwork *networkInterface = cman->GetNetworkInterface();
//////////////////////////////////////////////////////////////////////////
/* check network -interace : */
if(!networkInterface->IsValid())
{
//try to init the network interface :
if ( networkInterface->Init() != CGBLCOError::GBLCO_OK )
{
return CKBR_PARAMETERERROR;
}
}
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
//output packet info, this infos
/*get the last index */
int index = 0;
beh->GetLocalParameterValue(0, &index);
/* bounding check for the index: if out of range, set to zero and save it.*/
if(index >= networkInterface->GetOutgoingPackets()->Size() )
{
index = 0;
beh->SetLocalParameterValue(0,&index);
beh->ActivateOutput(0);
return CKBR_OK;
}
/*************************************/
/* behavior trigger event processing : */
/* */
/* */
/* Reset/On : sets the index to zero and save it */
if( beh->IsInputActive(0) )
{
beh->ActivateInput(0,FALSE);
index = 0 ;
beh->SetLocalParameterValue(0,&index);
beh->ActivateInput(1,TRUE);
}
/* Loop In : */
if( beh->IsInputActive(1) )
{
beh->ActivateInput(1,FALSE);
if(networkInterface->GetOutgoingPackets()->Size() && index < networkInterface->GetOutgoingPackets()->Size() )
{
//the following call is virtual. Both versions of ForwardPacketToScript are passing parameters to this building block.
cman->GetNetworkInterface()->ForwardPacketToScript(beh,index);
index++;
beh->SetLocalParameterValue(0,&index);
return CKBR_OK;
}
}
return CKBR_OK;
}
示例15: 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();
}
//.........这里部分代码省略.........