mirror of
https://github.com/godotengine/godot-docs-l10n.git
synced 2026-01-05 14:10:19 +03:00
This reverts commit 57781dc0bc.
The rename, although in line with what we did in the engine, caused problems with RTD we need to fix (or push for a fix) first.
220 lines
9.3 KiB
ReStructuredText
220 lines
9.3 KiB
ReStructuredText
:github_url: hide
|
|
|
|
.. _class_PrimitiveMesh:
|
|
|
|
PrimitiveMesh
|
|
=============
|
|
|
|
**继承:** :ref:`Mesh<class_Mesh>` **<** :ref:`Resource<class_Resource>` **<** :ref:`RefCounted<class_RefCounted>` **<** :ref:`Object<class_Object>`
|
|
|
|
**派生:** :ref:`BoxMesh<class_BoxMesh>`, :ref:`CapsuleMesh<class_CapsuleMesh>`, :ref:`CylinderMesh<class_CylinderMesh>`, :ref:`PlaneMesh<class_PlaneMesh>`, :ref:`PointMesh<class_PointMesh>`, :ref:`PrismMesh<class_PrismMesh>`, :ref:`RibbonTrailMesh<class_RibbonTrailMesh>`, :ref:`SphereMesh<class_SphereMesh>`, :ref:`TextMesh<class_TextMesh>`, :ref:`TorusMesh<class_TorusMesh>`, :ref:`TubeTrailMesh<class_TubeTrailMesh>`
|
|
|
|
所有图元网格的基类。处理将 :ref:`Material<class_Material>` 应用到图元网格的问题。
|
|
|
|
.. rst-class:: classref-introduction-group
|
|
|
|
描述
|
|
----
|
|
|
|
所有基本网格的基类,能够处理将 :ref:`Material<class_Material>` 应用到基本网格的操作。有 :ref:`BoxMesh<class_BoxMesh>`\ 、\ :ref:`CapsuleMesh<class_CapsuleMesh>`\ 、\ :ref:`CylinderMesh<class_CylinderMesh>`\ 、\ :ref:`PlaneMesh<class_PlaneMesh>`\ 、\ :ref:`PrismMesh<class_PrismMesh>`\ 、\ :ref:`SphereMesh<class_SphereMesh>` 等基本网格。
|
|
|
|
.. rst-class:: classref-reftable-group
|
|
|
|
属性
|
|
----
|
|
|
|
.. table::
|
|
:widths: auto
|
|
|
|
+---------------------------------+--------------------------------------------------------------+----------------------------+
|
|
| :ref:`bool<class_bool>` | :ref:`add_uv2<class_PrimitiveMesh_property_add_uv2>` | ``false`` |
|
|
+---------------------------------+--------------------------------------------------------------+----------------------------+
|
|
| :ref:`AABB<class_AABB>` | :ref:`custom_aabb<class_PrimitiveMesh_property_custom_aabb>` | ``AABB(0, 0, 0, 0, 0, 0)`` |
|
|
+---------------------------------+--------------------------------------------------------------+----------------------------+
|
|
| :ref:`bool<class_bool>` | :ref:`flip_faces<class_PrimitiveMesh_property_flip_faces>` | ``false`` |
|
|
+---------------------------------+--------------------------------------------------------------+----------------------------+
|
|
| :ref:`Material<class_Material>` | :ref:`material<class_PrimitiveMesh_property_material>` | |
|
|
+---------------------------------+--------------------------------------------------------------+----------------------------+
|
|
| :ref:`float<class_float>` | :ref:`uv2_padding<class_PrimitiveMesh_property_uv2_padding>` | ``2.0`` |
|
|
+---------------------------------+--------------------------------------------------------------+----------------------------+
|
|
|
|
.. rst-class:: classref-reftable-group
|
|
|
|
方法
|
|
----
|
|
|
|
.. table::
|
|
:widths: auto
|
|
|
|
+---------------------------+----------------------------------------------------------------------------------------------------------+
|
|
| :ref:`Array<class_Array>` | :ref:`_create_mesh_array<class_PrimitiveMesh_private_method__create_mesh_array>`\ (\ ) |virtual| |const| |
|
|
+---------------------------+----------------------------------------------------------------------------------------------------------+
|
|
| :ref:`Array<class_Array>` | :ref:`get_mesh_arrays<class_PrimitiveMesh_method_get_mesh_arrays>`\ (\ ) |const| |
|
|
+---------------------------+----------------------------------------------------------------------------------------------------------+
|
|
| |void| | :ref:`request_update<class_PrimitiveMesh_method_request_update>`\ (\ ) |
|
|
+---------------------------+----------------------------------------------------------------------------------------------------------+
|
|
|
|
.. rst-class:: classref-section-separator
|
|
|
|
----
|
|
|
|
.. rst-class:: classref-descriptions-group
|
|
|
|
属性说明
|
|
--------
|
|
|
|
.. _class_PrimitiveMesh_property_add_uv2:
|
|
|
|
.. rst-class:: classref-property
|
|
|
|
:ref:`bool<class_bool>` **add_uv2** = ``false`` :ref:`🔗<class_PrimitiveMesh_property_add_uv2>`
|
|
|
|
.. rst-class:: classref-property-setget
|
|
|
|
- |void| **set_add_uv2**\ (\ value\: :ref:`bool<class_bool>`\ )
|
|
- :ref:`bool<class_bool>` **get_add_uv2**\ (\ )
|
|
|
|
打开后将生成 UV2 UV 坐标,使用 :ref:`uv2_padding<class_PrimitiveMesh_property_uv2_padding>` 设置的间距。光照映射需要 UV2。
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_PrimitiveMesh_property_custom_aabb:
|
|
|
|
.. rst-class:: classref-property
|
|
|
|
:ref:`AABB<class_AABB>` **custom_aabb** = ``AABB(0, 0, 0, 0, 0, 0)`` :ref:`🔗<class_PrimitiveMesh_property_custom_aabb>`
|
|
|
|
.. rst-class:: classref-property-setget
|
|
|
|
- |void| **set_custom_aabb**\ (\ value\: :ref:`AABB<class_AABB>`\ )
|
|
- :ref:`AABB<class_AABB>` **get_custom_aabb**\ (\ )
|
|
|
|
用用户定义的用于使用视锥剔除的一种替代 :ref:`AABB<class_AABB>`\ 。在使用着色器偏移顶点时,避免非预期的剔除特别有用。
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_PrimitiveMesh_property_flip_faces:
|
|
|
|
.. rst-class:: classref-property
|
|
|
|
:ref:`bool<class_bool>` **flip_faces** = ``false`` :ref:`🔗<class_PrimitiveMesh_property_flip_faces>`
|
|
|
|
.. rst-class:: classref-property-setget
|
|
|
|
- |void| **set_flip_faces**\ (\ value\: :ref:`bool<class_bool>`\ )
|
|
- :ref:`bool<class_bool>` **get_flip_faces**\ (\ )
|
|
|
|
如果为 ``true``\ ,则会颠倒各个三角形中顶点的顺序,导致绘制网格的背面。
|
|
|
|
和在 :ref:`BaseMaterial3D.cull_mode<class_BaseMaterial3D_property_cull_mode>` 中使用 :ref:`BaseMaterial3D.CULL_FRONT<class_BaseMaterial3D_constant_CULL_FRONT>` 的效果一致。
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_PrimitiveMesh_property_material:
|
|
|
|
.. rst-class:: classref-property
|
|
|
|
:ref:`Material<class_Material>` **material** :ref:`🔗<class_PrimitiveMesh_property_material>`
|
|
|
|
.. rst-class:: classref-property-setget
|
|
|
|
- |void| **set_material**\ (\ value\: :ref:`Material<class_Material>`\ )
|
|
- :ref:`Material<class_Material>` **get_material**\ (\ )
|
|
|
|
该图元网格的当前 :ref:`Material<class_Material>`\ 。
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_PrimitiveMesh_property_uv2_padding:
|
|
|
|
.. rst-class:: classref-property
|
|
|
|
:ref:`float<class_float>` **uv2_padding** = ``2.0`` :ref:`🔗<class_PrimitiveMesh_property_uv2_padding>`
|
|
|
|
.. rst-class:: classref-property-setget
|
|
|
|
- |void| **set_uv2_padding**\ (\ value\: :ref:`float<class_float>`\ )
|
|
- :ref:`float<class_float>` **get_uv2_padding**\ (\ )
|
|
|
|
如果设置了 :ref:`add_uv2<class_PrimitiveMesh_property_add_uv2>`\ ,则指定沿网格接缝被应用的以像素为单位的填充。较低的填充值允许更好地利用光照贴图纹理(导致更高的纹素密度),但可能会沿边缘引入可见的光照贴图渗色。
|
|
|
|
如果在生成网格时无法确定光照贴图纹理的大小,则计算 UV2 时假定纹理大小为 1024x1024。
|
|
|
|
.. rst-class:: classref-section-separator
|
|
|
|
----
|
|
|
|
.. rst-class:: classref-descriptions-group
|
|
|
|
方法说明
|
|
--------
|
|
|
|
.. _class_PrimitiveMesh_private_method__create_mesh_array:
|
|
|
|
.. rst-class:: classref-method
|
|
|
|
:ref:`Array<class_Array>` **_create_mesh_array**\ (\ ) |virtual| |const| :ref:`🔗<class_PrimitiveMesh_private_method__create_mesh_array>`
|
|
|
|
重写该方法以自定义应如何生成该基本网格。应该返回一个 :ref:`Array<class_Array>`\ ,其中每个元素都是该网格所需的另一个值数组(请参阅 :ref:`ArrayType<enum_Mesh_ArrayType>` 常量)。
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_PrimitiveMesh_method_get_mesh_arrays:
|
|
|
|
.. rst-class:: classref-method
|
|
|
|
:ref:`Array<class_Array>` **get_mesh_arrays**\ (\ ) |const| :ref:`🔗<class_PrimitiveMesh_method_get_mesh_arrays>`
|
|
|
|
返回用于构成图元网格表面的网格数组。
|
|
|
|
\ **示例:**\ 将结果可以传递给 :ref:`ArrayMesh.add_surface_from_arrays()<class_ArrayMesh_method_add_surface_from_arrays>` 创建新的表面:
|
|
|
|
|
|
.. tabs::
|
|
|
|
.. code-tab:: gdscript
|
|
|
|
var c = CylinderMesh.new()
|
|
var arr_mesh = ArrayMesh.new()
|
|
arr_mesh.add_surface_from_arrays(Mesh.PRIMITIVE_TRIANGLES, c.get_mesh_arrays())
|
|
|
|
.. code-tab:: csharp
|
|
|
|
var c = new CylinderMesh();
|
|
var arrMesh = new ArrayMesh();
|
|
arrMesh.AddSurfaceFromArrays(Mesh.PrimitiveType.Triangles, c.GetMeshArrays());
|
|
|
|
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_PrimitiveMesh_method_request_update:
|
|
|
|
.. rst-class:: classref-method
|
|
|
|
|void| **request_update**\ (\ ) :ref:`🔗<class_PrimitiveMesh_method_request_update>`
|
|
|
|
请求根据其属性更新该基本网格。
|
|
|
|
.. |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 (无返回值。)`
|