// ---------------------------------------------------------------------------- Track::Track(f32 tx, f32 tz) { ISceneManager* sm = Editor::getEditor()->getSceneManager(); m_terrain = new Terrain(sm->getRootSceneNode(), sm, 1, tx, tz, min_(2 * ((s32) tx),200), min_(2 * ((s32) tz),200)); ISpline* spline = new TCR(sm->getRootSceneNode(), sm, 0); m_driveline = new DriveLine(sm->getRootSceneNode(), sm, 0, spline, L"DriveLine"); m_roads.push_back(m_driveline); m_music = "Origin.music"; m_valid = true; } // Track
int main() { IrrlichtDevice* irrDevice = createDevice(EDT_OPENGL,dimension2d<s32>(800,600),32,false,false,false,0); IVideoDriver* irrVideo = irrDevice->getVideoDriver(); ISceneManager* irrSceneMgr = irrDevice->getSceneManager(); TMovie* movie = new TMovie(irrDevice->getTimer()); movie->LoadMovie("Mymovie.avi"); irrVideo->setTextureCreationFlag(ETCF_CREATE_MIP_MAPS, false); u32 w = movie->getMovieWidth(); u32 h = movie->getMovieHeight(); ITexture* movTxtr = irrVideo->addTexture(dimension2d<s32>(w<513?512:1024,h<513?512:1024),"imovie"); irrSceneMgr->addCameraSceneNode(0, vector3df(0,0,-20), vector3df(0,0,0)); CSampleSceneNode* myNode = new CSampleSceneNode(irrSceneMgr->getRootSceneNode(), irrSceneMgr, 666); myNode->setMaterialTexture( 0, movTxtr); myNode->drop(); ISceneNodeAnimator* anim = irrSceneMgr->createRotationAnimator(vector3df(0,0.1f,0)); myNode->addAnimator(anim); anim->drop(); while(irrDevice->run()) { irrVideo->beginScene(true, true, SColor(0,200,200,200)); if (movie->NextMovieFrame()) movie->DrawMovie(0,0,movTxtr); irrSceneMgr->drawAll(); irrVideo->endScene(); } irrDevice->drop(); return 0; }
CWayPoint::CWayPoint() { m_objectType = CGameObject::WaypointObject; m_next = NULL; m_back = NULL; m_timeWait = 0; ISceneManager *smgr = getIView()->getSceneMgr(); // init waypoint mesh //CColladaMeshComponent *comp = new CColladaMeshComponent( this ); //comp->loadFromFile( getIView()->getPath("data/editor/waypoint.dae") ); //addComponent( comp ); //setLighting( false ); m_node = new CGameBoxSceneNode(this, 5, smgr->getRootSceneNode(), smgr, (s32)m_objectID); m_node->getMaterial(0).Lighting = true; #ifdef GSEDITOR setVisible ( true ); // add collision ITriangleSelector *selector = smgr->createTriangleSelectorFromBoundingBox( m_node ); m_node->setTriangleSelector(selector); selector->drop(); #else setVisible ( false ); #endif }
int example_customscenenode() { // create device IrrlichtDevice *device = startup(); if (device == 0) return 1; // could not create selected driver. // create engine and camera EventReceiver_basic receiver(device); device->setEventReceiver(&receiver); IVideoDriver* driver = device->getVideoDriver(); ISceneManager* smgr = device->getSceneManager(); IGUIEnvironment* guienv = device->getGUIEnvironment(); smgr->addCameraSceneNode(0, vector3df(0, -40, 0), vector3df(0, 0, 0)); CSampleSceneNode *myNode = new CSampleSceneNode(smgr->getRootSceneNode(), smgr, 666); ISceneNodeAnimator* anim = smgr->createRotationAnimator(vector3df(0.8f, 0, 0.8f)); if (anim) { myNode->addAnimator(anim); anim->drop(); anim = 0; // As I shouldn't refer to it again, ensure that I can't } myNode->drop(); myNode = 0; // As I shouldn't refer to it again, ensure that I can't return run(device); }
DummyObject::DummyObject(vector3df position, double radius, vector3df velocity, double maxSpeed, vector3df heading, double mass, vector3df scale, double turnRate, double maxForce, DUMMY_OBJECT_TYPE initState, u32 groupID) : BasePlayer(position, radius, velocity, maxSpeed, heading, mass, scale, turnRate, maxForce, PLAYER_ROLE_DUMMY) { m_pStateMachine = new StateMachine<DummyObject>(this); // start from idle state m_pStateMachine->SetCurrentState(IdleDummy::Instance()); // get ready sprite #if USE_BILL_BOARD_SPRITE ISceneManager* pSmgr = IrrDevice::GetInstance().GetSmgr(); m_p2DSprite = new BillBoard(pSmgr->getRootSceneNode(), pSmgr, 300); m_p2DSprite->setMaterialType(video::EMT_TRANSPARENT_ALPHA_CHANNEL); ITexture* pTexture = IrrDevice::GetInstance().GetDriver()->getTexture("Rsrc/hero.bmp"); m_p2DSprite->setMaterialTexture(0, pTexture); m_p2DSprite->setMaterialFlag(video::EMF_LIGHTING, false); m_p2DSprite->setMaterialFlag(video::EMF_ZBUFFER, false); m_p2DSprite->setPosition(position); m_p2DSprite->setID(0); m_p2DSprite->getMaterial(0).getTextureMatrix(0).setTextureScale(0.5f,0.5f); #else ISceneManager* pSmgr = IrrDvc.GetSmgr(); IVideoDriver* pDriver = IrrDvc.GetDriver(); m_p2DSprite = pSmgr->addBillboardSceneNode(); m_p2DSprite->setMaterialType(video::EMT_TRANSPARENT_ALPHA_CHANNEL); //video::ITexture* pTexture = pDriver->getTexture("Rsrc/bullet.tga"); video::ITexture* pTexture = pDriver->getTexture("Rsrc/z_tunnel2.tga"); pTexture->grab(); 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, true); //m_p2DSprite->setSize(dimension2df(scale.X, scale.Y)); m_p2DSprite->setPosition(position); m_p2DSprite->setID(ID()); // m_p2DSprite->getMaterial(0).getTextureMatrix(0).setTextureScale(0.5f,0.5f); m_initState = initState; //patrol¿¡ »ç¿ëµÉ µ¥ÀÌŸ ÃßÈÄ ·¹º§ µðÀÚÀÎµÈ ½ºÅ©¸³Æ®¿¡ ÀÇÇØ ™VÆõǵµ·Ï ¼öÁ¤¿ä //ÇöÀç MoviingEntity ¿Í º¯¼ö ¿¬°áÀº ³ªÁß¿¡ AI Å×½ºÆ®¸¦ À§ÇØ Àӽ÷Π¸¸µê. m_fSpeed = 30.0f; m_bDirection=true; m_3dfStart = this->Pos()-vector3df(30.0f,0.0f,0.0f); m_3dfDest= this->Pos()+vector3df(30.0f,0.0f,0.0f); #endif // add into entity mamager m_uGroupID = groupID; //EntityMgr.RegisterEntity(m_uGroupID,this);//test code Áö±ÝÀº ±×³É 1·Î ³ªÁß¿¡ ÀÎÀڷΠó¸® }
FugitivePlayer::FugitivePlayer(vector3df position, f64 radius, vector3df velocity, f64 maxSpeed, vector3df heading, f64 mass, vector3df scale, f64 turnRate, f64 maxForce, s32 gameFieldID) : BasePlayer(position, radius, velocity, maxSpeed, heading, mass, scale, turnRate, maxForce, PLAYER_ROLE_CHASER), m_gameFieldID(gameFieldID), m_pRushLine(null) { // m_patrolPoints.clear(); // get ready state machine m_pStateMachine = new StateMachine<FugitivePlayer>(this); // start from nothing m_pStateMachine->ChangeState(IdleFugitive::Instance()); // get ready sprite ISceneManager* pSmgr = IrrDvc.GetSmgr(); IVideoDriver* pDriver = IrrDvc.GetDriver(); m_p2DSprite = pSmgr->addBillboardSceneNode(); m_p2DSprite->setMaterialType(video::EMT_TRANSPARENT_ALPHA_CHANNEL); video::ITexture* pTexture = pDriver->getTexture("Rsrc/hero.tga"); // shkim, TODO. // why should I grap this texture here? as a result, get(+1)->grab(+1)->drop(-1) will give reference count as 1. // that means nobody know when I release texture after using at all. how do I figure it out? // answer is, keeping texture resource during Proc life time. it means loading texture at Proc initializing time and releasing them at Proc releasing time. // for doing that, need to use grab/drop pair after getTexture() pTexture->grab(); 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, true); m_p2DSprite->setSize(dimension2df(scale.X, scale.Y)); m_p2DSprite->setPosition(position); m_p2DSprite->setID(ID()); m_p2DSprite->getMaterial(0).getTextureMatrix(0).setTextureScale(0.5f,0.5f); m_p2DSprite->getMaterial(0).getTextureMatrix(0).setTextureTranslate(0.f,0.5f); // 3th sprite // rush line scene node m_pRushLine = new RushLineSceneNode(pSmgr->getRootSceneNode(), pSmgr, ID(), this); // set weapon m_pWeapon[0] = new Pistol_Basic; m_pWeapon[1] = new Mechine_Gun; m_nCurrentWeaponNum = 0; // center point(player pos) in screen coordinates for getting shooting direction m_uPosinScreenCoord.X =(u32)(IrrDvc.GetDevice()->getVideoDriver()->getScreenSize().Width * 0.5f); m_uPosinScreenCoord.Y =(u32)(IrrDvc.GetDevice()->getVideoDriver()->getScreenSize().Height * 0.5f); }
// newDocument // new 3d scene document void CDocument::newDocument() { ISceneManager *smgr = getIView()->getSceneMgr(); IrrlichtDevice *device = getIView()->getDevice(); // clear all history CHistoryManager::getInstance()->clearAll(); // create design camera m_designCamera = new CGameCamera(); m_designCamera->setName( L"Design camera" ); m_designCamera->setTarget(core::vector3df(300,100,300)); m_designCamera->setPosition( core::vector3df(0, 200, 0) ); getIView()->setActiveCamera( m_designCamera ); // add oxyz plane node CGameOxyzSceneNode *oxyPlane = new CGameOxyzSceneNode( smgr->getRootSceneNode(), smgr, 1 ); m_gridNode = oxyPlane; // add light ISceneNode* pNode = smgr->addEmptySceneNode(); // default light smgr->setAmbientLight( video::SColorf(0.2f, 0.2f, 0.2f ,1.0f) ); //ILightSceneNode *light = smgr->addLightSceneNode( pNode, core::vector3df(0, 0, 0) ); //light->setLightType( video::ELT_DIRECTIONAL ); // reset file path m_filePath = L""; // begin id CGameObject::s_objectID = 1; // add root const WCHAR *lpRootName = L"level"; uiTreeView *pTreeview = getIView()->getDocumentTreeView(); m_treeViewRoot = pTreeview->addItem( (WCHAR*)lpRootName ); // create a zone CZone *pZone = (CZone*)createZone(); getIView()->setCurrentZone( pZone ); getIView()->setObjectProperty( pZone ); m_treeViewRoot->expandChild( true ); // register draw all template obj if ( s_isFirstDocument == true ) { CObjTemplateFactory::registerDrawAllTemplateObject(); s_isFirstDocument = false; } // have 1 zone m_totalObjects = 1; }
void CreateCamera(int width, int height, vector3df position, vector3df target) { //Build camera ISceneManager* sm = g_GameGraph->GetSceneManager(); WorldState* worldState = static_cast<WorldState*> (g_GameGraph->GetWorldState()); HexMap* hm = worldState->GetCurrentMap(); if (NULL != sm) { if (NULL != hm) { ICameraSceneNode* orthoCam = sm->addCameraSceneNode( sm->getRootSceneNode(), position, target); matrix4 projMat; projMat.buildProjectionMatrixOrthoLH(width, height, -5, 5); orthoCam->setProjectionMatrix(projMat, true); orthoCam->bindTargetAndRotation(true); if (orthoCam->isOrthogonal()) { CameraAnimator* cameraAnim = new CameraAnimator(position, width, height, hm->GetMapDimensions().Height, hm->GetMapDimensions().Width, worldState->GetHero(), hm->GetCoordinateTranslator()); orthoCam->addAnimator(cameraAnim); cameraAnim->drop(); cameraAnim = NULL; if (width > height) { LOGI("Creating a landscape camera."); landscapeCamera = orthoCam; } else { LOGI("Creating a portrait camera"); portraitCamera = orthoCam; } } else { LOGE("The created camera is not orthoganol, something is wrong with the perspective matrix."); } } else { LOGE("The hex map created in the WorldState is NULL."); } } else { LOGE("The scene manager cannot be loaded from the device."); } }
// ---------------------------------------------------------------------------- IRoad::IRoad(ISceneNode* parent, ISceneManager* mgr, s32 id, FILE* fp) :ISceneNode(parent, mgr, id) { u8 size; c8* cc; fread(&size, sizeof(u8), 1, fp); if (size > 40) { m_valid = false; return; } cc = new c8[size]; fread(cc, sizeof(c8), size, fp); setName(cc); delete[] cc; fread(&m_closed, sizeof(bool), 1, fp); fread(&m_detail, sizeof(f32), 1, fp); fread(&m_width, sizeof(f32), 1, fp); if ( m_detail < 0 || m_width < 0 || m_detail > MAX_DETAIL || m_width > MAX_WIDTH) { m_valid = false; return; } stringw type; wchar_t* c; fread(&size, sizeof(u8), 1, fp); c = new wchar_t[size]; fread(c, sizeof(wchar_t), size, fp); type = c; delete[] c; ISceneManager* sm = Editor::getEditor()->getSceneManager(); if (type == L"TCR") m_spline = new TCR(sm->getRootSceneNode(), sm, 0, fp); else m_spline = new Bezier(sm->getRootSceneNode(), sm, 0, fp); setAutomaticCulling(EAC_OFF); m_valid = m_spline->isValid(); } // IRoad
// ---------------------------------------------------------------------------- void Track::createRoad(stringw type, stringw name) { // Viewport::get()->setState(Viewport::SELECT); IRoad* rm; ISceneManager* sm = Editor::getEditor()->getSceneManager(); ISpline* spline; if (type == L"Bezier") { spline = new Bezier(sm->getRootSceneNode(), sm, 0); } else spline = new TCR(sm->getRootSceneNode(), sm, 0); rm = new Road(sm->getRootSceneNode(), sm, 0, spline, name); Viewport::get()->roadBorn(rm); m_roads.push_back(rm); } // createRoad
void CIrrWindow::initScene() { IVideoDriver* driver = m_driver; IrrlichtDevice* device = m_device; ISceneManager* smgr = m_smgr; // create texture manager CTextureManager::createGetInstance(); // create design camera m_designCamera = new CGameCamera(); m_designCamera->setName( L"Design camera" ); m_designCamera->setTarget(core::vector3df(0,0,0)); m_designCamera->setPosition( core::vector3df(-400, 200, -400) ); // set active camera getIView()->setActiveCamera( m_designCamera ); // add oxyz plane node CGameOxyzSceneNode *oxyPlane = new CGameOxyzSceneNode( smgr->getRootSceneNode(), smgr, 1 ); oxyPlane->drop(); // add light ISceneNode* pNode = smgr->addEmptySceneNode(); // default light ILightSceneNode *light = smgr->addLightSceneNode( pNode, core::vector3df(0, 0, 0) ); light->setLightType( video::ELT_DIRECTIONAL ); // add demo particle m_particleObject = new CGameObject(); CParticleComponent *particleComp = new CParticleComponent(m_particleObject); particleComp->initParticle(); m_particleObject->m_components.push_back( particleComp ); }
// ---------------------------------------------------------------------------- Track::Track(path file) { m_valid = true; FILE* pFile; pFile = fopen(file.c_str(), "rb"); if (!pFile) { m_valid = false; stringw emsg = _("Editor failed to open file:\n \""); emsg += file; emsg += "\""; MsgWndw::get()->showMsg(emsg); return; } // SIGN u64 sign; fread(&sign, sizeof(u64), 1, pFile); if (sign != TOP_SECRET_SIGNATURE_NUMBER) { MsgWndw::get()->showMsg(_("File can not be opened: signature failed.")); m_valid = false; fclose(pFile); return; } // TRACK NAME u8 size; wchar_t* c; fread(&size, sizeof(u8), 1, pFile); if (!Editor::isValidSize(size)) { fclose(pFile); m_valid = false; MsgWndw::get()->showMsg(_("File loading failed!")); return; } c = new wchar_t[size]; fread(c, sizeof(wchar_t), size, pFile); m_track_name = c; delete[] c; // DESIGNER NAME fread(&size, sizeof(u8), 1, pFile); if (!Editor::isValidSize(size)) { fclose(pFile); m_valid = false; MsgWndw::get()->showMsg(_("File loading failed!")); return; } c = new wchar_t[size]; fread(c, sizeof(wchar_t), size, pFile); m_designer = c; delete[] c; // FILE NAME c8* cc; fread(&size, sizeof(u8), 1, pFile); if (!Editor::isValidSize(size)) { fclose(pFile); m_valid = false; MsgWndw::get()->showMsg(_("File loading failed!")); return; } cc = new c8[size]; fread(cc, sizeof(c8), size, pFile); m_file_name = cc; delete[] cc; // MUSIC fread(&size, sizeof(u8), 1, pFile); if (!Editor::isValidSize(size)) { fclose(pFile); m_valid = false; MsgWndw::get()->showMsg(_("File loading failed!")); return; } cc = new c8[size]; fread(cc, sizeof(c8), size, pFile); m_music = cc; delete[] cc; // TERRAIN ISceneManager* sm = Editor::getEditor()->getSceneManager(); m_terrain = new Terrain(sm->getRootSceneNode(), sm, 1, pFile); if (!m_terrain->isValid()) { fclose(pFile); MsgWndw::get()->showMsg(_("Loading failed :invalid terrain!")); m_valid = false; return; } // SKY Sky* s = Viewport::get()->getSky(); delete s; s = new Sky(pFile); Viewport::get()->setSky(s); // GRAVITY ROAD FLAG fread(&m_gravity_road, sizeof(bool), 1, pFile); // ROADS IRoad* r; fread(&size, sizeof(u8), 1, pFile); if (size < 0 || size > MAX_ROAD_NUM) { MsgWndw::get()->showMsg(_("Loading failed: invalid terrain!")); } else { if (size > 0) { m_driveline = new DriveLine(sm->getRootSceneNode(), sm, 0, pFile); if (!m_driveline->isValid()) { std::cerr << _("Warning: invalid driveline!\n"); ISpline* spline = new TCR(sm->getRootSceneNode(), sm, 0); m_driveline = new DriveLine(sm->getRootSceneNode(), sm, 0, spline, L"DriveLine"); } m_roads.push_back(m_driveline); m_driveline->refresh(); } // driveline for (u8 i = 1; i < size; i++) { r = new Road(sm->getRootSceneNode(), sm, 0, pFile); if (r->isValid()) { m_roads.push_back(r); r->refresh(); r->setWireFrame(false); Viewport::get()->setSplineMode(false); } else std::cerr << "Warning: invalid road - skipped :(\n"; } // roads } // valid roadnum // CHECKLINES Viewport::get()->loadCheckLines(pFile); // OBJECTS u32 num; fread(&num, sizeof(u32), 1, pFile); Viewport::setLastEntityID(num + MAGIC_NUMBER); for (u32 i = 0; i < num; i++) { ISceneNode* node = 0; vector3df pos, rot, sca; fread(&pos, sizeof(vector3df), 1, pFile); fread(&rot, sizeof(vector3df), 1, pFile); fread(&sca, sizeof(vector3df), 1, pFile); u8 size; fread(&size, sizeof(u8), 1, pFile); if (!Editor::isValidSize(size)) { m_valid = false; MsgWndw::get()->showMsg(_("Loading failed!")); fclose(pFile); return; } c8 *name = new c8[size]; fread(name, sizeof(c8), size, pFile); path p = name; if (p == path("banana") || p == path("item") || p == path("small-nitro") || p == path("big-nitro")) { node = loadItem(name); } // item else { node = sm->addAnimatedMeshSceneNode(sm->getMesh(p)); node->setName(name); } // object if (node) { node->setPosition(pos); node->setRotation(rot); node->setScale(sca); node->setID(MAGIC_NUMBER + i + 1); } // valid node else { std::cerr << "Warning: couldn't load object < " << name << " >!\n"; num -= 1; i -= 1; } // invalid node delete[] name; } fclose(pFile); } // Track - from file
GLbody *GLscene::addBody(OpenHRP::BodyInfo_var i_binfo) { ISceneManager* smgr = m_device->getSceneManager(); return new GLbody(smgr->getRootSceneNode(), smgr, -1, i_binfo); }
int main() { int idCenario = 0; int quadId; vector3df p1, p2, p3, p4; SMatrix mtxCenario; CArquivoMatrizes *_fileMtx = new CArquivoMatrizes(); CSampleSceneNode *myQuad[2500]; CGerEventos eventos; IrrlichtDevice *device = createDevice(EDT_OPENGL, dimension2d<s32>(800, 600), 16, false,false,false, &eventos); device->setWindowCaption(L"Editor de matrizes - Warbugs"); IVideoDriver* driver = device->getVideoDriver(); ISceneManager* smgr = device->getSceneManager(); smgr->addCameraSceneNodeFPS(); //smgr->addCameraSceneNode(0, vector3df(0,100,0), vector3df(0,0,0)); smgr->loadScene(pathCenario[idCenario]); mtxCenario = _fileMtx->getMatrix(idCenario); ITerrainSceneNode *sceneTerrain = (ITerrainSceneNode*)smgr->getSceneNodeFromType(ESNT_TERRAIN, 0); ITriangleSelector *sceneTris = smgr->createTerrainTriangleSelector(sceneTerrain, 0); sceneTerrain->setTriangleSelector(sceneTris); for(int i=0; i<50; i++) // z { for(int j=0; j<50;j++) // x { //if( //{ p1.X = 10.0; p1.Y = 1.0; p1.Z = 0.0; p2.X = 10.0; p2.Y = 1.0; p2.Z = 500.0; p3.X = 0.0; p3.Y = 1.0; p3.Z = 500.0; p4.X = 0.0; p4.Y = 1.0; p4.Z = 0.0; quadId = j + (i * 10); myQuad[quadId] = new CSampleSceneNode(smgr->getRootSceneNode(), smgr, quadId, p1, p2, p3, p4); //} } } while(device->run()) { driver->beginScene(true, true, SColor(0,100,100,100)); smgr->drawAll(); driver->endScene(); } device->drop(); return 0; }
Ztunnel::Ztunnel(vector3df position, double radius, irr::core::vector3df velocity, double maxSpeed, irr::core::vector3df heading, double mass, irr::core::vector3df scale, double turnRate, double maxForce, ZTUNNEL_TYPE initState, u32 groupID, BlackBoard* pbb) : BasePlayer(position, radius, velocity, maxSpeed, heading, mass, scale, turnRate, maxForce, PLAYER_ROLE_DUMMY) { m_pStateMachine = new StateMachine<Ztunnel>(this); // start from idle state m_pStateMachine->SetCurrentState(IdleZtunnel::Instance()); // get ready sprite #if USE_BILL_BOARD_SPRITE ISceneManager* pSmgr = IrrDevice::GetInstance().GetSmgr(); m_p2DSprite = new BillBoard(pSmgr->getRootSceneNode(), pSmgr, 300); m_p2DSprite->setMaterialType(video::EMT_TRANSPARENT_ALPHA_CHANNEL); ITexture* pTexture = IrrDevice::GetInstance().GetDriver()->getTexture("Rsrc/hero.bmp"); m_p2DSprite->setMaterialTexture(0, pTexture); m_p2DSprite->setMaterialFlag(video::EMF_LIGHTING, false); m_p2DSprite->setMaterialFlag(video::EMF_ZBUFFER, false); m_p2DSprite->setPosition(position); m_p2DSprite->setID(0); m_p2DSprite->getMaterial(0).getTextureMatrix(0).setTextureScale(0.5f,0.5f); #else ISceneManager* pSmgr = IrrDvc.GetSmgr(); IVideoDriver* pDriver = IrrDvc.GetDriver(); m_p2DSprite = pSmgr->addBillboardSceneNode(); m_p2DSprite->setMaterialType(video::EMT_TRANSPARENT_ALPHA_CHANNEL); //video::ITexture* pTexture = pDriver->getTexture("Rsrc/bullet.tga"); video::ITexture* pTexture = pDriver->getTexture("Rsrc/z_tunnel2.tga"); pTexture->grab(); 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, true); //m_p2DSprite->setSize(dimension2df(scale.X, scale.Y)); m_p2DSprite->setPosition(position); m_p2DSprite->setID(ID()); // m_p2DSprite->getMaterial(0).getTextureMatrix(0).setTextureScale(0.5f,0.5f); m_initState = initState; #endif // add into entity mamager m_uGroupID = groupID; //EntityMgr.RegisterEntity(m_uGroupID,this);//test code 지금은 그냥 1로 나중에 인자로 처리 //create skill CreateBasicZSkill* pcreatebasicZskill = new CreateBasicZSkill("CreateBasicZ", this, 0.5);//name,baseplayer, prof skills.insert(pair<std::string,Skill*>(pcreatebasicZskill->getName(), pcreatebasicZskill)); //create mission pBlacBoard = pbb; Mission mission("CreateBasicZ",1,1); defendmezombieCreateMission = mission; pBlacBoard->addMission(defendmezombieCreateMission); }
//When our engine is called up int main(int argc, char* argv[]) { //This is all that's needed to initialize the engine ... blahaha irrEngineManager *Manager = new irrEngineManager(); IrrlichtDevice *Device = Manager->getDevice(); ISceneManager *Smgr = Device->getSceneManager(); IVideoDriver *Video = Device->getVideoDriver(); irrBulletWorld *World = Manager->getBulletWorld(); ISoundEngine *Sound = Manager->getSoundEngine(); IGUIEnvironment *Gui = Device->getGUIEnvironment(); ICursorControl *cursor = Device->getCursorControl(); World->setGravity(vector3df(0,-100,0)); Manager->setWindowCaption(L"irrEngine"); Device->getFileSystem()->addZipFileArchive("map-20kdm2.pk3"); //Scene Begin CStaticProp *prop = new CStaticProp(Device, World, Smgr->getMesh("20kdm2.bsp")->getMesh(0)); // CGUIButton *button = new CGUIButton(Device); // button->setRelativePosition(vector2df(720, 450)); // button->setPosition(vector2df(720, 450)); // button->setScale(vector2df(2,2)); // Manager->registerStaticProp(prop); CGUIImage *image = new CGUIImage(Device); // image->setImage(Video->getTexture("draakan.png")); // image->setRelativePosition(vector2df(720, 450)); // image->setRelativeScale(vector2df(1,1)); CRigidBox *box = new CRigidBox(Device, World); box->setScale(vector3df(5,5,5)); box->setPosition(vector3df(715,1200,500)); box->setMaterialFlag(EMF_LIGHTING, false); box->setMaterialTexture(0, Video->getTexture("textures/crate.jpg")); Manager->registerRigidBox(box); // CRenderTarget *rt = new CRenderTarget(Device, box->getNode()); // rt->getCamera()->setPosition(vector3df(0,500,0)); ICameraSceneNode *Camera = Smgr->addCameraSceneNodeFPS(0, 100.f, 0.0f, -1, 0, 0, true, 0.0, false, true); // ICameraSceneNode*Camera = Smgr->addCameraSceneNodeFPS(); Smgr->addAnimatedMeshSceneNode(Smgr->getMesh("dwarf.x")); CIrrKlangSceneNode *Nodes = new CIrrKlangSceneNode(Sound, Smgr->getRootSceneNode(), Smgr, 666); Nodes->setMinMaxSoundDistance(); Nodes->setSoundFileName("Menu.mp3"); CFPSController *controller = new CFPSController(Device, World, Smgr->getMesh("dwarf.x")); Manager->registerFPSController(controller); Manager->setActivePlayer(controller); // controller->setCameraOffset(vector3df(0,50,0)); controller->setNodeOffset(vector3df(0,-10,0)); // rt->setFollowMode(true, Camera); // rt->setTrailMode(true, Camera, true, true); // box->setMaterialTexture(0, rt->getTexture()); // Manager->registerRenderTarget(rt); // // CRagdoll *doll = new CRagdoll(Device, World, Smgr->getMesh("dwarf.x")); //Continue using Irrlicht as normal u32 TimeStamp = Device->getTimer()->getTime(); u32 DeltaTime = 0; while (Manager->run()) { //The Manager handles everything inside of this drawAll call DeltaTime = Device->getTimer()->getTime() - TimeStamp; TimeStamp = Device->getTimer()->getTime(); World->stepSimulation(DeltaTime*0.001f, 120); Manager->drawAll(); } //When the device is closed, delete the irrEngine manager to cause a "domino" effect of deletion :) delete Manager; if (Device) Device->drop(); }