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


C++ CKBehavior类代码示例

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


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

示例1: LogEntryCB

CKERROR LogEntryCB(const CKBehaviorContext& behcontext)
{
	CKBehavior* beh = behcontext.Behavior;
	CKBeObject *beo = (CKBeObject *)beh->GetTarget();
	
	if (behcontext.CallbackMessage==CKM_BEHAVIOREDITED) 
	{
	/*	CKParameterIn* pin = beh->GetInputParameter(0);
		if (!pin) {
			CKBehavior* pbeh = beh;
			XString name;
			while ((pbeh=pbeh->GetParent())) {
				name << pbeh->GetName() << "->";
			}
			name << beh->GetName();

			XString str;
			str << '[' << name << "] : failed to retrieve first input parameter";
			behcontext.Context->OutputToConsole(str.Str(),TRUE);
			return CKBR_PARAMETERERROR;
		}
		
		if (pin->GetGUID()!=CKPGUID_MESSAGE) {
			pin->SetGUID(CKPGUID_MESSAGE,FALSE);

			CKBehavior* pbeh = beh;
			XString name;
			while ((pbeh=pbeh->GetParent())) {
				name << pbeh->GetName() << "->";
			}
			name << beh->GetName();

			XString str;
			str << '[' << name << "] : first input parameter type must be \"Message\"!";
			behcontext.Context->OutputToConsole(str.Str(),TRUE);
		}

		pin = beh->GetInputParameter(1);
		if (!pin) {
			CKBehavior* pbeh = beh;
			XString name;
			while ((pbeh=pbeh->GetParent())) {
				name << pbeh->GetName() << "->";
			}
			name << beh->GetName();

			XString str;
			str << '[' << name << "] : failed to retrieve second input parameter";
			behcontext.Context->OutputToConsole(str.Str(),TRUE);
			return CKBR_PARAMETERERROR;
		}
	
		if (!behcontext.ParameterManager->IsDerivedFrom(pin->GetGUID(),CKPGUID_OBJECT)) {
			pin->SetGUID(CKPGUID_BEOBJECT,FALSE);

			CKBehavior* pbeh = beh;
			XString name;
			while ((pbeh=pbeh->GetParent())) {
				name << pbeh->GetName() << "->";
			}
			name << beh->GetName();

			XString str;
			str << '[' << name << "] : second input parameter type must derived from \"BeObject\"!";
			behcontext.Context->OutputToConsole(str.Str(),TRUE);
		}*/
	}

	return CKBR_OK;
}
开发者ID:gbaumgart,项目名称:vt,代码行数:70,代码来源:LogOut.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: BehaviourFunction

int GBLCOBGWrapper::BehaviourFunction( const CKBehaviorContext& behContext )
{
	CKBehavior	*behaviour = behContext.Behavior;
	CKContext	*context = behContext.Context;
	int			iPin, nbPin;

	CKBehavior* script = (CKBehavior*)behaviour->GetLocalParameterObject(EGBLCOBGWRAPPERPARAM_PARAMETER_SCRIPT);

	if (script == NULL)
		return CKBR_GENERICERROR;

	// Activate the right inputs
	nbPin = behaviour->GetInputCount();
	for (iPin = 0; iPin < nbPin; iPin++)
		{
		if (behaviour->IsInputActive(iPin))
			{
			script->ActivateInput(iPin, TRUE);
			behaviour->ActivateInput(iPin, FALSE);
			}
		}
	
	// Deactivate all the outputs
	nbPin = script->GetOutputCount();
	for (iPin = 0; iPin < nbPin; iPin++)
		{
		behaviour->ActivateOutput(iPin, FALSE);
		}

	// Parameter In: Set Source
	int nbPinBB = behaviour->GetInputParameterCount();
	int nbPinBG = script->GetInputParameterCount();

	if (nbPinBB != nbPinBG)
		return CKBR_GENERICERROR;

	for (iPin = 0; iPin < nbPinBB; iPin++)
	{
		CKParameterIn *pBin = behaviour->GetInputParameter(iPin);
		CKParameter* pSource = pBin->GetDirectSource();

		CKParameterIn *pSin = script->GetInputParameter(iPin);
		pSin->SetDirectSource(pSource);
	}

	// Execute the contained script
	CKERROR result = script->Execute(behContext.DeltaTime);

	// The script loop on itself too much times
	if (result == CKBR_INFINITELOOP) 
		{
		context->OutputToConsoleExBeep("Execute Script : Script %s Executed too much times",script->GetName());
		script->Activate(FALSE,FALSE);
		return CKBR_OK;
		}

	// Activate the right outputs 
	nbPin = script->GetOutputCount();
	for (iPin = 0; iPin < nbPin; iPin++)
		{
		if (script->IsOutputActive(iPin))
			{
			behaviour->ActivateOutput(iPin);
			script->ActivateOutput(iPin, FALSE);
			}
		}

	// Update Parameters Out
	nbPin = behaviour->GetOutputParameterCount();
	for (iPin = 0; iPin < nbPin; iPin++)  
		{
		CKParameterOut *pBout = behaviour->GetOutputParameter(iPin);
		CKParameterOut *pSout = script->GetOutputParameter(iPin);
		pBout->CopyValue(pSout, TRUE);
		}

	
	// Test if there are any active sub-behaviors, restart the next frame if any
	BOOL bActivateNextFrame = FALSE;
	ActivateNextFrameSubBB(script,bActivateNextFrame);
	if (bActivateNextFrame)
		return CKBR_ACTIVATENEXTFRAME;

	// return the execute value
	return result;	
}
开发者ID:gbaumgart,项目名称:GBL_Backup,代码行数:86,代码来源:GBLCOBGWrapper.cpp

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

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

