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


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

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


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

示例1: AddNodalLink

int AddNodalLink(const CKBehaviorContext& behcontext)
{
	CKBehavior* beh = behcontext.Behavior;
	CKContext* ctx = behcontext.Context;
	CKAttributeManager* attman = ctx->GetAttributeManager();
	beh->ActivateInput(0,FALSE);
	beh->ActivateOutput(0);

	CKGroup* group = (CKGroup*)beh->GetInputParameterObject(0);			
	CKParameterOut* param = group->GetAttributeParameter(attman->GetAttributeTypeByName(Network3dName));
	if(!param) throw "Given Group isn't a Network";
	N3DGraph* graph;
	param->GetValue(&graph);

	CK3dEntity* s = (CK3dEntity*)beh->GetInputParameterObject(1);
	CK3dEntity* e = (CK3dEntity*)beh->GetInputParameterObject(2);
	float b;
	beh->GetInputParameterValue(3,&b);
	graph->InsertEdge(s,e,b);
	beh->ActivateOutput(0);





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

示例2: PCIgnorePair

//************************************
// Method:    PCIgnorePair
// FullName:  PCIgnorePair
// Access:    public 
// Returns:   int
// Qualifier:
// Parameter: const CKBehaviorContext& behcontext
//************************************
int PCIgnorePair(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;


		CK3dEntity *targetA = (CK3dEntity *) beh->GetInputParameterObject(0);
		CK3dEntity *targetB = (CK3dEntity *) beh->GetInputParameterObject(1);
		int ignore = GetInputParameterValue<int>(beh,2);
		//////////////////////////////////////////////////////////////////////////
		// the world :  
		pWorld *world=GetPMan()->getWorld(target); 
		
		if(world){
			world->cIgnorePair(targetA,targetB,ignore);
		}
		
		beh->ActivateInput(0,FALSE);
		beh->ActivateOutput(0);
	}
	return 0;
}
开发者ID:gbaumgart,项目名称:vt,代码行数:43,代码来源:PCIgnorePair.cpp

示例3: JDestroy

//************************************
// Method:    JDestroy
// FullName:  JDestroy
// Access:    public 
// Returns:   int
// Qualifier:
// Parameter: const CKBehaviorContext& behcontext
//************************************
int JDestroy(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: 
	
		int jointType = GetInputParameterValue<int>(beh,1); 

		CK3dEntity *target = (CK3dEntity *) beh->GetTarget();
		CK3dEntity *targetB = (CK3dEntity *) beh->GetInputParameterObject(0);
		
		if (!pFactory::Instance()->jointCheckPreRequisites(target,targetB,jointType))
		{
			return CK_OK;
		}
	
		
		// the world :  
		pWorld *worldA=GetPMan()->getWorldByBody(target); 
		pWorld *worldB=GetPMan()->getWorldByBody(targetB); 
		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);

		if(bodyA || bodyB)
		{

			pJoint *joint = worldA->getJoint(target,targetB,(JType)jointType);
			if (joint)
			{
				worldA->deleteJoint(joint);
			}
		}

		beh->ActivateOutput(0);
	}
	return 0;
}
开发者ID:gbaumgart,项目名称:vt,代码行数:67,代码来源:PJDestroy.cpp

示例4: 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,代码来源:

示例5: PClothDetachFromShape

//************************************
// Method:    PClothDetachFromShape
// FullName:  PClothDetachFromShape
// Access:    public 
// Returns:   int
// Qualifier:
// Parameter: const CKBehaviorContext& behcontext
//************************************
int PClothDetachFromShape(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 ) return CKBR_OWNERERROR;

		
		//////////////////////////////////////////////////////////////////////////

		CK3dEntity*shapeReference  = (CK3dEntity *) beh->GetInputParameterObject(bbI_ShapeReference);
		if (!shapeReference)
		{
			beh->ActivateOutput(0);
			return CKBR_PARAMETERERROR;
		}

		pCloth *cloth  = GetPMan()->getCloth(target->GetID());
		if (!cloth)
		{
			beh->ActivateOutput(0);
			return CKBR_PARAMETERERROR;
		}

		
		NxShape *shape  = cloth->getWorld()->getShapeByEntityID(shapeReference->GetID());
		if(shape)
		{
			cloth->detachFromShape((CKBeObject*)shapeReference);
		}

		
		beh->ActivateOutput(0);


		beh->ActivateOutput(0);
	}
	return 0;
}
开发者ID:gbaumgart,项目名称:vt,代码行数:59,代码来源:PCDetachFromShape.cpp

