virtual bool onEvent(irr::ode::IIrrOdeEvent *pEvent) {
      if (g_pCamera && g_pCamera->handlesEvent(pEvent)) g_pCamera->onEvent(pEvent);

      if (pEvent->getType()==irr::ode::eIrrOdeEventLoadScene) {
        searchPlaneBodies(m_pDevice->getSceneManager()->getRootSceneNode());
        searchTankBodies (m_pDevice->getSceneManager()->getRootSceneNode());
        searchCarBodies  (m_pDevice->getSceneManager()->getRootSceneNode());
        searchHeliBodies (m_pDevice->getSceneManager()->getRootSceneNode());

        const c8 sForests[][255]={ "RandomForest1", "RandomForest2", "Forest1", "Forest2" };

        for (u32 i=0; i<2; i++) {
          printf("merging \"%s\"...\n",sForests[i]);
          irr::scene::ISceneManager *smgr=m_pDevice->getSceneManager();
          scene::ISceneNode *p=smgr->getSceneNodeFromName(sForests[i]);
          CRandomForest *pForest=(CRandomForest *)p;
          if (pForest!=NULL) {
            CMeshCombiner *pCombine=new CMeshCombiner(0.8f);
            irr::core::array<irr::scene::IMeshSceneNode *> aMeshSceneNodes;
            irr::core::array<irr::scene::ISceneNode *> aTrees=pForest->getGeneratedTrees();

            for (u32 j=0; j<aTrees.size(); j++) {
              irr::scene::IMeshSceneNode *p=(irr::scene::IMeshSceneNode *)aTrees[j];
              aMeshSceneNodes.push_back(p);
            }

            printf("%i trees\n",aMeshSceneNodes.size());

            if (aMeshSceneNodes.size()>0) {
              c8 s[0xFF];
              sprintf(s,"MyCombinedTrees_%i",i);
              irr::scene::IMesh *pCombined=pCombine->combineMeshes(smgr,m_pDevice->getVideoDriver(),aMeshSceneNodes,s);
              if (pCombined!=NULL) {
                irr::scene::ISceneNode *pRoot=smgr->getSceneNodeFromName(sForests[i+2]);
                irr::scene::IMeshSceneNode *pNode=smgr->addMeshSceneNode(pCombined,pRoot==NULL?smgr->getRootSceneNode():pRoot);
                for (u32 i=0; i<pNode->getMaterialCount(); i++) {
                  pNode->getMaterial(i).setFlag(irr::video::EMF_LIGHTING,false);
                  pNode->getMaterial(i).MaterialType=irr::video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF;
                }
              }
            }
          }
        }
        return true;
      }

      if (pEvent->getType()==irr::ode::eIrrOdeEventStep) {
        irr::core::list<CCockpitPlane *>::Iterator pit;
        for (pit = m_lPlaneCockpits.begin(); pit != m_lPlaneCockpits.end(); pit++) (*pit)->update();

        irr::core::list<CCockpitCar *>::Iterator cit;
        for (cit = m_lCarCockpits.begin(); cit != m_lCarCockpits.end(); cit++) (*cit)->update();

        if (g_pCamera) g_pCamera->update();
      }

      return false;
    }
