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

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>
            欧美午夜寂寞影院| 国产精品v日韩精品v欧美精品网站 | 亚洲午夜伦理| 久久久水蜜桃| 久久精品91久久久久久再现| 国内外成人免费激情在线视频网站 | 亚洲国产精品毛片| 欧美电影免费观看高清| 在线日韩中文| 亚洲精品久久在线| 国产精品电影在线观看| 久久久99精品免费观看不卡| 久久精品欧美日韩| 亚洲全部视频| 一区二区三区四区五区精品| 国产日韩专区| 欧美激情按摩| 国产精品一区二区黑丝| 麻豆国产精品777777在线| 久久久精品免费视频| 亚洲精品免费观看| 亚洲免费在线视频| 亚洲国产精品悠悠久久琪琪 | 一本色道久久加勒比88综合| 亚洲在线成人| 亚洲第一中文字幕| 夜夜爽99久久国产综合精品女不卡| 国产女主播一区二区| 亚洲高清电影| 国产日本欧美一区二区| 亚洲人午夜精品免费| 国产欧美视频一区二区| 欧美aa国产视频| 国产美女精品一区二区三区 | 久久久精品动漫| 欧美黑人多人双交| 久久精品视频在线看| 欧美日韩精品不卡| 榴莲视频成人在线观看| 国产精品久久久久久久久久妞妞| 久久网站热最新地址| 国产精品啊啊啊| 亚洲国产精品一区| 国产亚洲午夜| 亚洲一区二区三区中文字幕| 亚洲精品一区在线观看| 久久久久国内| 久久精品2019中文字幕| 欧美三级欧美一级| 亚洲激情在线激情| 亚洲国产精品成人综合| 性欧美办公室18xxxxhd| 亚洲欧美电影院| 欧美日韩免费观看一区三区| 亚洲国产网站| 亚洲国产女人aaa毛片在线| 欧美在线看片a免费观看| 欧美一区二区三区四区高清| 欧美日一区二区三区在线观看国产免 | 欧美在线免费视频| 欧美一二区视频| 国产精品国产三级欧美二区 | 欧美一二区视频| 欧美性开放视频| 一区二区三区日韩精品| 一区二区三区日韩| 欧美日韩免费观看一区| 日韩视频中文字幕| 亚洲视频一区二区在线观看| 欧美午夜寂寞影院| 中文无字幕一区二区三区| 亚洲视频免费看| 欧美性猛交视频| 中文一区二区| 欧美在线视频二区| 国产综合一区二区| 久久青草福利网站| 亚洲国产精品悠悠久久琪琪| 亚洲毛片在线看| 欧美日韩中国免费专区在线看| aaa亚洲精品一二三区| 亚洲欧美日韩在线观看a三区| 国产欧美精品xxxx另类| 欧美在线一区二区三区| 欧美成人免费小视频| 99在线热播精品免费| 欧美午夜视频网站| 欧美一区二区三区视频| 欧美大胆成人| 亚洲专区欧美专区| 国产中文一区二区| 欧美国产激情二区三区| 亚洲视频第一页| 老司机精品导航| 一区二区三区毛片| 国产欧美在线播放| 美国十次成人| 亚洲午夜久久久久久尤物| 久久天天躁夜夜躁狠狠躁2022| 亚洲福利免费| 国产精品久久久久久久久久妞妞 | 欧美成人影音| 亚洲一区二区三区在线| 黄色精品免费| 欧美日韩在线一二三| 久久激五月天综合精品| 亚洲日本视频| 久久男人资源视频| 99精品国产在热久久下载| 国产日韩欧美综合| 欧美日韩国产精品专区| 久久精品视频导航| 亚洲美女黄网| 免费不卡视频| 久久精品官网| 国产精品99久久久久久人| 在线观看欧美视频| 国产日韩欧美另类| 欧美日韩系列| 欧美va亚洲va国产综合| 亚洲女同精品视频| 亚洲乱亚洲高清| 免费在线看成人av| 久久福利精品| 午夜日韩在线观看| 亚洲视频第一页| 亚洲精品孕妇| 亚洲风情在线资源站| 国产一区二区三区在线播放免费观看| 欧美精品情趣视频| 欧美成人综合| 免费成人性网站| 久久久午夜电影| 久久爱www久久做| 亚洲免费在线观看| 中文日韩在线| 一区二区欧美日韩| 99re6热只有精品免费观看| 91久久精品国产91性色| 欧美国产1区2区| 欧美成人在线网站| 欧美成人免费一级人片100| 麻豆国产精品va在线观看不卡 | 在线观看国产成人av片| 国产综合一区二区| 狠狠色噜噜狠狠色综合久| 国模精品一区二区三区色天香 | 欧美国产亚洲精品久久久8v| 久久夜色精品亚洲噜噜国产mv| 久久精品视频导航| 久久亚洲国产精品一区二区 | 亚洲国产色一区| 亚洲高清在线| 亚洲精品国产精品国自产在线| 亚洲欧洲精品一区二区三区| 亚洲国产网站| 99精品欧美| 亚洲一区观看| 欧美一区二区三区免费在线看| 亚洲欧美日韩精品久久久| 午夜精品视频在线| 久久青青草综合| 欧美国产日韩视频| 欧美三日本三级少妇三2023| 国产精品老女人精品视频| 国产嫩草一区二区三区在线观看 | 激情综合激情| 亚洲电影在线播放| 亚洲久久一区| 亚洲免费影院| 老司机精品视频网站| 亚洲第一网站免费视频| 亚洲剧情一区二区| 亚洲女ⅴideoshd黑人| 久久精品国内一区二区三区| 老司机免费视频一区二区三区| 欧美—级a级欧美特级ar全黄| 国产精品美腿一区在线看| 国产在线视频不卡二| 亚洲激情视频网| 亚洲中无吗在线| 欧美电影资源| 亚洲网站视频| 久久综合中文| 欧美性事免费在线观看| 狠狠操狠狠色综合网| 日韩一级欧洲| 久久精品国产亚洲aⅴ| 亚洲国产精品久久久| 亚洲欧美国产精品va在线观看| 久热精品视频| 国产噜噜噜噜噜久久久久久久久| 在线日韩中文| 午夜精品免费在线| 亚洲欧洲日本国产| 久久黄色网页| 国产精品私拍pans大尺度在线| 亚洲精品久久久久| 久久性天堂网| 亚洲制服少妇|