Presentation is loading. Please wait.

Presentation is loading. Please wait.

GUI I. Ogre3D Overlay. Project initialization 06_01_Ogre3D_Overlays_Base.zip Extract Run: OgreOverlays.sln Set.

Similar presentations


Presentation on theme: "GUI I. Ogre3D Overlay. Project initialization 06_01_Ogre3D_Overlays_Base.zip Extract Run: OgreOverlays.sln Set."— Presentation transcript:

1 GUI I. Ogre3D Overlay

2 Project initialization 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 One mesh model, Phong shading, post processing Camera motion(CameraAnimation : public FrameListener) Text file (bin\cameraanim.txt) Animation stops at given time positions (const float stopTimes[]) Ghosts: Particle system, billboards (media\ghosts.particle) 1 emitter, adjusting emission rate at animation stop and resume times

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

7 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 } HUD.overlay unique names relative, parent space values absolute, screen space values material HUD/IDMAP { technique { pass { lighting off texture_unit { texture idMap }

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 } 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: bool handleEvent(float t, float dt, OIS::Keyboard* keyboard, OIS::Mouse* mouse) { unsigned int w = renderWindow->getWidth(); unsigned int h = renderWindow->getHeight(); unsigned int mouseX = mouse->getMouseState().X.abs; unsigned int mouseY = 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(int allGhosts, int killedGhosts) { 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(PlayerTemplate) { left width top height 0.06 char_height 0.04 alignment center font_name TrebuchetMSBold } template element TextArea(KillsTemplate) { left width top height 0.06 char_height 0.04 alignment center font_name TrebuchetMSBold } template element TextArea(GhostsTemplate) { left 0.35 width top height 0.06 char_height 0.04 alignment center font_name TrebuchetMSBold } template element TextArea(HealthTemplate) { left 0.47 width top height 0.06 char_height 0.04 alignment center font_name TrebuchetMSBold }

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: bool handleEvent(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(); } void showStats() { 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() * (i+1));

22 The End


Download ppt "GUI I. Ogre3D Overlay. Project initialization 06_01_Ogre3D_Overlays_Base.zip Extract Run: OgreOverlays.sln Set."

Similar presentations


Ads by Google