示例6: 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 CGBLCHChatMoveHomogeneous::BehaviourFunction( const CKBehaviorContext& behaviorContext )
{
	CKBehavior *beh = behaviorContext.Behavior;
	CKContext *ctx = behaviorContext.Context;
	

	CK2dEntity *chatFrame = (CK2dEntity *)beh->GetInputParameterObject(0);

	if (chatFrame)
	{
		float left, top, right, bottom;

		beh->GetInputParameterValue(3, &left);
		beh->GetInputParameterValue(3, &top);
		beh->GetInputParameterValue(2, &right);
		right += left;
		beh->GetInputParameterValue(1, &bottom);
		bottom += top;

		VxRect rect(left, top, right, bottom);
		chatFrame->SetHomogeneousCoordinates ( 1 );
		int res = chatFrame->SetHomogeneousRect ( rect );
		if (res == 0)
		{
			beh->ActivateInput (0, 0);
			beh->ActivateOutput (0);
		}
		else
		{
			beh->ActivateInput (0, 0);
			beh->ActivateOutput (1);
		}
	}
	else
	{
		beh->ActivateInput (0, 0);
		beh->ActivateOutput (1);
	}
		
    return CKBR_OK;
}
开发者ID:gbaumgart,项目名称:GBL_Backup,代码行数:67,代码来源:GBLCHChatMoveHomogeneous.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: 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);
//.........这里部分代码省略.........
开发者ID:gbaumgart,项目名称:vt,代码行数:101,代码来源:PBPhysicalize.cpp

示例9: 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

