Trees are an integral part of the environments and have extended functionality, like bending affected by wind or the player. Additionally they can also have breakable trunks.
Sample File: trees.max
Setup in 3d Studio MAX
An average tree consists normally of 4 elements:
- trunk; provides pivot in the engine, elements are linked to the trunk for export
- leaves/foliage + branches
- bending proxy (green box in the picture below) - needed for trees with player/ AI interaction
- AI obstruct proxy (red box in the picture below) - needed for trees with player/ AI interaction
- LODs can be included to decrease rendering time in the distance
- Dummy; alternative root object: all objects, including trunk can be linked to the dummy
- example picture of sample tree
- example picture of sample tree hierarchy with dummy as root
When a player should be able to move the foliage with his body, the leaves need to be set up for Touch Bending
Detail Bending is used for wind based bending effects.
An average tree has a Multi/Sub-Object material with at least 4 different Material IDs. One for leaves/foliage and branches, one for the trunk, one for the bending proxy and one for AI cover.
the lower the number of rendered materials, the better the performance + naming is irrelevant, we will refer in the text below to the names given above
In order to have the physics settings work correctly, the Crytek shader must be applied on all materials.
Set the materials to the following settings:
- "Default" for the trunk; this enables procedural breaking in the engine.
- "noCollide" for the bending proxy. This defines the area where touchbending is possible.
- "obstruct" for the AI proxy. This Area the AI can not see through, but you and the AI can walk through.
- The material for leaves/foliage and (2D) branches do not need physics.
- example for physics selection
Only export the root of the object.
Everything linked to the root will be automatically exported into one .cgf-file.
Pay attention to the settings in the Geometry Export Options in the picture below.
- example for export settings
- example for link strukture with trunk as root
Setup in Sandbox
Breakable Trunk Setup
The surface type for the trunk material needs to be set to mat_wood_breakable.
More detailed information can be found here in the Breakable Vegetation Setup section.
Placing Trees in Sandbox
In the vegetation dialog a new vegetation object is added by pressing the most left pintree button.
To place your tree the paint tool can be used. Placing a single tree can be achieved by selecting the object and pressing shift+leftMB in the viewport.
For more information about the setup of the vegetation, refer to the relevant section in the Sandbox description.
These are the console commands you can use to debug your asset in the editor:
Shows physicalized meshes.
Shows the texture and mesh memory you object use
To turn it off use 0 instead of 1.