城市环境构建指南

上传人:子 文档编号:47039606 上传时间:2018-06-29 格式:PDF 页数:12 大小:584.49KB
返回 下载 相关 举报
城市环境构建指南_第1页
第1页 / 共12页
城市环境构建指南_第2页
第2页 / 共12页
城市环境构建指南_第3页
第3页 / 共12页
城市环境构建指南_第4页
第4页 / 共12页
城市环境构建指南_第5页
第5页 / 共12页
点击查看更多>>
资源描述

《城市环境构建指南》由会员分享,可在线阅读,更多相关《城市环境构建指南(12页珍藏版)》请在金锄头文库上搜索。

1、城市环境构建指南之第一部:vue/max 篇 城市环境构建指南之第二部:cityengine 篇 城市环境构建指南之第三部:udk 篇 本教程的目的是在 udk 中制作一个城市环境关卡,主要利用 vue 制作环境、cityengine 生成布局,最终 通过脚本导入 udk。根据制作流程分为三部分。本部分是用 cityengine 生成城市环境。 1 vue 篇 1.1 天空 在 vue 中新建一个工程(File-New),选择合适的天气(fig. 1.1)。 选择 File-Export Sky,导出天空。注意标出的选项(fig. 1.2)。提示:导出需要较长时间。 1.2 地形 在 vue

2、中选择 Standard Heightfield Terrain。将大小改为 256*256。 进入编辑器。由于我们要做的是城市地形,所以将地形修的平坦一些。做好之后点击 Export terrain, 导出为 bmp 格式(fig. 1.3)。 注意:尽管 udk 支持 bmp格式的地形,但此 bmp 非彼 bmp,需要转换一下。软件可以用 g16ed或 hmcs,用法很简单,就不细说了(fig. 1.4)。最后导出大小是 257*257(udk要求比原来加一)。 2 3ds max 篇 2.1 天空模型 新建一个 Sphere,转换为可编辑网格。进入多边形层级,删除下半球,并将上半球翻转法

3、线。导出成 ase 格式(fig.1.5)。 2.2 建筑模型 3ds max 建模没什么可说的,大家比我熟练。只是为了配合后面的制作,模型必须遵守以下规则: z 轴向上 y轴与屏幕垂直 底面与 xy平面重合 原点位于底面中心 建好模型、贴好贴图后,逐个建筑导出。分别导出成 obj和 aes 格式,其中 obj导出时要选择 flip yz- axis。文件名按 building_1.obj building_2.obj .依次排序,以便之后的脚本调用。 1 前期准备: 打开 cityengine,选择 File-New-Cityengine Project,新建一个工程。这时 cityengi

4、ne 会自动建立如图 1.1的目录结构。 用资源管理器打开,把上部教程生成的文件复制过去: building_x.obj模型及贴图放在 assets文件夹 terrain.bmp 放在 maps 文件夹。 用记事本编辑以下内容: 1. /* 2. * File: scifi_buildings_for_t3d.cga 3. * Created: 13 Jan 2010 16:49:10 GMT 4. * Author: andi 5. */ 6. 7. version “2010.3“ 8. 9. import reportInstances : “report3D.cga“ 10. 11.

5、# randomly select on of the three building assets 12. attr instanceID = 25% : 1 25% : 2 else : 3 13. 14. buildingObjFile(id) = “building_“+id+“.obj“ 15. 16. 17. 18. / prepares the footprint 19. Lot 20. convexify comp(f)all : alignScopeToGeometry(yUp,0,longest) innerRect Footprint 21. 22. LotInner Lo

6、t 23. LotCorner Lot 24. 25. / call building with an instanceID 26. Footprint 27. case scope.sx 32. alignScopeToAxes(y) 33. s(1,0,1) 34. i(buildingObjFile(id) Building. 35. reportInstances.InstanceReport(id, buildingObjFile(id) 复制代码 保存为 instancedBuildings.cga,放在 rules文件夹。 用记事本编辑以下内容: 1. /* 2. * File:

7、 reportInstance.cga 3. * Created: 7 Apr 2010 14:28:33 GMT 4. * Author: andi 5. */ 6. version “2010.3“ 7. / this rule prepares report variables that are read by the python export script 8. 9. InstanceReport(id, asset) 10. 11. report(“buildingID“, id) 12. report(“buildingName“, asset) 13. 14. # report

8、 scale value relative to bbox sizes from asset 15. report(“xscale“, scope.sx/assetInfo(asset, sx) 16. report(“zscale“, scope.sz/assetInfo(asset, sz) 17. report(“yscale“, scope.sy/assetInfo(asset, sy) 18. report(“yrot“, convert(y, pivot, world, orient, 0,0,0) 19. s(0.01,1,0.01) center(xz) / this is n

9、ecessary as building assets have their pivot in the center 20. 21. report(“xpos“, convert(x, scope, world, pos, 0,0,0) 22. report(“ypos“, convert(y, scope, world, pos, 0,0,0) 23. report(“zpos“, convert(z, scope, world, pos, 0,0,0) 24. NIL 复制代码 保存为 report3D.cga,放在 rules 文件夹。 用记事本编辑以下内容: 1. 2. Created

10、 on 4/7/2010 3. author: andi 4. 5. from scripting import * 6. # Get a CityEngine instance 7. ce = CE() 8. 9. # Globals 10. out = “ # global string that collects all data to be written 11. count = 0 # global count to enumerate all instances 12. 13. 14. # Called for each initial shape after generation

11、. 15. def finishModel(exportContextUUID, shapeUUID, modelUUID): 16. global out, count 17. ctx = ScriptExportModelSettings(exportContextUUID) 18. shape = Shape(shapeUUID) 19. model = Model(modelUUID) 20. 21. 22. if(model.getReports().has_key(xpos): # only write t3d entry if report data available 23.

12、l = len(model.getReports()xpos) # there might be more than one asset per model, therefore loop 24. 25. for i in range(-1,l-1): 26. out = out+writeT3dActor(model.getReports(),count, i) 27. count = count+1 28. 29. 30. # Called after all initial shaped are generated. 31. def finishExport(exportContextU

13、UID): 32. 33. # path and name of the output file 34. path = ce.toFSPath(“models“) # current projects model folder 35. 36. # you might want to export to your UDK directory directly 37. #path = “C:/Users/USER/Documents/My Games/Unreal Tournament 3/UTGame/Unpublished/CookedPC/scifi“ 38. 39. file = path

14、+“/instances.t3d“ 40. 41. global out 42. 43. # write collected data to file 44. out = writeT3d(file, out) 45. 46. 47. 48. 49. # 50. # t3d fucntions 51. # main t3d actor function 52. def writeT3dActor(reports, count, index): 53. 54. # make sure these values match the content in the UDK content browse

15、r 55. # in ce_scifi package, buildings are named e.g. building_2Shape 56. packagename = “building_tutorial“ 57. 58. #static mesh naming : 59. prefix = “building_“ 60. suffix = “ 61. 62. 63. instanceID = int(reportsbuildingIDindex) 64. 65. staticMeshName = packagename +“.“+ prefix + str(instanceID) + suffix; 66. # this will result in ce_scifi.building_2Shape. make sure your staticmeshes are named correctly in UDK content browser 67. 68. text =“ 69. text+= “tBegin Actor Class=StaticMeshActor Name=StaticMeshActor_“+str(count)+“ Archetype=St

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 生活休闲 > 科普知识

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号