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


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

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


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

示例1: MidiEvent

int MidiEvent(const CKBehaviorContext& behcontext)
{
  CKBehavior *beh = behcontext.Behavior;

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

    return CKBR_OK;
  }
  
  CKBOOL combiWasOK = FALSE;
  if( beh->IsInputActive(0) ){ // ON
    beh->ActivateInput(0, FALSE);
    beh->SetLocalParameterValue(0, &combiWasOK);
  } else {
    beh->GetLocalParameterValue(0, &combiWasOK);
  }

  MidiManager *mm = (MidiManager *) behcontext.Context->GetManagerByGuid( MIDI_MANAGER_GUID );

  // Channel
  int channel=0;
  beh->GetInputParameterValue(0, &channel);

  int note, count = beh->GetInputParameterCount();
  //--- test if all input notes are activated or not
  for( int a=1 ; a<count ; a++ ){
    beh->GetInputParameterValue(a, &note);
    if( !mm->IsNoteActive(note, channel) ) break;
  }

  if( a==count ){ // All notes are pressed
    if( !combiWasOK ){
      beh->ActivateOutput(0);
      
      combiWasOK = TRUE;
      beh->SetLocalParameterValue(0, &combiWasOK);
      
      return CKBR_ACTIVATENEXTFRAME;
    }
  } else { // Not all notes are pressed
    if( combiWasOK ){
      beh->ActivateOutput(1);
      
      combiWasOK = FALSE;
      beh->SetLocalParameterValue(0, &combiWasOK);
      
      return CKBR_ACTIVATENEXTFRAME;
    }
  }

  return CKBR_ACTIVATENEXTFRAME;
}
开发者ID:gbaumgart,项目名称:vt,代码行数:53,代码来源:MidiEvent.cpp

示例2: TextureSinus

int TextureSinus(const CKBehaviorContext& behcontext)
{
    CKBehavior* beh = behcontext.Behavior;

    // we get the amount value
    float xamp=0.1f;
    beh->GetInputParameterValue(0, &xamp);

    // we get the amount value
    float yamp=0.1f;
    beh->GetInputParameterValue(1, &yamp);

    float l= 1.0f;
    beh->GetInputParameterValue(2, &l);

    // we get the saved uv's
    VxUV* savedUV = (VxUV*) beh->GetLocalParameterReadDataPtr(0);

    // we get the interpolated mesh
    CKMesh *mesh = (CKMesh*) beh->GetInputParameterObject(4);

    int channel = -1;
    beh->GetInputParameterValue(3, &channel);
    int channelcount = mesh->GetChannelCount();
    if (channel < -1 || channel >= channelcount) {
        beh->ActivateInput(0, FALSE);
        beh->ActivateOutput(0);
        return CKBR_PARAMETERERROR;
    }

    CKDWORD Stride;
    VxUV *uvarray = (VxUV*) mesh->GetModifierUVs(&Stride,channel);
    int pointsNumber = mesh->GetModifierUVCount(channel);

    float time;
    beh->GetLocalParameterValue(1, &time);

    float t;
    for( int i=0 ; i<pointsNumber ; i++, uvarray =(VxUV *)((BYTE *)uvarray + Stride)) {
        t = ((float)i/pointsNumber-0.5f)*4.0f+time*l;
        uvarray->u = savedUV[i].u + ( 0.5f - savedUV[i].u ) * xamp * cosf(t);
        uvarray->v = savedUV[i].v + ( 0.5f - savedUV[i].v ) * yamp * sinf(t);
    }
    mesh->ModifierUVMove(channel);

    float pi = 3.1415926535f;
    time += behcontext.DeltaTime * 0.001f;

    if(l*time > 2*pi)
        time -= (2*pi / l);

    beh->SetLocalParameterValue(1, &time);

    beh->ActivateInput(0, FALSE);
    beh->ActivateOutput(0);
    return CKBR_OK;
}
开发者ID:,项目名称:,代码行数:57,代码来源:

示例3: GeneralCameraOrbitCallback

