Attention: Here be dragons

This is the latest (unstable) version of this documentation, which may document features not available in or compatible with released stable versions of Godot.

Using MultiMeshInstance3D

前言

In a normal scenario, you would use a MeshInstance3D node to display a 3D mesh like a human model for the main character, but in some cases, you would like to create multiple instances of the same mesh in a scene. You could duplicate the same node multiple times and adjust the transforms manually. This may be a tedious process and the result may look mechanical. Also, this method is not conducive to rapid iterations. MultiMeshInstance3D is one of the possible solutions to this problem.

MultiMeshInstance3D, as the name suggests, creates multiple copies of a MeshInstance over a surface of a specific mesh. An example would be having a tree mesh populate a landscape mesh with trees of random scales and orientations.

设置节点

The basic setup requires three nodes: the MultiMeshInstance3D node and two MeshInstance3D nodes.

One node is used as the target, the surface mesh that you want to place multiple meshes on. In the tree example, this would be the landscape.

另一个节点是作为源节点, 也就是你想复制的网格. 在树的情况下, 这将是树本身.

In our example, we would use a Node3D node as the root node of the scene. Your scene tree would look like this:

../../_images/multimesh_scene_tree.png

备注

出于简化目的,本教程使用内置图元。

Now you have everything ready. Select the MultiMeshInstance3D node and look at the toolbar, you should see an extra button called MultiMesh next to View. Click it and select Populate surface in the dropdown menu. A new window titled Populate MultiMesh will pop up.

../../_images/multimesh_toolbar.png ../../_images/multimesh_settings.png

MultiMesh 设置

以下是选项说明.

目标表面

用来放置源网格副本的目标表面的网格.

源网格

要在目标曲面上复制的网格.

网格向上轴

轴用作源网格的上轴.

随机旋转

随机地围绕源网格的向上轴旋转.

随机砖块

随机化源网格的整体旋转.

随机缩放

随机化源网格的比例.

Scale(大小)

将放置在目标曲面上的源网格的比例.

放置在目标曲面上的网格实例数量.

选择目标曲面. 在树情况下, 这应该是横向节点. 源网格应该是树节点. 根据您的喜好调整其他参数. 按 Populate , 源网格的多个副本将放在目标网格上. 如果对结果满意, 可以删除用作源网格的网格实例.

最终结果应如下所示:

../../_images/multimesh_result.png

要更改结果, 请使用不同的参数重复相同的步骤.