2014-08-11 20:15:20|?次阅读|上传:huigezrx【已有?条评论】发表评论
关键词:游戏, 虚拟现实, Unity3D|来源:唯设编程网
Reference Manual > Terrain Engine Guide > Trees
参考手册—>地形引擎指南—>树
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的地形引擎有特别为树的支持。You can put thousands of trees onto a Terrain, and render them in-game with a practical frame rate.你可以在一个地形上放置数千棵树,并用一个实际的帧速渲染它们。在一个全3D的摄像机附近进行树的重绘工作,并且把远的树变换成2D揭示牌。在远处的揭示牌它们自己将自动更正到恰当的方向以符合它们从不同的角度展示。这个变换系统处理一个元件树环境是非常简单特性。 你可以完全控制网格的参数到揭示牌的转换,以便你达到你需要的最佳性能。
You can easily paint lots of trees for beautiful environments like this 你可以轻松的绘制出像这个美丽的多树环境。
Select the Place Trees button in the Inspector.
在检视面板选择Place Trees(种树)按钮
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.
从你的项目面板视图中选择树木,然后拖拽它到这个树变量。如果你想增加额外的“风中的弯曲效应”效果动画给这些树木,你可以编辑Bend Factor(弯曲因子)。当你准备好,点击 添加 按钮,这个选定的树木将在检视面板中显示。
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 当前选定的树总是以蓝色突出显示
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 paintbrush tool 绘制树木与使用画刷工具一样容易
There are a number of options at your disposal when placing trees.
当种植树木是,这有几个选项由你支配。
Brush Size 画刷大小 |
Radius in meters of the tree placing brush. 树木刷子的米半径 |
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. 每一个树宽度差的允许量 |
Different Brush sizes cover different area sizes 不同的画刷大小覆盖不同区域的大小
Adjust Tree Spacing to change the density of the trees you're painting 在你绘制时,调整树间距改变树木的密度
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.(编辑树木按钮 ->编辑元件)。或双击你想要编辑的树。你将看到编辑树对话框,然后,你可以任意更改设置。
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棵树木立即种植
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(地形->刷新树和元件原型)。这样做完后,你已经更新了你的源资产并保持它,而且,将立即刷新在你地形里的树。
Every tree should consist of a single mesh with two Materials. One for the trunk and one for the leaves. 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的一个平均树。三角形越少越好,树网格的支点坐标必须正确的在树的根部,这是个坐标在那个地方遇到表面,它才能栽种上。这使它成为最容易导入到Uinty中和其它模型的应用。
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.
树必须使用自然/软闭塞树叶和自然/软闭塞树皮着色。为使用这些着色器,你也必须同样在一个指定的文件夹名称中含"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. Even if you don't want to use the builtin trees, we strongly recommend that you take a look at those trees as an example on how to model trees.
Unity也附带了几个高品质的树木在"Terrain Demo.unitypackage"中。你可以在你的游戏里容易的使用这些树。即使你不想使用内置的树,但我们强烈的建议你把这些树作为模型例子看看。
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个三角形和显示相当多的曲率。你可以为每个曲率添加更多的三角形。但是主要问题是:当处理树木时,三角形不能与四方形联合使用。如果你使用四方形,你基本上需要一样多三角形两次来取得分支同样的曲率。
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.
树本身损耗庞大的供应速率由巨大的无形阿尔法大量填充率的多边形提供。这应该是性能避免的原因,当然,目标为茂密树林也是其原因。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.它们它们它们是如此密集,甚至你看穿叶子。
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.
如果你希望你的树木使用碰撞器,这很容易。当你引入你的树资产文件,所有你需要做的是场景视图中实例化它们,添加一个Capsule Collider和调整它,使它成为一个新的预制游戏物体。然后,当你添加树木到你的地形时,你添加带有附着Capsule Collider预制的树。你也可以在添加带有碰撞的树时单独使用Capsule Colliders。