CKERROR GeneralCameraOrbitCallback(const CKBehaviorContext& context)
{
	CKBehavior* beh = context.Behavior;

	switch(context.CallbackMessage)
	{
		case CKM_BEHAVIORCREATE:
		case CKM_BEHAVIORLOAD:
		{
			VxVector InitialAngles(INF,INF,INF);
			beh->SetLocalParameterValue(LOCAL_INIT,&InitialAngles);

			VxVector RotationAngles(0,0,0);
			beh->SetLocalParameterValue(LOCAL_ROT,&RotationAngles);
		}
		break;

		case CKM_BEHAVIORSETTINGSEDITED:
		{
			// Update the needed input for "returns"
			CKBOOL Returns = TRUE;
			beh->GetLocalParameterValue(LOCAL_RETURN,&Returns);
			beh->EnableInputParameter(IN_SPEED_RETURN, Returns);

			// Updates the needed inputs for limiting the move
			CKBOOL Limited = TRUE;
			beh->GetLocalParameterValue(LOCAL_LIMITS,&Limited);
			beh->EnableInputParameter(IN_MIN_H,Limited);
			beh->EnableInputParameter(IN_MAX_H,Limited);
			beh->EnableInputParameter(IN_MIN_V,Limited);
			beh->EnableInputParameter(IN_MAX_V,Limited);
			beh->EnableInputParameter(IN_MIN_ZOOM,Limited);
			beh->EnableInputParameter(IN_MAX_ZOOM,Limited);
		}
		break;

		default:
		break;
	}

	return CKBR_OK; 
}
开发者ID:gbaumgart,项目名称:vt,代码行数:42,代码来源:GeneralCameraOrbit.cpp

