8CryENGINE 3.doc_第1页
8CryENGINE 3.doc_第2页
8CryENGINE 3.doc_第3页
8CryENGINE 3.doc_第4页
8CryENGINE 3.doc_第5页
已阅读5页,还剩42页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

Creating VehiclesIn this chapter, we will cover:47Creating a new car mesh (CGA)Creating a new car XMLGiving more speed to the carIncreasing the mass to push objects with the carDefining a sitting locationSetting up multiple cameras for the carNeed for a machine gunGiving the car a weak spotIntroductionBy this point, we have covered a vast majority of the basic principles behind a lot of themain components of CryENGINE 3. For this chapter, we will explore some more advancedcomponents by creating a new vehicle for your player to drive around in your level.Creating a new car mesh (CGA)In this recipe, we will show you how to build the basic mesh structure for your car to be usedin the next recipe. This recipe is not to viewed as a guide on how to model your own mesh, butrather as a template for how the mesh needs to be structured to work with the XML script ofthe vehicle. For this recipe, you will be using 3DSMax to create and export your .CGA.8788创建车辆在这一章里,将包含以下内容:创造一个新的汽车网格(CGA)创造一个新的汽车的XML给汽车更多速度增加汽车的块来推动物体指定座位坐标为汽车建立多角镜头设立机关枪制作汽车的弱光点Introduction到这里我们涵盖了CryENGINE 3的很多主要组成部分背后的大多数的基本原则。这一章里,我们将探讨一些更加先进的组件,为你的玩家创造能在关卡里到处驾驶的新车辆。创建一个新汽车网格(CGA)在这一节中,我们将向你展示如何为你的车辆建造基本网格结构,来用于下一小节。这一节并不是教你如何去建立网格模型,而是作为一个要建造的网格与车辆的XML脚本如何运作的模板。你将会用3 DSMax软件创建并输出您的.CGA。8788Creating Vehicles.CGA (Crytek Geometry Animation): The .cga file is created in the 3Dapplication and contains animated hard body geometry data. It only supportsdirectly-linked objects and does not support skeleton-based animation (boneanimation) with weighted vertices. It works together with .anm files.Getting readyReview the Creating and exporting the static objects recipe of Chapter 6, Asset Creation.Create a box primitive and four cylinders within Max and then create a new dummy helper.How to do it.After creating the basic primitives within Max, we need to rename these objects. Rename theprimitives to match the following naming convention:200Helper = MyVehicleBox = bodyFront Left Wheel = wheel1Front Right Wheel = wheel2Rear Left Wheel = wheel3Rear Right Wheel = wheel4Creating Vehicles.CGA(Crytek模型动画):.CGA文件在3 D应用里创造,它包含动画的硬体模型数据。它只支持直接相关的物体而不支持基于骨骼的加权顶点动画(骨动画)。它与.anm文件一起起作用。准备复习第6章资产创造 的创建和输出静态物体 小节。在MAX里面创建一个原始盒子和四个圆柱然后创建一个新的虚拟帮手。如何做在MAX里创作基本元素后,我们需要重命名这些对象。重命名请按照下列命名惯例:200帮手 = MyVehicle盒子 = body前左轮 = wheel1前右轮= wheel2后左轮= wheel3后右轮 = wheel4Chapter 8Remember that CryENGINE 3 assumes that y is forward. Rotate and reset anyx-forms if necessary.From here you can now set up the hierarchy to match what we will build into the script:1. In Max, link all the wheels to the body mesh.2. Link the body mesh to the MyVehicle dummy helper.Your hierarchy should look like the following screenshot in the Max schematic view:Next, you will want to create a proxy mesh for each wheel and the body. Be sure to attachthese proxies to each mesh. Proxy meshes can be a direct duplication of the simple primitivegeometry we have created.Before we export this mesh, make one final adjustment to the positioning of the vehicle1. Move the body and the wheels up on the Z axis to align the bottom surface of thewheels to be flushed with 0 on the Z.2. Without moving the body or the wheels, be sure that the MyVehicle helper ispositioned at 0,0,0 (this is the origin of the vehicle).3. Also, re-align the pivot of the body to 0,0,0.201Chapter 8记住CryENGINE3假设y轴是向前的。如果必要,旋转和重置任何x轴格式。你现在可以建立层次结构来符合我们建立进脚本的内容:1. 在MAX里连接所有的wheel到body网格。2. 连接body网格到MyVehicle虚拟帮手。你的层次在Max schematic view里应该看起来如下图:接下来,你将要为wheel 和body创建一个proxy mesh,确保把这些代理贴上每个网格。代理网格可以作为我们已创建的简单原始模型的直接副本。在我们输出网格前,对车辆的定位作最后的调整:1. 将身体和车轮上移到Z轴,将轮子底面与Z轴的0点齐平。2. 不移动身体和轮子,要确保MyVehicle帮手定位于0,0,0(这就是车辆的原点)。3. 也重新安排body的支点到0,0 0。201Creating VehiclesOnce complete, your left viewport should look something like the following screenshot (if youhave your body still selected):After setting up the materials that you learned from Chapter 6, Asset Creation, you are nowready to export the CGA:1. Open the CryENGINE Exporter from the Utilities tab.2. Select the MyVehicle dummy helper and click the Add Selected button.3. Change the export to: Animated Geometry (*.cga).4. Set Export File per Node to True.5. Set Merge All Nodes to False.6. Save this Max scene in the following directory: MyGameFolderObjectsvehiclesMyVehicle.7.202Now, click on Export Nodes to export the CGA.Creating Vehicles完成后,你的左视口将看到如下图(如果你选择了body):根据第6章资产创造学到的创建材料之后,你现在可以准备输出CGA:1. 从 Utilities 标签打开CryENGINE Exporter.2. 选择 MyVehicle 虚拟帮手并点击Add Selected按钮.3. 改变输出到: Animated Geometry (*.cga).4. 设置 Export File per Node 为True.5. 设置Merge All Nodes 为False.6. 保存Max场景在下面目录: MyGameFolderObjectsvehiclesMyVehicle.7.202现在,点击Export Nodes 来输出CGA.Chapter 8How it works.This setup of the CGA is a basic setup of the majority of the four wheeled vehicles usedfor CryENGINE 3. This same basic setup can also be seen in the HMMWV provided in theincluded assets with the SDK package of CryENGINE 3.203Chapter 8How it works.CGA的设置是用于CryENGINE 3的多数四轮车辆的基本设置。这个相同的基本设置也能在包含资产的CryENGINE 3 SDK软件包提供的HMMWV里看到。203Creating VehiclesEven though the complete HMMWV may seem to be a very complicated mesh used as avehicle, it can also be broken down into the same basic structure as the vehicle wejust created.The main reason for the separation of the parts on the vehicles is because each partperforms its own function. Since the physics of the vehicle code drives the vehicle forward inthe engine, it actually controls each wheel independently, so it can animate them based onwhat they can do at that moment. This means that you have the potential for a four wheeldrive on all CryENGINE 3 vehicles, all animating at different speeds based on the friction thatthey grip.Since all of the wheels are parented to the body (or hull) mesh, this means that they drivetheir parent (the body of the vehicle) but the body also handles where the wheels need to beoffset from in order to stay aligned when driving. The body itself acts as the base mesh forall other extras put onto the vehicle. Everything else from Turrets to Doors to Glass Windowsbranch out from the body.The dummy helper is only the parent for the body mesh due to the fact that it is easier toexport multiple LODs for that vehicle (for example, HMMWV, HMMWV_LOD1, HMMWV_LOD2, andso on). In the XML, this dummy helper is ignored in the hierarchy and the body is treated asthe parent node.204Creating Vehicles即使这个完整的HMMWV可能似乎是一个非常复杂的车辆网格,它也可以被分解成相同的基本结构,和我们刚刚创建的车辆一样。分离车辆部件的主要原因是因为每个部件有它自己的功能。由于车辆的物理代码在引擎里驱动车辆向前行进,它实际上独立地控制每个轮,因此能基于那刻所能做的让它们动画。这意味着你在所有CryENGINE车辆上有潜在的四轮驱动器。所有不同速度的动画基于他们柄的摩擦力。因为所有的轮子被建立父体到身体(船体)网格,这意味着他们驱动他们的父体(车辆的身体)但身体也操控轮子需要从哪里位移以保持开车时均衡。body本身充当所有其他额外部分装在车辆上的基础网格。其他的body以外的分支部分从Turrets 到Doors 到 Glass Windows.虚拟帮手只是身体网格的父体,归于这个事实为车辆(例如HMMWV,HMMWV_LOD1,HMMWV_LOD2等等)输出多个LOD是很容易的。在XML中,该虚拟助手在层次结构里是被忽略的且身体被作为父节点。204Chapter 8Theres more.Here are some of the more advanced techniques used.Dummy helpers for modification of the partsA more advanced trick is the use of dummy helpers set inside the hierarchy to be used in laterreference through the vehicles mod system. How this works is that if you had a vehicle suchas the basic car shown previously, but you wanted to add on an additional mesh just to havea modified type of this same car (something like adding a spoiler to the back), then you cancreate a dummy helper and align it to the pivot of the object, so it will line up to the body ofthe mesh when added through the script later on.This same method was used in Crysis 2 with the Taxi signs on the top of the Taxi cars. The Taxiitself was the same model used as the basic civilian car, but had an additional dummy helperwhere the sign needed to be placed. This allowed for a clever way to save on memory whenrendering multiple vehicle props within a single area but making each car look different.Parts for vehicles and their limitless possibilityiesAdding the basic body and four wheels to make a basic car model is only the beginning.There are limitless possibilities to what you can make as far as the parts on a vehicle areconcerned. Anything from a classic gunner turret seen on the HMMWV or even tank turrets,all the way to arms for an articulated Battlemech as seen in the Crysis 2 Total ConversionmodMechWarrior: Living Legends. Along with the modifications system, you have thecapabilities to add on a great deal of extra parts to be detach ed and exploded off throughthe damage scripts later on. The possibilities are limitless.See alsoCreating a new car XMLThe Creating and exporting the static objects recipe in Chapter 6, Asset CreationCreating a new car XMLIn this recipe, we will show you how to build a new script for CryENGINE 3 to recognizeyour car model as a vehicle entity. For this recipe, you must have some basic knowledgein XML formatting.205Chapter 8更多.这里是一些更高级的使用技巧。虚拟助手部件修正一个更先进的窍门是使用虚拟助手设置内部层次用于随后的车辆模式系统的参考。这是如何操作的,如果你有一辆前面出现的基本车,但你想添加一个附加网格只是去修改这种相同车的类型(像在后面添加一个扰流板),那么你就可以创建一个虚拟帮手,调整它到物体的支点,这样当通过脚本添加后它将排列到身体网格。同样的方法应用于孤岛危机2里出租车顶上的出租标志。出租车本身是一模一样的基本民用车,但是有一个附加的虚拟帮手在标志要放置的位置。当在单个地区渲染多个车辆道具让每辆车看起来不同,这就是一个保存到内存的聪明的办法。车辆部件和它们的无限的可能性增加基本身体和四个轮子做一个基本的汽车模型仅仅是个开始。有无限的可能,对于您能做的远远不只是涉及汽车的部件。任何东西,从出现在HMMWV的经典的炮手炮塔甚至坦克炮塔,到特殊武器例如在孤岛危机2总转化模式-机甲战士:活的传奇里被采用的铰链式战斗机甲。随着修正系统,你就有能力通过随后的损毁脚本添加上大量的被分离的和爆炸了的额外部件。这个可能性是无限的。另请参阅创建一个新的汽车的XML创建和输出静态物体 小节 在第6章创造资产创建一个新的汽车的XML在这节里我们将告诉你如何为CryENGINE 3建立一个新脚本去把你的汽车模型识别为一个车辆的实体。对于这一节,你应该有一些基本的XML格式化的知识。205Creating VehiclesGetting readyOpen DefaultVehicle.xml in the XML editor of your choice (Notepad, Notepad+,UltraEdit, and so on). This XML will be used as the basic template to construct our newvehicle XML.DefaultVehicle.xml is found at the following location: MyGameFolderScriptsEntitiesVehiclesImplementationsXml.Open the MyVehicle.max scene made from the previous recipe to use as a reference for theparts section within this recipe.How to do it.Basic Properties:1. First, we will need to rename the filename to what the vehicles name would be.2. Delete filename = Objects/Default.cgf.3. Rename name = DefaultVehicle to name = MyVehicle.4. Add actionMap = landvehicle to the end of the cell.5. Save the file as MyVehicle.XML.6. Your first line should now look like the followingDownloading the example codeYou can download the example code files for all Packt books you havepurchased from your account at http:/www.PacktP. If youpurchased this book elsewhere, you can visit http:/www.PacktP/support and register to have the files e-mailed directly to you.7.Now we need to add some physics simulation to the vehicle otherwise there might besome strange reactions with the vehicle. Insert the following after the third line (afterthe Buoyancy cell):Damages and Components:For now, we will skip the Damages and Components cells as we will address them in adifferent recipe.206 Creating Vehicles准备打开你选择的 XML editor里的 DefaultVehicle.xml (通过Notepad, Notepad+,UltraEdit等等). 这个XML 将用作基本模板去建造我们的新车辆 XML.DefaultVehicle.xml 文件可以在下面的位置找到:MyGameFolderScriptsEntitiesVehiclesImplementationsXml.打开前面小节做的MyVehicle.max 场景,作为这节里部件的资料使用。如何做.基本性能:1. 首先,我们要重命名文件名为车辆的名字2. 删除 filename = Objects/Default.cgf.3. 重命名 name = DefaultVehicle为name = MyVehicle.4. 添加actionMap = landvehicle 到单元的末尾.5. 保存文件为 MyVehicle.XML.6. 第一行应该看起来如下:Downloading the example code你可以为你在http:/www.PacktP购买的所有的Packt书籍下载例子代码文件,如果你是在其他地方购买的此书,你可以访问http:/www.PacktP/support注册直接得到e-mail给你的文件。7.现在我们需要添加一些物理的模仿到这个车辆,否则这个车可能会有一些奇怪的反应。在第三行后插入如下: (在Buoyancy 单元后):损害和部件:现在,我们将跳过Damages and Components单元,因为我们将在别的章节里讲解。206 Chapter 8Parts:1. To associate the parts made in the Max file, the hierarchy of the geometry in 3DSMaxneeds to be the very same as is referenced in the XML. To do this, we will first clearout the class = Static cell and replace it with the following:2. Now, within the tag that is underneath the body, we will put in the wheelsas the children:3. Remaining within the tag, add in wheels 2-4 using the same values aspreviously listed. The only dif

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论