示例6: RetrieveCI

/*
 *******************************************************************
 * 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 RetrieveCI(const CKBehaviorContext& behcontext)
{
	/************************************************************************/
	/*  collecting data :													*/
	/*  																	*/
	CKBehavior* beh = behcontext.Behavior;
  	CKContext* ctx = behcontext.Context;
	CGBLCIConfigurationController* cman=(CGBLCIConfigurationController*)ctx->GetManagerByGuid(CONFIGURATION_MAN_GUID);
	IGBLCIManageInterface *cisFac   =  cman->GetCISFactoryInterface();
	IGBLCIAccessInterface * accessInterface  = cman->GetCISAccessInterface(); 

	

	BOOL getAsString,outputAttriubtes = false;
	beh->GetLocalParameterValue(BEH_SETTINGS_GET_AS_STRING,&getAsString);
	beh->GetLocalParameterValue(BEH_SETTINGS_GET_CUSTOM_ATTRIBUTES,&outputAttriubtes);

	using namespace GBLCommon::BehaviorTools;
	using namespace GBLCommon::ParameterTools;
	using namespace Customisation::typedefs;

	int idCI = GetInputParameterValue<int>(beh,BEH_PAR_INDEX_CI);

	CGBLCI *currentCI = NULL;

	CGBLSMStorageManager *storageManager = static_cast<CGBLSMStorageManager *>(ctx->GetManagerByGuid(GBLSMStorageManagerGUID));
	IGBLSMConfigurationAccess* smCIS = storageManager->GetConfigurationInterface();

	
	currentCI = new CGBLCI("temp",CKPGUID_INT);
	
	CGBLCOError returnValue  = 	accessInterface->GetCI(currentCI,idCI);

	//get error parameter
	CKParameterOut *parameterOutError = beh->GetOutputParameter(BEH_PIN_OUT_INDEX_ERROR);
	// check results and output error
	if (returnValue == CGBLCOError::EGBLCOErrorType::GBLCO_OK)
	{
		//////////////////////////////////////////////////////////////////////////
		// output values :
		CKParameterOut *pout = beh->GetOutputParameter(1);
		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
			{
				pout->SetType(currentCI->realValue->GetType());
				return CKBR_PARAMETERERROR;
			}
		}



		//////////////////////////////////////////////////////////////////////////
		// output custom attributes :
		if(outputAttriubtes)
		{
			//output unique name : 
			CKParameterOut *poutName = beh->GetOutputParameter(BEH_OUT_INDEX_UNAME);
			poutName->SetStringValue(currentCI->name.Str());		
			//output description : 
			CKParameterOut *poutDescription = beh->GetOutputParameter(BEH_OUT_INDEX_DESCRIPTION);
			poutDescription->SetStringValue(currentCI->description.Str());
//.........这里部分代码省略.........
开发者ID:gbaumgart,项目名称:GBL_Backup,代码行数:101,代码来源:GBLCIRetrieveCI.cpp

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

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

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

示例10: CISIteratorBB

/*
 *******************************************************************
 * Function: int CISIteratorBB( 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 CISIteratorBB(const CKBehaviorContext& behcontext)
{
	
	/************************************************************************/
	/* collecting data :													*/
	/*  																	*/
	
	CKBehavior* beh = behcontext.Behavior;
  	CKContext* ctx = behcontext.Context;
	CGBLCIConfigurationController* cman=(CGBLCIConfigurationController*)ctx->GetManagerByGuid(CONFIGURATION_MAN_GUID);
	

    	
	/*get the last index */
	int index = 0;
	beh->GetLocalParameterValue(BEH_LOCAL_PAR_INDEX_INDEX, &index);

	BOOL getFromDB = false;
	beh->GetLocalParameterValue(BEH_LOCAL_PAR_INDEX_DB_MODE,&getFromDB);
    
	using namespace GBLCommon::BehaviorTools;
	using namespace GBLCommon::ParameterTools;

	using namespace Customisation::typedefs;


	/************************************************************************/
	/*   behavior trigger event processing  :							    */
	/*																		*/
	/*																		*/
    


	/* Reset/On : sets the index to zero and save it  */
	if( beh->IsInputActive(0) )
	{
		beh->ActivateInput(0,FALSE);
		

		if (getFromDB)
		{
			CKDataArray * resultArray = NULL; 
			beh->GetLocalParameterValue(BEH_LOCAL_PAR_INDEX_CIID_LIST,&resultArray);
			if (resultArray)
			{
				resultArray->Clear();
				while ( resultArray->GetColumnCount() )
					resultArray->RemoveColumn(0);
			}
			else
			{
				resultArray  = static_cast<CKDataArray*>(ctx->CreateObject( CKCID_DATAARRAY, "IGBLSMConfigurationAccess::CIS_IDLIST", CK_OBJECTCREATION_DYNAMIC ));
			}
			ctx->GetCurrentLevel()->AddObject( resultArray );
			
			////////////////////////////////////////////////////////////////////////// retrieve list of CI ID's  :
			CGBLSMStorageManager *storageManager = static_cast<CGBLSMStorageManager *>(ctx->GetManagerByGuid(GBLSMStorageManagerGUID));
			IGBLSMConfigurationAccess* smCIS = storageManager->GetConfigurationInterface();

			int idCIS = GetInputParameterValue<int>(beh,BEH_IN_PAR_CIS_ID);
			smCIS->RetrieveCIList(resultArray,CGBLCISID(idCIS));
			
			beh->SetLocalParameterValue(BEH_LOCAL_PAR_INDEX_CIID_LIST,&resultArray,sizeof(CKDataArray*));
			
			int cis_size = resultArray->GetRowCount();
			beh->SetLocalParameterValue(BEH_LOCAL_PAR_INDEX_CIS_SIZE,&cis_size);
		}else
		{
			Customisation::typedefs::CIS* currentCIS = cman->GetCIS();
			if(!currentCIS)
				Logger::ShowDebugMessage(ctx,Logger::ELOGERROR,"CISIterator : couldn't find CIS");	

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

示例11: PVWSet

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


		body = GetPMan()->getBody(target);
		if (!body)	bbErrorME("No Reference Object specified");


		pWheel *wheel = body->getWheel(target);
		if (!wheel)bbErrorME("pWheel object doesnt exist!");

		pWheel2 *wheel2  = wheel->castWheel2();
		if (!wheel2)bbErrorME("Couldnt cast a pWheel2 object");



		BB_DECLARE_PIMAP;


		/************************************************************************/
		/* engel 
		kuehne un partner 
		*/
		/************************************************************************/

		/************************************************************************/
		/* retrieve settings state  */
		/************************************************************************/
		BBSParameter(bbI_XML);
		BBSParameter(bbI_AxleSpeed);
		BBSParameter(bbI_Steer);
		BBSParameter(bbI_MotorTorque);
		BBSParameter(bbI_BrakeTorque);
		BBSParameter(bbI_SuspensionSpring);
		BBSParameter(bbI_SuspensionTravel);
		BBSParameter(bbI_Radius);

		BBSParameter(bbI_WFlags);
		BBSParameter(bbI_WSFlags);

		BBSParameter(bbI_LatFunc);
		BBSParameter(bbI_LongFunc);


		/************************************************************************/
		/* retrieve values                                                                     */
		/************************************************************************/

		int xmlValue = GetInputParameterValue<int>(beh,BB_IP_INDEX(bbI_XML));
		float axleVel = GetInputParameterValue<float>(beh,BB_IP_INDEX(bbI_AxleSpeed));
		float steer = GetInputParameterValue<float>(beh,BB_IP_INDEX(bbI_Steer));
		float mTorque = GetInputParameterValue<float>(beh,BB_IP_INDEX(bbI_MotorTorque));
		float bTorque = GetInputParameterValue<float>(beh,BB_IP_INDEX(bbI_BrakeTorque));
		float suspensionTravel = GetInputParameterValue<float>(beh,BB_IP_INDEX(bbI_SuspensionTravel));

		int wFlags = GetInputParameterValue<int>(beh,BB_IP_INDEX(bbI_WFlags));
		int wSFlags = GetInputParameterValue<int>(beh,BB_IP_INDEX(bbI_WSFlags));

		pSpring sSpring;
		if (sbbI_SuspensionSpring)
		{
			CKParameterIn *par = beh->GetInputParameter(bbI_SuspensionSpring);
			if (par)
			{
				CKParameter *rPar = par->GetRealSource();
				if (rPar)
				{
					sSpring  = pFactory::Instance()->createSpringFromParameter(rPar);
					NxSpringDesc xsp;
					xsp.damper = sSpring.damper;
					xsp.spring = sSpring.spring;
					xsp.targetValue = sSpring.targetValue;
//.........这里部分代码省略.........
开发者ID:gbaumgart,项目名称:vt,代码行数:101,代码来源:PVWSet.cpp

示例12: PyTuple_Size

//************************************
// Method:    vt_GetInVal
// FullName:  vt_GetInVal
// Access:    public static 
// Returns:   PyObject *
// Qualifier:
// Parameter: PyObject * self
// Parameter: PyObject * args
//************************************
static PyObject *vt_GetInVal( PyObject * self, PyObject * args )
{

	int size = PyTuple_Size(args);
	int bid, index;
	PyArg_ParseTuple(args, "ii", &bid, &index); 

	CK_ID cid = bid; 
	CKBehavior *beh = static_cast<CKBehavior*>(pym->m_Context->GetObject(cid)); 
	if (size!=2)
	{
		pym->m_Context->OutputToConsole("PyError : This function needs 2 arguments : \n\t bid,index");
		Py_RETURN_NONE;
	}

	using namespace vtTools;
	using namespace vtTools::Enums;

	CKParameterManager *pam = static_cast<CKParameterManager *>(pym->m_Context->GetParameterManager());

	if (index < beh->GetInputParameterCount() )
	{
		CKParameterIn *ciIn = beh->GetInputParameter(index);

		CKParameterType pType  = ciIn->GetType();
		vtTools::Enums::SuperType sType = ParameterTools::GetVirtoolsSuperType(pym->m_Context,pam->ParameterTypeToGuid(pType));	
	
		PyObject *val;

		switch (sType)
		{
		case vtSTRING:
			{
				val = PyString_FromString( vtTools::BehaviorTools::GetInputParameterValue<CKSTRING>(beh,index ));
				break;
			}
		case vtFLOAT:
			{
				val = PyFloat_FromDouble(static_cast<float>(vtTools::BehaviorTools::GetInputParameterValue<float>(beh,index )));
				break;
			}
		case vtINTEGER:
			{
				val = PyInt_FromLong( static_cast<long>(vtTools::BehaviorTools::GetInputParameterValue<int>(beh,index )));
				break;
			}

		default :
			XString err("wrong input parameter type: ");
			err << ciIn->GetName() << "Only Types derivated from Interger,Float or String are acceptable";
			pym->m_Context->OutputToConsole(err.Str(),FALSE );
			Py_RETURN_NONE;
		}

		if (!val)
		{
			Py_DECREF(val);	  
		}
		return val;
	}
	Py_RETURN_NONE;
}
开发者ID:,项目名称:,代码行数:71,代码来源:

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

示例14: LogEntry

int LogEntry(const CKBehaviorContext& behcontext)
{

	CKBehavior* beh = behcontext.Behavior;
	CKMessageManager* mm = behcontext.MessageManager;
	CKContext* ctx = behcontext.Context;
	CKParameterManager *pam = static_cast<CKParameterManager *>(ctx->GetParameterManager());


	XString File((CKSTRING) beh->GetInputParameterReadDataPtr(0));
	

	if (GetPMan()->GetLastLogEntry().Length())
	{
			CKParameterOut *pout  = beh->GetOutputParameter(0);
			pout->SetStringValue(GetPMan()->GetLastLogEntry().Str());
			GetPMan()->SetLastLogEntry("");


			vtTools::BehaviorTools::SetOutputParameterValue<int>(beh,1,xLogger::GetInstance()->lastTyp);
			int descriptionS = xLogger::GetInstance()->getItemDescriptions().size();

			int compo  = xLogger::GetInstance()->lastComponent;
			
			XString compoStr;
			/*if(compo<= xLogger::GetInstance()->getItemDescriptions().size() )
				compoStr.Format("%s",xLogger::GetInstance()->getItemDescriptions().at(compo));*/



			beh->ActivateOutput(0,TRUE);
			switch (xLogger::GetInstance()->lastTyp)
			{

			case ELOGERROR:
				beh->ActivateOutput(1,TRUE);

				case ELOGWARNING:
					beh->ActivateOutput(2,TRUE);
				
				case ELOGINFO:
					beh->ActivateOutput(3,TRUE);
				
				case ELOGTRACE:
					beh->ActivateOutput(4,TRUE);

				case ELOGDEBUG:
					beh->ActivateOutput(5,TRUE);
				default:
					beh->ActivateOutput(0,TRUE);

			}

		
			
	}


	//	Steering	
	if( beh->IsInputActive(1) )
	{
		beh->ActivateOutput(0,FALSE);

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

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


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