示例4: 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 CGBLBuildCommand::BehaviourFunction(const CKBehaviorContext& behaviorContext)
{
	CKBehavior* behavior = behaviorContext.Behavior;
  	CKContext* context = behaviorContext.Context;

	if( behavior->IsInputActive(EGBLBuildCommandBehInputs::BuildCommand) ) 
	{
		DeactivateInputs(behaviorContext);
		DeactivateOutputs(behaviorContext);
		return DoBuildCommand (behaviorContext);
	}

	if( behavior->IsInputActive(EGBLBuildCommandBehInputs::CancelOperation))
	{
		DeactivateInputs(behaviorContext);
		DeactivateOutputs(behaviorContext);
		ClearParameterOutputs (behaviorContext);

		int stateValue = EGBLBuildCommandState::Initial;
		behavior->SetLocalParameterValue (gblBuildCommandStateLocalPos, &stateValue);

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

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

		behavior->ActivateOutput (EGBLBuildCommandBehOutputs::Cancelled);
	}

	if( behavior->IsInputActive(EGBLBuildCommandBehInputs::ReadNextParameterValue))
	{
		DeactivateInputs(behaviorContext);
		DeactivateOutputs(behaviorContext);

		int stateValue = 0;
		behavior->GetLocalParameterValue (gblBuildCommandStateLocalPos, &stateValue);

		if (! ( (stateValue == EGBLBuildCommandState::AwaitingParametersForUntargeted) || (stateValue == EGBLBuildCommandState::AwaitingParametersForNetwork) || (stateValue == EGBLBuildCommandState::GetTargets) ) )
		{
			int stateValue = EGBLBuildCommandState::Initial;
			behavior->SetLocalParameterValue (gblBuildCommandStateLocalPos, &stateValue);

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

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

			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 DoReadNextParameterValue (behaviorContext);
	}

	return CKBR_OK;
}
开发者ID:gbaumgart,项目名称:GBL_Backup,代码行数:86,代码来源:GBLBuildCommand.cpp

示例5: CISIteratorCB

/*
*******************************************************************
* Function: int CISIteratorCB( const CKBehaviorContext& behaviorContext )
*
* Description : The Behavior Callback function is called by Virtools when various events happen 
*               in the life of a BuildingBlock. Exactly which events trigger a call to the 
*               Behavior Callback function is defined in the Behavior Prototype, along with the 
*               declaration of the function pointer 
*
* Parameters :
*    behaviourContext    r   Behavior context reference, which gives 
*                            access to frequently used global objects 
*                            ( context, level, manager, etc... )
*
* Returns : int, The return value of the callback function should be one of the CK_BEHAVIOR_RETURN values.
*
*******************************************************************
*/
CKERROR CISIteratorCB(const CKBehaviorContext& behcontext)
{
	/************************************************************************/
	/*  collecting data :													*/
	/*  																	*/
	CKBehavior *beh = behcontext.Behavior;
	CKContext* ctx = beh->GetCKContext();
	CKParameterManager *pm = static_cast<CKParameterManager*>(ctx->GetParameterManager());
	CGBLCIConfigurationController* cman=(CGBLCIConfigurationController*)ctx->GetManagerByGuid(CONFIGURATION_MAN_GUID);


	/************************************************************************/
	/*	process virtools callbacks		:									*/
	/*  																	*/

	switch(behcontext.CallbackMessage)
	{
	case CKM_BEHAVIORRESET:
		{
			CKDataArray *array = NULL;
			beh->SetLocalParameterValue(BEH_LOCAL_PAR_INDEX_CIID_LIST,&array);
			break;
		}
	case CKM_BEHAVIOREDITED:
	case CKM_BEHAVIORSETTINGSEDITED :
		{

			assert(beh && ctx);

			BOOL getFromDB = false;
			beh->GetLocalParameterValue(BEH_LOCAL_PAR_INDEX_DB_MODE,&getFromDB);

			if( getFromDB &&  ( beh->GetInputParameterCount() ==  BEH_IN_INDEX_MIN_COUNT ) )
			{
				beh->CreateInputParameter("CIS ID", CKPGUID_INT);
			}
			//////////////////////////////////////////////////////////////////////////
			//remove all pIns :
			int p_count  =  beh->GetInputParameterCount();

			while( (getFromDB ? BEH_IN_INDEX_MAX_COUNT : BEH_IN_INDEX_MIN_COUNT ) < p_count )
			{ 
				CKDestroyObject( beh->RemoveInputParameter( --p_count) );
			}

			break;

		}

	}
	return CKBR_OK;
}
开发者ID:gbaumgart,项目名称:GBL_Backup,代码行数:70,代码来源:GBLCICISIterator.cpp

示例6: onHit

bool pRayCastReport::onHit(const NxRaycastHit& hit)
{

	CKBehavior *beh =(CKBehavior*)GetPMan()->m_Context->GetObject(mCurrentBehavior);
	if ( beh )
	{
		pRayCastHits *carray = NULL;
		beh->GetLocalParameterValue(0,&carray);
		if (carray)
		{
			//carray->clear();
		}else
		{
			carray =  new pRayCastHits();
		}

		//carray->push_back(const_cast<NxRaycastHit&>(&hit));

		NxRaycastHit *_hit = new NxRaycastHit();

		_hit->distance = hit.distance;
		_hit->faceID = hit.faceID;
		_hit->flags = hit.flags;
		_hit->internalFaceID = hit.internalFaceID;
		_hit->materialIndex = hit.materialIndex;
		_hit->shape = hit.shape;
		_hit->u =  hit.u;
		_hit->v = hit.v;
		_hit->worldImpact = hit.worldImpact;
		_hit->worldNormal = hit.worldNormal;
		
		const char *name = hit.shape->getName();
		
		carray->push_back(_hit);




		beh->SetLocalParameterValue(0,&carray);


	}
	return true;
}
开发者ID:gbaumgart,项目名称:vt,代码行数:44,代码来源:pWorldCollision.cpp

示例7: TextureSinusCallBackObject

CKERROR TextureSinusCallBackObject(const CKBehaviorContext& behcontext)
{
    CKBehavior* beh = behcontext.Behavior;

    switch(behcontext.CallbackMessage) {

#ifdef macintosh
    case CKM_BEHAVIORLOAD:
    {


        CKMesh *mesh = (CKMesh*) beh->GetInputParameterObject(4);
        if(!mesh)
            return 0;
        int nbvert = mesh->GetModifierUVCount();
        // we get the saved uv's
        DWORD *savedUV = (DWORD *) beh->GetLocalParameterWriteDataPtr(0);

        for(int i=0; i<nbvert*2; i++) {
            savedUV[i] = ENDIANSWAP32(savedUV[i]);
        }
    }
    break;
#endif

    case CKM_BEHAVIORATTACH:
    {
        // we get the mesh vertices
        CKMesh *mesh = (CKMesh*) beh->GetInputParameterObject(4);
        if(!mesh) return 0;

        CKDWORD Stride;
        VxUV *uvarray = (VxUV*) mesh->GetModifierUVs(&Stride);
        int nbvert = mesh->GetModifierUVCount();

        VxUV *savedUV;
        savedUV = new VxUV[nbvert];

        for(int i=0 ; i<nbvert ; i++, uvarray = (VxUV*)((BYTE*)uvarray + Stride) ) {
            savedUV[i] = *uvarray;
        }

        beh->SetLocalParameterValue(0, savedUV, nbvert * sizeof(VxUV) );

        delete[] savedUV;
    }
    break;
    case CKM_BEHAVIORDETACH:
    {
        // we get the mesh vertices
        if(!beh) return 0;
        CKMesh *mesh = (CKMesh*) beh->GetInputParameterObject(4);
        if(!mesh) return 0;

        CKDWORD Stride;
        VxUV *uvarray = (VxUV*) mesh->GetModifierUVs(&Stride);
        int nbvert = mesh->GetModifierUVCount();

        VxUV *savePos = (VxUV*) beh->GetLocalParameterWriteDataPtr(0);
        if(!savePos) return 0;

        for(int i=0 ; i<nbvert ; i++, uvarray = (VxUV*)((BYTE*)uvarray + Stride) ) {
            *uvarray = savePos[i];
        }
        mesh->ModifierUVMove();
    }

    }
    return CKBR_OK;
}
开发者ID:,项目名称:,代码行数:70,代码来源:

示例8: GeneralCameraOrbit

int GeneralCameraOrbit(const CKBehaviorContext& behcontext,INPUTPROCESSFUNCTION InputFunction)
{
	// Get the behavior
	CKBehavior* beh = behcontext.Behavior;
	float delta = behcontext.DeltaTime;

	// Current state of the behavior
	CKBOOL stopping;

	// Indicates the behavior we are stopping if returns, stop otherwise
	CKBOOL Returns = TRUE;
	beh->GetLocalParameterValue(LOCAL_RETURN,&Returns);

	// Stop Entrance, we stop
	if (beh->IsInputActive(1))
	{
		// Set IO State
		beh->ActivateInput(1,FALSE);

		// A protection in case we stop the behavior before having started it
		VxVector InitialAngles;
		beh->GetLocalParameterValue(LOCAL_INIT,&InitialAngles);

		// Get current position
		VxVector RotationAngles;
		beh->GetLocalParameterValue(LOCAL_ROT,&RotationAngles);

		// Stopping Now
		stopping = TRUE;
		beh->SetLocalParameterValue(LOCAL_STOPPING,&stopping);
		if ( !Returns || ((RotationAngles.x == 0) && (RotationAngles.y == 0)) ) {
			beh->ActivateOutput(1,TRUE);
			return CKBR_OK;
		}
	}

	// Gets the current camera
	CKCamera *Camera = (CKCamera *) beh->GetTarget();
	if( !Camera ) return CKBR_OWNERERROR;

	// Gets the target informations
	VxVector TargetPosition;
	beh->GetInputParameterValue(IN_TARGET_POS,&TargetPosition);

	CK3dEntity* TargetRef = (CK3dEntity*)beh->GetInputParameterObject(IN_TARGET_REF);


	//////////////////////////////////////////////
	// Gets the input parameters of the behavior
	//////////////////////////////////////////////
	VxVector InitialAngles(0,0,0), RotationAngles(0,0,0);

	// First entrance, sets the initial values here only
	if (beh->IsInputActive(0))
	{
		// Sets IO State
		beh->ActivateInput(0,FALSE);
		beh->ActivateOutput(0,TRUE);

		// Not Stopping
		stopping = FALSE;
		beh->SetLocalParameterValue(LOCAL_STOPPING,&stopping);

		// Compute the Initial Angles, the radius
		VxVector InitialPosition;
		Camera->GetPosition(&InitialPosition, TargetRef);
	
		InitialPosition -= TargetPosition;
		InitialAngles.z = Magnitude(InitialPosition);
		if ( InitialAngles.z == 0.0f ) {
			InitialAngles.x = 0.0f;
			InitialAngles.y = 0.0f;
		}
		else {
			// Vertical Polar Angle
			float d;
			InitialPosition.Normalize();
			d = DotProduct(InitialPosition,VxVector::axisY());

			// bound the value of d to avoid errors due to precision.
			if (d < -1)
				d = -1;
			else if (d > 1)
				d = 1;
 			InitialAngles.y = acosf(d);

			// Horizontal Polar Angle
			InitialPosition.y = 0;
			if ( (InitialPosition.x == 0.0f) && (InitialPosition.y == 0.0f) && (InitialPosition.z == 0.0f) )
				InitialAngles.x = PI/2;
			else {
				InitialPosition.Normalize();
				d = DotProduct(InitialPosition,VxVector::axisX());
				// bound the value of d to avoid eroors due to precision.
				if (d < -1)
					d = -1;
				else if (d > 1)
					d = 1;
				InitialAngles.x = acosf(d);
				d = DotProduct(InitialPosition,VxVector::axisZ());
//.........这里部分代码省略.........
开发者ID:gbaumgart,项目名称:vt,代码行数:101,代码来源:GeneralCameraOrbit.cpp

示例9: BehaviourFunction


//.........这里部分代码省略.........

   	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;
开发者ID:gbaumgart,项目名称:GBL_Backup,代码行数:67,代码来源:GBLListBox.cpp

示例10: 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);

		}
//.........这里部分代码省略.........
开发者ID:gbaumgart,项目名称:vt,代码行数:101,代码来源:PWSphereOverlap.cpp

示例11: 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;
					}
				}
			}
