using_multi_mesh_instance.rst 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. .. _doc_using_multi_mesh_instance:
  2. Using MultiMeshInstance
  3. -----------------------
  4. Introduction
  5. ~~~~~~~~~~~~
  6. In a normal scenario, you would use a :ref:`MeshInstance <class_MeshInstance>`
  7. node to display a 3D mesh like a human model for the main character, but in some
  8. cases, you would like to create multiple instances of the same mesh in a scene.
  9. You *could* duplicate the same node multiple times and adjust the transforms
  10. manually. This may be a tedious process and the result may look mechanical.
  11. Also, this method is not conducive to rapid iterations.
  12. :ref:`MultiMeshInstance <class_MultiMeshInstance>` is one of the possible
  13. solutions to this problem.
  14. MultiMeshInstance, as the name suggests, creates multiple copies of a
  15. MeshInstance over a surface of a specific mesh. An example would be having a
  16. tree mesh populate a landscape mesh with trees of random scales and orientations.
  17. Setting up the nodes
  18. ~~~~~~~~~~~~~~~~~~~~
  19. The basic setup requires three nodes: the MultiMeshInstance node
  20. and two MeshInstance nodes.
  21. One node is used as the target, the mesh that you want to place multiple meshes
  22. on. In the tree example, this would be the landscape.
  23. The other node is used as the source, the mesh that you want to have duplicated.
  24. In the tree case, this would be the tree itself.
  25. In our example, we would use a :ref:`Spatial <class_Spatial>` node as the root node of
  26. the scene. Your scene tree would look like this:
  27. .. image:: img/multimesh_scene_tree.png
  28. .. note:: For simplicity's sake, this tutorial uses built-in primitives.
  29. Now you have everything ready. Select the MultiMeshInstance node and look at the
  30. toolbar, you should see an extra button called ``MultiMesh`` next to ``View``.
  31. Click it and select *Populate surface* in the dropdown menu. A new window titled
  32. *Populate MultiMesh* will pop up.
  33. .. image:: img/multimesh_toolbar.png
  34. .. image:: img/multimesh_settings.png
  35. MultiMesh settings
  36. ~~~~~~~~~~~~~~~~~~
  37. Below are descriptions of the options.
  38. Target Surface
  39. ++++++++++++++
  40. The mesh used as the target surface on which to place copies of your
  41. source mesh.
  42. Source Mesh
  43. +++++++++++
  44. The mesh you want duplicated on the target surface.
  45. Mesh Up Axis
  46. ++++++++++++
  47. The axis used as the up axis of the source mesh.
  48. Random Rotation
  49. +++++++++++++++
  50. Randomizing the rotation around the up axis of the source mesh.
  51. Random Tilt
  52. +++++++++++
  53. Randomizing the overall rotation of the source mesh.
  54. Random Scale
  55. ++++++++++++
  56. Randomizing the scale of the source mesh.
  57. Scale
  58. +++++
  59. The scale of the source mesh that will be placed over the target surface.
  60. Amount
  61. ++++++
  62. The amount of mesh instances placed over the target surface.
  63. Select the target surface. In the tree case, this should be the landscape node.
  64. The source mesh should be the tree node. Adjust the other parameters
  65. according to your preference. Press ``Populate`` and multiple copies of the
  66. source mesh will be placed over the target mesh. If you are satisfied with the
  67. result, you can delete the mesh instance used as the source mesh.
  68. The end result should look like this:
  69. .. image:: img/multimesh_result.png
  70. To change the result, repeat the previous steps with different parameters.