惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

IT之家
IT之家
H
Help Net Security
GbyAI
GbyAI
博客园_首页
G
Google Developers Blog
Microsoft Security Blog
Microsoft Security Blog
博客园 - 【当耐特】
月光博客
月光博客
美团技术团队
B
Blog RSS Feed
博客园 - 三生石上(FineUI控件)
WordPress大学
WordPress大学
博客园 - 叶小钗
有赞技术团队
有赞技术团队
T
The Blog of Author Tim Ferriss
Engineering at Meta
Engineering at Meta
Google DeepMind News
Google DeepMind News
Y
Y Combinator Blog
宝玉的分享
宝玉的分享
Microsoft Azure Blog
Microsoft Azure Blog
罗磊的独立博客
云风的 BLOG
云风的 BLOG
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
P
Proofpoint News Feed

博客园 - 安徽飞雪游戏工作室

贴几张我们用irrlicht做的游戏截图 jpg图片效果有点差,看起来是不是有点像劲舞团? 3dmax导出为my3d教程 从内存中加载图片资源 3dmax文件导出到ms3d文件. irrlicht1.3中文支持 Audiere PK OpenAL 【原创】IrrLicht中ms3D模型不支持多个贴图问题的解决 【引】[翻译]Irrlicht引擎里的冲突检测与响应 [原创]IrrLicht中MS3D模型骨骼动画支持bug的排除 MS3D model 的 Frame count - 安徽飞雪游戏工作室 材质动画 Irrlicht 论坛好贴 精选(不断补充中...) [转]Scrolling Credits Code [转](C++) How to animate and move an entity [原创]为Irrlicht中的人物添加武器 [原创]Irrlicht中的Texture透明色(colorkey) [原创]IrrLicht-1.0中文支持 [原创]一个在Irrlicht中会常用的字符串转换函数 [转]宽字符标量L"xx"在VC6.0/7.0和GNU g++中的不同实现。
[原创]IrrLicht的GUI使用
安徽飞雪游戏工作室 · 2006-07-23 · via 博客园 - 安徽飞雪游戏工作室

irrlicht有自己的ui系统,不用再去找其他的ui系统来挂载了.下面介绍一下irrlicht

UI系统的基本使用方法.我用一个hello world的工程来讲解.因为代码量并不多,就将所有的代码都贴出来了.

#include <windows.h>
#include <irrlicht.h>

//头函数,因为将调用GetWindowsDirectory()函数获得系统目录所以包含了<windows.h>

using namespace irr;

using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;

//名字空间,不用每次都用irr::等来声明

IGUIEditBox *edtName = 0;
IGUIButton *pbtn = 0;
CGUITTFont *pFont;
IGUIListBox* listbox = 0;
IGUISkin* skin;
IrrlichtDevice *Device;

//用到的几个全局变量,CGUITTFont是从IGUIFont派生出的类,非irrlicht自带.用于中文支持.不用中文的话,定义为IGUIFont即可

class MyEventReceiver : public IEventReceiver
{
public:
 virtual bool OnEvent(SEvent event)
 {
  if (event.EventType == EET_GUI_EVENT)
  {
   s32 id = event.GUIEvent.Caller->getID();
   switch(event.GUIEvent.EventType)
   {   
   case EGET_BUTTON_CLICKED://这里只处理了按钮点击的消息
    if (id == 101)
    {     
     listbox->addItem(edtName->getText());

    //点发送按钮时,把editbox里的内容加到listbox中;
     return true;
    }   
    break;   
   }
  }
  return false;
 }
};

//自定义的消息处理类,重载了OnEvent()函数,demo将用这个类来出理消息.注意后面会调用一个setEventReceiver()函数来设定消息处理类.

int main()
{

 Device =createDevice( video::EDT_DIRECT3D9, dimension2d<s32>(640,480), 16,false, false, false, 0);

//main函数开始,创设备.

Device->setWindowCaption(L"鬼火引擎,第一个例子");

IVideoDriver* driver = Device->getVideoDriver();
ISceneManager* smgr = Device->getSceneManager();
IGUIEnvironment* guienv = Device->getGUIEnvironment();
smgr->addCameraSceneNode(0, vector3df(0,30,-40), vector3df(0,5,0));

//添加了一个摄像机,位置和观察点分别为(0,30,-40),(0,5,0).

 MyEventReceiver receiver;
 Device->setEventReceiver(&receiver);

//指定消息处理类

skin = guienv->getSkin();
c8 tmp[512];
GetWindowsDirectory(tmp,511);
strcat(tmp,"\\fonts\\simhei.ttf");
pFont = (CGUITTFont *)guienv->getFont(tmp,15);//获得ttf字体
skin->setFont(pFont);//设置字体

//得到系统目录fonts下的simhei.ttf字体,并设置为当前使用的字体.

edtName = guienv->addEditBox(L"岁月无声",rect<s32>(350,400,530,430));
edtName->setOverrideColor(SColor(0,0,0,255));

//添加一个EditBox,并将字体颜色设成蓝色.也可以这样调用类指定自己的字体:

edtName->setOverrideFont(pFont),pFont要另行加载.

pbtn = guienv->addButton(rect<s32>(540,400,590,430), 0, 101, L"发送");

listbox = guienv->addListBox(rect<s32>(350, 300, 590, 380));

//添加了一个按钮和一个列表框

IAnimatedMesh* mesh = smgr->getMesh("../../media/sydney.md2");
 IAnimatedMeshSceneNode* node = smgr->addAnimatedMeshSceneNode( mesh );

if (node)
 {
  node->setMaterialFlag(EMF_LIGHTING, false);
  node->setMD2Animation ( scene::EMAT_STAND );
  node->setMaterialTexture( 0, driver->getTexture("../../media/sydney.bmp") );
 }

//场景太单调了,还是留下原来的这个md2 "美女"模型

while(Device->run())
 {
  /*
  Anything can be drawn between a beginScene() and an endScene()
  call. The beginScene clears the screen with a color and also the
  depth buffer if wanted. Then we let the Scene Manager and the
  GUI Environment draw their content. With the endScene() call
  everything is presented on the screen.
  */
  driver->beginScene(true, true, SColor(255,100,102,140));

  smgr->drawAll();
  guienv->drawAll();
  driver->endScene();
 }

//游戏循环

Device->drop();

 return 0;
}

//main函数结束.

呵呵,挺简单的吧,irrlicht好像还有ui编辑器哦,这样就不用我们自己算坐标了,用起来就更方便了.好了,看看我们的成果吧.