Exemple #1
0
//************************************
// Method:    PClothDestroy
// FullName:  PClothDestroy
// Access:    public 
// Returns:   int
// Qualifier:
// Parameter: const CKBehaviorContext& behcontext
//************************************
int PClothDestroy(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;
		//////////////////////////////////////////////////////////////////////////
		pCloth *cloth  = GetPMan()->getCloth(target->GetID());
		if (!cloth)
		{
			beh->ActivateOutput(0);
			return CKBR_PARAMETERERROR;
		}

		pWorld *world = cloth->getWorld();
		world->destroyCloth(target->GetID());

		beh->ActivateOutput(0);
	}
	return 0;
}
Exemple #2
0
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;
}
/*
 *******************************************************************
 * 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;
}
/*
 *******************************************************************
 * 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 CGBLLAESetLoadState::BehaviourFunction( const CKBehaviorContext& behaviorContext )
{
	CKBehavior* beh = behaviorContext.Behavior;
  	CKContext* ctx = behaviorContext.Context;

	CGBLLAEManager *laeManager = (CGBLLAEManager *)ctx->GetManagerByGuid(GBLLAEManagerGUID);

	if (laeManager)
	{
		int state = 0;
		beh->GetInputParameterValue(0, &state);
		laeManager->SetLoadState(state);
		
		beh->ActivateInput(0, FALSE);
		beh->ActivateOutput(0);
	}
	else
	{
		beh->ActivateInput(0, FALSE);
		CKParameterOut *parameterOutError = beh->GetOutputParameter(0);
		TGBLError::SetTGBLError(parameterOutError,CGBLCOError::EGBLCOErrorType::GBLCO_LOCAL,GBLLAE_ERROR_CANTSETLAEIDENTITY,GBLLAE_ERROR_CANTSETLAEIDENTITY_DESC);
		beh->ActivateOutput(1);
	}

    return CKBR_OK;
}
Exemple #5
0
//************************************
// 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;
}
//************************************
// Method:    RegisterAttributeType
// FullName:  RegisterAttributeType
// Access:    public
// Returns:   int
// Qualifier:
// Parameter: const CKBehaviorContext& behcontext
//************************************
int RegisterAttributeType(const CKBehaviorContext& behcontext)
{
	CKBehavior* beh = behcontext.Behavior;
  	CKContext* ctx = behcontext.Context;
	PhysicManager *pm = GetPMan();

	CKAttributeManager* attman = ctx->GetAttributeManager();
	CKParameterManager *pMan  = ctx->GetParameterManager();

	using namespace vtTools::BehaviorTools;

	if( beh->IsInputActive(0) )
	{
		beh->ActivateInput(0,FALSE);

		
		CKSTRING name = GetInputParameterValue<CKSTRING>(beh,bbI_Name);
		CKSTRING category = GetInputParameterValue<CKSTRING>(beh,bbI_Category);
		CKSTRING defValue = GetInputParameterValue<CKSTRING>(beh,bbI_DefValue);
		int pType = GetInputParameterValue<int>(beh,bbI_PType);
		CK_CLASSID classId = GetInputParameterValue<CK_CLASSID>(beh,bbI_Class);

		int attFlags = 0 ;
		int user = GetInputParameterValue<int>(beh,bbI_User);
		int save = GetInputParameterValue<int>(beh,bbI_Save);

		if(user)
			attFlags|=CK_ATTRIBUT_USER;

		if(save)
			attFlags|=CK_ATTRIBUT_TOSAVE;

		attFlags|=CK_ATTRIBUT_CAN_DELETE;

		CKAttributeType aIType = attman->GetAttributeTypeByName(name);
		if (aIType!=-1)
		{
			beh->ActivateOutput(1);
		}

		int att =  attman->RegisterNewAttributeType(name,pMan->ParameterTypeToGuid(pType),classId,(CK_ATTRIBUT_FLAGS)attFlags);

		if (strlen(category))
		{
			attman->AddCategory(category);
			attman->SetAttributeCategory(att,category);
		}
		if (strlen(defValue))
		{
			attman->SetAttributeDefaultValue(att,defValue);
		}

	}
	pm->populateAttributeFunctions();
	pm->_RegisterAttributeCallbacks();

	beh->ActivateOutput(0);
	return 0;
}
Exemple #7
0
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;
}
Exemple #8
0
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;
}
Exemple #9
0
/*
 *******************************************************************
 * Function: int GetCIS( 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 GetCIS(const CKBehaviorContext& behcontext)
{

	////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
	//						Retrieving min data : 
	
	CKBehavior* beh = behcontext.Behavior;
  	CKContext* ctx = behcontext.Context;

	CGBLCIConfigurationController* cman=static_cast<CGBLCIConfigurationController*>(ctx->GetManagerByGuid(CONFIGURATION_MAN_GUID));
	IGBLCIAccessInterface *accessInterface   =  cman->GetCISAccessInterface();

	CGBLSMStorageManager *storageManager = static_cast<CGBLSMStorageManager *>(ctx->GetManagerByGuid(GBLSMStorageManagerGUID));
	IGBLSMConfigurationAccess* smCIS = storageManager->GetConfigurationInterface();
		
	CKParameterOut *parameterOutError = beh->GetOutputParameter(BEH_OUT_INDEX_ERROR);

	int idCIS = GBLCommon::BehaviorTools::GetInputParameterValue<int>(beh,BEH_IN_INDEX_CIS);
	
	CGBLCOError  returnValue = accessInterface->GetCIS(idCIS);


	// check results and output error
	if (returnValue == CGBLCOError::EGBLCOErrorType::GBLCO_OK)
	{
		TGBLError::SetTGBLError(parameterOutError,returnValue.GetType(),returnValue.GetCode(),(CKSTRING)returnValue.GetDescription());
		beh->ActivateOutput(BEH_PIN_OUT_INDEX_SUCCESS, true);
	}
	else
	{

		CGBLCOError::EGBLCOErrorType tType = CGBLCOError::EGBLCOErrorType::GBLCO_OK;
		switch((CGBLCOError::EGBLCOErrorType)returnValue)
		{
		case 0:
			tType = CGBLCOError::EGBLCOErrorType::GBLCO_OK;
			break;
		case 1:
			tType = CGBLCOError::EGBLCOErrorType::GBLCO_FATAL;
			break;
		case 2:
			tType = CGBLCOError::EGBLCOErrorType::GBLCO_LOCAL;
			break;
		case 3:
			tType = CGBLCOError::EGBLCOErrorType::GBLCO_LOCAL;
			break;
		}
		TGBLError::SetTGBLError(parameterOutError,tType,returnValue.GetCode(),(CKSTRING)returnValue.GetDescription());
		beh->ActivateOutput(BEH_PIN_OUT_INDEX_ERROR, true);
	}
	return CKBR_OK;

}
Exemple #10
0
int DirToArray(const CKBehaviorContext& behcontext)
{
	CKBehavior* beh = behcontext.Behavior;
  	CKContext* ctx = behcontext.Context;

	XString filename((CKSTRING) beh->GetInputParameterReadDataPtr(0));
	XString Mask((CKSTRING) beh->GetInputParameterReadDataPtr(1));
		
	int rec;

	beh->GetInputParameterValue(2,&rec);

	

	if( beh->IsInputActive(0) ){
		beh->ActivateInput(0,FALSE);

		flist.erase(flist.begin(),flist.end());

		CKDirectoryParser MyParser(filename.Str(),Mask.Str(),rec);
		char* str = NULL;
		while(str = MyParser.GetNextFile())
			flist.push_back(XString(str));

		counter = 0;
		beh->ActivateInput(1,TRUE);

		
	}


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

		if ( counter < flist.size() ){
			XString entry = flist.at(counter);
			CKParameterOut * pout = beh->GetOutputParameter(0);
			pout->SetStringValue(entry.Str() );
				
			counter++;
			beh->SetOutputParameterValue(1,&counter);
			beh->ActivateOutput(1);

		}else{

			beh->SetOutputParameterValue(1,&counter);
			counter = 0 ; 
			beh->ActivateOutput(0);
		}
	}
	return 0;
}
Exemple #11
0
//************************************
// 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;
}
Exemple #12
0
//************************************
// Method:    PBSetTriggerMask
// FullName:  PBSetTriggerMask
// Access:    public 
// Returns:   int
// Qualifier:
// Parameter: const CKBehaviorContext& behcontext
//************************************
int PBSetTriggerMask(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;


		//////////////////////////////////////////////////////////////////////////
		// the world :  
		
		pWorld *world  = GetPMan()->getWorldByShapeReference(target);
		if (!world)
		{
			beh->ActivateOutput(0);
			return 0;
		}

		if (world)
		{
			NxShape *shape  = world->getShapeByEntityID(target->GetID());
			if (shape)
			{

				int onEnter = GetInputParameterValue<int>(beh,bbI_OnEnter);
				int onStay = GetInputParameterValue<int>(beh,bbI_OnStay);
				int onLeave = GetInputParameterValue<int>(beh,bbI_OnLeave);

				shape->setFlag(NX_TRIGGER_ON_ENTER,onEnter);
				shape->setFlag(NX_TRIGGER_ON_STAY,onStay);
				shape->setFlag(NX_TRIGGER_ON_LEAVE,onLeave);

			}
		}
			
		beh->ActivateOutput(0);
	}
	return 0;
}
Exemple #13
0
int FTPLogin(const CKBehaviorContext& behcontext)
{
	CKBehavior* beh = behcontext.Behavior;
  	CKContext* ctx = behcontext.Context;

		if( beh->IsInputActive(0)){
			beh->ActivateInput(0,FALSE);
	
			HWND win = (HWND)ctx->GetMainWindow();
			FtpInit(win);
			//HFILE hLogFile =  _lcreat (LOG_FILE, 0);
			//FtpLogTo (hLogFile);
			
			
	
			FtpSetDefaultTimeOut (30);
			FtpSetPassiveMode(TRUE);
			FtpSetAsynchronousMode();
	
			int Port;
			beh->GetInputParameterValue(3,&Port);
			


			XString Host((CKSTRING) beh->GetInputParameterReadDataPtr(0));
			XString User((CKSTRING) beh->GetInputParameterReadDataPtr(1));
			XString Pw((CKSTRING) beh->GetInputParameterReadDataPtr(2));
			
			int Login = FtpLogin(Host.Str(),User.Str(),Pw.Str(),win,0);
			beh->SetOutputParameterValue(0,&Login);
			

			if (Login == 0)beh->ActivateOutput(0);
				else{
					beh->ActivateOutput(2);
					return CKBR_OK;
				}
				return CKBR_ACTIVATENEXTFRAME;
			}

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

			FtpCloseConnection();
			FtpRelease ();
			beh->ActivateOutput(1);
			return CKBR_OK;
		}
	return CKBR_ACTIVATENEXTFRAME;
}
Exemple #14
0
int GetFile(const CKBehaviorContext& behcontext)
{
	CKBehavior* beh = behcontext.Behavior;
  	CKContext* ctx = behcontext.Context;

	int Length=0;

	// Start by In0
	if( beh->IsInputActive(0)){
		beh->ActivateInput(0,FALSE);

		
		XString RemoteFile((CKSTRING) beh->GetInputParameterReadDataPtr(0));
		XString LocalFile((CKSTRING) beh->GetInputParameterReadDataPtr(1));
		
		char *Type = "Type_B";
		int Get = FtpRecvFile (	RemoteFile.Str(),LocalFile.Str(),*Type, FALSE,NULL,NULL);
		Length = FtpBytesToBeTransferred();

		if ( Get !=0 ){
			beh->SetOutputParameterValue(3,&Get);
			beh->ActivateOutput(2);
			return CKBR_OK;
		}

		beh->SetOutputParameterValue(0,&Length);
		beh->ActivateOutput(0);
		return CKBR_ACTIVATENEXTFRAME;
	}


	beh->GetOutputParameterValue(0,&Length);

	int down=FtpBytesTransferred(); 
	beh->SetOutputParameterValue(1,&down);
	float progress=(float)(down*100.0f/Length); // percentage of file downloaded
	progress /=100.0f;
	beh->SetOutputParameterValue(2,&progress);


	
	if ( down == Length){

			beh->ActivateOutput(1);
			return CKBR_OK;
	}

	return CKBR_ACTIVATENEXTFRAME;
	
}
Exemple #15
0
int GBLCOSetID::BehaviourFunction( const CKBehaviorContext& behContext )
{
    CKBehavior	*behaviour = behContext.Behavior;
    CKContext	*context = behContext.Context;

    behaviour->ActivateInput(ECGBLCOSetLAIDBehInputs::InSetIdentity, FALSE);

    CKAttributeManager*attributeManager = context->GetAttributeManager();
    if (attributeManager != NULL)
    {
        CKLevel *level = context->GetCurrentLevel();
        if ( level != NULL )
        {
            int attributeType = attributeManager->GetAttributeTypeByName("GBLCOLAID");
            if (attributeType == -1)
                attributeType = attributeManager->RegisterNewAttributeType("GBLCOLAID", GUID_TGBLLAID, CKCID_BEOBJECT);
            else if ( level->HasAttribute(attributeType) )
                level->RemoveAttribute(attributeType);

            attributeManager->SetAttributeCategory(attributeType,"GBL");
            level->SetAttribute(attributeType);

            CKParameter*attribute = level->GetAttributeParameter(attributeType);
            if ( attribute != NULL )
            {
                CKParameterIn*pin = behaviour->GetInputParameter(ECGBLCOSetLAIDBehInputs::InSetIdentity);
                CKParameter*laid = pin->GetDirectSource();
                if ( laid != NULL )
                {
                    CKERROR err = attribute->CopyValue(laid);
                    if ( err == CK_OK )
                    {
                        behaviour->ActivateOutput(ECGBLCOSetLAIDBehOutputs::OutIdentitySet, TRUE);
                        behaviour->ActivateOutput(ECGBLCOSetLAIDBehOutputs::OutError, FALSE);
                        return CKBR_OK;
                    }
                }
            }
        }
    }

    CKParameterOut *parameterOutError = behaviour->GetOutputParameter(ECGBLCOSetLAIDParamOutputs::GetError);
    TGBLError::SetTGBLError(parameterOutError,CGBLCOError::EGBLCOErrorType::GBLCO_LOCAL,GBLCO_ERROR_SETID_ATTRIBUTE,GBLCO_ERROR_SETID_ATTRIBUTE_DESC);

    behaviour->ActivateOutput(ECGBLCOSetLAIDBehOutputs::OutIdentitySet, FALSE);
    behaviour->ActivateOutput(ECGBLCOSetLAIDBehOutputs::OutError, TRUE);
    return CKBR_GENERICERROR;
}
Exemple #16
0
int GetLastFileName(const CKBehaviorContext& behcontext)
{

    CKBehavior* beh = behcontext.Behavior;
    CKContext* ctx = behcontext.Context;

    XString Inpath (ctx->GetLastCmoLoaded());



    CKParameterOut *pout = beh->GetOutputParameter(0);
    pout->SetStringValue(Inpath.Str());

    PathRemoveFileSpec(Inpath.Str());


    CKParameterOut *pout2 = beh->GetOutputParameter(1);
    pout2->SetStringValue(Inpath.Str());



    beh->ActivateOutput(0);


    return 0;

}
Exemple #17
0
int SetMousPos(const CKBehaviorContext& behcontext)
{
	

	CKBehavior* beh = behcontext.Behavior;
  	CKContext* ctx = behcontext.Context;

	if( beh->IsInputActive(0) ){
		beh->ActivateInput(0,FALSE);

 DWORD data = 0;
 DWORD flags = MOUSEEVENTF_ABSOLUTE;
 
 // - Has the pointer moved since the last event?
 
 
 flags |= MOUSEEVENTF_MOVE;

 mouse_event(flags, 100,100, data, 0);
 

		beh->ActivateOutput(0);
	

	}

	return 0;

}
Exemple #18
0
int GetNextBBId(const CKBehaviorContext& behcontext)
{
	CKBehavior* beh = behcontext.Behavior;
	CKContext* ctx = behcontext.Context;
	
	beh->ActivateInput(0,FALSE);
	
	int count = beh->GetParent()->GetSubBehaviorLinkCount();
	int result = -1;
    
	for (int i=0; i<count; i++)
	{
		CKBehaviorLink *link =  beh->GetParent()->GetSubBehaviorLink(i);
		if (link->GetInBehaviorIO() == beh->GetOutput(0))
		{
			result   = link->GetOutBehaviorIO()->GetOwner()->GetID();
			beh->SetOutputParameterValue(0,&result);
			break;
		}
	}
	
	CKBehavior *script   = static_cast<CKBehavior*>(ctx->GetObject(result));
	if (script)
	{
		int bc = script->GetOutputCount();

		int bc2 = script->GetInputCount();

	}


	beh->ActivateOutput(0);
	beh->SetOutputParameterValue(0,&result);
	return CKBR_OK;
}
Exemple #19
0
int LoadCIS(const CKBehaviorContext& behcontext)
{
	CKBehavior* beh = behcontext.Behavior;
  	CKContext* ctx = behcontext.Context;
	GBLConfigurationManager* cman=(GBLConfigurationManager*)ctx->GetManagerByGuid(CONFIGURATION_MAN_GUID);

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


	int LA = GetInputParameterValue<int>(beh,0);
	Customisation::typedefs::CIS* currentCIS = cman->GetCISAccessInterface()->GetCIS(LA);

	if( beh->IsInputActive(0) ){
		beh->ActivateInput(0,FALSE);
		


		beh->ActivateOutput(0);	
		beh->ActivateOutput(1);	
		return CKBR_OK;
		}

	return CKBR_OK;
}
Exemple #20
0
//************************************
// 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;
}
/*
*******************************************************************
* 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 GBLLDGetSetup::BehaviourFunction( const CKBehaviorContext& behaviorContext )
{
    CKBehavior    *beh;
    CKContext     *context;
    GBLLDManager  *GBLLDMan;
    XString       DBName;
    CKBOOL        logging;
    XString       ODBCName;
    XString       proxyLogin;
    XString       proxyPassword;
    XString       serverAddress;
    XString       serverLogin;
    XString       serverPassword;
    CKBOOL        serverMode;
    XString       userName;
    int           virtoolsUserID;
    CKBOOL        webPlayerMode;
    int           ConnectionID;

    if ( (beh      = behaviorContext.Behavior)                                   == NULL ) return CKBR_BEHAVIORERROR;
    if ( (context  = behaviorContext.Context)                                    == NULL ) return CKBR_BEHAVIORERROR;
    if ( (GBLLDMan = (GBLLDManager*)context->GetManagerByGuid(GBLLDManagerGUID)) == NULL ) return CKBR_BEHAVIORERROR;

    beh->ActivateInput( POS_I_IN, FALSE );

    // Force the reading of the attributes
    GBLLDMan->ReadSetup();

    ConnectionID     = GBLLDMan->GetConnectionID();
    DBName           = GBLLDMan->GetDBName();
    logging          = GBLLDMan->IsLogging();
    ODBCName         = GBLLDMan->GetODBCName();
    proxyLogin       = GBLLDMan->GetProxyLogin();
    proxyPassword    = GBLLDMan->GetProxyPassword();
    serverAddress    = GBLLDMan->GetServerAddress();
    serverLogin      = GBLLDMan->GetServerLogin();
    serverPassword   = GBLLDMan->GetServerPassword();
    serverMode       = GBLLDMan->GetServerMode();
    userName         = GBLLDMan->GetUserName();
    webPlayerMode    = GBLLDMan->IsWebplayerMode();
    virtoolsUserID   = GBLLDMan->GetVirtoolsUserID();

    beh->SetOutputParameterValue( POS_OP_CONNECTIONID,   &ConnectionID );
    beh->SetOutputParameterValue( POS_OP_DBNAME,         DBName.CStr(),         DBName.Length() );
    beh->SetOutputParameterValue( POS_OP_LOGGING,        &logging );
    beh->SetOutputParameterValue( POS_OP_ODBCNAME,       ODBCName.CStr(),       ODBCName.Length() );
    beh->SetOutputParameterValue( POS_OP_PROXYLOGIN,     proxyLogin.CStr(),     proxyLogin.Length() );
    beh->SetOutputParameterValue( POS_OP_PROXYPASSWORD,  proxyPassword.CStr(),  proxyPassword.Length() );
    beh->SetOutputParameterValue( POS_OP_SERVERADDRESS,  serverAddress.CStr(),  serverAddress.Length() );
    beh->SetOutputParameterValue( POS_OP_SERVERLOGIN,    serverLogin.CStr(),    serverLogin.Length() );
    beh->SetOutputParameterValue( POS_OP_SERVERMODE,     &serverMode );
    beh->SetOutputParameterValue( POS_OP_SERVERPASSWORD, serverPassword.CStr(), serverPassword.Length() );
    beh->SetOutputParameterValue( POS_OP_USERNAME,       userName.CStr(),       userName.Length() );
    beh->SetOutputParameterValue( POS_OP_WEBPLAYERMODE,  &webPlayerMode );
    beh->SetOutputParameterValue( POS_OP_VIRTOOLSUSERID, &virtoolsUserID );

    beh->ActivateOutput( POS_O_OUT, TRUE );
    return CKBR_OK;
}
/*
*******************************************************************
* Function: void CGBLBuildCommand::DeactivateOutputs(const CKBehaviorContext& behaviorContext)
*
* Description : Deactivates behavioral outputs for this building block
*
* Parameters :
*    behaviourContext    r   Behavior context reference, which gives 
*                            access to frequently used global objects 
*                            ( context, level, manager, etc... )
*
*******************************************************************
*/
void CGBLBuildCommand::DeactivateOutputs(const CKBehaviorContext& behaviorContext)
{
	CKBehavior* behavior = behaviorContext.Behavior;
	for (int output = EGBLBuildCommandBehOutputs::Cancelled; output <= EGBLBuildCommandBehOutputs::Error; output++)
	{
		behavior->ActivateOutput (output, FALSE);
	}
}
//************************************
// Method:    PClothAttachVertexToPosition
// FullName:  PClothAttachVertexToPosition
// Access:    public 
// Returns:   int
// Qualifier:
// Parameter: const CKBehaviorContext& behcontext
//************************************
int PClothAttachVertexToPosition(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;

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

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

		int vertexIndex = GetInputParameterValue<int>(beh,bbI_VertexIndex);
		VxVector localPosition = GetInputParameterValue<VxVector>(beh,bbI_GlobalPosition);

		cloth->attachVertexToGlobalPosition(vertexIndex,localPosition);

		beh->ActivateOutput(0);
	}
	return 0;
}
int SetCIConnectionDetails(const CKBehaviorContext& behcontext)
{
	/************************************************************************/
	/*  collecting data : 													*/
	/*  																	*/
	CKBehavior* beh = behcontext.Behavior;
  	CKContext* ctx = behcontext.Context;


	GBLConfigurationManager* cman=(GBLConfigurationManager*)ctx->GetManagerByGuid(CONFIGURATION_MAN_GUID);
	CGBLSyncInterface *CINetworkInterface = cman->GetSynInterface();

    
	
	/************************************************************************/
	/*  check interface :													*/
	/*  																	*/
	if (!CINetworkInterface->isValidInterface())
	{
		//try to init the network interface : 
		if (!CINetworkInterface->Init(ctx))
		{
			return CKBR_BEHAVIORERROR;
		}
	}

	/************************************************************************/
	/*  process building block events	:						*/
	/*  																	*/
	if( beh->IsInputActive(0) )
	{
		beh->ActivateInput(0,FALSE);
		XString message((CKSTRING) beh->GetInputParameterReadDataPtr(0));
		int connectionID = -1; 
		beh->GetInputParameterValue(1,&CINetworkInterface->connectionID);
		CKAttributeManager *aMan = static_cast<CKAttributeManager*>(ctx->GetAttributeManager());
		
		//////////////////////////////////////////////////////////////////////////
		//store connection details in the scipt dummies attribute :
		CKAttributeType gblNetworkAtt = aMan->GetAttributeTypeByName( GBL_API_ENTRY("NetworkDetails"));
		if (!CINetworkInterface->messageDummy->HasAttribute(gblNetworkAtt) )
		{		
			CINetworkInterface->messageDummy->SetAttribute(gblNetworkAtt);
		}
		GBLCommon::ParameterTools::SetParameterStructureValue<int>(CINetworkInterface->messageDummy->GetAttributeParameter(gblNetworkAtt),0,CINetworkInterface->connectionID);
		GBLCommon::ParameterTools::SetParameterStructureValue<CKSTRING>(CINetworkInterface->messageDummy->GetAttributeParameter(gblNetworkAtt),1,CINetworkInterface->messageName.Str());
		
		//////////////////////////////////////////////////////////////////////////
		//activate and execute the script :
		behcontext.CurrentScene->Activate(CINetworkInterface->synchronizeScript,true);
		behcontext.CurrentScene->Activate(CINetworkInterface->messageDummy,FALSE);
		CINetworkInterface->synchronizeScript->Execute(1);
		
		beh->ActivateOutput(0);
	}
	return CKBR_OK;
}
Exemple #25
0
/*
 *******************************************************************
 * 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 CGBLLAEGetLA::BehaviourFunction( const CKBehaviorContext& behaviorContext )
{
	CKBehavior* beh = behaviorContext.Behavior;
  	CKContext* ctx = behaviorContext.Context;


	IGBLSMProfileAccess* pin = NULL;
    CGBLSMStorageManager *storageManager = (CGBLSMStorageManager *)ctx->GetManagerByGuid(GBLSMStorageManagerGUID);
	IGBLSMLAAccess *laInterface = storageManager->GetLAInterface();

	char *arrayName = "laList";
	CKDataArray* array;

	array = (CKDataArray *)ctx->GetObjectByNameAndClass(arrayName,CKCID_DATAARRAY,NULL);

	if ( !array )
	{
		array = (CKDataArray *)ctx->CreateObject(CKCID_DATAARRAY,arrayName, CK_OBJECTCREATION_DYNAMIC);
		behaviorContext.CurrentLevel->AddObject( array );
	
		array->InsertColumn( -1, CKARRAYTYPE_INT,	 "LAID" );
	}
	else
	{
		array->Clear();
	}

	CGBLCOError res = laInterface->RetrieveLAList(array);
	if ( res == CGBLCOError::EGBLCOErrorType::GBLCO_OK)
	{
		beh->ActivateInput(0, FALSE);
		beh->SetOutputParameterObject(0, array);
		beh->ActivateOutput(0);
	}
	else
	{
		beh->ActivateInput(0, FALSE);
		CKParameterOut *parameterOutError = beh->GetOutputParameter(1);
		TGBLError::SetTGBLError(parameterOutError,CGBLCOError::EGBLCOErrorType::GBLCO_LOCAL,GBLLAE_ERROR_GETLISTOFLAIDS,GBLLAE_ERROR_GETLISTOFLAIDS_DESC);
		beh->ActivateOutput(1);
	}

    return CKBR_OK;
}
/*
 *******************************************************************
 * Function: int BehaviourFunction( const CKBehaviorContext& behaviorContext )
 *
 * Description : The execution function is the function that will be called
 *               during the process loop of the behavior engine, if the behavior
 *               is defined as using an execution function. This function is not
 *               called if the behavior is defined as a graph. This function is the
 *               heart of the behavior: it should compute the essence of the behavior,
 *               in an incremental way. The minimum amount of computing should be
 *               done at each call, to leave time for the other behaviors to run.
 *               The function receives the delay in milliseconds that has elapsed
 *               since the last behavioral process, and should rely on this value to
 *               manage the amount of effect it has on its computation, if the effect
 *               of this computation relies on time.
 *
 * Paramters :
 *    behaviourContext    r   Behavior context reference, which gives access to
 *                            frequently used global objects ( context, level, manager, etc... )
 *
 * Returns : int, If it is done, it should return CKBR_OK. If it returns
 *                CKBR_ACTIVATENEXTFRAME, the behavior will again be called
 *                during the next process loop.
 *
 *******************************************************************
 */
