青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品

OGre實際應用程序[五]譯

Posted on 2008-09-06 16:56 美洲豹 閱讀(247) 評論(0)  編輯 收藏 引用

更進一步

CEGUI

在這篇文章中,我們將把CEGUI集成到應用程序中。

Rendering The UI

CEGUI 將它的 UI elements 畫成四方形的Mesh形式畫到"screen space". CEGUI 通過"OgreGUIRenderer"Ogre進行交互。

CEGUI Data Files

CEGUI中的文件有如下幾個:

  • Scheme. Definition of the different UI elements that are valid in a particular "scheme", for example buttons, listboxes, and so on. Found in .scheme files.
  • Look-And-Feel. Definition of the way that each UI element is presented on the display, including its behaviors and the textures used to render it. Found in .looknfeel files.
  • Layout. Defines the position, size, parenting hierarchy and other properties used to display actual UI elements in a single unit: the UI "sheet". Found in .layout files.
  • Imageset. Defines the textures used in a scheme, and the UV coordinates that are actually mapped to UI element quads on your screen. Found in .imageset files.
  • Font. Should be obvious; CEGUI needs to know where to find the fonts you intend to use for your text, including the glyph definitions and the font texture to use. Found in .font files.

In the gui.zip resource data file accompanying the source for this article, you will find many examples of all of these types of files. Look through each type of file and see what they contain -- they are all just text XML files. This article uses the "TaharezLookSkin" scheme.

Falagard Skinning System

There is also another part of CEGUI that works behind the scenes, but starting with CEGUI 0.5.x (the version used in this article), is core to its operation. The "Falagard" skinning system was devised as a way to remove the need to create a separate code module (DLL) that was used actually to assemble and render each different scheme and look-and-feel. As you might expect (if you are a regular in the Ogre forums) the person (at least mostly) responsible for its creation was Falagard (unless my information is incorrect, of course). This method of UI skinning is a generalized, data-driven way to render the UI elements without having to author special code to do it. It relies on all of that data found in the look-and-feel and scheme files for its operation -- verbosity of data is one of the prices you pay for flexibility. ;)

The Code

先介紹到這里,下面讓我們看一下代碼。在這個版本中,原來的初始版本將顯示我們這里創建的layout.

And Then, Now The Code

對于添加CEGUI需要的修改,會指出。首先在main.cpp添加附加的頭文件

// needed to be able to create the CEGUI renderer interface
#include "OgreCEGUIRenderer.h"
 
// CEGUI includes
#include "CEGUISystem.h"
#include "CEGUIInputEvent.h"
#include "CEGUIWindow.h"
#include "CEGUIWindowManager.h"
#include "CEGUISchemeManager.h"
#include "CEGUIFontManager.h"
#include "elements/CEGUIFrameWindow.h"

Initializing CEGUI

main.cpp

        // with a scene manager and window, we can create a the GUI renderer
        CEGUI::OgreCEGUIRenderer* pGUIRenderer = new CEGUI::OgreCEGUIRenderer(
               window,                               // the render window created earlier; CEGUI renders to this
               Ogre::RENDER_QUEUE_OVERLAY,           // CEGUI should render in this render queue
               false,                                // put everything in the above render queue first, not last
               3000,                                 // this is actually unnecessary now in CEGUI -- max quads for the UI
               sceneMgr                              // use this scene manager to manage the UI
        );
 
        // create the root CEGUI class
        CEGUI::System* pSystem = new CEGUI::System(pGUIRenderer);
 
        // tell us a lot about what is going on (see CEGUI.log in the working directory)
        CEGUI::Logger::getSingleton().setLoggingLevel(CEGUI::Informative);
 
        // use this CEGUI scheme definition (see CEGUI docs for more)
        CEGUI::SchemeManager::getSingleton().loadScheme((CEGUI::utf8*)"TaharezLookSkin.scheme", (CEGUI::utf8*)"GUI");
 
        // show the CEGUI mouse cursor (defined in the look-n-feel)
        pSystem->setDefaultMouseCursor((CEGUI::utf8*)"TaharezLook", (CEGUI::utf8*)"MouseArrow");
 
        // use this font for text in the UI
        CEGUI::FontManager::getSingleton().createFont("Tahoma-8.font", (CEGUI::utf8*)"GUI");
        pSystem->setDefaultFont((CEGUI::utf8*)"Tahoma-8");
 
        // load a layout from the XML layout file (you'll find this in resources/gui.zip), and 
        // put it in the GUI resource group
        CEGUI::Window* pLayout = CEGUI::WindowManager::getSingleton().loadWindowLayout("katana.layout", "", "GUI");
 
        // you need to tell CEGUI which layout to display. You can call this at any time to change the layout to
        // another loaded layout (i.e. moving from screen to screen or to load your HUD layout). Note that this takes
        // a CEGUI::Window instance -- you can use anything (any widget) that serves as a root window.
        pSystem->setGUISheet(pLayout);