//.........这里部分代码省略.........
开发者ID:gbaumgart,项目名称:vt,代码行数:101,代码来源:PCGoupTriggerEvent.cpp

示例12: DoHandleNextLocalArgument

/*
*******************************************************************
* Function: int CGBLBuildCommand::DoHandleNextLocalArgument (const CKBehaviorContext& behaviorContext)
*
* Description : Checks if there are more arguments to be specified for global 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::DoHandleNextLocalArgument (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, &currentParameterPosition);
	CKParameter* nextArgument = CGBLCommandUtil::GetCommandArgument(*targetBB, currentParameterPosition);

	currentParameterPosition++;
	behavior->SetLocalParameterValue (currentParameterPositionLocalPos, &currentParameterPosition);

	if (nextArgument == NULL)
	{
		//no arguments required, build finished
		//char commandString[512];
		
		//behavior->GetLocalParameterValue(commandStringLocalPos,&commandString);
		CKSTRING commandString = (CKSTRING) behavior->GetLocalParameter(commandStringLocalPos)->GetReadDataPtr();
		int res = CGBLCommandUtil::InvokeCommand (commandString, behaviorContext);

		ClearParameterOutputs(behaviorContext);

		if (res != CK_OK)
		{
			CKParameterOut *parameterOutError = behavior->GetOutputParameter(EGBLBuildCommandParamOutputs::GetError);
			TGBLError::SetTGBLError(parameterOutError,CGBLCOError::EGBLCOErrorType::GBLCO_LOCAL,GBLFC_ERROR_BUILDCOMMAND_INVOKING_FAILED, GBLFC_ERROR_BUILDCOMMAND_INVOKING_FAILED_DESC);

			behavior->ActivateOutput (EGBLBuildCommandBehOutputs::Error);
			return CKBR_OK;
		}
	
        behavior->ActivateOutput (EGBLBuildCommandBehOutputs::HandleUntargetedCommand);
		return CKBR_OK;
	}
	else
	{
		//get next argument
		gblBuildCommandState = EGBLBuildCommandState::AwaitingParametersForUntargeted;
		behavior->SetLocalParameterValue (gblBuildCommandStateLocalPos, &gblBuildCommandState);

		GetNextArgument (nextArgument, targetBB, behaviorContext);
		return CKBR_OK;
	}
}
开发者ID:gbaumgart,项目名称:GBL_Backup,代码行数:75,代码来源:GBLBuildCommand.cpp

示例13: 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, &currentParameterPosition);
	CKParameter* nextArgument = CGBLCommandUtil::GetCommandArgument(*targetBB, currentParameterPosition);

	currentParameterPosition++;
	behavior->SetLocalParameterValue (currentParameterPositionLocalPos, &currentParameterPosition);

	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;
	}
}
开发者ID:gbaumgart,项目名称:GBL_Backup,代码行数:77,代码来源:GBLBuildCommand.cpp

示例14: 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);

//.........这里部分代码省略.........
开发者ID:gbaumgart,项目名称:GBL_Backup,代码行数:101,代码来源:GBLBuildCommand.cpp

示例15: DoBuildCommand

/*
*******************************************************************
* 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;
}
开发者ID:gbaumgart,项目名称:GBL_Backup,代码行数:88,代码来源:GBLBuildCommand.cpp


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