예제 #1
0
static void
keyboard(unsigned char key, int x, int y)
{
	int index = key - 'a';
	
	if(0 <= index && index < demoCount){
		runDemo(demos[index]);
	} else if(key == '\r'){
		runDemo(currDemo);
  } else if(key == '`'){
		paused = !paused;
  } else if(key == '1'){
		step += 1;
	} else if(key == '-'){
		options.drawHash = !options.drawHash;
	} else if(key == '='){
		options.drawBBs = !options.drawBBs;
	} else if(key == '\\'){
		glEnable(GL_LINE_SMOOTH);
		glEnable(GL_POINT_SMOOTH);
		glEnable(GL_BLEND);
		glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
		glHint(GL_LINE_SMOOTH_HINT, GL_DONT_CARE);
		glHint(GL_POINT_SMOOTH_HINT, GL_DONT_CARE);
	}
}
예제 #2
0
int
main(int argc, const char **argv)
{
	cpInitChipmunk();
	cp_collision_slop = 0.2f;
	
#ifdef TIME_TRIAL
	sleep(1);
	for(int i=0; i<demoCount; i++){
		if(i == 'l' - 'a') continue;
		time_trial(i, 1000);
	}
//	time_trial(0, 1000);
	exit(0);
#endif
	
	mouseBody = cpBodyNew(INFINITY, INFINITY);
	
	glutStuff(argc, argv);
	
	runDemo(demos[firstDemoIndex]);
	glutMainLoop();

	return 0;
}
예제 #3
0
int
main(int argc, const char **argv)
{
	ChipmunkDemo demo_list[] = {
		LogoSmash,
		PyramidStack,
		Plink,
		BouncyHexagons,
		Tumble,
		PyramidTopple,
		Planet,
		Springies,
		Pump,
		TheoJansen,
		Query,
		OneWay,
		Joints,
		Tank,
		Chains,
		Crane,
		ContactGraph,
		Buoyancy,
		Player,
		Slice,
		Convex,
		Unicycle,
	};
	
	demos = demo_list;
	demoCount = sizeof(demo_list)/sizeof(ChipmunkDemo);
	int trial = 0;
	
	for(int i=0; i<argc; i++){
		if(strcmp(argv[i], "-bench") == 0){
			demos = bench_list;
			demoCount = bench_count;
		} else if(strcmp(argv[i], "-trial") == 0){
			trial = 1;
		}
	}
	
	if(trial){
//		sleep(1);
		for(int i=0; i<demoCount; i++) time_trial(i, 1000);
//		time_trial('d' - 'a', 10000);
		exit(0);
	} else {
		mouseBody = cpBodyNew(INFINITY, INFINITY);
		
		glutStuff(argc, argv);
		
		runDemo(demoIndex);
		glutMainLoop();
	}

	return 0;
}
예제 #4
0
void OgreApp::startDemo(void* uiWindow, void* uiView, unsigned int width, unsigned int height, const char* name, MusicMode musica)
#endif
{
    globals.playerName = name;
    gameState = STATE_PLAY;
    musicMode = musica;
    
	new OgreFramework();
#if !defined(OGRE_IS_IOS)
    if (!OgreFramework::getSingletonPtr()->initOgre(this, this, this))
        return;
#else
	if (!OgreFramework::getSingletonPtr()->initOgre(uiWindow, uiView, width, height, this))
		return;
#endif
    
    
	m_bShutdown = false;
    
	OgreFramework::getSingletonPtr()->m_pLog->logMessage("Demo initialized!");
	
#ifdef USE_RTSHADER_SYSTEM
    initializeRTShaderSystem(OgreFramework::getSingletonPtr()->m_pSceneMgrMain);
    MaterialPtr baseWhite = MaterialManager::getSingleton().getByName("BaseWhite", ResourceGroupManager::INTERNAL_RESOURCE_GROUP_NAME);
    baseWhite->setLightingEnabled(false);
    mShaderGenerator->createShaderBasedTechnique(
                                                 "BaseWhite",
                                                 MaterialManager::DEFAULT_SCHEME_NAME,
                                                 RTShader::ShaderGenerator::DEFAULT_SCHEME_NAME);
    mShaderGenerator->validateMaterial(RTShader::ShaderGenerator::DEFAULT_SCHEME_NAME,
                                       "BaseWhite");
    baseWhite->getTechnique(0)->getPass(0)->setVertexProgram(
                                                             baseWhite->getTechnique(1)->getPass(0)->getVertexProgram()->getName());
    baseWhite->getTechnique(0)->getPass(0)->setFragmentProgram(
                                                               baseWhite->getTechnique(1)->getPass(0)->getFragmentProgram()->getName());
    
    // creates shaders for base material BaseWhiteNoLighting using the RTSS
    mShaderGenerator->createShaderBasedTechnique(
                                                 "BaseWhiteNoLighting",
                                                 MaterialManager::DEFAULT_SCHEME_NAME,
                                                 RTShader::ShaderGenerator::DEFAULT_SCHEME_NAME);
    mShaderGenerator->validateMaterial(RTShader::ShaderGenerator::DEFAULT_SCHEME_NAME,
                                       "BaseWhiteNoLighting");
    MaterialPtr baseWhiteNoLighting = MaterialManager::getSingleton().getByName("BaseWhiteNoLighting", ResourceGroupManager::INTERNAL_RESOURCE_GROUP_NAME);
    baseWhiteNoLighting->getTechnique(0)->getPass(0)->setVertexProgram(
                                                                       baseWhiteNoLighting->getTechnique(1)->getPass(0)->getVertexProgram()->getName());
    baseWhiteNoLighting->getTechnique(0)->getPass(0)->setFragmentProgram(
                                                                         baseWhiteNoLighting->getTechnique(1)->getPass(0)->getFragmentProgram()->getName());
    
    
#endif
    
	setupDemoScene();
#if !((OGRE_PLATFORM == OGRE_PLATFORM_APPLE) && __LP64__)
	runDemo();
#endif
}
예제 #5
0
void ChipmunkTestLayer::ccTouchesEnded(CCSet* touches, CCEvent *event)
{
    demoIndex++;
    if( demoIndex >= maxDemos )
        demoIndex = 0;

    runDemo(demos[demoIndex]);

    label->setString( demos[demoIndex]->name );
}
예제 #6
0
static void
keyboard(unsigned char key, int x, int y)
{
	int index = key - 'a';
	
	if(0 <= index && index < demoCount){
		demos[demoIndex].destroyFunc();
		runDemo(index);
	} else if(key == '\r'){
		demos[demoIndex].destroyFunc();
		runDemo(demoIndex);
  } else if(key == '`'){
		paused = !paused;
  } else if(key == '1'){
		step = cpTrue;
	} else if(key == '='){
		drawBBs = !drawBBs;
	} else if(key == '\\'){
		glDisable(GL_LINE_SMOOTH);
		glDisable(GL_POINT_SMOOTH);
	}
	
	GLfloat translate_increment = 50.0/scale;
	GLfloat scale_increment = 1.2;
	if(key == '5'){
		translate_x = 0.0;
		translate_y = 0.0;
		scale = 1.0;
	}else if(key == '4'){
		translate_x += translate_increment;
	}else if(key == '6'){
		translate_x -= translate_increment;
	}else if(key == '2'){
		translate_y += translate_increment;
	}else if(key == '8'){
		translate_y -= translate_increment;
	}else if(key == '7'){
		scale /= scale_increment;
	}else if(key == '9'){
		scale *= scale_increment;
	}
}
예제 #7
0
void DemoApp::startDemo()
{
	new OgreFramework();
	if(!OgreFramework::getSingletonPtr()->initOgre("DemoApp v1.0", this, 0))
		return;
 
	m_bShutdown = false;
 
	OgreFramework::getSingletonPtr()->m_pLog->logMessage("Demo initialized!");

	setupDemoScene();
	runDemo();
}
예제 #8
0
static void
keyboard(unsigned char key, int x, int y)
{
	int index = key - 'a';
	
	if(0 <= index && index < demoCount){
		demos[demoIndex].destroyFunc();
		runDemo(index);
	} else if(key == '\r'){
		demos[demoIndex].destroyFunc();
		runDemo(demoIndex);
  } else if(key == '`'){
		paused = !paused;
  } else if(key == '1'){
		step = cpTrue;
	} else if(key == '='){
		drawBBs = !drawBBs;
	} else if(key == '\\'){
		glDisable(GL_LINE_SMOOTH);
		glDisable(GL_POINT_SMOOTH);
	}
}
예제 #9
0
void App::startDemo()
{
    new OgreFramework();
    if(!OgreFramework::getSingletonPtr()->initOgre("Open Uber Shader", this, 0))
        return;
    
    m_bShutdown = false;

    OgreFramework::getSingletonPtr()->m_pLog->logMessage("Application initialized!");

    setupDemoScene();
    runDemo();
}
예제 #10
0
void DemoApp::startDemo()
{
	new OgreFramework();
	if(!OgreFramework::getSingletonPtr()->initOgre("DemoApp v1.0", this, this))
		return;
    
	m_bShutdown = false;
    
	OgreFramework::getSingletonPtr()->m_pLog->logMessage("Demo initialized!");
	
#ifdef USE_RTSHADER_SYSTEM
    initializeRTShaderSystem(OgreFramework::getSingletonPtr()->m_pSceneMgr);
    MaterialPtr baseWhite = MaterialManager::getSingleton().getByName("BaseWhite", ResourceGroupManager::INTERNAL_RESOURCE_GROUP_NAME);				
    baseWhite->setLightingEnabled(false);
    mShaderGenerator->createShaderBasedTechnique(
                                                 "BaseWhite", 
                                                 MaterialManager::DEFAULT_SCHEME_NAME, 
                                                 RTShader::ShaderGenerator::DEFAULT_SCHEME_NAME);	
    mShaderGenerator->validateMaterial(RTShader::ShaderGenerator::DEFAULT_SCHEME_NAME, 
                                       "BaseWhite");
    baseWhite->getTechnique(0)->getPass(0)->setVertexProgram(
                                                             baseWhite->getTechnique(1)->getPass(0)->getVertexProgram()->getName());
    baseWhite->getTechnique(0)->getPass(0)->setFragmentProgram(
                                                               baseWhite->getTechnique(1)->getPass(0)->getFragmentProgram()->getName());
    
    // creates shaders for base material BaseWhiteNoLighting using the RTSS
    mShaderGenerator->createShaderBasedTechnique(
                                                 "BaseWhiteNoLighting", 
                                                 MaterialManager::DEFAULT_SCHEME_NAME, 
                                                 RTShader::ShaderGenerator::DEFAULT_SCHEME_NAME);	
    mShaderGenerator->validateMaterial(RTShader::ShaderGenerator::DEFAULT_SCHEME_NAME, 
                                       "BaseWhiteNoLighting");
    MaterialPtr baseWhiteNoLighting = MaterialManager::getSingleton().getByName("BaseWhiteNoLighting", ResourceGroupManager::INTERNAL_RESOURCE_GROUP_NAME);
    baseWhiteNoLighting->getTechnique(0)->getPass(0)->setVertexProgram(
                                                                       baseWhiteNoLighting->getTechnique(1)->getPass(0)->getVertexProgram()->getName());
    baseWhiteNoLighting->getTechnique(0)->getPass(0)->setFragmentProgram(
                                                                         baseWhiteNoLighting->getTechnique(1)->getPass(0)->getFragmentProgram()->getName());
    
    
#endif
    
	setupDemoScene();
#if !((OGRE_PLATFORM == OGRE_PLATFORM_APPLE) && __LP64__)
	runDemo();
#endif
}
예제 #11
0
int
main(int argc, const char **argv)
{
	cpInitChipmunk();
	
//	for(int i=0; i<demoCount; i++)
//		time_trial(i, 1000);
//	time_trial('d' - 'a', 10000);
//	exit(0);
	
	mouseBody = cpBodyNew(INFINITY, INFINITY);
	
	glutStuff(argc, argv);
	
	runDemo(demos[firstDemoIndex]);
	glutMainLoop();

	return 0;
}
예제 #12
0
void ChipmunkTestLayer::init()
{
    CCLayer::init();
    CCLayer::setIsTouchEnabled(true);
	
	demoIndex = 0;

    cpInitChipmunk();
	cp_collision_slop = 0.2f;
    mouseBody = cpBodyNew(INFINITY, INFINITY);

    runDemo(demos[firstDemoIndex]);

    label = CCLabelTTF::labelWithString(demos[firstDemoIndex]->name, "Arial", 32);
    label->setPosition( ccp(0, -300) );
    label->setColor(ccBLACK);
    addChild(label);

    // [self schedule: @selector(step:)];
    scheduleUpdate();
}
예제 #13
0
void Controller::checkState()
{
	Coordinate create_coord;

	bool Bumper_Hit = false;
std::cout << "total_distance:" << this->create.getTotalDistance() << std::endl;
std::cout << "angle:" << this->create.getTotalAngle() << std::endl;
std::cout << "(" << this->create.getCurrentCoordinate().x << ", " << this->create.getCurrentCoordinate().y << ")" << std::endl;
std::cout << "direction:"<< this->create.direction << std::endl;

std::cout << "current mesh:" << this->block.getCurrentMeshNum(this->create.getCurrentCoordinate()) << std::endl;


// 1.壁探索
	if(this->search_flag == WALL)
	{
		int bumper_hit = getBumpsAndWheelDrops();
		Coordinate wall_coord;
//1-1.バンパーに衝突したかを判定
// 1-1-1.バンパセンサ反応無し → 現在座標、超音波センサの観測座標を記録
		this->block.showMesh();
		if(bumper_hit == 0)
		{
			float soner_distance;
			// 1-1-1-1各座表値の計算
			this->create.doNormalMode(create_coord, wall_coord, soner_distance);
			// 1-1-1-2座標値の記録 → Map		
			this->map.push_back_CreatePointList( create_coord );	//createの現在座標を記録(プッシュバック)					
			if(soner_distance < RECORD_OBSTACLE_TH) // RECORD_OBSTACLE_TH 以上離れた障害物は記録しない
			{
				this->map.push_back_WallPointList( wall_coord ); // 障害物の座標を記録(プッシュバック)
			}
			this->create.run();
		}	
// 1-1-2.バンパセンサに衝突
		else if( bumper_hit != 0)
		{	
			// 1-1-2-1.現在座標とバンパーヒット座標を計算 & 方向転換 → Createクラスへ
			this->create.doBumperHitMode(bumper_hit, create_coord, wall_coord);

			// 1-1-2-2.座標値の記録 → Mapクラスへ
			this->map.push_back_CreatePointList( create_coord );	
			this->map.push_back_WallPointList( wall_coord );
		}
//1-2.メッシュの更新
		this->block.setMeshMark( create_coord, Bumper_Hit );

//1-3.壁探索終了の判定
		Coordinate start_coord;
		int total_distance = this->create.getTotalDistance();
		// 1個目ドッキング検知
		if(this->create.getTotalDistance() > 4000 && this->create.isDockFound() && !this->LinePointSet)
		{
			this->create.stopRun(); 	// 壁探索が終わったら、即Createを止める
std::cout << "2line point set!" << std::endl;
			std::vector<Coordinate> tmp_obstacle_list;
			std::vector<Coordinate> SOC_list;	// search obstacle create list 障害物を探索する時のcreateの座標値リスト

			this->map.set2LinePoint();	// 	2辺分の座標値をwall_point_list2に入れる
			this->output_WallList2();
//			this->showWall2();
			this->LinePointSet = true;

			tmp_obstacle_list = create.searchObstacle(SOC_list);	// 衝突した障害物の周りを回る
			for(int i=0;i<SOC_list.size();i++)
			{
				this->map.push_back_CreatePointList( SOC_list[i] );
				this->map.push_back_ObstaclePointList( SOC_list[i] );
			}
			this->search_flag = DOCK;
			this->showWall2();

		}
		else if(this->create.getTotalDistance() > 10000 && this->create.isDockFound()) // 2個目ドッキング検知
		{
			std::vector<Coordinate> tmp_obstacle_list;
			std::vector<Coordinate> SOC_list;	// search obstacle create list 障害物を探索する時のcreateの座標値リスト
			this->create.stopRun(); // 壁探索が終わったら、即Createを止める

			tmp_obstacle_list = create.searchObstacle(SOC_list);	// 衝突した障害物の周りを回る
			for(int i=0;i<SOC_list.size();i++)
			{
				this->map.push_back_CreatePointList( SOC_list[i] );
				this->map.push_back_ObstaclePointList( SOC_list[i] );
			}

std::cout << "Docking!" << std::endl;
			this->search_flag = DOCK;
		}

	}

//2.障害物探索
	else if(this->search_flag == OBSTACLE) // 障害物探索
	{

		int goal;
		std::vector<Coordinate> move_point_list;  // Createが辿る座標を格納したリスト
		std::vector<Coordinate> tmp_create_list;
		std::vector<Coordinate> tmp_obstacle_list;
		this->block.showMesh();

		bool Bumper = false;
// 2-1.createの現在座標を取得
		create_coord = this->create.getCurrentCoordinate();
// 2-2.createの現在座標から向かうメッシュを計算し、辿る座標リストを得る
		goal = this->block.getNextMeshNum();
		move_point_list = this->block.getMovePointList(create_coord, this->create.direction, goal);// → Createの現在座標を元に、ゴールまでに辿る座標のリストを得る
// 2-3.座標リスト通りに進む
		for(int i=0;i<move_point_list.size();i++)
		{
			// 2-3-1.次の座標値を渡して、移動し、各座表値の計算を行う
			this->create.runNextPoint(move_point_list[i], Bumper, tmp_create_list, tmp_obstacle_list);
			if(Bumper)	// runNextPoint()中に障害物に衝突したら
			{
				this->create.changeDirection();
				break;
#if 1
				std::vector<Coordinate> SOC_list;	// search obstacle create list 障害物を探索する時のcreateの座標値リスト
				Bumper = false;
				tmp_obstacle_list = create.searchObstacle(SOC_list);	// 衝突した障害物の周りを回る
				for(int i=0;i<tmp_obstacle_list.size();i++)
				{
					this->map.push_back_ObstaclePointList( tmp_obstacle_list[i] );
					this->block.setMeshMark(tmp_obstacle_list[i], true);
					//obstacle_list.push_back(tmp_obstacle_list[i]);
				}
				for(int i=0;i<SOC_list.size();i++)
				{
					this->map.push_back_CreatePointList( SOC_list[i] );
					this->block.setMeshMark(SOC_list[i], false);// 
					//create_list.push_back(create_coord[i]);
				}
#endif
			}
			// 2-3-2 移動後の座標値を渡して、メッシュを更新
			for(int j=0;j<tmp_create_list.size();j++)
			{
				this->block.setMeshMark(tmp_create_list[j], false);// 
			// 2-3-3各座表の情報を渡して、map,obstacleリストを更新
				this->map.push_back_CreatePointList( tmp_create_list[j] );
			}
			for(int j=0;j<tmp_obstacle_list.size();j++)
			{
//				this->block.setMeshMark(tmp_obstacle_list[j], true);// 
				this->map.push_back_ObstaclePointList( tmp_obstacle_list[j] );
			}
			this->block.showMesh();

		}
// 2-4.全部のメッシュをチェックし終えたかを判定
		if( !this->block.checkAllSearchEnd() )
		{
			this->search_flag = DOCK;

		}
	}

// 3.ドッキングステーションへゴール
	else if(this->search_flag == DOCK)
	{
		this->create.stopRun();
		runDemo(DEMO_COVER_AND_DOCK);
		this->finished = true;
		std::cout << "finished!" << std::endl;
	}



}