# 为更现实的环境添加变体

Randomizer is a UnigineEditor tool designed for adding variations of the scene objects in few clicks. Randomizer是UnigineEditor工具，设计用于只需单击几下即可添加场景对象的变体。

Randomizer Tool Randomizer工具

To open the Randomizer tool, choose Tools -> Randomizer in the Menu Bar.要打开Randomizer工具，请在菜单栏中选择Tools -> Randomizer

The Randomizer can perform the following operations with nodes: Randomizer可以对节点执行以下操作：

• Replace the selected nodes with other nodes taken randomly from the specified set according to the normal law of distribution.根据正常分布规律，将选定的节点替换为从指定集合中随机抽取的其他节点。
• Change position, rotation, and scale of the selected nodes randomly within the range according to the normal law of distribution.根据正态分布规律在范围内随机更改所选节点的位置，旋转和比例。

You can perform all operations together. Besides, you can perform the randomization as many times as you want: every time you will get the different result.您可以一起执行所有操作。此外，您可以根据需要执行任意多次随机操作：每次都会得到不同的结果。

## Randomizer Settings随机化器设置#

The Randomizer tool provides the following settings: Randomizer工具提供以下设置：

Offset Offset of the selected nodes taken randomly from the specified range. An offset range is specified for each axis. From specifies the minimum offset of nodes in units.From specifies the minimum offset of nodes in units. To specifies the maximum offset of nodes in units.To specifies the maximum offset of nodes in units. You can specify both negative and positive values. From specifies the minimum offset of nodes in units.To specifies the maximum offset of nodes in units.所选节点的偏移量是从指定范围内随机获取的。为每个轴指定一个偏移范围。 From specifies the minimum offset of nodes in units. From指定节点的最小偏移量。 To specifies the maximum offset of nodes in units. To指定节点的最大偏移量。 您可以指定负值和正值。 Rotation of the selected nodes by the angle taken randomly from the specified range. Rotation is performed relative to the current direction of an axis. An angle range is specified for each axis. From specifies the minimum angle by which nodes can be rotated.From specifies the minimum angle by which nodes can be rotated. To specifies the maximum angle by which nodes can be rotated.To specifies the maximum angle by which nodes can be rotated. If one of the values is negative, the nodes will be rotated about the axis in both directions (clockwise and counterclockwise). From specifies the minimum angle by which nodes can be rotated.To specifies the maximum angle by which nodes can be rotated.从指定范围中随机选取的角度旋转选定节点。相对于轴的当前方向执行旋转。为每个轴指定一个角度范围。 From specifies the minimum angle by which nodes can be rotated. From指定可以旋转节点的最小角度。 To specifies the maximum angle by which nodes can be rotated. To指定可以旋转节点的最大角度。 如果值之一为负，则节点将沿两个方向（顺时针和逆时针）绕轴旋转。 Scale of the selected nodes taken randomly from the specified range. A scale coefficient is specified for each axis. 注意If you enable the Uniform Scale option, you can specify the coefficient only once: the nodes will be scaled along all axes.If you enable the Uniform Scale option, you can specify the coefficient only once: the nodes will be scaled along all axes. From specifies the minimum scale coefficient for nodes.From specifies the minimum scale coefficient for nodes. To specifies the maximum scale coefficient for nodes.To specifies the maximum scale coefficient for nodes. To downscale the selected nodes, specify values in range [0;1). If you enable the Uniform Scale option, you can specify the coefficient only once: the nodes will be scaled along all axes.From specifies the minimum scale coefficient for nodes.To specifies the maximum scale coefficient for nodes.从指定范围中随机选取的选定节点的比例。为每个轴指定比例系数。 注意If you enable the Uniform Scale option, you can specify the coefficient only once: the nodes will be scaled along all axes.如果启用Uniform Scale选项，则只能指定一次系数：节点将沿所有轴缩放。 From specifies the minimum scale coefficient for nodes. From指定节点的最小比例系数。 To specifies the maximum scale coefficient for nodes. To指定节点的最大比例系数。 要缩小所选节点的大小，请在范围 [0; 1）中指定值。 Toggles adding the specified nodes as NodeReferences to the scene on and off. If the option is disabled, the replaced nodes will change its types to the types of the replacing nodes stored in the .node files.切换将指定的节点作为 NodeReferences 添加到场景中。如果禁用此选项，则替换的节点的类型将更改为.node文件中存储的替换节点的类型。 Set of nodes (.node) or/and meshes (.mesh) that will be used for random replacing of the selected nodes. To add a new node/mesh, click or drag a file from the Asset Browser. The following fields will appear: File Name field displays the name of the replacing file.File Name field displays the name of the replacing file. Probability field allows specifying the probability of node/mesh occurrence. According to this value, the frequency of node/mesh occurrence is calculated as follows: the probability value of each node is divided by the sum of probabilities set for all nodes/meshes in the set.Probability field allows specifying the probability of node/mesh occurrence. According to this value, the frequency of node/mesh occurrence is calculated as follows: the probability value of each node is divided by the sum of probabilities set for all nodes/meshes in the set. File Name field displays the name of the replacing file.Probability field allows specifying the probability of node/mesh occurrence. According to this value, the frequency of node/mesh occurrence is calculated as follows: the probability value of each node is divided by the sum of probabilities set for all nodes/meshes in the set.节点（.node）或/和网格（.mesh）的集合，将用于随机替换所选节点。要添加新的节点/网格，请单击或从资源浏览器中拖动文件。将显示以下字段： File Name field displays the name of the replacing file. File Name字段显示替换文件的名称。 Probability field allows specifying the probability of node/mesh occurrence. According to this value, the frequency of node/mesh occurrence is calculated as follows: the probability value of each node is divided by the sum of probabilities set for all nodes/meshes in the set. Probability字段允许指定节点/网格出现的概率。根据此值，节点/网格出现的频率计算如下：将每个节点的概率值除以集合中所有节点/网格的概率总和。

## Replacing Nodes更换节点#

To replace nodes with other nodes taken randomly from the specified set, you need to do the following:要将节点替换为从指定集合中随机抽取的其他节点，您需要执行以下操作：

1. Select the nodes that should be replaced. 选择应替换的节点。
2. Add nodes that will be used for random replacing of the selected nodes in one of the following ways:
• In the Nodes section, press , then click in the field that appears and choose a .node or .mesh file in the dialog window that opens.
注意
You can specify a .node file stored inside the asset container.You can specify a .node file stored inside the asset container.
You can specify a .node file stored inside the asset container.
In the Nodes section, press , then click in the field that appears and choose a .node or .mesh file in the dialog window that opens.
注意
You can specify a .node file stored inside the asset container.You can specify a .node file stored inside the asset container.
• Select the required nodes in the Asset Browser and drag them to the Nodes section.
注意
You can also drag an .fbx, .dae, .obj or .3ds file: a .node file stored inside the asset container will be specified automatically.You can also drag an .fbx, .dae, .obj or .3ds file: a .node file stored inside the asset container will be specified automatically.
You can also drag an .fbx, .dae, .obj or .3ds file: a .node file stored inside the asset container will be specified automatically.
Select the required nodes in the Asset Browser and drag them to the Nodes section.
注意
You can also drag an .fbx, .dae, .obj or .3ds file: a .node file stored inside the asset container will be specified automatically.You can also drag an .fbx, .dae, .obj or .3ds file: a .node file stored inside the asset container will be specified automatically.
In the Nodes section, press , then click in the field that appears and choose a .node or .mesh file in the dialog window that opens.
注意
You can specify a .node file stored inside the asset container.You can specify a .node file stored inside the asset container.
You can specify a .node file stored inside the asset container.Select the required nodes in the Asset Browser and drag them to the Nodes section.
注意
You can also drag an .fbx, .dae, .obj or .3ds file: a .node file stored inside the asset container will be specified automatically.You can also drag an .fbx, .dae, .obj or .3ds file: a .node file stored inside the asset container will be specified automatically.
You can also drag an .fbx, .dae, .obj or .3ds file: a .node file stored inside the asset container will be specified automatically.
以下列方式之一添加将用于随机替换所选节点的节点：
• In the Nodes section, press , then click in the field that appears and choose a .node or .mesh file in the dialog window that opens.
注意
You can specify a .node file stored inside the asset container.You can specify a .node file stored inside the asset container.
You can specify a .node file stored inside the asset container.
Nodes部分中，按，然后点击在出现的字段中，然后在打开的对话框窗口中选择.node.mesh文件。
注意
You can specify a .node file stored inside the asset container.您可以指定存储在资产容器内的.node文件。
• Select the required nodes in the Asset Browser and drag them to the Nodes section.
注意
You can also drag an .fbx, .dae, .obj or .3ds file: a .node file stored inside the asset container will be specified automatically.You can also drag an .fbx, .dae, .obj or .3ds file: a .node file stored inside the asset container will be specified automatically.
You can also drag an .fbx, .dae, .obj or .3ds file: a .node file stored inside the asset container will be specified automatically.
资产浏览器中选择所需的节点，然后将其拖到Nodes部分。
注意
You can also drag an .fbx, .dae, .obj or .3ds file: a .node file stored inside the asset container will be specified automatically.您还可以拖动.fbx.dae.obj.3ds文件：将自动指定资产容器中存储的.node文件。
3. Specify the probability of the node occurrence in the field to the right.在右侧字段中指定节点出现的概率
4. Toggle the Place Nodes as NodeReference option on, if required.如果需要，将Place Nodes as NodeReference选项打开。
5. Click Replace. 单击 Replace.

The randomization will be performed according to the normal law of distribution.将根据分布的正常规律进行随机化。

### Usage Example使用范例#

For example, we have several identical barrels:例如，我们有几个相同的桶：

To diversify the types of barrels, we need to perform as follows:要使桶的类型多样化，我们需要执行以下操作：

1. Select all barrels in the scene.

选择场景中的所有桶。

2. Add the .node files with different types of barrels to the Nodes section by dragging them from the Asset Browser.

通过从资源浏览器中拖动将桶类型不同的.node文件添加到Nodes部分。

3. Specify the probabilities of occurrence of each type of barrels:
• 10 for red barrels10 for red barrels
• 5 for blue barrels5 for blue barrels
• 2 for light brown barrels2 for light brown barrels
• 1 for brown barrels1 for brown barrels

According to our set probabilities, the frequency of occurrence of barrels of each type will be the following:According to our set probabilities, the frequency of occurrence of barrels of each type will be the following:

• 10/18 for red barrels10/18 for red barrels
• 5/18 for blue barrels5/18 for blue barrels
• 2/18 for light brown barrels2/18 for light brown barrels
• 1/18 for brown barrels1/18 for brown barrels
10 for red barrels5 for blue barrels2 for light brown barrels1 for brown barrelsAccording to our set probabilities, the frequency of occurrence of barrels of each type will be the following:10/18 for red barrels5/18 for blue barrels2/18 for light brown barrels1/18 for brown barrels
指定每种桶的出现概率：
• 10 for red barrels 10 （红色桶）
• 5 for blue barrels 5 （用于蓝色桶）
• 2 for light brown barrels 2 （浅棕色桶）
• 1 for brown barrels 1 棕色桶

According to our set probabilities, the frequency of occurrence of barrels of each type will be the following:根据我们设置的概率，每种类型的桶的出现频率如下：

• 10/18 for red barrels红色桶的10/18
• 5/18 for blue barrels用于蓝色桶5/18
• 2/18 for light brown barrels浅棕色桶的2/18
• 1/18 for brown barrels棕色桶1/18
4. Toggle the Place Nodes as NodeReferences option on, so that the specified nodes are added to the scene as NodeReferences. It may be useful if you will decide to change barrels of a certain type later. In this case, you will need to edit only one barrel: the others will be updated as well. 启用Place Nodes as NodeReferences选项，以便将指定的节点作为NodeReferences添加到场景。如果您以后决定更换某种类型的桶，这可能会很有用。在这种情况下，您将只需要编辑一个桶，其他桶也将被更新。
5. Click Replace. The selected nodes will be replaced with the node references from the list.

单击Replace。所选节点将被列表中的节点引用替换。

## Transforming Nodes转换节点#

To translate, rotate or scale the selected nodes randomly within the specified range, you need to do the following:要在指定范围内随机平移，旋转或缩放所选节点，您需要执行以下操作：

1. Select the nodes that should be transformed. 选择应转换的节点。
2. Specify ranges for the Offset, Rotation and Scale values.

指定OffsetRotationScale值的范围。

3. Click Replace. 单击 Replace.

The randomization will be performed according to the normal law of distribution.将根据分布的正常规律进行随机化。

### Usage Example使用范例#

1. Select all barrels in the scene.

选择场景中的所有桶。

2. Specify ranges for the transformation parameters:
• [30;180] degree for rotation about the Z axis.[30;180] degree for rotation about the Z axis.
• [0;30] for offset along the X and Y axes.[0;30] for offset along the X and Y axes.
• [1;3] for scale by the X, Y, and Z axes.[1;3] for scale by the X, Y, and Z axes.

[30;180] degree for rotation about the Z axis.[0;30] for offset along the X and Y axes.[1;3] for scale by the X, Y, and Z axes.
指定转换参数的范围：
• [30;180] degree for rotation about the Z axis. [30; 180] 度，以绕Z轴旋转。
• [0;30] for offset along the X and Y axes. [0; 30] 用于沿X和Y轴的偏移。
• [1;3] for scale by the X, Y, and Z axes. [1; 3] ，用于按X，Y和Z轴缩放。

3. Click Replace. The selected nodes will be transformed according to the specified values.

单击Replace。所选节点将根据指定的值进行转换。