class_multimesh.rst 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. .. Generated automatically by doc/tools/makerst.py in Godot's source tree.
  2. .. DO NOT EDIT THIS FILE, but the doc/base/classes.xml source instead.
  3. .. _class_MultiMesh:
  4. MultiMesh
  5. =========
  6. **Inherits:** :ref:`Resource<class_resource>` **<** :ref:`Reference<class_reference>` **<** :ref:`Object<class_object>`
  7. **Category:** Core
  8. Brief Description
  9. -----------------
  10. Provides high performance mesh instancing.
  11. Member Functions
  12. ----------------
  13. +------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------+
  14. | void | :ref:`generate_aabb<class_MultiMesh_generate_aabb>` **(** **)** |
  15. +------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------+
  16. | :ref:`AABB<class_aabb>` | :ref:`get_aabb<class_MultiMesh_get_aabb>` **(** **)** const |
  17. +------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------+
  18. | :ref:`Color<class_color>` | :ref:`get_instance_color<class_MultiMesh_get_instance_color>` **(** :ref:`int<class_int>` instance **)** const |
  19. +------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------+
  20. | :ref:`int<class_int>` | :ref:`get_instance_count<class_MultiMesh_get_instance_count>` **(** **)** const |
  21. +------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------+
  22. | :ref:`Transform<class_transform>` | :ref:`get_instance_transform<class_MultiMesh_get_instance_transform>` **(** :ref:`int<class_int>` instance **)** const |
  23. +------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------+
  24. | :ref:`Mesh<class_mesh>` | :ref:`get_mesh<class_MultiMesh_get_mesh>` **(** **)** const |
  25. +------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------+
  26. | void | :ref:`set_aabb<class_MultiMesh_set_aabb>` **(** :ref:`AABB<class_aabb>` visibility_aabb **)** |
  27. +------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------+
  28. | void | :ref:`set_instance_color<class_MultiMesh_set_instance_color>` **(** :ref:`int<class_int>` instance, :ref:`Color<class_color>` color **)** |
  29. +------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------+
  30. | void | :ref:`set_instance_count<class_MultiMesh_set_instance_count>` **(** :ref:`int<class_int>` count **)** |
  31. +------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------+
  32. | void | :ref:`set_instance_transform<class_MultiMesh_set_instance_transform>` **(** :ref:`int<class_int>` instance, :ref:`Transform<class_transform>` transform **)** |
  33. +------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------+
  34. | void | :ref:`set_mesh<class_MultiMesh_set_mesh>` **(** :ref:`Mesh<class_mesh>` mesh **)** |
  35. +------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------+
  36. Description
  37. -----------
  38. MultiMesh provides low level mesh instancing. If the amount of :ref:`Mesh<class_mesh>` instances needed goes from hundreds to thousands (and most need to be visible at close proximity) creating such a large amount of :ref:`MeshInstance<class_meshinstance>` nodes may affect performance by using too much CPU or video memory.
  39. For this case a MultiMesh becomes very useful, as it can draw thousands of instances with little API overhead.
  40. As a drawback, if the instances are too far away of each other, performance may be reduced as every single instance will always rendered (they are spatially indexed as one, for the whole object).
  41. Since instances may have any behavior, the AABB used for visibility must be provided by the user, or generated with :ref:`generate_aabb<class_MultiMesh_generate_aabb>`.
  42. Member Function Description
  43. ---------------------------
  44. .. _class_MultiMesh_generate_aabb:
  45. - void **generate_aabb** **(** **)**
  46. Generate a new visibility AABB, using mesh AABB and instance transforms. Since instance information is stored in the :ref:`VisualServer<class_visualserver>`, this function is VERY SLOW and must NOT be used often.
  47. .. _class_MultiMesh_get_aabb:
  48. - :ref:`AABB<class_aabb>` **get_aabb** **(** **)** const
  49. Return the visibility AABB.
  50. .. _class_MultiMesh_get_instance_color:
  51. - :ref:`Color<class_color>` **get_instance_color** **(** :ref:`int<class_int>` instance **)** const
  52. Get the color of a specific instance.
  53. .. _class_MultiMesh_get_instance_count:
  54. - :ref:`int<class_int>` **get_instance_count** **(** **)** const
  55. Return the amount of instances that is going to be drawn.
  56. .. _class_MultiMesh_get_instance_transform:
  57. - :ref:`Transform<class_transform>` **get_instance_transform** **(** :ref:`int<class_int>` instance **)** const
  58. Return the transform of a specific instance.
  59. .. _class_MultiMesh_get_mesh:
  60. - :ref:`Mesh<class_mesh>` **get_mesh** **(** **)** const
  61. Return the :ref:`Mesh<class_mesh>` resource drawn as multiple instances.
  62. .. _class_MultiMesh_set_aabb:
  63. - void **set_aabb** **(** :ref:`AABB<class_aabb>` visibility_aabb **)**
  64. Set the visibility AABB. If not provided, MultiMesh will not be visible.
  65. .. _class_MultiMesh_set_instance_color:
  66. - void **set_instance_color** **(** :ref:`int<class_int>` instance, :ref:`Color<class_color>` color **)**
  67. Set the color of a specific instance.
  68. .. _class_MultiMesh_set_instance_count:
  69. - void **set_instance_count** **(** :ref:`int<class_int>` count **)**
  70. Set the amount of instances that is going to be drawn. Changing this number will erase all the existing instance transform and color data.
  71. .. _class_MultiMesh_set_instance_transform:
  72. - void **set_instance_transform** **(** :ref:`int<class_int>` instance, :ref:`Transform<class_transform>` transform **)**
  73. Set the transform for a specific instance.
  74. .. _class_MultiMesh_set_mesh:
  75. - void **set_mesh** **(** :ref:`Mesh<class_mesh>` mesh **)**
  76. Set the :ref:`Mesh<class_mesh>` resource to be drawn in multiple instances.