int CGBLLAESetLAEData::BehaviourFunction( const CKBehaviorContext& behaviorContext )
{
    CKBehavior* beh = behaviorContext.Behavior;
    CKContext* ctx = behaviorContext.Context;

    IGBLSMProfileAccess* pin = NULL;
    CGBLSMStorageManager *storageManager = (CGBLSMStorageManager *)ctx->GetManagerByGuid(GBLSMStorageManagerGUID);
    IGBLSMLAEAccess *laeInterface = storageManager->GetLAEInterface();

    int cisid;
    CGBLLAID laid;
    XString xlaid;
    XString laeName;
    int laeState = 0;

    CKDataArray *userIDList = NULL;

    CGBLLAEID laeid = 0;

    int dlaeid;
    beh->GetInputParameterValue(1, &dlaeid);
    laeid = dlaeid;

    GBLLAEDataType::GetGBLLAEData(beh->GetInputParameter(0)->GetRealSource(), cisid, laeName, laeState, xlaid, &userIDList );

    laid.FromString(xlaid);

    CGBLCOError res = laeInterface->StoreLAE (laeState, cisid, laid, laeName, &laeid);
    if ( res == CGBLCOError::EGBLCOErrorType::GBLCO_OK)
    {
        beh->ActivateInput(0, FALSE);
        beh->ActivateOutput(0);
    }
    else
    {
        CKParameterOut *parameterOutError = beh->GetOutputParameter(0);
        TGBLError::SetTGBLError(parameterOutError,CGBLCOError::EGBLCOErrorType::GBLCO_LOCAL,GBLLAE_ERROR_STORELAE,GBLLAE_ERROR_STORELAE_DESC);
        beh->ActivateOutput(1);

    }

    return CKBR_OK;
}
Exemple #27
0
int HasFFEffects(const CKBehaviorContext& behcontext)
{
	CKBehavior* beh = behcontext.Behavior;
	CKContext* ctx = behcontext.Context;

	HWND mWin = (HWND )ctx->GetMainWindow();

	DirectInput8Create( GetModuleHandle(NULL), DIRECTINPUT_VERSION, IID_IDirectInput8, (VOID**)&g_pDI2, NULL )  ;

    // Get the first enumerated force feedback device
    g_pDI2->EnumDevices( 0, EnumFFDevicesCallback0, 0, DIEDFL_ATTACHEDONLY | DIEDFL_FORCEFEEDBACK );

	if( g_pFFDevice2 == NULL )
          beh->ActivateOutput(1);
	else
		beh->ActivateOutput(0);
	
	FreeDirectInput0();
	return CKBR_OK;
}
/*
 *******************************************************************
 * 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;
}
//************************************
// Method:    PClothAddForceAtVertex
// FullName:  PClothAddForceAtVertex
// Access:    public 
// Returns:   int
// Qualifier:
// Parameter: const CKBehaviorContext& behcontext
//************************************
int PClothAddForceAtVertex(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;

		
		//////////////////////////////////////////////////////////////////////////
		pCloth *cloth  = GetPMan()->getCloth(target->GetID());
		if (!cloth)
		{
			beh->ActivateOutput(0);
			return CKBR_PARAMETERERROR;
		}
		
		int vertexIndex = GetInputParameterValue<int>(beh,bbI_VertexIndex);
		VxVector force = GetInputParameterValue<VxVector>(beh,bbI_Force);
		int forceMode = GetInputParameterValue<int>(beh,bbI_ForceMode);

		cloth->addForceAtVertex(force,vertexIndex,(ForceMode)forceMode);



		beh->ActivateOutput(0);
	}
	return 0;
}
Exemple #30
0
int GetCurrentCamera(const CKBehaviorContext& behcontext)
{
	CKBehavior* beh = behcontext.Behavior;

  // Set IO states
	beh->ActivateInput(0,FALSE);
	beh->ActivateOutput(0);

	CKCamera* cam = behcontext.CurrentRenderContext->GetAttachedCamera();

	beh->SetOutputParameterObject(0,cam);

	return CKBR_OK;
}