示例10: 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.
*
* 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 CGBLCHPopulateAvailableRecipients::BehaviourFunction( const CKBehaviorContext& behaviorContext )
{
    enum 
    {
        GETACTIVEPLAYERSARRAY_COLUMN_VIRTOOLSUSERID,
        GETACTIVEPLAYERSARRAY_COLUMN_USERNAME,
        GETACTIVEPLAYERSARRAY_COLUMN_GBLTEAMID
    };
   
    enum 
    {
        AVAILABLERECIPIENTSARRAY_COLUMN_USERNAME,
        AVAILABLERECIPIENTSARRAY_COLUMN_VIRTOOLSUSERID,
        AVAILABLERECIPIENTSARRAY_COLUMN_GBLTEAMID
    };

    CKBehavior *beh = behaviorContext.Behavior;
    CGBLCOError localError(CGBLCOError::EGBLCOErrorType::GBLCO_OK);

    if (!beh)
    {
        assert(NULL);
        return CKBR_BEHAVIORERROR;
    }

    // Get profile controller
    CGBLProfileManager* profileManager = static_cast<CGBLProfileManager*>(beh->GetCKContext()->GetManagerByGuid(GBLProfileManagerGUID));
    if (!profileManager)
    {
        assert(NULL);
        return CKBR_BEHAVIORERROR;
    }

    // Get GBL Loader manager
    GBLLDManager* loaderManager = static_cast<GBLLDManager*>(beh->GetCKContext()->GetManagerByGuid(GBLLDManagerGUID));
    if (!profileManager)
    {
        assert(NULL);
        return CKBR_BEHAVIORERROR;
    }

    // Check we have been passed an array
    CKDataArray* availableRecipientsArray = static_cast<CKDataArray*>(beh->GetInputParameterObject(eParamInputAvailableRecipientsArray));
    if (!availableRecipientsArray)
    {
        return CKBR_BEHAVIORERROR;
    }

    // Clear array and set up structure
    availableRecipientsArray->Clear();
    while (availableRecipientsArray->GetColumnCount())
        availableRecipientsArray->RemoveColumn(0);

    availableRecipientsArray->InsertColumn(-1, CKARRAYTYPE_STRING, "Name");
    availableRecipientsArray->InsertColumn(-1, CKARRAYTYPE_INT, "VirtoolsUserID");
    availableRecipientsArray->InsertColumn(-1, CKARRAYTYPE_PARAMETER, "GBLTeamID", GUID_TEAM_ID);

    // Create a temporary array of active players to be filled in by the Profile Controller
    CKDataArray* tmpActivePlayersArray = (CKDataArray*)beh->GetCKContext()->CreateObject(CKCID_DATAARRAY,
                                    "CGBLCHPopulateAvailableRecipients temp array", 
                                    CK_OBJECTCREATION_DYNAMIC);
    if (!tmpActivePlayersArray)
    {
        assert(NULL);
        return CKBR_BEHAVIORERROR;
    }

    // Create temporary array for team names to be filled in by the Profile Controller
    CKDataArray* tmpTeamNameArray = (CKDataArray*)beh->GetCKContext()->CreateObject(CKCID_DATAARRAY,
                                    "CGBLCHPopulateAvailableRecipients temp array 2", 
                                    CK_OBJECTCREATION_DYNAMIC);
    if (!tmpTeamNameArray)
    {
        assert(NULL);
//.........这里部分代码省略.........
开发者ID:gbaumgart,项目名称:GBL_Backup,代码行数:101,代码来源:GBLCHPopulateAvailableRecipients.cpp

示例11: DOUserValueModified

int DOUserValueModified(const CKBehaviorContext& behcontext)
{
	CKBehavior* beh = behcontext.Behavior;
	CKMessageManager* mm = behcontext.MessageManager;
	CKContext* ctx = behcontext.Context;

	//////////////////////////////////////////////////////////////////////////
	//connection id : 
	int connectionID = vtTools::BehaviorTools::GetInputParameterValue<int>(beh,0);





	if (beh->IsInputActive(1))
	{
		beh->ActivateInput(1,FALSE);
		beh->ActivateOutput(1);
		return 0;
	}



	//////////////////////////////////////////////////////////////////////////
	//the object :
	CK3dEntity *obj= (CK3dEntity*)beh->GetInputParameterObject(1);
	if (!obj)
	{
		beh->ActivateOutput(3);
		return CKBR_ACTIVATENEXTFRAME;
	}

	//////////////////////////////////////////////////////////////////////////
	//network ok  ? 
	xNetInterface *cin  = GetNM()->GetClientNetInterface();
	if (!cin)
	{
		CKParameterOut *pout = beh->GetOutputParameter(2);
		XString errorMesg("distributed object creation failed,no network connection !");
		pout->SetStringValue(errorMesg.Str());
		beh->ActivateOutput(3);
		return CKBR_ACTIVATENEXTFRAME;
	}

	//use objects name, if not specified : 
	CKSTRING name= obj->GetName();
	
	IDistributedObjects*doInterface  = cin->getDistObjectInterface();
	IDistributedClasses*cInterface = cin->getDistributedClassInterface();
    
	XString className((CKSTRING) beh->GetLocalParameterReadDataPtr(0));
	XString parameterName((CKSTRING) beh->GetLocalParameterReadDataPtr(1));

	xDistributedClass *_class = cInterface->get(className.CStr());
	
	
	//////////////////////////////////////////////////////////////////////////
	//dist class ok  ? 
	if (_class==NULL)
	{
		beh->ActivateOutput(3);
		ctx->OutputToConsoleEx("Distributed Class doesn't exists : %s",className.CStr());
		return CKBR_ACTIVATENEXTFRAME;
	}
	const char * cNAme  = _class->getClassName().getString();

	int classType  = _class->getEnitityType();
	int bcount = beh->GetInputParameterCount();

	//////////////////////////////////////////////////////////////////////////
	//we come in by input 0 : 

	

	xDistributedObject *dobjDummy = NULL;
	xDistributedObject *dobj = doInterface->getByEntityID(obj->GetID());
	if (!dobj)
	{
		beh->ActivateOutput(3);
		return CKBR_ACTIVATENEXTFRAME;
	}

	if (dobj)
	{
		xDistributedProperty * prop  = dobj->getUserProperty(parameterName.CStr());
		if (prop)
		{
			if ( dobj->getGhostUpdateBits().testStrict(1 << prop->getBlockIndex()))
			{
				CKParameterManager *pam = static_cast<CKParameterManager *>(ctx->GetParameterManager());
				CKParameterOut *ciIn = beh->GetOutputParameter(1);
				CKParameterType pType  = ciIn->GetType();

				int sType = vtTools::ParameterTools::GetVirtoolsSuperType(ctx,pam->ParameterTypeToGuid(pType));	
				int userType = xDistTools::ValueTypeToSuperType(prop->getPropertyInfo()->mValueType);
				if ( userType ==sType )
				{
					beh->ActivateOutput(2);
					dobj->getGhostUpdateBits().set(1 << prop->getBlockIndex(),false);
					switch(xDistTools::ValueTypeToSuperType(prop->getPropertyInfo()->mValueType))
//.........这里部分代码省略.........
开发者ID:,项目名称:,代码行数:101,代码来源:

示例12: RenderCallback

/*
  *******************************************************************
  * Function: RenderCallback()
  *
  * Description : Is called from Virtools every frame. We draw the widget's visual elements in this function.
  *
  * Parameters :
  *    Passed in from Virtools. See Virtools SDK documentation:
  *    *renderContext, rw:
  *    renderObject, rw:
  *    *iArg, rw:
  *
  * Returns :  Return TRUE for success or FALSE for failure. The implications of returning FALSE are not documented in the Virtools
  * SDK documentation. Let's hope it doesn't format the user's hard disk.
  *
  *******************************************************************
*/
CKBOOL CGBLListBox::RenderCallback(CKRenderContext *renderContext, CKRenderObject* renderObject, void *iArg)
{
    const int cFixedStringBufferSize = 256;
	static VxRect fullUVRect(0.0f, 0.0f, 1.0f, 1.0f);

	CKContext* context = renderContext->GetCKContext();
	CK2dEntity* ent = CK2dEntity::Cast(renderObject);

	// Sanity check
	if (!ent) 
    {
		assert(NULL);
		return FALSE;
	}

	// Get a pointer to the building block behaviour
	CKBehavior* beh = (CKBehavior*)context->GetObject(reinterpret_cast<CK_ID>(iArg));
	if (!beh) 
		return FALSE;

	// Use clipping class to manage the clipping for us
	CGBLRenderClipper cRenderClipper(renderContext, ent);

	// Get client rectangle
	VxRect clientRect;
	ent->GetExtents(fullUVRect, clientRect);

    // Get the font from the base helper class
    VirtoolsSource::CKTextureFont* font = CGBLWidget::GetFont(context, beh);
    if (!font) 
    {
        // Don't output an error - we check for a font in the behavioural function
        return FALSE;
    }

    // Get material
    CKMaterial* material = (CKMaterial*)beh->GetInputParameterObject(eParamInputMaterial);
    if (!material) 
    {
        return FALSE;
    }

    // Are we using proportional scaling?
    CKBOOL isPropScaling = CGBLWidget::IsProportionalScaling(beh);

    // Get the font height
    float fontHeight = CGBLWidget::GetFontHeight(font, renderContext, isPropScaling);

    // Render down arrow
    CKBOOL isDownButtonPressed = FALSE;
    beh->GetLocalParameterValue(eLocalParamIsScrollDownButtonPressed, &isDownButtonPressed);

    VxRect buttonRect = GetRectDownArrow(clientRect, fontHeight);
    CGBLWidget::DrawMaterialRectangle(renderContext, material, buttonRect, 
        isDownButtonPressed ? CGBLWidgetsTheme::GetListBoxRegionDownArrowPressed() : CGBLWidgetsTheme::GetListBoxRegionDownArrowUnpressed(), 
        clientRect);
    
    // Render up arrow
    CKBOOL isUpButtonPressed = FALSE;
    beh->GetLocalParameterValue(eLocalParamIsScrollUpButtonPressed, &isUpButtonPressed);

    buttonRect = GetRectUpArrow(clientRect, fontHeight);
    CGBLWidget::DrawMaterialRectangle(renderContext, material, buttonRect, 
        isUpButtonPressed ? CGBLWidgetsTheme::GetListBoxRegionUpArrowPressed() : CGBLWidgetsTheme::GetListBoxRegionUpArrowUnpressed(), 
        clientRect);

    // Render headings if present

    // Get columns array
    CKDataArray* columnsArray = static_cast<CKDataArray*>(beh->GetInputParameterObject(eParamInputColumnsArray));
    int numColumns = columnsArray ? columnsArray->GetRowCount() : 1;

    // If we have at least one row in the columns array, we are drawing headings
    if (columnsArray && (columnsArray->GetRowCount() >= 1)) 
    {
        VxRect headingsRect = GetRectHeadings(clientRect, fontHeight, columnsArray);

        VxRect headingRect = headingsRect;
        for (int column = 0;column < numColumns;column++) 
        {
            headingRect.right = headingRect.left + GetColumnWidth(beh, columnsArray, column) * headingsRect.GetWidth() / 100.0f;

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

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

示例14: JD6SetParameters

//************************************
// Method:    JD6SetParameters
// FullName:  JD6SetParameters
// Access:    public 
// Returns:   int
// Qualifier:
// Parameter: const CKBehaviorContext& behcontext
//************************************
int JD6SetParameters(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(0);
		
		if (!pFactory::Instance()->jointCheckPreRequisites(target,targetB,JT_D6))
		{

			return CK_OK;
		}
		
		
		
		// the world :  
		pWorld *worldA=GetPMan()->getWorldByBody(target); 
		pWorld *worldB=GetPMan()->getWorldByBody(targetB); 
		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);

		if(bodyA || bodyB)
		{

			pJointD6 *joint =static_cast<pJointD6*>(worldA->getJoint(target,targetB,JT_D6));
			VxVector linVel = GetInputParameterValue<VxVector>(beh,1); 
			VxVector aVel = GetInputParameterValue<VxVector>(beh,2); 
			VxVector pos = GetInputParameterValue<VxVector>(beh,3); 
			VxQuaternion rot = GetInputParameterValue<VxQuaternion>(beh,4); 

			float ratio = GetInputParameterValue<float>(beh,5); 
			
			
			joint->setDriveLinearVelocity(linVel);
			joint->setDriveAngularVelocity(aVel);
			joint->setRatio(ratio);
			
			joint->setDrivePosition(pos);
			joint->setDriveRotation(rot);



		}
	
		beh->ActivateOutput(0);
	}
	return 0;
}
开发者ID:gbaumgart,项目名称:vt,代码行数:80,代码来源:JD6SetParameters.cpp

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

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


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