ImageVerifierCode 换一换
格式:DOCX , 页数:16 ,大小:25.86KB ,
资源ID:6880486      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bdocx.com/down/6880486.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(OgreMadMard教程4翻译版.docx)为本站会员(b****6)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

OgreMadMard教程4翻译版.docx

1、OgreMadMard教程4翻译版MadMarx Tutorial 4 ManualObject to Mesh 手动创建meshForeword.If you prefer tutorials that come with a framework = check the other wiki tutorial series.If you prefer tutorials that go step by step without a framework = this page should be ok.加入你希望教程中是有framework的版本=请在主页中寻找其他教程系列。如果你希望教程中是

2、没有framework,一步一步来实现代码的=这一页就可以。I assume you know C+. If not, this tutorial will probably be hard to understand !咱假设你懂C+语言,否则你很难看得懂这页教程。This tutorial presents only a few elements of Ogre3D.这个教程只适合有一定OGRE3D基础的开发者。You can download the code and media for this tutorial at the bottom of this wiki page.This

3、 little tutorial is an extract of a bigger project which contains more tutorials & helper classes.你可以下载本教程需要的媒体文件和代码在本页中,这是一个小小的教程,但是是从一个巨大的项目里面提取出来的,而那个巨大的项目里面则有更多的教程和帮助类。This bigger project is avaible there :这个逼格(括弧笑)项目在这里:Also, make sure you read these tutorials in order!同时,确认你能良好的完成本教程。Table of

4、contents Foreword.o Tutorial Descriptiono After viewport creation main.cppTutorial DescriptionIn this program, I create aManualObject(like in the previous tutorial).在这个程序中,咱创建了一个手动创建对象(就像之前的教程一样)。This time it will be a little more complicated than just a quad.这此将会比一个正方形更加复杂一点。To be able to make seve

5、ral copies of it, and at the same time re-use the already created3D data, I will convert the Ogre:ManualObjectto an Ogre:Mesh.为了能多做几份拷贝,同时重用已经创建的数据,咱将用Ogre:Mesh代替掉Ogre:ManualObject。Such mesh can be used to create several Entities.这样的mesh可以用来创建多个实体。AnEntityis an instance of a mesh, and allow differen

6、tmaterialinformation for eachentity.Entities are often the most common object in a Ogre application.一个实体是一个mesh的实例,并且允许不同的实体附加材质信息。实体通常是ogre程序里最常见的单位。Different Entities can have different materials, while sharing the same mesh.It is possible to create Entities with different meshes too.不同的实体可以拥有不同的材

7、质,以其共享相同的mesh,还可以创建不同的mesh来创建实体。In order to move anEntity, attach it to aSceneNode, and move thisSceneNode.为了移动实体,我们需要将实体绑定到节点上,然后移动节点。Note : It was reported that on some video drivers (mesa/intel),ManualObject:convertToMesh()producessome kind of degenerated (invisible) mesh. If that is the case for

8、 you, please update your drivers.注意:在一些显卡驱动中会回报这种(mesa/intel),ManualObject:convertToMesh()producessome kind of degenerated (invisible) mesh。如果你遇见这种情况,请更新你的显卡驱动。After viewport creation在视口创建后 Ogre:ManualObject* lManualObject = NULL; The manualObject creation requires a name.ManualObject构造器需要一个名字: Ogre

9、:String lManualObjectName = CubeWithAxes; lManualObject = lScene-createManualObject(lManualObjectName);Always tell if you want to update the 3D (vertex/index) later or not.别忘记要告诉你的程序在稍后是否要更新3D(顶点/索引): bool lDoIWantToUpdateItLater = false; lManualObject-setDynamic(lDoIWantToUpdateItLater);Here I crea

10、te a cube in a first part with triangles, and then axes (in red/green/blue).这里咱要创建一个用三角形构成的立方体,and the axes(in red/green/blue)【这句话咱猜是赋予其轴向颜色】BaseWhiteNoLighting is the name of amaterialthat already exist inside Ogre.BaseWhiteNoLighting是一个已经在ogre里面的材质的名字。Ogre:RenderOperation:OT_TRIANGLE_LIST is a kin