bool
ProcGameIntro::OnRender(irr::IrrlichtDevice& device)
{	
	device.getVideoDriver()->beginScene(true, true, SColor(255,128,0,255));

	device.getSceneManager()->drawAll();
	device.getGUIEnvironment()->drawAll();

	device.getVideoDriver()->endScene();

	return true;
}
bool 
ProcGameIntro::OnInit(irr::IrrlichtDevice& device)
{	
	device.setWindowCaption(L"demo - game intro");


	// create camera	
	BaseCamera* pCamera = new BaseCamera(vector3df(0,0,0),
							 vector3df(0,0,-150),
							 10,
							 vector3df(0.08f, 0.08f, 0.08f),
							 10,
							 vector3df(10, 10, 10),
							 10,
							 vector3df(1, 1, 1),
							 10,
							 10);

	// background
	GameBackground* pBg = new GameBackground();

	// battle board
	BattleBoard* pBattleBoard = new BattleBoard(dimension2d<irr::s32>(10,10));

	// register entity
	EntityMgr.RegisterEntity(pCamera);
	EntityMgr.RegisterEntity(pBg);
	EntityMgr.RegisterEntity(pBattleBoard);
	//EntityMgr.RegisterEntity(pCard);

	return true;
}
Beispiel #4
0
bool
ProcGame::OnRender(irr::IrrlichtDevice& device)
{
    device.getVideoDriver()->beginScene(true, true, SColor(255,128,0,255));

    device.getSceneManager()->drawAll();
    device.getGUIEnvironment()->drawAll();

#ifdef AI_TEST_DISPLAY_INFO
    //add sk for AI
    EntityMgr.DrawExtraInfo();
    //end add sk for AI
#endif

    device.getVideoDriver()->endScene();

    return true;
}
Beispiel #5
0
bool
ProcTitle::OnExit(irr::IrrlichtDevice& device)
{	
	IGUIEnvironment* env = device.getGUIEnvironment();
	env->clear();

	// should I need to clear all texture here? 
	IVideoDriver* pDriver = IrrDvc.GetDriver();
	pDriver->removeAllTextures();

	return true;
}
bool 
ProcGameIntro::OnInit(irr::IrrlichtDevice& device)
{	
	device.setWindowCaption(L"I'm gonna show you folding map - game intro");

	BaseCamera* pCamera = null;
	NaviPlayer* pNaviPlayer = null;
	GameField* pGameField = null;
	GameField2nd* pGameField2nd = null;

	// create map
	pGameField = new GameField(dimension2d<s32>(5, 5), "Rsrc/map.bmp");
	pGameField2nd = new GameField2nd();

	// create player
	pNaviPlayer = new NaviPlayer(vector3df(5.f, 5.f, --g_gameIntrozOrder),
								 3.f,
								 vector3df(0.05f, 0.05f, 0.05f),
								 10.f, 
								 vector3df(10, 10, 10),
								 10.f, 
								 vector3df(10, 10, 10),
								 10.f, 
								 10.f);
	pNaviPlayer->SetCollisionType(BaseGameEntity::ENTITY_COLLISION_TYPE_NORMAL);
	pNaviPlayer->SetName("FugitivePlayer");

	// create camera
	vector3df camPos = pNaviPlayer->Pos();
	camPos.Z -= 50;
	pCamera = new BaseCamera(pNaviPlayer->Pos(),
							 camPos,
							 10,
							 vector3df(0.08f, 0.08f, 0.08f),
							 10,
							 vector3df(10, 10, 10),
							 10,
							 vector3df(1, 1, 1),
							 10,
							 10);
	pCamera->SetTargetEntityID(pNaviPlayer->ID());	

	// register entity
	EntityMgr.RegisterEntity(pCamera);
	EntityMgr.RegisterEntity(pGameField);
	EntityMgr.RegisterEntity(pGameField2nd);
	EntityMgr.RegisterEntity(pNaviPlayer);	

	return true;
}
Beispiel #7
0
bool 
ProcTitle::OnInit(irr::IrrlichtDevice& device)
{	
	device.setWindowCaption(L"Artistic Controlled Car - title");

	IGUIEnvironment* env = device.getGUIEnvironment();
	IGUIButton* pButton = env->addButton(rect<s32>(10, 240, 200, 240+100), 0, GUI_ID_START_BUTTON, L"Start", L"Start Game");
	pButton->setDrawBorder(false);
	IVideoDriver* pDriver = IrrDvc.GetDriver();
	video::ITexture* pTexture = pDriver->getTexture("Rsrc/hero.tga");	// refcount = 1
	pButton->setImage(pTexture);										// refcount += 2, means when button released refcount will be 1	
	pButton->setUseAlphaChannel(true);									// 1 will be decreased pDriver->removeAllTextures();

	{
		ITexture* pTexture = pDriver->getTexture("Rsrc/map.bmp");
		pButton->setPressedImage(pTexture);
	}

	// sound test
	IrrSnd.GetSndEngine()->play2D("Rsrc/getout.ogg", true);	

	return true;
}
Beispiel #8
0
bool 
ProcTitle::OnInit(irr::IrrlichtDevice& device)
{	
	device.setWindowCaption(L"Pair - title");
	//device.getCursorControl()->setVisible(false);

	u32 width = IrrDvc.GetDriver()->getScreenSize().Width;
	u32 height = IrrDvc.GetDriver()->getScreenSize().Height;

	scene::ISceneManager* pSmgr = IrrDvc.GetSmgr();
	IVideoDriver* pDriver = IrrDvc.GetDriver();

	// camera setting 
	{		
		irr::scene::ICameraSceneNode* pCamera = pSmgr->addCameraSceneNode(0, core::vector3df(0,0,-100), core::vector3df(0,0,0));		
		//f32 zNear = 1;
		//f32 zFar = 3000;
		//f32 zNear = pCamera->getNearValue();
		//f32 zFar = pCamera->getFarValue();
#if 0
		CMatrix4<f32> matOrtho;				
		matOrtho.buildProjectionMatrixOrthoLH(width, height, zNear, zFar);
		pCamera->setProjectionMatrix(matOrtho, true);
#else
		//CMatrix4<f32> matPerspective;
		//matPerspective.buildProjectionMatrixPerspectiveLH((f32)width, (f32)height, zNear, zFar);
		//pCamera->setProjectionMatrix(matPerspective, false);
#endif
	}

	// title
	{		
		m_p2DSprite = pSmgr->addBillboardSceneNode();
		video::ITexture* pTexture = pDriver->getTexture("Rsrc/title.png");		
		m_p2DSprite->setMaterialTexture(0, pTexture);
		m_p2DSprite->setMaterialFlag(video::EMF_LIGHTING, false);
		m_p2DSprite->setMaterialFlag(video::EMF_ZBUFFER, true);
		m_p2DSprite->setMaterialFlag(video::EMF_ZWRITE_ENABLE, false);
		m_p2DSprite->setMaterialFlag(video::EMF_ANTI_ALIASING, true);
		m_p2DSprite->setMaterialFlag(video::EMF_BILINEAR_FILTER, true);
		m_p2DSprite->setSize(dimension2df((f32)width, (f32)height));
		m_p2DSprite->setPosition(vector3df(0.f, 0.f, 300.f));
		m_p2DSprite->setID(1004);
		m_p2DSprite->getMaterial(0).getTextureMatrix(0).setTextureScale(1.0f, 1.0f);

		// animation test
		//scene::ISceneNodeAnimator* pAni = pSmgr->createFlyCircleAnimator(core::vector3df(0,0,200), 20.0f);
		//m_p2DSprite->addAnimator(pAni);
	}

	// card
	{
		for (int i = 0; i < 3; i++)
		{
			IMeshSceneNode* pCard = pSmgr->addCubeSceneNode();
			char buff[20];
			sprintf_s(buff, 20, "Rsrc/card%d.png", i);
			video::ITexture* pTexture = pDriver->getTexture(buff);			
			pCard->setMaterialTexture(0, pTexture);
			pCard->setScale(vector3df(4.f, 4.f * 1.618f, 0.1f));
			pCard->setPosition(vector3df(-60.f + 60.f * i, 0.f, 0.f));
			pCard->setMaterialFlag(video::EMF_LIGHTING, false);

			// animation test
			scene::ISceneNodeAnimator* pAni = pSmgr->createRotationAnimator(vector3df(0.f, 1.f, 0.f));
			pCard->addAnimator(pAni);
			pAni->drop();
		}
	}

	// mesh
	{
		IAnimatedMesh* mesh = pSmgr->getMesh("Rsrc/sydney.md2");
		IAnimatedMeshSceneNode* pNode = pSmgr->addAnimatedMeshSceneNode(mesh);
		if (pNode)
		{
			//pNode->setScale(vector3df(10.f, 10.f, 10.f));
			pNode->setMaterialFlag(EMF_LIGHTING, false);
			//pNode->setMaterialFlag(EMF_ZBUFFER, false);
			pNode->setMD2Animation(scene::EMAT_STAND);
			pNode->setMaterialTexture( 0, pDriver->getTexture("Rsrc/sydney.bmp") );
			pNode->setPosition(vector3df(0.0f, -5.f, -55.f));
		}
	}

	// button 
	{
		IGUIEnvironment* env = device.getGUIEnvironment();
		
		video::ITexture* pTexture = pDriver->getTexture("Rsrc/new_game_btn_normal.PNG");	// refcount = 1
		dimension2d<u32> dim = pTexture->getOriginalSize();
		s32 offsetX = width / 2 - dim.Width / 2;
		s32 offsetY = height - dim.Height * 3;
		IGUIButton* pButton = env->addButton(rect<s32>(offsetX, offsetY, offsetX + dim.Width, offsetY + dim.Height), 0, GUI_ID_START_BUTTON);
		pButton->setDrawBorder(false);		
		pButton->setImage(pTexture);										// refcount += 2, means when button released refcount will be 1	
		pButton->setUseAlphaChannel(true);									// 1 will be decreased pDriver->removeAllTextures();

		{
			ITexture* pTexture = pDriver->getTexture("Rsrc/new_game_btn_pressed.PNG");
			pButton->setPressedImage(pTexture);
		}
	}

	// sound test
	IrrSnd.GetSndEngine()->play2D("Rsrc/getout.ogg", true);

	return true;
}
Beispiel #9
0
bool
ProcGame::OnInit(irr::IrrlichtDevice& device)
{
    device.setWindowCaption(L"Catch me if you can - game");

    BaseCamera* pCamera;
    FugitivePlayer* pFugitive;

#ifdef MAKE_CHASERONE
    ChaserPlayer* pChaser;
#endif

#ifdef MAKE_CHASERFLOCK
    //ChaserPlayer* pChaserGroup[TEST_CHASER_PATROL];
    ChaserPlayer* pChaserFlock1[TEST_CHASER_FLOCKING];
    ChaserPlayer* pChaserFlock2[TEST_CHASER_FLOCKING2];
    //ChaserPlayer* pChaserFlock3;
#endif
    DummyObject*  pDummyObjBlocktile[TEST_DUMMY_BLOCK];

#ifdef MAKE_ZTUNNELTILE
    Ztunnel*      pZtunnelTile[TEST_ZTUNNEL_BLOCK];
#endif
    //BulletBasic* pBullet;
    GameField* pGameField;
    GameField2nd* pGameField2nd = null;

    // create map
    pGameField = new GameField(dimension2d<s32>(10, 10), "Rsrc/map.bmp");
    pGameField2nd = new GameField2nd();

    // create player
    pFugitive = new FugitivePlayer(vector3df(5.f, 5.f, --g_zOrder),
                                   3.f,
                                   vector3df(0.05f, 0.05f, 0.05f),
                                   10.f,
                                   vector3df(10, 10, 10),
                                   10.f,
                                   vector3df(10, 10, 10),
                                   10.f,
                                   10.f,
                                   pGameField->ID());
    pFugitive->SetCollisionType(BaseGameEntity::ENTITY_COLLISION_TYPE_NORMAL);
    pFugitive->SetName("FugitivePlayer");

    // create camera
    vector3df camPos = pFugitive->Pos();
    camPos.Z -= 50;
    pCamera = new BaseCamera(pFugitive->Pos(),
                             camPos,
                             10,
                             vector3df(0.08f, 0.08f, 0.08f),
                             10,
                             vector3df(10, 10, 10),
                             10,
                             vector3df(1, 1, 1),
                             10,
                             10);
    pCamera->SetTargetEntityID(pFugitive->ID());

    // sk
#ifdef MAKE_CHASERONE
    pChaser = new ChaserPlayer(vector3df(20, 10, --g_zOrder),
                               3,
                               vector3df(0, 0, 0),
                               10,
                               vector3df(10, 10, 10),
                               10,
                               vector3df(10, 10, 10),
                               10,
                               10);
    pChaser->SetCollisionType(BaseGameEntity::ENTITY_COLLISION_TYPE_NORMAL);
    pChaser->SetName("ChaserPlayer");
#endif
    /*
    pBullet = new BulletBasic(vector3df(25, 10, 0),
    						  10,
    						  vector3df(10.0f, 0, 0),
    						  10,
    						  vector3df(10, 10, 10),
    						  10,
    						  vector3df(10, 10, 10),
    						  10,
    						  10,
    						  BULLET_STATE_MOVE);
    */
    // test patrol
    /*for (int i=0;i<TEST_CHASER_PATROL;i++)
    {
    	m_pChaserGroup[i] = new ChaserPlayer(vector3df(20+(i*10), 20+(i*5), 0),
    							 10,
    							 vector3df(0, 0, 0),
    							 10,
    							 vector3df(10, 10, 10),
    							 10,
    							 vector3df(10, 10, 10),
    							 10,
    							 10);
    }*/

#ifdef MAKE_CHASERFLOCK
    for(int i=0; i<TEST_CHASER_FLOCKING; i++)
    {
        pChaserFlock1[i] = new ChaserPlayer(vector3df(20.f+(i*10), 70.f+(i*5), --g_zOrder),
                                            4,
                                            vector3df(0, 0, 0),
                                            10,
                                            vector3df(0.5f, -0.5f, 0.0f),
                                            10,
                                            vector3df(10, 10, 10),
                                            10,
                                            10,
                                            CHASWER_STATE_ROAMSTATE,//CHASWER_STATE_STARTPATROL,//CHASWER_STATE_CHASERGROUPSTATE,
                                            1);
        pChaserFlock1[i]->SetCollisionType(BaseGameEntity::ENTITY_COLLISION_TYPE_NORMAL);
        //FirstFlockChaser.m_Flocklist.push_back(m_pChaserFlock1[i]);
    }

    ////주인공을 쫓는 그룹
    for (int i = 0; i < 2; i++)
    {
        for (int j = 0; j < 5; j++)
        {
            pChaserFlock2[j+(i*5)] = new ChaserPlayer(vector3df(80.f+(j*10), 90.f+(i*10), --g_zOrder),
                    4,
                    vector3df(0, 0, 0),
                    10,
                    vector3df(-0.5f, -0.5f, 0.0f),
                    10,
                    vector3df(10, 10, 10),
                    10,
                    10,
                    CHASWER_STATE_CHASERGROUPSTATE,
                    2);
            pChaserFlock2[j+(i*5)]->SetCollisionType(BaseGameEntity::ENTITY_COLLISION_TYPE_NORMAL);
            pChaserFlock2[j+(i*5)]->SetName("Chaser");
            //FirstFlockChaser.m_Flocklist.push_back(m_pChaserFlock2[i]);
        }
    }
#endif
//	pChaserFlock3 = new ChaserPlayer(vector3df(30, 80, --g_zOrder),
//							 10,
//							 vector3df(0, 0, 0),
//							 10,
//							 vector3df(-0.5f, -0.5f, 0.0f),
//							 10,
//							 vector3df(10, 10, 10),
//							 10,
//							 10,
//							 CHASWER_STATE_ROAMSTATE,
//							 3);
//*/
    pDummyObjBlocktile[0] = new DummyObject(vector3df(85, 15, --g_zOrder),
                                            10,
                                            vector3df(0, 0, 0),
                                            10,
                                            vector3df(-0.5f, -0.5f, 0.0f),
                                            10,
                                            vector3df(10, 10, 10),
                                            10,
                                            10,
                                            DUMMY_STATE_IDLECHASER,
                                            4);
    pDummyObjBlocktile[1] = new DummyObject(vector3df(35, 55, --g_zOrder),
                                            10,
                                            vector3df(0, 0, 0),
                                            10,
                                            vector3df(-0.5f, -0.5f, 0.0f),
                                            10,
                                            vector3df(10, 10, 10),
                                            10,
                                            10,
                                            DUMMY_STATE_IDLECHASER,
                                            4);
    pDummyObjBlocktile[2] = new DummyObject(vector3df(55, 35, --g_zOrder),
                                            10,
                                            vector3df(0, 0, 0),
                                            10,
                                            vector3df(-0.5f, -0.5f, 0.0f),
                                            10,
                                            vector3df(10, 10, 10),
                                            10,
                                            10,
                                            DUMMY_STATE_IDLECHASER,
                                            4);
    pDummyObjBlocktile[3] = new DummyObject(vector3df(55, 55, --g_zOrder),
                                            10,
                                            vector3df(0, 0, 0),
                                            10,
                                            vector3df(-0.5f, -0.5f, 0.0f),
                                            10,
                                            vector3df(10, 10, 10),
                                            10,
                                            10,
                                            DUMMY_STATE_IDLECHASER,
                                            4);

#ifdef MAKE_ZTUNNELTILE
    pZtunnelTile[0] = new Ztunnel(vector3df(75, 75, --g_zOrder),
                                  10,
                                  vector3df(0, 0, 0),
                                  10,
                                  vector3df(-0.5f, -0.5f, 0.0f),
                                  10,
                                  vector3df(10, 10, 10),
                                  10,
                                  10,
                                  ZTUNNEL_STATE_IDLE,
                                  4,
                                  pBlackBoard);

    //end sk
#endif
    // register entity
    EntityMgr.RegisterEntity(pCamera);
    EntityMgr.RegisterEntity(pGameField);
    EntityMgr.RegisterEntity(pGameField2nd);
    EntityMgr.RegisterEntity(pFugitive);
    EntityMgr.RegisterEntity(100, pFugitive);
#ifdef MAKE_CHASERONE
    EntityMgr.RegisterEntity(pChaser);
#endif
    //EntityMgr.RegisterEntity(pBullet);
    EntityMgr.RegisterEntity(pDummyObjBlocktile[0]);
    EntityMgr.RegisterEntity(pDummyObjBlocktile[1]);
    EntityMgr.RegisterEntity(pDummyObjBlocktile[2]);
    EntityMgr.RegisterEntity(pDummyObjBlocktile[3]);
#ifdef MAKE_ZTUNNELTILE
    EntityMgr.RegisterEntity(pZtunnelTile[0]);
#endif

#ifdef MAKE_CHASERFLOCK
    for(int i=0; i<TEST_CHASER_FLOCKING; i++)
    {
        EntityMgr.RegisterEntity(pChaserFlock1[i]);
        EntityMgr.RegisterEntity(1, pChaserFlock1[i]);
    }

    for (int i = 0; i < 2; i++)
    {
        for (int j = 0; j < 5; j++)
        {
            EntityMgr.RegisterEntity(pChaserFlock2[j+(i*5)]);
            EntityMgr.RegisterEntity(2, pChaserFlock2[j+(i*5)]);//test code 지금은 그냥 1로 나중에 인자로 처리
        }
    }
#endif
//	EntityMgr.RegisterEntity(pChaserFlock3);

    //임시로 추가한 코드
    //scene::ISceneManager* pSmgr = IrrDvc.GetSmgr();
    //m_pSceneNode = new TerritorySceneNode(pSmgr->getRootSceneNode(), pSmgr, ID(), this);
    //new DarkShadowsSceneNode(pSmgr->getRootSceneNode(), pSmgr);

    return true;
}