Unity3D中创建树木指南

Unity3D中创建树木指南

Tree Creator Guide  树木创建指南

()

The TreeCreator allows you to create and edit trees procedurally. The resultingtrees can be used as normal GameObjects orintegrated into the Terrain Engine. With this tool, you can create greatlooking trees quickly and fine tune your trees using a number of design toolsto achieve the perfect look in your game. The Tree Creator is very useful whenyou want to create a forest or a jungle where you need different tree forms.

树木创建器允许你程序化的创造和编辑树木。 创造出来的树木能够像普通的游戏物体一样使用或者融入(Terrain)地形引擎。 利用这个工具,在你的游戏中你能使用一些设计工具快速的调整你的树木达到最好的形状。

这个树木创建器非常重要当你想要创建一片森林或者树林的时候它能让你创建不同的树木。

创建你的第一棵树

In this section we walk you stepby step to create your first tree in Unity.

这一章我们带领你在 Unity中一步一步创建你的第一棵树。

We'll now walk you through thecreation of your first Tree Creator Tree in Unity. First, make sure you haveincluded the tree creator package in your project. If you don't, select Assets->Import Package..., navigate to your Unityinstallation folder, and open the folder named Standard Packages. Select the Tree Creator.unityPackage package to get the needed assets into your project.

我们现在带领你在unity中用树木创建器创造你的第一棵树木。首先,确保在你的项目里包含有树木创建器包裹。如果没用,选择Assets->ImportPackage...,进入到你的unity安装文件夹,然后打开名为Standard Packages的包裹。选择这个Tree Creator.unityPackage得到所需要的资源导入到你的项目中。

Adding a new Tree 添加一个新的树木

To create a new Tree asset, select GameObject->CreateOther->Tree.

选择GameObject->Create Other->Tree,创建一个新的树木资源。

You'll see a new Tree asset iscreated in your Project View, and instantiated in the currently open Scene.This new Tree is very basic with only a single branch, so let's add somecharacter to it.

你能够在你的工程视图(Project View)中看到一个新的树木资源,在当前打开的场景中也能看到它的实体。这个非常基本的树木只有仅仅一个树枝,因此让我们添加一些特征给它。

Adding Branches 添加分支


A brand new tree in your scene一个全新的树木在你的场景中

Select the tree toview the Tree Creator in the Inspector. This interface provides all the tools forshaping and sculpting your trees. You will see the TreeHierarchy with two nodes present: the Tree Rootnode and a single Branch Group node, whichwe'll call the trunk of the tree.

选择这个树木然后观察树木创建器的监视面板(Inspector)。这个界面为你提供了所有的塑造和雕刻树木的工具。你将会看到2个树的层次结构节点:一个树的根节点和一个单一树枝组节点,我我们讲给这个树的树干。

In the Tree Hierarchy, select the BranchGroup, which acts as the trunk of the tree. Click on the Add Branch Group button and you'll see a new Branch Group appear connected to the Main Branch. Nowyou can play with the settings in the Branch GroupProperties to see alterations of the branches attached to the treetrunk.

在树的层次结构(Tree Hierarchy)中,选择树枝组(Branch Group),它作为树的躯干。单击添加树枝组(Add Branch Group)按钮,你将看到一个连接到主枝干的树枝组。现在你能够在树枝组属性(Branch GroupProperties)中改变附着在树干的树枝了。


Adding branches to the tree trunk.添加树枝到树干。

After creating the branches that areattached to the trunk, we can now add smaller twigs to the newly createdbranches by attaching another Branch Groupnode. Select the secondary Branch Group andclick the Add Branch Group button again. Tweakthe values of this group to create more branches that are attached to thesecondary branches.

在创建附着于树干的分支以后,我们现在能够通过附加另外的树枝组节点(Branch Group)添加较小的末梢给刚刚创建的分支。选择第二个树枝组,然后再次点击添加树枝组按钮。

调整这个组的值去创建更多的附着于第二个树枝的分支。


Adding branches to the secondary branches. 添加树枝到第二个分支。

Now the tree's branchstructure is in place. Our game doesn't take place in the winter time, so weshould also add some Leaves to the differentbranches, right?