11、d of primitive.Ogre:RenderOperation:OT_TRIANGLE_LIST是一种原语。 float lSize = 0.7f; lManualObject-begin(BaseWhiteNoLighting, Ogre:RenderOperation:OT_TRIANGLE_LIST); float cp = 1.0f * lSize ; float cm = -1.0f * lSize; lManualObject-position(cm, cp, cm);/ a vertex lManualObject-colour(Ogre:ColourValue(0.0f

12、,1.0f,0.0f,1.0f); lManualObject-position(cp, cp, cm);/ a vertex lManualObject-colour(Ogre:ColourValue(1.0f,1.0f,0.0f,1.0f); lManualObject-position(cp, cm, cm);/ a vertex lManualObject-colour(Ogre:ColourValue(1.0f,0.0f,0.0f,1.0f); lManualObject-position(cm, cm, cm);/ a vertex lManualObject-colour(Ogr

13、e:ColourValue(0.0f,0.0f,0.0f,1.0f); lManualObject-position(cm, cp, cp);/ a vertex lManualObject-colour(Ogre:ColourValue(0.0f,1.0f,1.0f,1.0f); lManualObject-position(cp, cp, cp);/ a vertex lManualObject-colour(Ogre:ColourValue(1.0f,1.0f,1.0f,1.0f); lManualObject-position(cp, cm, cp);/ a vertex lManua

14、lObject-colour(Ogre:ColourValue(1.0f,0.0f,1.0f,1.0f); lManualObject-position(cm, cm, cp);/ a vertex lManualObject-colour(Ogre:ColourValue(0.0f,0.0f,1.0f,1.0f);face behind / front朝向 背面/前面;(其实这里指的是咱创建的立方体的正面和背面) lManualObject-triangle(0,1,2); lManualObject-triangle(2,3,0); lManualObject-triangle(4,6,5

15、); lManualObject-triangle(6,4,7);face top / down朝向 上/下 lManualObject-triangle(0,4,5); lManualObject-triangle(5,1,0); lManualObject-triangle(2,6,7); lManualObject-triangle(7,3,2);face left / right朝向 左/右 lManualObject-triangle(0,7,4); lManualObject-triangle(7,0,3); lManualObject-triangle(1,5,6); lManu

16、alObject-triangle(6,2,1); lManualObject-end();Here I have finished myManualObjectconstruction.这里咱完成了咱的手动创建对象的构造。It is possible to add more begin()-end() thing, in order to usedifferent rendering operation types, or different materials in 1ManualObject.很可能需要添加更多的begin()和end()来应对不同的渲染操作类型或是1个手动创建对象的不同

17、材质。 lManualObject-begin(BaseWhiteNoLighting,Ogre:RenderOperation:OT_LINE_LIST); float lAxeSize = 2.0f * lSize; lManualObject-position(0.0f, 0.0f, 0.0f); lManualObject-colour(Ogre:ColourValue:Red); lManualObject-position(lAxeSize, 0.0f, 0.0f); lManualObject-colour(Ogre:ColourValue:Red); lManualObject

18、-position(0.0f, 0.0f, 0.0f); lManualObject-colour(Ogre:ColourValue:Green); lManualObject-position(0.0, lAxeSize, 0.0); lManualObject-colour(Ogre:ColourValue:Green); lManualObject-position(0.0f, 0.0f, 0.0f); lManualObject-colour(Ogre:ColourValue:Blue); lManualObject-position(0.0, 0.0, lAxeSize); lMan

19、ualObject-colour(Ogre:ColourValue:Blue); lManualObject-index(0); lManualObject-index(1); lManualObject-index(2); lManualObject-index(3); lManualObject-index(4); lManualObject-index(5); lManualObject-end(); Ogre:String lNameOfTheMesh = MeshCubeAndAxe; Ogre:String lResourceGroup = Ogre:ResourceGroupMa

20、nager:DEFAULT_RESOURCE_GROUP_NAME; lManualObject-convertToMesh(lNameOfTheMesh);Now I can create several entities using that mesh现在咱创建了几个使用mesh的实体。 int lNumberOfEntities = 5; for(int iter = 0; iter createEntity(lNameOfTheMesh);Now I attach it to a scenenode, so that it becomes present in the scene.现在

21、咱将它绑定在节点上, Ogre:SceneNode* lNode = lRootSceneNode-createChildSceneNode(); lNode-attachObject(lEntity);I move theSceneNodeso that it is visible to thecamera.咱移动了SceneNode,以便于摄像机的访问 float lPositionOffset = float(1+ iter * 2) - (float(lNumberOfEntities); lNode-translate(lPositionOffset, lPositionOffset

22、, -10.0f); (PS:完成上面的代码,你应该可以看到几个彩色的正方体在屏幕中,还有几个彩色的坐标轴线)main.cpp/ In this program, I create a ManualObject (like in the previous tutorial)./ This time it will be a little more complicated than just a quad./ To be able to make several copies of it, and at the same time re-use the already created/ 3D d

23、ata, I will convert the Ogre:ManualObject to an Ogre:Mesh./ Such mesh can be used to create several Entities. / An Entity is an instance of a mesh, and allow different material information for each entity./ Entities are often the most common object in a Ogre application. / Different Entities can hav

24、e different materials, while sharing the same mesh./ It is possible to create Entities with different meshes too./ In order to move an Entity, attach it to a SceneNode, and move this SceneNode./ Note : It was reported that on some video drivers (mesa/intel), convertToMesh produces/ some kind of dege

25、nerated (invisible) mesh. If that is the case for you, please update your drivers./ I will use std:auto_ptr so I need to include memory. / If you dont know std:auto_ptr, you should check some C+ tutorials/lesson on this matter.#include / I will check for std:exception. If you dont know what exceptio

26、n/try/catch means, you should learn C+ first.#include / These are some files that we need to include to use Ogre3D. Note that you can at the beginnings use directly Ogre.h, to include lots of commonly used classes.#include OGRE/OgreRoot.h#include OGRE/OgreRenderSystem.h#include OGRE/OgreRenderWindow

27、.h#include OGRE/OgreWindowEventUtilities.h#include OGRE/OgreManualObject.h#include OGRE/OgreEntity.h/Here I include my other files, like the one for SimpleOgreInit.#include SimpleOgreInit.h#include EasyDefines.h/ I declare a function in which I will make my whole application./ This is easy then to a

28、dd more things later in that function./ The main will call this function and take care of the global try/catch.void AnOgreApplication() / I construct my object that will allow me to initialise Ogre easily. OgreEasy:SimpleOgreInit lOgreInit; if(!lOgreInit.initOgre() std:coutImpossible to init Ogre co

29、rrectly.std:endl; return; /I prefer to be able to access my variables directly. Ogre:Root* lRoot = lOgreInit.mRoot.get(); Ogre:RenderWindow* lWindow = lOgreInit.mWindow; / I create a scenemanager. This is like a Scene, in which I can put lights, 3d objects, etc. / The scenemanager contains an arborescent graph of SceneNodes. To manage elements of the scene, / I will create SceneNodes in the SceneManager, and attach the elements to the scenenodes. / First parameter : I select a kind of SceneManager. This may have a huge impact on perfo

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1