void AlternateStoichiometries::create(std::vector<ElementaryReaction>& fastRxnsReindexed, std::vector<dense_vec>& slowRxnFastStoich, std::vector<Reactants>& slowRxnFastReactantsReindexed) {
//	std::cout << "creating alternate stoichiometries...\n";

//	std::cout << "slowRxnFastStoich passed to create has size: "<<slowRxnFastStoich.size()<<"\n";		
			
	fastReactions=fastRxnsReindexed;
	slowRxnStoich=slowRxnFastStoich;
	slowRxnFastReactants=slowRxnFastReactantsReindexed;
	
//	std::cout << "slowRxnFastReactants.size()="<<slowRxnFastReactants.size()<<"\n";
//	for (std::size_t i=0; i!=slowRxnFastReactants.size(); ++i) {
//		std::cout << "slowRxnFastReactants["<<i<<"].display: ";
//		slowRxnFastReactants[i].display();
//		std::cout << "\n";
//	}
	
//		std::cout << "slowRxn stoichiometries (size="<<slowRxnStoich.size()<<"): \n";
//		for (std::size_t i=0; i!=slowRxnStoich.size(); ++i) {
//			//print_dense_vec(slowRxnStoich[i]);
//			std::cout << "rxn "<<i<<": ";
//			for (std::size_t j=0; j!=slowRxnStoich[i].size(); ++j) {
//				std::cout << slowRxnStoich[i][j] << "\t";
//			}
//			std::cout << "\n";
//		}
	
	createLevel0AlternateStoichiometries(slowRxnFastStoich,slowRxnFastReactantsReindexed);
//		std::cout << "level 0 alternate stoichiometries:\n";
//		for (std::size_t i=0; i!=level0.size(); ++i) {
//			std::cout << "reaction "<<i<<":";
//			level0[i].display();
//		}

	//buildReactantSets();

//std::cout << "about to create level 1...\n";

	createLevel1(slowRxnFastStoich,slowRxnFastReactantsReindexed);

//std::cout << "about to create level 2...\n";

	createLevel2(slowRxnFastStoich,slowRxnFastReactantsReindexed);

//std::cout << "about to buildAltStoichVectors...\n";

	buildAltStoichVectors(slowRxnFastStoich);
	
//std::cout << "done building alt stoich vectors, done with AlternateStoichiometries::create.\n";
}
示例#2
0
void Game::initPhysicsObjects(){
	//IMPLEMENTATION OF WORLD
#ifdef _DEBUG
	hkMemoryRouter* memoryRouter = hkMemoryInitUtil::initChecking( hkMallocAllocator::m_defaultMallocAllocator, hkMemorySystem::FrameInfo(2*1024*1024) );
#else
	hkMemoryRouter* memoryRouter = hkMemoryInitUtil::initDefault( hkMallocAllocator::m_defaultMallocAllocator, hkMemorySystem::FrameInfo(1024*1024) );
#endif
	hkBaseSystem::init( memoryRouter, errorReport);
	hkpWorldCinfo worldInfo;	// Create the simulation world1
	worldInfo.m_gravity.set(0.0f,-9.8f,0.0f);
	worldInfo.setBroadPhaseWorldSize(100.0f);	//
	m_world = new hkpWorld(worldInfo); 
	m_world->lock();	//****
	// This is needed to detect collisionss
	hkpAgentRegisterUtil::registerAllAgents(m_world->getCollisionDispatcher());
#ifdef _DEBUG
	m_physicsContext = new hkpPhysicsContext();//Connect VDB
	m_physicsContext->addWorld(m_world); // add all worlds
	hkpPhysicsContext::registerAllPhysicsProcesses();
	hkArray<hkProcessContext*> contexts;
	contexts.pushBack(m_physicsContext );  
	m_vdb = new hkVisualDebugger( contexts );
	m_vdb->serve();
#endif
	intCalled = true;
	
	//OBJECTS
	//Make Level1
	createLevel1();
	//Make Sphere and drop it
	pSphere = Sphere::getInstance(sphereDensity);
	pSphere->setPos(Vector(0.0,3.0,0.0));
	pSphere->init(m_world);
	dropSphere();

	//makeWall();

	//Constraints

	//END
	m_world->unlock();
}
示例#3
0
void Game::Update(){
	//Timers
	while(timer->getElapsedTime() - lft - 1.0f/60.0f < 0.001f); //Frame Limiter (set to 60 FPS)
	cft = timer->getElapsedTime();
	tbf = cft - lft;
	lft = cft;
	//Havok
	if(GAMESTATE == MAINSTATESCREEN){

	}
	if(GAMESTATE == PLAYSTATESCREEN){
		if(physicsState){
			m_world->stepDeltaTime(tbf); //update physics engine
			#ifdef _DEBUG
				m_vdb->step(tbf);	// update VDB when running
			#endif
		}
		//if(physicsState == true){
		//	if(pBox->getPos().y < -4 /*|| pBoxArray[0]->getPos().y < 6 || pBoxArray[1]->getPos().y < 6 || pBoxArray[2]->getPos().y < 6 || pBoxArray[3]->getPos().y < 6*/){
		//		//physicsState = false;
		//		pBoxArray[0]->getRigidBody()->setPosition(hkVector4(0.0,0.0,0.0));
		//	}
		//}
		//if(pSphere->getPos().y < -10.0){//to stop error
		//	physicsState = false;
		//}
		
		//Object Updates
		if(oSphere){
			oSphere->update();
		}
		if(oLevel1){
			oLevel1->update();
		}
		//Collision dectection
		if(goal && oSphere){
			isColliding = goal->collidesWithSphere(oSphere);
			if(isColliding == true){
				deleteEverything();
				makeGoal();
				deleteLevel1();
				createLevel1();
			}
		}
		if(pSphere->getPos().y <= -15){
			sphereInZone == false;
			if(sphereInZone == false){
					dropSphere();
					lives--;
			}
		}
		if(enemyf){
			enemyf->aiUpdate(pSphere);
			isCollidingModelSphere = oSphere->collisionModel(enemyf, oSphere);
			if(isCollidingModelSphere == true){
				lives--;
				dropSphere();
				delete enemyf;
				enemyf = NULL;
			}
		}
		//Camera
		//if(pLevel1){
			toX = pLevel1->getPos().x; toY = pLevel1->getPos().y; toZ = pLevel1->getPos().z;
		//}
	}
}