Input Support For CEGUI

需要修改 InputHandler類以處理一個新增的參數:一個指向main.cpp中創建的CEGUI::System的指針:

input.cpp

// MouseListener
bool InputHandler::mouseMoved(const OIS::MouseEvent &evt) {
        m_pSystem->injectMouseWheelChange(evt.state.Z.rel);
        return m_pSystem->injectMouseMove(evt.state.X.rel, evt.state.Y.rel);
}
 
bool InputHandler::mousePressed(const OIS::MouseEvent &evt, OIS::MouseButtonID btn) {
        CEGUI::MouseButton button = CEGUI::NoButton;
        if (btn == OIS::MB_Left)
               button = CEGUI::LeftButton;
        if (btn == OIS::MB_Middle)
               button = CEGUI::MiddleButton;
        if (btn == OIS::MB_Right)
               button = CEGUI::RightButton;
        return m_pSystem->injectMouseButtonDown(button);
}
 
bool InputHandler::mouseReleased(const OIS::MouseEvent &evt, OIS::MouseButtonID btn) {
        CEGUI::MouseButton button = CEGUI::NoButton;
        if (btn == OIS::MB_Left)
               button = CEGUI::LeftButton;    
        if (btn == OIS::MB_Middle)
               button = CEGUI::MiddleButton;  
        if (btn == OIS::MB_Right)
               button = CEGUI::RightButton;   
        return m_pSystem->injectMouseButtonUp(button);
}
 
               
// KeyListener
bool InputHandler::keyPressed(const OIS::KeyEvent &evt) {
        unsigned int ch = evt.text;
        m_pSystem->injectKeyDown(evt.key);
        return m_pSystem->injectChar(ch);
}
 
bool InputHandler::keyReleased(const OIS::KeyEvent &evt) {
        if (evt.key == OIS::KC_ESCAPE)
               m_simulation->requestStateChange(SHUTDOWN);
        return m_pSystem->injectKeyUp(evt.key);
}
 

很顯然的,輸入系統通過inject…等命令,將自己掛進CEGUI.

main.cpp

        // since the input handler deals with pushing input to CEGUI, we need to give it a pointer
        // to the CEGUI System instance to use
        InputHandler *handler = new InputHandler(pSystem, sim, hWnd);
 
        // put us into our "main menu" state
        sim->requestStateChange(GUI);

同時,需要將狀態轉成GUI,如前面所述。在一個正常的應用程序中,你通常是先進入“主菜單”,而不是直接進入游戲。你還需要建立一個類來處理UI的動作,為簡單起見,我們在main.cpp來處理:

        // make an instance of our GUI sheet handler class
        MainMenuDlg* pDlg = new MainMenuDlg(pSystem, pLayout, sim);

其定義見文件MainMenuDlg.h and .cpp:

MainMenuDlg.h

#pragma once
 
#include "CEGUIWindow.h"
 
namespace CEGUI
{
        class System;
        class Window;
}
 
class Simulation;
 
class MainMenuDlg
{
public:
        MainMenuDlg(CEGUI::System* pSystem, CEGUI::Window* pSheet, Simulation* pSimulation);
        ~MainMenuDlg();
 
        // CEGUI event handlers. You can name these whatever you like, so long as they have the proper 
        // signature: bool <method name>(const CEGUI::EventArgs &args)
        bool Quit_OnClick(const CEGUI::EventArgs &args);
        bool Options_OnClick(const CEGUI::EventArgs &args);
        bool Launch_OnClick(const CEGUI::EventArgs &args);
 
private:
        CEGUI::System* m_pSystem;      // pointer to the CEGUI System instance
        CEGUI::Window* m_pWindow;      // pointer to the layout sheet window
        Simulation* m_pSimulation;     // pointer to the Simulation controller 
};

MainMenuDlg.cpp