现在树木的分支结构在合适的位置。由于我们的游戏不是在冬天的季节,因此我们应该添加一些树叶给不同的树枝,对吗?

Adding Leaves  添加树叶

We decorate our tree with leavesby adding Leaf Groups, which basically work thesame as the Branch groups we've already used. Select your secondary BranchGroup node and then click the Add Leaf Groupbutton. If you're really hardcore, you can add another leaf group to thetiniest branches on the tree as well.

我们通过添加叶子组(Leaf Groups)用树叶来装饰我们的树,它的基本操作和我们已经使用过的树枝组操作一致。选择你的第二个树枝组节点,然后点击添加叶子组(Add Leaf Group)按钮。如果是真实的铁杆,你同样能够在树上添加另外的叶子组到微小的分支。


Leaves added to the secondary and smallestbranches  添加树叶到第二和最小的树枝

Right now the leavesare rendered as opaque planes. This is because we want to adjust the leaves'values (size, position, rotation, etc.) before we add a material to them. Tweakthe Leaf values until you find some settings you like.

此刻这些树叶是以不透明的位面渲染出来的。这是因为我们想在给它们添加材质以前,调整树叶的值(尺寸,位置,旋转,等等。)。

Adding Materials 添加材质

In order to make our treerealistic looking, we need to apply Materialsfor the branches and the leaves. Create a new Material in your project using^Assets->Create->Material. Rename it to "MyTree Bark", and choose Nature->Tree Creator Bark^^ from theShader drop-down. From here you can assign the Texturesprovided in the Tree Creator Package to the Base, Normalmap, and Glossproperties of the Bark Material. We recommend using the texture"BigTree_bark_diffuse" for the Base and Gloss properties, and"BigTree_bark_normal" for the Normalmap property.

为了使我们的树看起来逼真,我们需要应用材质给分支和树叶。使用^Assets->Create->Material(菜单栏中点击Assets或者在project view中右击鼠标创建材质)创建一个新的材质。给它重命名为"My Tree Bark",然后从Shader的下拉菜单中选择Nature->Tree Creator Bark^^。从树木创建包裹(Tree Creator Package)里面提供的纹理,你能够指定合适的纹理到树皮材质(Bark Material)的基础(Base),法线贴图(Normalmap),和光泽属性(Glossproperties),和"BigTree_bark_normal" 给这个法线贴图属性。

Now we'll follow thesame steps for creating a Leaf Material. Create a new Material and assign theshader as Nature->Tree Creator Leaves. Assignthe texture slots with the leaf textures from the Tree Creator Package.

现在我们将遵循同样的步骤去创建叶子材质。创建一个新的材质,然后指定Nature->TreeCreator Leaves这个着色器。指定树木创建包裹(Tree Creator Package)中的叶子纹理给这个纹理槽。

Material for theLeaves  材质的的叶子

When both Materialsare created, we'll assign them to the different Group Nodes of the Tree. Selectyour Tree and click any Branch or Leaf node, then expand the Geometry section of the BranchGroup Properties. You will see a Material assignment slot for the typeof node you've selected. Assign the relevant Material you created and view theresults.

当所有的材质被创建,我们将赋值给这棵树的不同的组节点。选择你的树接着点击任何树枝或者叶子节点,然后展开这个树枝组属性(Branch GroupProperties)的选项。你将看到你选择的节点类型的材质赋值槽。指定相关的材质给你所创建的然后观看结果。


Setting the leaves material 设置树叶的材质

To finish off thetree, assign your Materials to all the Branchand Leaf Group nodes in the Tree. Now you'reready to put your first tree into a game!

完成这颗树,指定你的材质给所有的树枝和叶子组节点。现在可以放置你的第一棵树到游戏中去了!


Tree with materials on leaves and branches.一棵有树叶和树枝材质的树

Hints. 提示

Creating trees is a trialand error process.

Don't create too manyleaves/branches as this can affect the performance of your game.

Check the  guide for creating custom leaves.

创建树是一个反复试验的过程。

不要创建太多的树叶/分支,因为这影响你的游戏性能。

查看指南创建自定义的树叶。

2012/6/30