mirror of
https://github.com/godotengine/godot-docs-l10n.git
synced 2025-12-31 09:49:22 +03:00
580 lines
32 KiB
ReStructuredText
580 lines
32 KiB
ReStructuredText
:github_url: hide
|
|
|
|
.. meta::
|
|
:keywords: batch
|
|
|
|
.. _class_MultiMesh:
|
|
|
|
MultiMesh
|
|
=========
|
|
|
|
**繼承:** :ref:`Resource<class_Resource>` **<** :ref:`RefCounted<class_RefCounted>` **<** :ref:`Object<class_Object>`
|
|
|
|
使用 GPU 實例提供單一網格的高性能多次繪製。
|
|
|
|
.. rst-class:: classref-introduction-group
|
|
|
|
說明
|
|
----
|
|
|
|
MultiMesh 提供了低級別的網格產生實體功能。繪製數以千計的 :ref:`MeshInstance3D<class_MeshInstance3D>` 節點可能會很慢,因為每個物件都要提交給 GPU 然後單獨繪製。
|
|
|
|
MultiMesh 要快得多,因為它可以通過一次繪製呼叫來繪製成千上萬的實例,從而減少 API 的開銷。
|
|
|
|
缺點是,如果實例之間的距離太遠,性能可能會降低,因為每一個實例總是會被算繪(對於整個物件,它們在空間上被索引為一個)。
|
|
|
|
由於實例可能具有任何行為,因此用於可見性的 AABB 必須由使用者提供。
|
|
|
|
\ **注意:**\ MultiMesh 是單個物件,因此適用相同的對每個物件的最大燈光限制。這意味著,一旦最大燈光被一個或多個實例消耗了,其餘的 MultiMesh 實例將\ **不會**\ 接收任何光照。
|
|
|
|
\ **注意:**\ 在 MultiMesh 中使用的 Blend Shape 將被忽略。
|
|
|
|
.. rst-class:: classref-introduction-group
|
|
|
|
教學
|
|
----
|
|
|
|
- :doc:`使用 MultiMeshInstance <../tutorials/3d/using_multi_mesh_instance>`
|
|
|
|
- :doc:`使用 MultiMesh 進行優化 <../tutorials/performance/using_multimesh>`
|
|
|
|
- :doc:`使用 MultiMeshInstance 動畫化數千條魚 <../tutorials/performance/vertex_animation/animating_thousands_of_fish>`
|
|
|
|
.. rst-class:: classref-reftable-group
|
|
|
|
屬性
|
|
----
|
|
|
|
.. table::
|
|
:widths: auto
|
|
|
|
+--------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------+----------------------------+
|
|
| :ref:`PackedFloat32Array<class_PackedFloat32Array>` | :ref:`buffer<class_MultiMesh_property_buffer>` | ``PackedFloat32Array()`` |
|
|
+--------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------+----------------------------+
|
|
| :ref:`PackedColorArray<class_PackedColorArray>` | :ref:`color_array<class_MultiMesh_property_color_array>` | |
|
|
+--------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------+----------------------------+
|
|
| :ref:`AABB<class_AABB>` | :ref:`custom_aabb<class_MultiMesh_property_custom_aabb>` | ``AABB(0, 0, 0, 0, 0, 0)`` |
|
|
+--------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------+----------------------------+
|
|
| :ref:`PackedColorArray<class_PackedColorArray>` | :ref:`custom_data_array<class_MultiMesh_property_custom_data_array>` | |
|
|
+--------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------+----------------------------+
|
|
| :ref:`int<class_int>` | :ref:`instance_count<class_MultiMesh_property_instance_count>` | ``0`` |
|
|
+--------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------+----------------------------+
|
|
| :ref:`Mesh<class_Mesh>` | :ref:`mesh<class_MultiMesh_property_mesh>` | |
|
|
+--------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------+----------------------------+
|
|
| :ref:`PhysicsInterpolationQuality<enum_MultiMesh_PhysicsInterpolationQuality>` | :ref:`physics_interpolation_quality<class_MultiMesh_property_physics_interpolation_quality>` | ``0`` |
|
|
+--------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------+----------------------------+
|
|
| :ref:`PackedVector2Array<class_PackedVector2Array>` | :ref:`transform_2d_array<class_MultiMesh_property_transform_2d_array>` | |
|
|
+--------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------+----------------------------+
|
|
| :ref:`PackedVector3Array<class_PackedVector3Array>` | :ref:`transform_array<class_MultiMesh_property_transform_array>` | |
|
|
+--------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------+----------------------------+
|
|
| :ref:`TransformFormat<enum_MultiMesh_TransformFormat>` | :ref:`transform_format<class_MultiMesh_property_transform_format>` | ``0`` |
|
|
+--------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------+----------------------------+
|
|
| :ref:`bool<class_bool>` | :ref:`use_colors<class_MultiMesh_property_use_colors>` | ``false`` |
|
|
+--------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------+----------------------------+
|
|
| :ref:`bool<class_bool>` | :ref:`use_custom_data<class_MultiMesh_property_use_custom_data>` | ``false`` |
|
|
+--------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------+----------------------------+
|
|
| :ref:`int<class_int>` | :ref:`visible_instance_count<class_MultiMesh_property_visible_instance_count>` | ``-1`` |
|
|
+--------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------+----------------------------+
|
|
|
|
.. rst-class:: classref-reftable-group
|
|
|
|
方法
|
|
----
|
|
|
|
.. table::
|
|
:widths: auto
|
|
|
|
+---------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`AABB<class_AABB>` | :ref:`get_aabb<class_MultiMesh_method_get_aabb>`\ (\ ) |const| |
|
|
+---------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`Color<class_Color>` | :ref:`get_instance_color<class_MultiMesh_method_get_instance_color>`\ (\ instance\: :ref:`int<class_int>`\ ) |const| |
|
|
+---------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`Color<class_Color>` | :ref:`get_instance_custom_data<class_MultiMesh_method_get_instance_custom_data>`\ (\ instance\: :ref:`int<class_int>`\ ) |const| |
|
|
+---------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`Transform3D<class_Transform3D>` | :ref:`get_instance_transform<class_MultiMesh_method_get_instance_transform>`\ (\ instance\: :ref:`int<class_int>`\ ) |const| |
|
|
+---------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`Transform2D<class_Transform2D>` | :ref:`get_instance_transform_2d<class_MultiMesh_method_get_instance_transform_2d>`\ (\ instance\: :ref:`int<class_int>`\ ) |const| |
|
|
+---------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| |void| | :ref:`reset_instance_physics_interpolation<class_MultiMesh_method_reset_instance_physics_interpolation>`\ (\ instance\: :ref:`int<class_int>`\ ) |
|
|
+---------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| |void| | :ref:`reset_instances_physics_interpolation<class_MultiMesh_method_reset_instances_physics_interpolation>`\ (\ ) |
|
|
+---------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| |void| | :ref:`set_buffer_interpolated<class_MultiMesh_method_set_buffer_interpolated>`\ (\ buffer_curr\: :ref:`PackedFloat32Array<class_PackedFloat32Array>`, buffer_prev\: :ref:`PackedFloat32Array<class_PackedFloat32Array>`\ ) |
|
|
+---------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| |void| | :ref:`set_instance_color<class_MultiMesh_method_set_instance_color>`\ (\ instance\: :ref:`int<class_int>`, color\: :ref:`Color<class_Color>`\ ) |
|
|
+---------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| |void| | :ref:`set_instance_custom_data<class_MultiMesh_method_set_instance_custom_data>`\ (\ instance\: :ref:`int<class_int>`, custom_data\: :ref:`Color<class_Color>`\ ) |
|
|
+---------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| |void| | :ref:`set_instance_transform<class_MultiMesh_method_set_instance_transform>`\ (\ instance\: :ref:`int<class_int>`, transform\: :ref:`Transform3D<class_Transform3D>`\ ) |
|
|
+---------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| |void| | :ref:`set_instance_transform_2d<class_MultiMesh_method_set_instance_transform_2d>`\ (\ instance\: :ref:`int<class_int>`, transform\: :ref:`Transform2D<class_Transform2D>`\ ) |
|
|
+---------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
|
|
.. rst-class:: classref-section-separator
|
|
|
|
----
|
|
|
|
.. rst-class:: classref-descriptions-group
|
|
|
|
列舉
|
|
----
|
|
|
|
.. _enum_MultiMesh_TransformFormat:
|
|
|
|
.. rst-class:: classref-enumeration
|
|
|
|
enum **TransformFormat**: :ref:`🔗<enum_MultiMesh_TransformFormat>`
|
|
|
|
.. _class_MultiMesh_constant_TRANSFORM_2D:
|
|
|
|
.. rst-class:: classref-enumeration-constant
|
|
|
|
:ref:`TransformFormat<enum_MultiMesh_TransformFormat>` **TRANSFORM_2D** = ``0``
|
|
|
|
使用 2D 變換時使用此選項。
|
|
|
|
.. _class_MultiMesh_constant_TRANSFORM_3D:
|
|
|
|
.. rst-class:: classref-enumeration-constant
|
|
|
|
:ref:`TransformFormat<enum_MultiMesh_TransformFormat>` **TRANSFORM_3D** = ``1``
|
|
|
|
使用 3D 變換時使用此選項。
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _enum_MultiMesh_PhysicsInterpolationQuality:
|
|
|
|
.. rst-class:: classref-enumeration
|
|
|
|
enum **PhysicsInterpolationQuality**: :ref:`🔗<enum_MultiMesh_PhysicsInterpolationQuality>`
|
|
|
|
.. _class_MultiMesh_constant_INTERP_QUALITY_FAST:
|
|
|
|
.. rst-class:: classref-enumeration-constant
|
|
|
|
:ref:`PhysicsInterpolationQuality<enum_MultiMesh_PhysicsInterpolationQuality>` **INTERP_QUALITY_FAST** = ``0``
|
|
|
|
Always interpolate using Basis lerping, which can produce warping artifacts in some situations.
|
|
|
|
.. _class_MultiMesh_constant_INTERP_QUALITY_HIGH:
|
|
|
|
.. rst-class:: classref-enumeration-constant
|
|
|
|
:ref:`PhysicsInterpolationQuality<enum_MultiMesh_PhysicsInterpolationQuality>` **INTERP_QUALITY_HIGH** = ``1``
|
|
|
|
Attempt to interpolate using Basis slerping (spherical linear interpolation) where possible, otherwise fall back to lerping.
|
|
|
|
.. rst-class:: classref-section-separator
|
|
|
|
----
|
|
|
|
.. rst-class:: classref-descriptions-group
|
|
|
|
屬性說明
|
|
--------
|
|
|
|
.. _class_MultiMesh_property_buffer:
|
|
|
|
.. rst-class:: classref-property
|
|
|
|
:ref:`PackedFloat32Array<class_PackedFloat32Array>` **buffer** = ``PackedFloat32Array()`` :ref:`🔗<class_MultiMesh_property_buffer>`
|
|
|
|
.. rst-class:: classref-property-setget
|
|
|
|
- |void| **set_buffer**\ (\ value\: :ref:`PackedFloat32Array<class_PackedFloat32Array>`\ )
|
|
- :ref:`PackedFloat32Array<class_PackedFloat32Array>` **get_buffer**\ (\ )
|
|
|
|
.. container:: contribute
|
|
|
|
There is currently no description for this property. Please help us by `contributing one <https://contributing.godotengine.org/en/latest/documentation/class_reference.html>`__!
|
|
|
|
**Note:** The returned array is *copied* and any changes to it will not update the original property value. See :ref:`PackedFloat32Array<class_PackedFloat32Array>` for more details.
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_MultiMesh_property_color_array:
|
|
|
|
.. rst-class:: classref-property
|
|
|
|
:ref:`PackedColorArray<class_PackedColorArray>` **color_array** :ref:`🔗<class_MultiMesh_property_color_array>`
|
|
|
|
**已棄用:** Accessing this property is very slow. Use :ref:`set_instance_color()<class_MultiMesh_method_set_instance_color>` and :ref:`get_instance_color()<class_MultiMesh_method_get_instance_color>` instead.
|
|
|
|
Array containing each :ref:`Color<class_Color>` used by all instances of this mesh.
|
|
|
|
**Note:** The returned array is *copied* and any changes to it will not update the original property value. See :ref:`PackedColorArray<class_PackedColorArray>` for more details.
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_MultiMesh_property_custom_aabb:
|
|
|
|
.. rst-class:: classref-property
|
|
|
|
:ref:`AABB<class_AABB>` **custom_aabb** = ``AABB(0, 0, 0, 0, 0, 0)`` :ref:`🔗<class_MultiMesh_property_custom_aabb>`
|
|
|
|
.. rst-class:: classref-property-setget
|
|
|
|
- |void| **set_custom_aabb**\ (\ value\: :ref:`AABB<class_AABB>`\ )
|
|
- :ref:`AABB<class_AABB>` **get_custom_aabb**\ (\ )
|
|
|
|
Custom AABB for this MultiMesh resource. Setting this manually prevents costly runtime AABB recalculations.
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_MultiMesh_property_custom_data_array:
|
|
|
|
.. rst-class:: classref-property
|
|
|
|
:ref:`PackedColorArray<class_PackedColorArray>` **custom_data_array** :ref:`🔗<class_MultiMesh_property_custom_data_array>`
|
|
|
|
**已棄用:** Accessing this property is very slow. Use :ref:`set_instance_custom_data()<class_MultiMesh_method_set_instance_custom_data>` and :ref:`get_instance_custom_data()<class_MultiMesh_method_get_instance_custom_data>` instead.
|
|
|
|
Array containing each custom data value used by all instances of this mesh, as a :ref:`PackedColorArray<class_PackedColorArray>`.
|
|
|
|
**Note:** The returned array is *copied* and any changes to it will not update the original property value. See :ref:`PackedColorArray<class_PackedColorArray>` for more details.
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_MultiMesh_property_instance_count:
|
|
|
|
.. rst-class:: classref-property
|
|
|
|
:ref:`int<class_int>` **instance_count** = ``0`` :ref:`🔗<class_MultiMesh_property_instance_count>`
|
|
|
|
.. rst-class:: classref-property-setget
|
|
|
|
- |void| **set_instance_count**\ (\ value\: :ref:`int<class_int>`\ )
|
|
- :ref:`int<class_int>` **get_instance_count**\ (\ )
|
|
|
|
將被繪製的實例數。這會清除緩衝區,並(重新)調整其大小。之後設定的資料格式或旗標將無效。
|
|
|
|
預設情況下,所有實例都會被繪製,但可以使用 :ref:`visible_instance_count<class_MultiMesh_property_visible_instance_count>` 來限制它。
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_MultiMesh_property_mesh:
|
|
|
|
.. rst-class:: classref-property
|
|
|
|
:ref:`Mesh<class_Mesh>` **mesh** :ref:`🔗<class_MultiMesh_property_mesh>`
|
|
|
|
.. rst-class:: classref-property-setget
|
|
|
|
- |void| **set_mesh**\ (\ value\: :ref:`Mesh<class_Mesh>`\ )
|
|
- :ref:`Mesh<class_Mesh>` **get_mesh**\ (\ )
|
|
|
|
要被產生實體的 :ref:`Mesh<class_Mesh>` 資源。
|
|
|
|
各個實例的外觀可以通過 :ref:`set_instance_color()<class_MultiMesh_method_set_instance_color>` 和 :ref:`set_instance_custom_data()<class_MultiMesh_method_set_instance_custom_data>` 來修改。
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_MultiMesh_property_physics_interpolation_quality:
|
|
|
|
.. rst-class:: classref-property
|
|
|
|
:ref:`PhysicsInterpolationQuality<enum_MultiMesh_PhysicsInterpolationQuality>` **physics_interpolation_quality** = ``0`` :ref:`🔗<class_MultiMesh_property_physics_interpolation_quality>`
|
|
|
|
.. rst-class:: classref-property-setget
|
|
|
|
- |void| **set_physics_interpolation_quality**\ (\ value\: :ref:`PhysicsInterpolationQuality<enum_MultiMesh_PhysicsInterpolationQuality>`\ )
|
|
- :ref:`PhysicsInterpolationQuality<enum_MultiMesh_PhysicsInterpolationQuality>` **get_physics_interpolation_quality**\ (\ )
|
|
|
|
Choose whether to use an interpolation method that favors speed or quality.
|
|
|
|
When using low physics tick rates (typically below 20) or high rates of object rotation, you may get better results from the high quality setting.
|
|
|
|
\ **Note:** Fast quality does not equate to low quality. Except in the special cases mentioned above, the quality should be comparable to high quality.
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_MultiMesh_property_transform_2d_array:
|
|
|
|
.. rst-class:: classref-property
|
|
|
|
:ref:`PackedVector2Array<class_PackedVector2Array>` **transform_2d_array** :ref:`🔗<class_MultiMesh_property_transform_2d_array>`
|
|
|
|
**已棄用:** Accessing this property is very slow. Use :ref:`set_instance_transform_2d()<class_MultiMesh_method_set_instance_transform_2d>` and :ref:`get_instance_transform_2d()<class_MultiMesh_method_get_instance_transform_2d>` instead.
|
|
|
|
Array containing each :ref:`Transform2D<class_Transform2D>` value used by all instances of this mesh, as a :ref:`PackedVector2Array<class_PackedVector2Array>`. Each transform is divided into 3 :ref:`Vector2<class_Vector2>` values corresponding to the transforms' ``x``, ``y``, and ``origin``.
|
|
|
|
**Note:** The returned array is *copied* and any changes to it will not update the original property value. See :ref:`PackedVector2Array<class_PackedVector2Array>` for more details.
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_MultiMesh_property_transform_array:
|
|
|
|
.. rst-class:: classref-property
|
|
|
|
:ref:`PackedVector3Array<class_PackedVector3Array>` **transform_array** :ref:`🔗<class_MultiMesh_property_transform_array>`
|
|
|
|
**已棄用:** Accessing this property is very slow. Use :ref:`set_instance_transform()<class_MultiMesh_method_set_instance_transform>` and :ref:`get_instance_transform()<class_MultiMesh_method_get_instance_transform>` instead.
|
|
|
|
Array containing each :ref:`Transform3D<class_Transform3D>` value used by all instances of this mesh, as a :ref:`PackedVector3Array<class_PackedVector3Array>`. Each transform is divided into 4 :ref:`Vector3<class_Vector3>` values corresponding to the transforms' ``x``, ``y``, ``z``, and ``origin``.
|
|
|
|
**Note:** The returned array is *copied* and any changes to it will not update the original property value. See :ref:`PackedVector3Array<class_PackedVector3Array>` for more details.
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_MultiMesh_property_transform_format:
|
|
|
|
.. rst-class:: classref-property
|
|
|
|
:ref:`TransformFormat<enum_MultiMesh_TransformFormat>` **transform_format** = ``0`` :ref:`🔗<class_MultiMesh_property_transform_format>`
|
|
|
|
.. rst-class:: classref-property-setget
|
|
|
|
- |void| **set_transform_format**\ (\ value\: :ref:`TransformFormat<enum_MultiMesh_TransformFormat>`\ )
|
|
- :ref:`TransformFormat<enum_MultiMesh_TransformFormat>` **get_transform_format**\ (\ )
|
|
|
|
用於變換網格的變換格式,可以是 2D 或 3D。
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_MultiMesh_property_use_colors:
|
|
|
|
.. rst-class:: classref-property
|
|
|
|
:ref:`bool<class_bool>` **use_colors** = ``false`` :ref:`🔗<class_MultiMesh_property_use_colors>`
|
|
|
|
.. rst-class:: classref-property-setget
|
|
|
|
- |void| **set_use_colors**\ (\ value\: :ref:`bool<class_bool>`\ )
|
|
- :ref:`bool<class_bool>` **is_using_colors**\ (\ )
|
|
|
|
如果為 ``true``\ ,則該 **MultiMesh** 將使用顏色資料(參見 :ref:`set_instance_color()<class_MultiMesh_method_set_instance_color>`\ )。只有在 :ref:`instance_count<class_MultiMesh_property_instance_count>` 為 ``0`` 或更少時才能被設定。這意味著需要在設定實例計數之前呼叫該方法,或者暫時將實例計數重設為 ``0``\ 。
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_MultiMesh_property_use_custom_data:
|
|
|
|
.. rst-class:: classref-property
|
|
|
|
:ref:`bool<class_bool>` **use_custom_data** = ``false`` :ref:`🔗<class_MultiMesh_property_use_custom_data>`
|
|
|
|
.. rst-class:: classref-property-setget
|
|
|
|
- |void| **set_use_custom_data**\ (\ value\: :ref:`bool<class_bool>`\ )
|
|
- :ref:`bool<class_bool>` **is_using_custom_data**\ (\ )
|
|
|
|
如果為 ``true``\ ,則該 **MultiMesh** 將使用自訂資料(參見 :ref:`set_instance_custom_data()<class_MultiMesh_method_set_instance_custom_data>`\ )。只有在 :ref:`instance_count<class_MultiMesh_property_instance_count>` 為 ``0`` 或更少時才能被設定。這意味著需要在設定實例計數之前呼叫該方法,或者暫時將實例計數重設為 ``0``\ 。
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_MultiMesh_property_visible_instance_count:
|
|
|
|
.. rst-class:: classref-property
|
|
|
|
:ref:`int<class_int>` **visible_instance_count** = ``-1`` :ref:`🔗<class_MultiMesh_property_visible_instance_count>`
|
|
|
|
.. rst-class:: classref-property-setget
|
|
|
|
- |void| **set_visible_instance_count**\ (\ value\: :ref:`int<class_int>`\ )
|
|
- :ref:`int<class_int>` **get_visible_instance_count**\ (\ )
|
|
|
|
限制繪製的實例數量,-1 會繪製所有的實例。改變這一點並不改變緩衝區的大小。
|
|
|
|
.. rst-class:: classref-section-separator
|
|
|
|
----
|
|
|
|
.. rst-class:: classref-descriptions-group
|
|
|
|
方法說明
|
|
--------
|
|
|
|
.. _class_MultiMesh_method_get_aabb:
|
|
|
|
.. rst-class:: classref-method
|
|
|
|
:ref:`AABB<class_AABB>` **get_aabb**\ (\ ) |const| :ref:`🔗<class_MultiMesh_method_get_aabb>`
|
|
|
|
返回局部空間中的可見性軸對齊包圍框。
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_MultiMesh_method_get_instance_color:
|
|
|
|
.. rst-class:: classref-method
|
|
|
|
:ref:`Color<class_Color>` **get_instance_color**\ (\ instance\: :ref:`int<class_int>`\ ) |const| :ref:`🔗<class_MultiMesh_method_get_instance_color>`
|
|
|
|
獲取特定實例的顏色倍數。
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_MultiMesh_method_get_instance_custom_data:
|
|
|
|
.. rst-class:: classref-method
|
|
|
|
:ref:`Color<class_Color>` **get_instance_custom_data**\ (\ instance\: :ref:`int<class_int>`\ ) |const| :ref:`🔗<class_MultiMesh_method_get_instance_custom_data>`
|
|
|
|
返回已經為特定實例設定的自訂資料。
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_MultiMesh_method_get_instance_transform:
|
|
|
|
.. rst-class:: classref-method
|
|
|
|
:ref:`Transform3D<class_Transform3D>` **get_instance_transform**\ (\ instance\: :ref:`int<class_int>`\ ) |const| :ref:`🔗<class_MultiMesh_method_get_instance_transform>`
|
|
|
|
返回指定實例的 :ref:`Transform3D<class_Transform3D>`\ 。
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_MultiMesh_method_get_instance_transform_2d:
|
|
|
|
.. rst-class:: classref-method
|
|
|
|
:ref:`Transform2D<class_Transform2D>` **get_instance_transform_2d**\ (\ instance\: :ref:`int<class_int>`\ ) |const| :ref:`🔗<class_MultiMesh_method_get_instance_transform_2d>`
|
|
|
|
返回指定實例的 :ref:`Transform2D<class_Transform2D>`\ 。
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_MultiMesh_method_reset_instance_physics_interpolation:
|
|
|
|
.. rst-class:: classref-method
|
|
|
|
|void| **reset_instance_physics_interpolation**\ (\ instance\: :ref:`int<class_int>`\ ) :ref:`🔗<class_MultiMesh_method_reset_instance_physics_interpolation>`
|
|
|
|
When using *physics interpolation*, this function allows you to prevent interpolation on an instance in the current physics tick.
|
|
|
|
This allows you to move instances instantaneously, and should usually be used when initially placing an instance such as a bullet to prevent graphical glitches.
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_MultiMesh_method_reset_instances_physics_interpolation:
|
|
|
|
.. rst-class:: classref-method
|
|
|
|
|void| **reset_instances_physics_interpolation**\ (\ ) :ref:`🔗<class_MultiMesh_method_reset_instances_physics_interpolation>`
|
|
|
|
When using *physics interpolation*, this function allows you to prevent interpolation for all instances in the current physics tick.
|
|
|
|
This allows you to move all instances instantaneously, and should usually be used when initially placing instances to prevent graphical glitches.
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_MultiMesh_method_set_buffer_interpolated:
|
|
|
|
.. rst-class:: classref-method
|
|
|
|
|void| **set_buffer_interpolated**\ (\ buffer_curr\: :ref:`PackedFloat32Array<class_PackedFloat32Array>`, buffer_prev\: :ref:`PackedFloat32Array<class_PackedFloat32Array>`\ ) :ref:`🔗<class_MultiMesh_method_set_buffer_interpolated>`
|
|
|
|
An alternative to setting the :ref:`buffer<class_MultiMesh_property_buffer>` property, which can be used with *physics interpolation*. This method takes two arrays, and can set the data for the current and previous tick in one go. The renderer will automatically interpolate the data at each frame.
|
|
|
|
This is useful for situations where the order of instances may change from physics tick to tick, such as particle systems.
|
|
|
|
When the order of instances is coherent, the simpler alternative of setting :ref:`buffer<class_MultiMesh_property_buffer>` can still be used with interpolation.
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_MultiMesh_method_set_instance_color:
|
|
|
|
.. rst-class:: classref-method
|
|
|
|
|void| **set_instance_color**\ (\ instance\: :ref:`int<class_int>`, color\: :ref:`Color<class_Color>`\ ) :ref:`🔗<class_MultiMesh_method_set_instance_color>`
|
|
|
|
Sets the color of a specific instance by *multiplying* the mesh's existing vertex colors. This allows for different color tinting per instance.
|
|
|
|
\ **Note:** Each component is stored in 32 bits in the Forward+ and Mobile rendering methods, but is packed into 16 bits in the Compatibility rendering method.
|
|
|
|
For the color to take effect, ensure that :ref:`use_colors<class_MultiMesh_property_use_colors>` is ``true`` on the **MultiMesh** and :ref:`BaseMaterial3D.vertex_color_use_as_albedo<class_BaseMaterial3D_property_vertex_color_use_as_albedo>` is ``true`` on the material. If you intend to set an absolute color instead of tinting, make sure the material's albedo color is set to pure white (``Color(1, 1, 1)``).
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_MultiMesh_method_set_instance_custom_data:
|
|
|
|
.. rst-class:: classref-method
|
|
|
|
|void| **set_instance_custom_data**\ (\ instance\: :ref:`int<class_int>`, custom_data\: :ref:`Color<class_Color>`\ ) :ref:`🔗<class_MultiMesh_method_set_instance_custom_data>`
|
|
|
|
Sets custom data for a specific instance. ``custom_data`` is a :ref:`Color<class_Color>` type only to contain 4 floating-point numbers.
|
|
|
|
\ **Note:** Each number is stored in 32 bits in the Forward+ and Mobile rendering methods, but is packed into 16 bits in the Compatibility rendering method.
|
|
|
|
For the custom data to be used, ensure that :ref:`use_custom_data<class_MultiMesh_property_use_custom_data>` is ``true``.
|
|
|
|
This custom instance data has to be manually accessed in your custom shader using ``INSTANCE_CUSTOM``.
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_MultiMesh_method_set_instance_transform:
|
|
|
|
.. rst-class:: classref-method
|
|
|
|
|void| **set_instance_transform**\ (\ instance\: :ref:`int<class_int>`, transform\: :ref:`Transform3D<class_Transform3D>`\ ) :ref:`🔗<class_MultiMesh_method_set_instance_transform>`
|
|
|
|
為指定實例設定 :ref:`Transform3D<class_Transform3D>`\ 。
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_MultiMesh_method_set_instance_transform_2d:
|
|
|
|
.. rst-class:: classref-method
|
|
|
|
|void| **set_instance_transform_2d**\ (\ instance\: :ref:`int<class_int>`, transform\: :ref:`Transform2D<class_Transform2D>`\ ) :ref:`🔗<class_MultiMesh_method_set_instance_transform_2d>`
|
|
|
|
為指定實例設定 :ref:`Transform2D<class_Transform2D>`\ 。
|
|
|
|
.. |virtual| replace:: :abbr:`virtual (本方法通常需要使用者覆寫才能生效。)`
|
|
.. |required| replace:: :abbr:`required (This method is required to be overridden when extending its base class.)`
|
|
.. |const| replace:: :abbr:`const (本方法沒有副作用。不會修改該實例的任何成員變數。)`
|
|
.. |vararg| replace:: :abbr:`vararg (本方法除了這裡描述的參數外,還可以接受任意數量的參數。)`
|
|
.. |constructor| replace:: :abbr:`constructor (本方法用於建構一個型別。)`
|
|
.. |static| replace:: :abbr:`static (本方法無需實例即可呼叫,因此可以直接使用類別名稱呼叫。)`
|
|
.. |operator| replace:: :abbr:`operator (本方法描述將本型別作為左運算元時可用的有效運算子。)`
|
|
.. |bitfield| replace:: :abbr:`BitField (此值是由下列旗標組成的位元遮罩整數。)`
|
|
.. |void| replace:: :abbr:`void (無回傳值。)`
|