[Unity] 4.5 tree creator, unity4.5 tree Creation

Source: Internet
Author: User
Tags unity 5

[Unity] 4.5 tree creator, unity4.5 tree Creation

Classification: Unity, C #, VS2015

Created on: 1. Introduction

The section in the terrain editor shows you how to use a created tree to form a large forest. This section shows you how to use the tree builder in Unity 5.3.4 to create a tree step by step:

After learning how to create a tree, you can create a tree of any shape as needed:

2. Import the Environment component of Unity

If you have not imported the Environment component that comes with Unity, You need to import it:

To do this, right-click the Assets folder in the project view, select Environment, click All in the displayed window, and then click Inport.

In this case, the imported resources are displayed in the Standard Assets Folder:

Click the subfolders in the Environment/SpeedTree folder, and observe the files in the subfolders so that you can have a rough understanding of the structure.

In addition to the SpeedTree component, Environment also contains the TerrainAssets and Water components ).

After importing Environment, you can directly use these components. 3. Create the first tree

1. Create a scenario

Add a Demo06 folder and create a scenario named Demo06Scene under the folder:

Double-click to open the scenario.

2. Add a new tree

To create a new Tree resource in the created scenario, right-click the Hierarchy view (Hierarchy) and choose 3D Object> Tree ]:

In the Project View, a pre-fabricated object file named Tree is created and dragged to the Demo06 Folder:

After dragging and dropping, you can see the file in the Demo06 folder and rename it Demo06Tree01 to identify which example was created:

After the name is changed, you can see the instantiated Demo06Tree01 tree in the current scenario (if this is not the case, rotate and scale it to see it ):

Now this new tree is quite simple. There is only one trunk. Next we will add branches and leaves for it.

3. Observe the general structure of the tree builder.

Select the tree and check the structure of the tree builder in the Inspector (red box ):

The viewer provides all the tools and attributes for shaping and engraving the tree you created.

On the Tree tab, you can see the Tree Hierarchy view of the nodes: Tree Root node and a single Branch Group) node (called trunk ).

For convenience, four small buttons (in the red box) in the lower right corner of the tree builder will be added later) name "button 1", "button 2", "button 3", and "button 4" respectively from left to right ]:

[Add Leaf]: Add leaves. Add a leaf node to the selected node group.

[Add Branch]: Add branches. Add a node to the selected group.

[Copy Node]: Copy Node. Copy the selected group.

[Delete Node]: deletes a Node. Deletes a node or Spline in the currently selected group or scenario View in Hierarchy.

In addition to the four buttons, there are:

[Tree State]: State information of a Tree (above the four small buttons). This state tells you how many vertices, triangles, and materials a Tree has.

External Reload: This is also called refresh, that is, calculating the entire tree again (this button is on the left of the four small buttons ). You can use this button when the leaf mesh has changed.

4. Add Branches)

On the Tree tab, click Add Branch to Add a Branch:

Select the newly added branches, and use the move branches, rotate branches, custom branches, and Delete Node buttons below the four buttons )], drag and Drop a small square to change the shape of the branch in the scene:

Click the main trunk, click Add Branch, and Add another Branch according to the same method described above:

After creating a Branch on the trunk, you can further select the secondary Branch Group and click Add Branch again)] add smaller branches to the newly created branches. Fine-tune the value of this group to continue creating more branches connected to the secondary branches.

Now, the branches structure of this simple tree has been completed. If the game is not in winter, you also need to add leaves (Leaf) on the branches ).

5. Add leaves

The operations for adding leaves and branches are basically the same. The basic steps are as follows: select a branch node and click Add Leaf.

You can add another leaf group to the smallest branches if you want to create it in a very detailed manner.

The scenario where one leaf is added to the trunk and two branches respectively:

Now, the leaves are only rendered into an opaque plane. This is because we need to adjust the leaf value (size, position, rotation, etc.) before adding materials to them ). After adjustment, you can add materials for it.

6. Add Materials

To make the tree look more realistic, you also need to apply the Material (Material) on the branches and leaves ).

(1) Create branch material

Right-click the Demo06 folder and choose Create> Material. In this folder, Create a new Material and rename it Demo06Bark01, this is the 1st Bark material created in the Demo06 folder.

From the Shader drop-down menu, choose Nature> Tree Creator Bark )]:

Select the BroadleafBark texture for the basic attribute and Gloss attribute:

Use the [BroadleafBark_Normal] texture for the normal map attribute:

In this way, the created branch material (Demo06Bark01. mat file) is obtained in the Demo06 Folder ):

Select a branch and apply the created branch material to the Branch:

Select other branches until all materials are applied.

(2) create leaf material

Follow the same steps to create a branch material, and then create a material named Demo06Leaf01. mat.

From the Shader drop-down menu, choose Nature> Tree Creator Leaves )]:

Specify the texture:

The leaf material is obtained:

Select a leaf and apply the material to the leaf:

Make the same treatment for all leaves until all leaves are applied.

Now let's take a look at the tree after the material is added (each tree has a leaf ):

Select a leaf and observe the value of the [Frequency] attribute. The default value is 1:

Next, adjust the value of the [Frequency] attribute to 42 to get the following results:

After performing the same operation on the other two branches, we get the desired tree:

Note: creating a tree is a process of repeated experiments. The general principle is not to create too many leaves/branches, because too many trees will affect the rendering performance.

7. Add a role Controller

Finally, add a 1st person-role controller to rotate, stretch, and move the scenario:

Click play to preview the running effect.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.