#include "MainMenuDlg.h"
#include "Simulation.h"
#include "CEGUISystem.h"
#include "CEGUIWindow.h"
#include "CEGUIWindowManager.h"
#include "elements/CEGUIPushButton.h"
 
MainMenuDlg::MainMenuDlg(CEGUI::System *pSystem, CEGUI::Window *pSheet, Simulation *pSimulation)
{
        m_pSystem = pSystem;
        m_pWindow = pSheet;
        m_pSimulation = pSimulation;
 
        // hook up the event handlers to the window elements
        CEGUI::PushButton* pQuitButton = (CEGUI::PushButton *)CEGUI::WindowManager::getSingleton().getWindow("cmdQuit");
        pQuitButton->subscribeEvent(CEGUI::PushButton::EventClicked, CEGUI::Event::Subscriber(&MainMenuDlg::Quit_OnClick, this));
 
        CEGUI::PushButton* pOptionsButton = (CEGUI::PushButton *)CEGUI::WindowManager::getSingleton().getWindow("cmdOptions");
        pOptionsButton->subscribeEvent(CEGUI::PushButton::EventClicked, CEGUI::Event::Subscriber(&MainMenuDlg::Options_OnClick, this));
 
        CEGUI::PushButton* pLaunchButton = (CEGUI::PushButton *)CEGUI::WindowManager::getSingleton().getWindow("cmdInstantAction");
        pLaunchButton->subscribeEvent(CEGUI::PushButton::EventClicked, CEGUI::Event::Subscriber(&MainMenuDlg::Launch_OnClick, this));
}
 
MainMenuDlg::~MainMenuDlg()
{
}
 
bool MainMenuDlg::Quit_OnClick(const CEGUI::EventArgs &args)
{
        m_pSimulation->requestStateChange(SHUTDOWN);
        return true;
}
 
bool MainMenuDlg::Launch_OnClick(const CEGUI::EventArgs &args)
{
        return true;
}
 
bool MainMenuDlg::Options_OnClick(const CEGUI::EventArgs &args)
{
        return true;
}

兩個主要的事情是 (a) action handler methods 如何掛接 CEGUI events, and (b) “Quit”按鈕告訴程序狀態轉換到Shutdown.

Conclusion

Enjoy!

Link:  OIS: http://sourceforge.net/projects/wgois      


只有注冊用戶登錄后才能發表評論。
網站導航: 博客園   IT新聞   BlogJava   博問   Chat2DB   管理


posts - 15, comments - 2, trackbacks - 0, articles - 29

Copyright © 美洲豹

