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

OGre實際應(yīng)用程序[五]譯

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

更進一步

CEGUI

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

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

先介紹到這里,下面讓我們看一下代碼。在這個版本中,原來的初始版本將顯示我們這里創(chuàng)建的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類以處理一個新增的參數(shù):一個指向main.cpp中創(chuàng)建的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);
}
 

很顯然的,輸入系統(tǒng)通過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);

同時,需要將狀態(tài)轉(zhuǎn)成GUI,如前面所述。在一個正常的應(yīng)用程序中,你通常是先進入“主菜單”,而不是直接進入游戲。你還需要建立一個類來處理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”按鈕告訴程序狀態(tài)轉(zhuǎn)換到Shutdown.

Conclusion

Enjoy!

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


只有注冊用戶登錄后才能發(fā)表評論。
網(wǎng)站導(dǎo)航: 博客園   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>
            欧美一区二区三区精品电影| 亚洲欧美日韩国产成人| 亚洲精品日韩精品| 国产精品无码专区在线观看| 美女精品国产| 久久久久免费| 欧美一区国产一区| 亚洲天堂av在线免费观看| 精品不卡视频| 国内精品一区二区| 国产亚洲成av人在线观看导航 | 国产偷国产偷亚洲高清97cao| 亚洲在线一区二区| 亚洲少妇诱惑| 亚洲一区二区在线看| 亚洲天堂av综合网| 久久综合九色欧美综合狠狠| 欧美精品国产精品日韩精品| 亚洲欧美乱综合| 久久久精品国产免费观看同学| 久久综合久久综合久久综合| 99国产精品国产精品久久| 玉米视频成人免费看| 亚洲福利视频一区二区| 在线观看成人av| 亚洲日本成人女熟在线观看| 亚洲最新合集| 午夜日韩在线| 国产精品久久久亚洲一区| 欧美亚洲第一页| 国产精品久久久久久久久果冻传媒 | 亚洲视频在线观看网站| 一区二区三区久久久| 欧美电影在线| 欧美日韩中文字幕日韩欧美| 欧美第一黄色网| 男男成人高潮片免费网站| 欧美一区二视频在线免费观看| 欧美电影免费观看| 欧美sm重口味系列视频在线观看| 亚洲女人天堂成人av在线| 欧美中文字幕视频| 亚洲免费观看在线视频| 亚洲美女一区| 亚洲天堂男人| 亚洲无限乱码一二三四麻| 亚洲欧美日韩国产综合在线| 久久久久**毛片大全| 亚洲国产精品ⅴa在线观看 | 久久精品视频99| 国产精品日韩欧美综合| 男女激情久久| 欧美日韩高清区| 在线观看国产成人av片| 亚洲天堂视频在线观看| 亚洲日本无吗高清不卡| 欧美一区二区大片| 欧美va亚洲va日韩∨a综合色| 国产精品综合网站| 亚洲精品中文字| 卡通动漫国产精品| 亚洲一区二区三区精品视频| 亚洲欧洲一区二区在线播放| 亚洲香蕉伊综合在人在线视看| 久久深夜福利| 亚洲欧美日韩国产一区二区| 久久久蜜桃精品| 国产精品欧美在线| 国产一区成人| 亚洲毛片在线观看| 亚洲一区网站| 久久综合五月| 亚洲性色视频| 久热这里只精品99re8久| 欧美成人午夜| 国产欧美一区二区白浆黑人| 国产午夜精品理论片a级探花| 9l国产精品久久久久麻豆| 老司机久久99久久精品播放免费 | 亚洲午夜精品福利| 欧美激情91| 久久全国免费视频| 国产精品日韩二区| 欧美精品久久久久久久免费观看| 国产精品黄页免费高清在线观看| 亚洲三级色网| 红桃视频欧美| 久久视频在线视频| 先锋亚洲精品| 国产日韩欧美麻豆| 午夜久久电影网| 亚洲视屏在线播放| 国产乱码精品| 亚洲女性喷水在线观看一区| 91久久黄色| 欧美女同在线视频| 亚洲一区免费视频| 亚洲午夜电影在线观看| 国产精品视频最多的网站| 亚洲人成在线播放网站岛国| 美日韩精品免费观看视频| 99天天综合性| 欧美日韩国产大片| 亚洲黄页视频免费观看| 欧美二区在线| 欧美激情国产日韩| 最近中文字幕mv在线一区二区三区四区| 欧美3dxxxxhd| 久久不见久久见免费视频1| 国产精品外国| 麻豆精品网站| 久久成人精品无人区| 在线免费日韩片| 91久久极品少妇xxxxⅹ软件| 欧美日韩一区不卡| 久久国产黑丝| 午夜精品剧场| 久久婷婷人人澡人人喊人人爽 | 最新日韩av| 亚洲综合好骚| 亚洲第一网站免费视频| 亚洲免费婷婷| 最新国产成人在线观看| 日韩视频免费看| 影音先锋亚洲视频| 亚洲精品国产日韩| 国产一区在线看| 日韩一级不卡| 亚洲欧美乱综合| 国产亚洲欧美另类一区二区三区| 久久久久高清| 国产精品伦子伦免费视频| 久久综合九色综合网站| 欧美日韩一区二区三区免费| 欧美不卡三区| 国产日韩欧美日韩| 99国产精品视频免费观看一公开| 国产小视频国产精品| 亚洲精品久久久一区二区三区| 国产伦精品一区二区三区照片91 | 亚洲美女电影在线| 亚洲一区网站| 99在线精品观看| 欧美护士18xxxxhd| 国产亚洲精品一区二555| 亚洲国产小视频在线观看| 国产欧美日韩视频| 亚洲天堂成人| 母乳一区在线观看| 欧美jizzhd精品欧美巨大免费| 国产精品婷婷| 在线午夜精品自拍| 亚洲美女免费精品视频在线观看| 久久国产精品色婷婷| 午夜精品www| 亚洲午夜极品| 亚洲欧美日韩中文视频| 欧美激情四色 | 欧美激情精品久久久久久黑人 | 亚洲精选中文字幕| 久久久www| 玖玖玖免费嫩草在线影院一区| 国产精品视频内| 国产精品99久久久久久www| 在线亚洲电影| 欧美日韩在线影院| 夜夜精品视频一区二区| 欧美视频中文一区二区三区在线观看 | 一区二区欧美精品| 亚洲精品免费一区二区三区| 欧美影院久久久| 久久aⅴ乱码一区二区三区| 国产欧美日韩91| 久久视频在线看| 亚洲视频免费在线| 国产精品老牛| 久久精品国产免费观看| 欧美岛国激情| 欧美尤物巨大精品爽| 好看不卡的中文字幕| 亚洲午夜成aⅴ人片| 欧美不卡在线视频| 亚洲高清久久网| 国产精品久久国产精品99gif| 亚洲一区二区在线看| 欧美一区二区三区日韩| 影音先锋久久| 欧美日韩不卡一区| 欧美一区二区三区婷婷月色 | 久久视频在线看| 亚洲日本无吗高清不卡| 日韩写真在线| 美女视频黄a大片欧美| 影音先锋日韩精品| 欧美视频第二页| 久久久免费精品| 亚洲在线成人精品| 亚洲精品久久嫩草网站秘色 | 久久婷婷av| 亚洲自拍另类|