使用IRRLICHT引擎 需要先创建一个DEVICE。

device 里面比较重要的三个方面包括:
  1. IVideoDriver
  2. ISceneManager 
            IAnimatedMesh 是ISceneManager里面3D模型的对象。
            IAnimatedMeshSceneNode 则是载入3D模型的模块
  3. IGUIEnvironment
创建3d模型以及载入3d模型的代码
    IAnimatedMesh* mesh = smgr->getMesh("../../media/ninja.b3d");
    
if (!mesh)
    {
        device
->drop();
        
return 1;
    }
    IAnimatedMeshSceneNode
* node = smgr->addAnimatedMeshSceneNode( mesh );
为展现3d世界,需要设置view point, 代码如下
smgr->addCameraSceneNode(0, vector3df(0,30,-40), vector3df(0,5,0));
绘制整个世界的代码
while(device->run())
    {
        
/*
        Anything can be drawn between a beginScene() and an endScene()
        call. The beginScene() call clears the screen with a color and
        the depth buffer, if desired. 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(truetrue, SColor(255,100,101,140));

        smgr
->drawAll();
        guienv
->drawAll();

        driver
->endScene();
    }

总结:
使用3d引擎的真个流程包括:
创建 DEVICE
配置 SceneManager, 包括创建模型,改变模型的appearance, 载入模型, 设置camera方位 等
设置 GUIEnvironment 参数
绘制画面

初次接触引擎方面的东西, 有两个疑问要好好查查看
1. 动画是如何实现的, 比如打斗场面, mesh的变形是即时的还是已经设置好的?
2. Texture的载入 这方面的东西还不了解。 如何给一个3d模型加入不同的texture?
Posted on 2011-05-21 23:08 清正 阅读(506) 评论(0)  编辑 收藏 引用

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理