Terrain
A terrain is available only at the scene level and represents the land relief (physical geography) on which rigid bodies can interact.
A terrain consists of a set of tiles generated from a Graphics Gallery file, which you import in the Scene Editor, only one terrain per scene is allowed.
The Editor uses a basic parametrization in order to subdivide the terrain's polygons into tiles. When you first import terrain file, and any time you need to edit the terrain object, you can change this default parametrization in these ways:
By default the UV plane of the grid is mapped to the local XY plane of the terrain, which means that the local Z axis corresponds to the up axis in the simulation. You can change one or both of the UV axes to use any of the XYZ axes.
You can change the default number of cells (which is
100) along the terrain's U and V coordinates.By default only one level of hierarchical subdivision is performed, but you can increase this by specifying a maximal number of subdivisions.
If you enable hierarchical subdivision, you can also specify how many sub-cells to create, as well as a minimum number of triangles per cell to prevent further subdivision.
In addition, you can build a list of mapping rules that allow you to specify which materials are mapped to which textures, and you can also turn off shadow casting for the terrain to boost the resolution of your shadow maps.
Once set up, a terrain can be modified in terms of the parametrization, the material mapping, the shadow casting, and you can even specify an entirely new file to use.
- 1 Adding a Terrain to the Scene
- 2 Editing an Existing Terrain
- 3 Mapping Materials on the Terrain
- 4 Setting the Default Material
- 5 Mapping from Textures
- 6 Building Rules
- 7 Avoiding Cracks Between Triangles
- 8 Tweaking the Terrain Parameters
- 9 Ensuring valid terrain triangle normals with the Mesh Normal Visualizer
Adding a Terrain to the Scene
You can add a terrain to a scene that Vortex® will build from the Graphics Gallery (*.vxgraphicgallery) file that you specify.
If you are not already in the Scene editor, either open an existing scene or create a new one.
To add a terrain, select Environment in the Toolbox, then double-click Terrain From File.... A dialog panel appears.
Click the Browse
button to the right of the Terrain File text box under the Source section and double-click the file you want to use from the file browser.
The file name you specified appears in the Terrain File text box.To specify how you want to map materials in the terrain, you can set up a number of rules using regular expressions that will match either nodes or textures to materials.
For more information, see Mapping Materials on the Terrain.If you want to change the default parametrization that Vortex uses to generate the terrain from the file, you can follow the instructions under Tweaking the Terrain Parameters.
When you are satisfied with the parameter settings for generating the terrain from file, click Ok. The Editor generates a new terrain from the parameters you specified (which may take a while, depending on the complexity of the file and the parametrization). When completed, the new terrain appears in the 3D View and a new Terrain object appears under the scene in the Explorer Panel.
Note You can return to modify the terrain specification at any time by following the instructions under Editing an Existing Terrain.
Editing an Existing Terrain
You can change how Vortex® generates your terrain by editing the same parameters you set up when you created the terrain in the first place.
In the scene file that contains the terrain you want to edit, locate the terrain object in the Explorer panel.
Right-click the terrain object and click Edit from the context menu. The UV Grid Visualizer will activate.
Now you can make any of the following changes:
Change the file from which Vortex will build the terrain by changing the value in the Terrain File text box.
Change how the materials map onto the terrain (see Mapping Materials on the Terrain).
Change the default parametrization that Vortex uses to generate the terrain from the 3D mesh file (see Tweaking the Terrain Parametrization).
When you complete the modifications to the parameter settings for generating the terrain from file, click Ok.
The Editor regenerates the terrain from the parameters (which may take a while, depending on the complexity of the mesh and the parametrization). When completed, the newly regenerated terrain appears in the 3D View.
Mapping Materials on the Terrain
Most terrains contain several different objects or areas that need discrete materials to be applied, such as buildings, roads, bodies of water or ice, etc.
In order to define specific materials for each area of your terrain, you need to build a set of rules to tell Vortex® how to assign these materials.
You build each rule by matching the name of the node(s) or texture(s) where you want to assign the material with the name of the material to assign. You can use regular expressions to identify a group of nodes or textures, so for example, you could assign a name to every texture that appears on the side of a building with a designated keyword (Siding001, Siding002, Siding003, etc.) which can then be used in your rule (for example, Siding00.? or Siding.*, etc.).
The material names you use must correspond to the materials table you are using for the scene. For more information about materials tables and how to use them, see Contact Materials.
Note The procedures in this section assume you are in the middle of creating or editing a terrain specification. If that is not the case, follow the instructions for either creating or editing a terrain before proceeding.
Setting the Default Material
Typically most materials tables contain a default material definition (usually also named default), and the Editor uses this material throughout the terrain unless you specify a different material to use.
If you have a terrain which is mostly sand (for example, a desert), you can set sand as the default material by typing the name into the Default Material text box:
Warning If you specify material mapping rules to match node(s) or texture(s) to the specific materials, anything on the terrain that does not match these rules will use the default texture defined on the materials table you are using (not the material you specified in the Default Material text box).
Mapping from Textures
By default, Vortex® assumes that the rules defined for mapping materials on a terrain apply to the graphics nodes in the 3D mesh file.
However, you can change this to use textures instead by selecting By Texture from the Mapping Strategy drop-down box under the Materials section.
Building Rules
When you have a terrain with more than one texture requiring specialized materials, you can build a set of mapping rules that will match each specialized area to a material by naming the node(s) or texture(s) using a regular expression.
For example, if you have a terrain with several patches of ice, and the textures associated with these areas all use Ice in their names (Barn_Ice, Ice_Pond, Road_Ice_001, Road_Ice_002, etc.), you can capture these discrete areas using .*Ice.* as a regular expression.
Rule Ordering
The order of how the rules appear in the list is important: the first rule that appears takes precedence over subsequent rules.
For example, given this set of textures: Road_Asphalt_Wet, Road_Asphalt, Road_Gravel, Road_Sand, Road_Sidewalk, Road_Snow, Road_Grass, and a set of rules ordered as below, everything is assigned mat23 while mat09 and mat14 are never assigned anywhere because what appears in the list first matches everything:
Road.* => mat23
Road_Asphalt_Wet => mat14
Road_Gravel => mat09
But in the following set where the rules are ordered opposite, Road_Gravel is assigned mat09, Road_Asphalt_Wet is assigned mat14, and everything else is assigned mat23 because the specific rules for Road_Gravel and Road_Asphalt_Wet are allowed to make their matches before the general rule matches everything:
Road_Gravel => mat09
Road_Asphalt_Wet => mat14
Road.* => mat23If you want to change the order of rules in the rule list, you must remove the earlier rule and re-add it to the list so that it appears after the other rules (see Adding and Removing Rules).
Adding and Removing Rules
To define a rule for mapping materials to textures or nodes, follow this procedure.
From the Materials section, click the Add Rule button.
A blank row appears in the list.
Double-click in the cell under the Name (RegExp) column and type the regular expression that describes the node or texture and press Enter. For example,
Road.*or.*_Texture00.?, etc.Double-click in the cell under the Materials column and type the name of the material and press Enter. For example,
ClayorSand, etc. The new rule appears in the list.To delete a rule from the list, click anywhere on the rule and then click the Remove Rule button.