コード例 #1
0
ファイル: Puppeteer.cpp プロジェクト: LudoSapiens/Dev
void
GraphRetargetingTask::execute()
{
   // 1. Clone the graph.
   RCP<AnimationGraph> graph = _graph->clone();

   // 2. Retarget each animation in each node.

   // Fetch all animations contained in the graph.
   Vector< SkeletalAnimation* > anims;
   _graph->getAnimations( anims );

   // Retarget all animation.
   Vector< RCP< Resource<SkeletalAnimation> > > animsRes (anims.size());
   for( uint i = 0; i < anims.size(); ++i )
   {
      animsRes[i] = ResManager::retarget( anims[i], _skel.ptr(), this );
   }
   waitForAll();

   // Replace all animations.
   Map< SkeletalAnimation*, RCP<SkeletalAnimation> > ranims;
   for( uint i = 0; i < anims.size(); ++i )
   {
      ranims[anims[i]] = waitForData( animsRes[i].ptr() );
   }
   graph->replaceAnimations( ranims );

   _res->data( graph.ptr() );
}
コード例 #2
0
/** Creates a new wait action. If there are no action ids then WaitForAll is created.
Otherwise, the wait function will wait for the specified action ids to complete. 
This function takes ownership of action ids at the END of the function. */
CMtfTestActionWait* CMtfTestActionWait::NewL(CMtfTestCase& aTestCase, CMtfTestActionParameters* aActionIds)  
{
	TBool waitForAll(aActionIds->Count()==0);

	CMtfTestActionWait* self = new (ELeave) CMtfTestActionWait(aTestCase,waitForAll);
	CleanupStack::PushL(self);
	self->ConstructL(aActionIds);
	CleanupStack::Pop(self);
	return self;
}
コード例 #3
0
ファイル: ProceduralWorld.cpp プロジェクト: LudoSapiens/Dev
//------------------------------------------------------------------------------
//!
void
ProceduralWorld::execute()
{
   RCP<World> world( new World() );

   // Create working context for this vm.
   WorldContext context( this );
   context._world = world.ptr();
   context._ref   = Reff::identity();
   context.curDir( ResManager::dir(_id) );

   // Open vm.
   VMState* vm = VM::open( VM_CAT_WORLD | VM_CAT_MATH, true );

   // keep context pointer into vm.
   VM::userData( vm, &context );

   // Push parameters.
   if( _params.isValid() )
   {
      VM::push( vm, *_params );
      // Execute script.
      VM::doFile( vm, _path, 1, 0 );
   }
   else
   {
      // Execute script.
      VM::doFile( vm, _path, 0 );
   }

   // Wait for all auxilliary task (loading resource) to finish.
   waitForAll();

   // Assign all resources.
   // Geometry.
   for( size_t i = 0; i < context._geomRes.size(); ++i )
   {
      WorldContext::GeomEntityPair& p = context._geomRes[i];
      p.first->geometry( waitForData( p.second ) );
   }
   // MaterialSet.
   for( size_t i = 0; i < context._matRes.size(); ++i )
   {
      WorldContext::MatEntityPair& p = context._matRes[i];
      p.first->materialSet( waitForData( p.second ) );
   }
   // BrainProgram.
   for( size_t i = 0; i < context._brainRes.size(); ++i )
   {
      WorldContext::BrainProgPair& p = context._brainRes[i];
      p.first->program( waitForData( p.second ) );
   }

   // Animation graph.
   for( size_t i = 0; i < context._graphRes.size(); ++i )
   {
      WorldContext::SkelGraphPair& p = context._graphRes[i];
      // Retarget animation graph to skeleton.
      if( p.first->skeleton() )
      {
         RCP< Resource<AnimationGraph> > graph = ResManager::retarget(
            waitForData( p.second ), p.first->skeleton(), this
         );
         context.keepResource( graph.ptr() );
         p.second = graph.ptr();
      }
   }

   // Wait for all auxilliary task (loading resource) to finish.
   waitForAll();

   // At this point, the skeletal entity's animation graph has been retargetted, and the brains are set.
   for( size_t i = 0; i < context._graphRes.size(); ++i )
   {
      WorldContext::SkelGraphPair& p  = context._graphRes[i];
      SkeletalEntity*            skel = p.first;
      Brain*                    brain = skel->brain();
      AnimationGraph*           graph = waitForData( p.second );
      if( brain == NULL )
      {
         StdErr << "Attempted to set an animation graph (" << (void*)graph << ") on a brainless skeletal entity (" << (void*)skel << "); ignoring." << nl;
         continue;
      }
      // Connect the graph into the skeletal entity through a puppeteer action.
      PuppeteerAction* action = (PuppeteerAction*)brain->findAction( PuppeteerAction::actionType() );
      if( action == NULL )
      {
         action = new PuppeteerAction();
         brain->actions().pushBack( action );
      }
      action->entity( skel );
      action->graph( graph );
   }

   // Guarantee a material group in every entity.
   uint n = world->numEntities();
   for( uint i = 0; i < n; ++i )
   {
      Entity* e = world->entity( i );
      if( e->materialSet() == nullptr )
      {
         MaterialSet* ms = new MaterialSet();
         ms->add( Material::white() );
         e->materialSet( ms );
      }
   }

   VM::close( vm );

   _res->data( world.ptr() );
}
コード例 #4
0
ファイル: Network.cpp プロジェクト: john-r-iii/cppfbp
void Network::go(label_ent * label_blk, bool dynam, FILE * fp, bool timereq, _anchor proc_anchor) {	
	Process *this_proc;
	cnxt_ent *cnxt_tab;
	proc_ent *proc_tab;
	label_ent *label_tab;
	label_ent *label_curr;
	label_ent *label_new;
	
	char file_name[10];

	Port *cpp;
	time_t st_time, end_time;
	double secs;
	st_time = time(NULL);

	Process * mother = (Process *) proc_anchor.reserved;

	_CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_CHECK_ALWAYS_DF | _CRTDBG_LEAK_CHECK_DF);

	label_tab = (label_ent *)malloc(sizeof(label_ent));
	label_curr = label_tab;
	label_ent * label_this = label_blk;
	if (!dynam) {
		for (;;) {
			strcpy(label_curr->label,
				label_this->label);
			strcpy(label_curr->file,
				label_this->file);
			label_curr->cnxt_ptr = 
				label_this->cnxt_ptr;
			label_curr->proc_ptr = 
				label_this->proc_ptr;
			label_curr->ent_type = 
				label_this->ent_type;
			label_this = label_this->succ;
			if (label_this == 0) break;
			label_new = (label_ent *)malloc(sizeof(label_ent));  // handle subnets
			label_curr->succ = label_new;
			label_curr = label_new;
		}

		cnxt_tab = label_tab -> cnxt_ptr;
		proc_tab = label_tab -> proc_ptr;
	}
	else {
		label_tab->succ = 0;
		file_name[0] = '\0'; 

		//if (fp == 0) {
		//	printf("File does not exist: %s\n", fp);
		//	exit(4);
		//}
		if (thxscan(fp, label_tab, file_name) != 0) {

			printf("Scan error\n");
			exit(4);
		}
	}
	//network = new Appl;
	//network = this;
	if (proc_anchor.reserved == NULL)
		strcpy(name,"APPL");
	else
		strcpy(name,"SUBNET");
	//first_ready_proc = 0;
	first_child_proc = 0;
	first_child_comp = 0;
	first_cnxt = 0;
	dynam = dynam;
	active = FALSE;
	possibleDeadlock = FALSE;
	deadlock = FALSE;

	thxbnet(label_tab, mother, this, label_tab);  // first param is network/subnet, 2nd is "mother" process", 4th is network as a whole

	int thread_count = 0;

	this_proc = (Process*) first_child_proc;
	while (this_proc != 0)
	{
		thread_count ++;
		this_proc = this_proc -> next_proc;
	}

	/* Look for processes with no input ports */

	latch =  new Cdl(thread_count);

	Cnxt * cnxt_ptr = (Cnxt *) first_cnxt;
	while (cnxt_ptr != 0) {	 
		cnxt_ptr -> closed = FALSE;
		cnxt_ptr = cnxt_ptr -> succ;
	}

	this_proc = (Process*) first_child_proc;
	while (this_proc != 0)
	{
		this_proc -> network = this;
		this_proc-> self_starting = TRUE;
		cpp = this_proc -> in_ports;
		while (cpp != 0) {	 
			for (int i = 0; i < cpp -> elem_count; i++) {
				if (cpp -> elem_list[i].gen.connxn != 0 &&
					! cpp -> elem_list[i].is_IIP)
					this_proc->self_starting = FALSE;
			}
			cpp = cpp -> succ;
		}
		if (this_proc -> self_starting)
		{
			// add to ready chain
			//this_proc -> status = INITIATED;

			if (this_proc -> trace)
				printf("%s Initiated\n",this_proc -> procname);

			this_proc -> activate();
		}
		//thread_count ++;
		this_proc = this_proc -> next_proc;
	}

	active = TRUE;

	waitForAll();
	delete latch;


	//if (dynam) {                  -- check this out!
	//	free(cnxt_tab);
	//	free(proc_tab);		
	//}


	//free (latch);  
	thxfcbs();
	//free(label_tab);

	end_time = time(NULL);
	secs = difftime(end_time, st_time);
	if (timereq){
		printf("Elapsed time in seconds: %5.3f\n",secs);
	}

	if (strcmp(name, "SUBNET") != 0) {
	  //_CrtDumpMemoryLeaks();
	  //char c; 
	  printf("Press enter to terminate\n");
	  std::cin.get();  // to see console
	  //system("pause");  // to see console
	  exit(0);
	}
}