1 / 22

GUI I.

GUI I. Ogre3D Overlay. Project initialization. http://cg.iit.bme.hu/gamedev/KIC/06_GUI / 06_01_Ogre3D_ Overlays _ Base.zip Extract Run: OgreOverlays.sln Set include and library paths (if not correct) Set working directory (if not $( SolutionDir )/bin) Compile Run Play !!.

sukey
Download Presentation

GUI I.

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. GUI I. Ogre3D Overlay

  2. Project initialization • http://cg.iit.bme.hu/gamedev/KIC/06_GUI/ • 06_01_Ogre3D_Overlays_Base.zip • Extract • Run: OgreOverlays.sln • Set include and library paths (if not correct) • Set working directory (if not $(SolutionDir)/bin) • Compile • Run • Play!!

  3. Ghost Buster Game

  4. Newness / implementation • Onemeshmodel, Phongshading, post processing • Camera motion(CameraAnimation : public FrameListener) • Text file (bin\cameraanim.txt) • Animationstopsatgiventimepositions (const float stopTimes[]) • Ghosts: • Particlesystem, billboards (media\ghosts.particle) • 1 emitter, adjustingemissionrateatanimation stop and resumetimes

  5. Newness / implementation • Counting the number of ghost births • Register a ParticleAffector descendant(GhostCounter: public ParticleAffector) • Shot ghosts • Need pixel-wise solution • ID map • How to set an ID to particles ??? • How to read back the ID map ???

  6. HUD, Overlay main.cpp #include “HUD.h” ... HUD* mainHUD; ... void setupScene() { … mainHUD = new HUD(); } HUD.h #ifndef HUD_H #define HUD_H #include "stdafx.h" #include "Ogre.h" class HUD { public: HUD() { Ogre::Overlay* mainOverlay = Ogre::OverlayManager::getSingleton().getByName("MainOverlay"); mainOverlay->show(); } }; #endif /* HUD_H */

  7. HUD.overlay material HUD/IDMAP { technique { pass { lighting off texture_unit { textureidMap } } } } MainOverlay { container Panel(MainContainer) { transparent true left 0 top 0 width 1 height 1 element Panel(GhostIDMap) { left 0.8 top 0.0 width 0.2 height 0.2 material HUD/IDMAP transparent false uv_coords 0 0 1 1 } } } unique names relative, parentspacevalues absolute, screenspacevalues

  8. Run

  9. Cross-hair, hiding the cursor inputs.h #if defined OIS_WIN32_PLATFORM pl.insert(std::make_pair(std::string("w32_mouse"), std::string("DISCL_FOREGROUND" ))); pl.insert(std::make_pair(std::string("w32_mouse"), std::string("DISCL_NONEXCLUSIVE"))); pl.insert(std::make_pair(std::string("w32_keyboard"), std::string("DISCL_FOREGROUND"))); pl.insert(std::make_pair(std::string("w32_keyboard"), std::string("DISCL_NONEXCLUSIVE"))); #elif defined OIS_LINUX_PLATFORM pl.insert(std::make_pair(std::string("x11_mouse_grab"), std::string("false"))); pl.insert(std::make_pair(std::string("x11_mouse_hide"), std::string("false"))); pl.insert(std::make_pair(std::string("x11_keyboard_grab"), std::string("false"))); pl.insert(std::make_pair(std::string("XAutoRepeatOn"), std::string("true"))); #endif

  10. Cross-hair image MainOverlay { container Panel(MainContainer) { …. element Panel(Cross) { metrics_mode pixels width 20 height 20 material HUD/crosshair uv_coords 0 0 1 1 } material HUD/crosshair { technique { pass { lighting off scene_blend add texture_unit { texture crosshair.jpg } } } }

  11. Cross-hair movement I. class HUD { float cursorSize; float cursorScaler; public: HUD() { ... cursorSize = 20; cursorScaler = 1; } void setCursorPos(float x, float y) { Ogre::OverlayElement* cursor = Ogre::OverlayManager::getSingleton() .getOverlayElement("Cross", false); cursor->setPosition(x-cursorScaler*cursorSize*0.5f, y-cursorScaler*cursorSize*0.5f); } void setCursorSize(float scaler) { cursorScaler = scaler; Ogre::OverlayElement* cursor = Ogre::OverlayManager::getSingleton() .getOverlayElement("Cross", false); cursor->setWidth(cursorScaler*cursorSize); cursor->setHeight(cursorScaler*cursorSize); } };

  12. Cross-hair movement II. class ShootController { public: boolhandleEvent(float t, float dt, OIS::Keyboard* keyboard, OIS::Mouse* mouse) { unsigned int w = renderWindow->getWidth(); unsigned int h = renderWindow->getHeight(); unsigned intmouseX = mouse->getMouseState().X.abs; unsigned intmouseY = mouse->getMouseState().Y.abs; if(mouse->getMouseState().buttonDown(OIS::MB_Left)) { mainHUD->setCursorSize(2.0); … } else { mainHUD->setCursorSize(1.0); } mainHUD->setCursorPos(mouseX, mouseY); return true; }

  13. Test

  14. Diplaying current score I. MainOverlay { container Panel(TMP) { transparent true element TextArea(TMPTEXT) { font_name TrebuchetMSBold caption blablablab } } container Panel(MainContainer) { left 0 top 0 width 1 height 1 element TextArea(Score) { left 0.02 width 0.2 top 0.02 height 0.06 char_height 0.04 font_name TrebuchetMSBold caption 0/0 } BUG!!!???

  15. Diplaying current score II. class HUD { ... public: ... void refreshScore(intallGhosts, intkilledGhosts) { Ogre::String newCaption = Ogre::StringConverter::toString(killedGhosts) + "/" + Ogre::StringConverter::toString(allGhosts); Ogre::OverlayElement* score = Ogre::OverlayManager::getSingleton().getOverlayElement("Score"); score->setCaption(newCaption); } Main.cpp printf("ghosts %i/%i\n", ghostBorn, ghostShooted); mainHUD->refreshScore(ghostBorn, ghostShooted);

  16. Test

  17. Game statistics I. template element TextArea(GhostsTemplate) { left 0.35 width 0.153 top 0.045 height 0.06 char_height 0.04 alignment center font_nameTrebuchetMSBold } template element TextArea(HealthTemplate) { left 0.47 width 0.153 top 0.045 height 0.06 char_height 0.04 alignment center font_nameTrebuchetMSBold } template elementTextArea(PlayerTemplate) { left 0.106 width 0.153 top 0.045 height 0.06 char_height 0.04 alignment center font_nameTrebuchetMSBold } template element TextArea(KillsTemplate) { left 0.245 width 0.153 top 0.045 height 0.06 char_height 0.04 alignment center font_nameTrebuchetMSBold }

  18. Game statistics II. container Panel(MainContainer) { ... } container Panel(PlayerStats) { left 0.2 top 0.02 width 0.6 height 0.6 material HUD/Stats element TextArea(PlayerName) : PlayerTemplate { caption Player } element TextArea(PlayerKills) : KillsTemplate { caption Kills } element TextArea(PlayerGhosts) : GhostsTemplate { caption Ghosts } element TextArea(PlayerHealth) : HealthTemplate { caption Health } } material HUD/Stats { technique { pass { lighting off scene_blend alpha_blend texture_unit { texture stats.png } } } }

  19. Game statistics III. class ShootController : public InputListener, public RenderTargetListener { public: boolhandleEvent(float t, float dt, OIS::Keyboard* keyboard, OIS::Mouse* mouse) { if(keyboard->isKeyDown(OIS::KC_SPACE) && mTimeUntilNextToggle < 0) { mainHUD->showStats(); mTimeUntilNextToggle = 1; } ...

  20. Game statistics IV. class HUD { … HUD() { … Ogre::OverlayElement* stats = Ogre::OverlayManager::getSingleton().getOverlayElement("PlayerStats", false); stats->hide(); } voidshowStats() { Ogre::OverlayElement* stats = Ogre::OverlayManager::getSingleton().getOverlayElement("PlayerStats", false); if(stats->isVisible()) stats->show() else stats->hide(); }

  21. Example of inserting a new element into the statistics table Ogre::OverlayElement* ke = Ogre::OverlayManager::getSingleton(). createOverlayElementFromTemplate( "KillsTemplate", "TextArea", name + "Kills"); ke->setTop(ke->getTop() + 0.04 + 0.04 * (i+1));

  22. The End

More Related