- 最后登录
- 2018-12-19
- 注册时间
- 2012-8-20
- 阅读权限
- 90
- 积分
- 54706
- 纳金币
- 32328
- 精华
- 41
|
Unity's Terrain Engine has special support for Trees. You can put thousands of trees onto a Terrain, and render them in-game with a practical frame rate. This works by rendering trees near the camera in full 3D, and transitioning far-away trees to 2D billboards. Billboards in the distance will automatically update to orient themselves correctly as they are viewed from different angles. This transition system makes a detailed tree environment very simple for performance. You have complete control over tweaking the parameters of the mesh-to-billboard transition so you can get the best performance you need.Unity的地形引擎对树有特别的支持。你可以放上千棵树在地形上面,然后在用1个实际的帧率渲染它们。它将靠近相机的树渲染为3D,将远离摄像机的树转变为2D公告板。这些公告板能够自动转动它们自己,这样不管用哪个角度观察它们,都不会出错。转换系统使得精细的树环境在效率方面非常简单。你可以完全控制调整"模型到公告板"转换的参数,这样你能得到你需要的最好的表现。
You can easily paint lots of trees for beautiful environments like this
你可以很简单的绘制很多树去构建一个美丽的环境,如上图所示。
Adding Trees 添加树Select the Place Trees button in the Inspector.在检视面板上选择种树按钮。Before you can place trees on your terrain, you have to add them to the library of available trees. To do this, click the Edit Trees button->Add Tree. You'll see the Add Tree dialog appear.在你往地上种树之前,你需要先往可用的树库里面增加他们。为了实现这个,需要点击Edit Trees button->Add Tree。你将看到添加树对话框。
The Add Tree dialog 增加树对话框Select the tree from your Project View and drag it to the Tree variable. You can also edit the Bend Factor if you want to add an additional bit of animated "bending in the wind" effect to the trees. When you're ready, click Add. The tree will now appear selected in the Inspector.从项目视图选择1棵树拖到树变量上面。如果你想添加一个附加的动画"风吹的树弯了"的效果给树,你也可以编辑弯曲因数。当你做好准备后,按添加按钮。树将在检视面板出现,而且被选择。
The newly added tree appears selected in the Inspector
新添加的树,而且被选择,出现在检视面板上。You can add as many trees as you like. Each one will be selectable in the Inspector for you to place on your Terrain.你可以增加足够多的树。每一棵都能在检视面板被选中,然后种在你的地面上。
The currently selected tree will always be highlighted in blue
当前选择的树总是在蓝色背景里呈现高亮
【Painting Trees 种树】While still using the Place Trees tool, click anywhere on the Terrain to place your trees. To erase trees, hold the Shift button and click on the Terrain.使用种树工具,点击地形的任何地方都能种树。按住shift按钮然后点击地面,可以擦掉树。
Painting trees is as easy as using a paint***sh tool
通过使用笔刷工具,种树变的非常容易There are a number of options at your disposal when placing trees.当你种树时,这里有一些选择。 ***sh Size 笔刷大小
Radius in meters of the tree placing ***sh.
以米为单位的笔刷半径。
Tree Spacing 树间距
Percentage of tree width between trees.
树之间的距离在树宽度里面占的百分比
Color Variation 颜色变化
Allowed amount of color difference between each tree.
允许每棵树颜色的差异值
Tree Height 树高度
Height adjustment of each tree compared to the asset.
每棵树相比于资源的高度调整
Height Variation 高度变化
Allowed amount of difference in height between each tree.
允许每棵树高度的差异
Tree Width 树宽度
Width adjustment of each tree compared to the asset.
每棵树相比于资源的宽度调整
Width Variation 宽度变化
Allowed amount of difference in width between each tree.
允许每棵树宽度的差异 【Tree Painting Tips 树木绘制技巧】
Different ***sh sizes cover different area sizes
不同笔刷大小覆盖不同大小的地面
Adjust Tree Spacing to change the density of the trees you're painting
调整树间距来改变树的密度
【Editing Trees 编辑树】To change any import parameters for an added tree, select the detail and choose Edit Trees button->Edit Detail. Or double-click the tree you want to edit. You will then see the Edit Tree dialog, and you can change any of the settings.为了改变新添加的树的导入参数,可以选择Edit Trees button->Edit Detail。或者双击你想编辑的树。你将看到编辑树对话框,你可以改任何配置。
【Mass Placement 批量植树】If you don't want to paint your trees and you just want a whole forest created, you can use Terrain->Mass Place Trees. Here, you will see the Mass Place Trees dialog. You can set the number of trees you want placed, and they'll be instantly positioned. All the trees added to your Terrain will be used in this mass placement.如果你不想画树而只是想创建整个一片森林,你可以选择Terrain->Mass Place Trees。这里,你将看到大量放置树对话框。你可以设置你想放置的树的数量,它们将立刻定位。通过这个,所有的树将被添加到地形上
10,000 Trees placed at once
10000棵树被立即种上去
【Refreshing Source Assets 刷新源资源】If you make any updates to your tree asset source file, it must be manually re-imported into the Terrain. To do this, use Terrain->Refresh Tree and Detail Prototypes. This is done after you've changed your source asset and saved it, and will refresh the trees in your Terrain immediately.如果你想对树的资源文件做任何更新,它必须被重新导入到地形上。使用Terrain->Refresh Tree and Detail Prototypes。当你改变资源文件而且保存后,它将立即刷新到你的地形上。
【Creating Trees 创建树】Trees can be created in two ways to the terrain engine:地形引擎提供了2种通道创建树The first one is by using the Tree creator that Unity comes with, and the second one is by using a 3rd party modeling program compatible with Unity, in this case every tree should consist of a single mesh with two Materials. One for the ***nk and one for the leaves.第一种使用Unity自带的树创建器,另外是用Unity整合的第3方的建模软件。每棵树由1个模型和2个材质组成。一个是主一个是树叶。For performance reasons, triangle count should be kept below 2000 for an average tree. The fewer triangles the better. The pivot point of the tree mesh must be exactly at the root of the tree, that is at the point where the tree should meet the surface it is placed on. This makes it the easiest to import into Unity and other modelling applications.由于执行的因素,平均每棵树多边形的数量应保持在2000以下。多边形越少越好。中枢点必须是树的根结点,这个点需要满足表面放上去。这个很容易导入到Unity和其他模型程序。Trees must use the Nature/Soft Occlusion Leaves and Nature/Soft Occlusion Bark shader. In order to use those shaders you also have to place the tree in a special folder that contains the name "Ambient-Occlusion". When you place a model in that folder and reimport it, Unity will calculate soft ambient occlusion specialized for trees. The "Nature/Soft Occlusion" shaders need this information. If you don't follow the naming conventions the tree will look weird with completely black parts.树必须使用Nature/Soft Occlusion Leaves 和 Nature/Soft Occlusion Bark shader着色器。为了使用这些着色器,你还必须放置在一个特殊的名为Ambient-Occlusion的文件夹。当你在该文件夹中放置一个模型,并重新导入,Unity将计算树的软环境光遮蔽。Nature/Soft Occlusion需要此信息。如果你不遵循命名约定树将看起来完全是怪异的黑色。Unity also ships with several high quality trees in the "Terrain Demo.unitypackage". You can use those trees readily in your game.Unity也自带了一些高质量的树在"Terrain Demo.unitypackage"中。你可以在你的游戏里使用那些树。
【Using Low Poly Trees 使用低多边形树】One branch with leaves is done with only six triangles and shows quite a bit of curvature. You can add more triangles for even more curvature. But the main point is: When making trees, work with triangles not with quads. If you use quads you basically need twice as many triangles to get the same curvature on branches.一个带叶子的树枝有6个面,显示出一些弯曲。你可以增加更多的多边形,使其更加的弯曲。但是要点是:当制作树时多边形不要用正方体。如果你用了,你将用2倍的多边形达到同样的弯曲效果。The tree itself wastes a lot of fillrate by having large polygons but almost everything is invisible due to the alpha. This should be avoided for performance reasons and of course because the goal is to make dense trees. This is one of the things that makes Oblivion's trees look great. They are so dense you cant even see through the leaves.树浪费了很多的多边形,因为它们大部分会因为alpha通道而看不到。由于执行的因素,这个应该被避免,因为目标是创建稠密的树。这也是其中一个原因使得不引人注意的树看起来很好。它们非常稠密,你不能通过叶子看到它们。
【Setting up Tree Collisions 设置树碰撞器】If you'd like your trees to make use of colliders, it's very easy. When you've imported your Tree asset file, all you need to do is instantiate it in the Scene View, add a Capsule Collider and tweak it, and make the GameObject into a new Prefab. Then when you're adding trees to your Terrain, you add the tree Prefab with the Capsule Collider attached. You can only use Capsule Colliders when adding collisions with trees.如果你想要树有碰撞,这个非常容易。当导入树资源文件时,你所要做得就是在场景视图里面,增加一个胶囊碰撞然后调整它,然后将这个游戏物体放到一个新的预制件里面。然后在你增加树到你的地形上面时,你添加的是这个带胶囊碰撞体的prefab。你只能用胶囊碰撞体添加到树上面。
【Making your Trees Collide. 使你的树带碰撞】
Terrain Collider Inspector 地形碰撞器检视面板If you want to make your trees collide with rigid bodies, make sure you you check the Create Tree Colliders box. else your objects will go trough the trees you create. Note that the PhysX engine used by Unity only handles a maximum of 65536 colliders in a scene. If you use more trees then that (minus the other colliders already in the scene), then enabling tree colliders will fail with an error.如果你想要你的树碰撞带有刚体,请确认你选了"Create Tree Colliders"这个复选框。否则物体将可穿过这些树。注意在1个场景里,Unity整合的PhysX引擎只能处理最多65536个碰撞体。如果你使用了更多的树(不包括那些已经存在在场景中的碰撞体),它们会掉下去,还会报错。
【来源:互联网】
更多精彩教程,尽在web3D纳金网http://www.narkii.com/college/ |
|