青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            亚洲一区二区在| 国产亚洲精品自拍| 国产精品久久久久aaaa九色| 欧美视频在线观看视频极品| 精品1区2区3区4区| 99视频精品全部免费在线| 久久成人一区| 亚洲精品午夜精品| 久久综合99re88久久爱| 欧美视频四区| 欧美一级在线播放| 久久亚洲电影| 一本色道88久久加勒比精品| 久久精品一区蜜桃臀影院| 久久精品一区二区三区不卡| 久久成人精品| 欧美亚洲免费| 欧美精品一区二区高清在线观看| 国产精品videosex极品| 国产精品成人观看视频免费| 亚洲欧美日韩一区二区| 欧美华人在线视频| 欧美一区二区在线免费播放| 亚洲电影免费在线观看| 久热爱精品视频线路一| 亚洲男人av电影| 欧美特黄一级大片| 久久久7777| 欧美在线观看视频在线| 国产欧美va欧美va香蕉在| 性做久久久久久久久| 久久一二三国产| 亚洲高清资源综合久久精品| 麻豆freexxxx性91精品| 欧美色大人视频| 欧美高潮视频| 美女视频黄a大片欧美| 伊人久久大香线蕉av超碰演员| 欧美在线一二三| 欧美激情久久久| aaa亚洲精品一二三区| 欧美淫片网站| 亚洲一区区二区| 欧美精品亚洲| 牛牛影视久久网| 欧美激情国产高清| 可以看av的网站久久看| 国产精品实拍| 裸体一区二区三区| 国产精品尤物福利片在线观看| 久久av在线看| 欧美体内she精视频在线观看| 亚洲大胆在线| 久久久久高清| 欧美午夜精品久久久久久人妖| 媚黑女一区二区| 欧美日本高清视频| 亚洲欧美不卡| 欧美日韩精品在线播放| 校园激情久久| 国产精品久久久久久久久久尿| 久久大逼视频| 国产欧美一区二区精品婷婷| 亚洲私人黄色宅男| 亚洲二区精品| 久久亚洲一区二区三区四区| 久久夜色精品国产亚洲aⅴ| 国产日韩高清一区二区三区在线| 一本久道久久久| 亚洲高清视频在线观看| 久久久久久久久一区二区| 宅男精品视频| 久久久久久久久伊人| 久久亚洲视频| 亚洲国产视频直播| 亚洲欧美综合国产精品一区| 亚洲三级电影全部在线观看高清| 亚洲一区二区三区在线看| 在线成人中文字幕| 老色批av在线精品| 亚洲国产高潮在线观看| 日韩午夜中文字幕| 久久久久这里只有精品| 欧美大色视频| 夜夜嗨av色综合久久久综合网| 欧美另类极品videosbest最新版本| 亚洲精品欧美专区| 亚洲一区二区成人在线观看| 久久亚洲精品伦理| 亚洲激情视频在线| 在线日韩欧美视频| 欧美人与性禽动交情品| 亚洲一区二区影院| 免费久久99精品国产| 日韩视频免费在线| 欧美ed2k| 牛牛影视久久网| 一本一本久久| 国产性做久久久久久| 午夜精品久久久久久久蜜桃app| 久久免费黄色| 国产亚洲一区二区在线观看| 另类专区欧美制服同性| 99国产精品国产精品久久| 久久精品综合网| 99国产精品99久久久久久| 国产欧美丝祙| 欧美激情视频一区二区三区免费 | 亚洲精品韩国| 国产精品一区二区久激情瑜伽| 久久久久se| 一区二区三区日韩欧美精品| 久久精品久久99精品久久| 国产精品家教| 蜜桃av一区二区三区| 亚洲一区二区三区欧美| 亚洲精品1234| 久久欧美中文字幕| 亚洲字幕一区二区| 日韩午夜激情| 在线播放日韩| 国产一区导航| 国产精品久久一级| 欧美日本亚洲韩国国产| 巨乳诱惑日韩免费av| 欧美一区二区精品在线| 99视频一区| 亚洲黄网站在线观看| 男人插女人欧美| 久久久久久尹人网香蕉| 亚洲一区久久久| 中文国产成人精品| 国产亚洲永久域名| 国产精品区二区三区日本| 欧美精品一区二| 欧美国产日韩一区| 免费一级欧美在线大片| 久久综合久久美利坚合众国| 欧美一区二区三区视频在线| 亚洲一区二区三区三| 亚洲一区中文| 一区二区三区欧美成人| 一区二区三区**美女毛片 | 亚洲男人第一网站| 亚洲午夜激情网页| 亚洲一区二区伦理| 亚洲一区二区三区高清| 亚洲天堂网在线观看| 国产精品99久久久久久久久久久久 | 亚洲午夜视频在线| 亚洲亚洲精品三区日韩精品在线视频| 亚洲精品男同| 久久久国产精彩视频美女艺术照福利| 亚洲嫩草精品久久| 欧美资源在线观看| 久久久免费精品视频| 麻豆成人av| 亚洲激情成人| 一本色道久久综合狠狠躁篇的优点 | 欧美高清视频www夜色资源网| 欧美成年人视频网站欧美| 亚洲二区精品| 99国产欧美久久久精品| 亚洲一区二区三区777| 欧美一区二区女人| 另类激情亚洲| 欧美日韩中文字幕日韩欧美| 国产精品私拍pans大尺度在线| 国产日韩欧美高清免费| 亚洲高清在线观看| 一本一本a久久| 欧美与黑人午夜性猛交久久久| 久久国产精品久久久| 欧美国产日本| 一区二区三区久久| 久久久噜噜噜久久久| 欧美日韩不卡一区| 国产视频精品va久久久久久| 亚洲福利视频专区| 亚洲影音先锋| 嫩草成人www欧美| 亚洲一区二区三区在线观看视频 | 日韩亚洲国产欧美| 亚洲国内欧美| 91久久精品视频| 亚洲欧美在线aaa| 欧美国产91| 黑人极品videos精品欧美裸| 国产欧美日韩麻豆91| 亚洲精品在线视频观看| 久久久久91| 中文亚洲欧美| 亚洲欧美日韩直播| 欧美精品v国产精品v日韩精品| 国产伦精品一区二区三区视频黑人| 亚洲电影激情视频网站| 性久久久久久久久久久久| 亚洲精品1234| 久久综合久久综合久久| 国产一区二区高清|