Files
godot-docs/classes/class_primitivemesh.rst

206 lines
8.3 KiB
ReStructuredText

:github_url: hide
.. DO NOT EDIT THIS FILE!!!
.. Generated automatically from Godot engine sources.
.. Generator: https://github.com/godotengine/godot/tree/master/doc/tools/make_rst.py.
.. XML source: https://github.com/godotengine/godot/tree/master/doc/classes/PrimitiveMesh.xml.
.. _class_PrimitiveMesh:
PrimitiveMesh
=============
**Inherits:** :ref:`Mesh<class_Mesh>` **<** :ref:`Resource<class_Resource>` **<** :ref:`RefCounted<class_RefCounted>` **<** :ref:`Object<class_Object>`
**Inherited By:** :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>`
Base class for all primitive meshes. Handles applying a :ref:`Material<class_Material>` to a primitive mesh.
.. rst-class:: classref-introduction-group
Description
-----------
Base class for all primitive meshes. Handles applying a :ref:`Material<class_Material>` to a primitive mesh. Examples include :ref:`BoxMesh<class_BoxMesh>`, :ref:`CapsuleMesh<class_CapsuleMesh>`, :ref:`CylinderMesh<class_CylinderMesh>`, :ref:`PlaneMesh<class_PlaneMesh>`, :ref:`PrismMesh<class_PrismMesh>`, and :ref:`SphereMesh<class_SphereMesh>`.
.. rst-class:: classref-reftable-group
Properties
----------
.. 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
Methods
-------
.. table::
:widths: auto
+---------------------------+--------------------------------------------------------------------------------------------------------+
| :ref:`Array<class_Array>` | :ref:`_create_mesh_array<class_PrimitiveMesh_method__create_mesh_array>` **(** **)** |virtual| |const| |
+---------------------------+--------------------------------------------------------------------------------------------------------+
| :ref:`Array<class_Array>` | :ref:`get_mesh_arrays<class_PrimitiveMesh_method_get_mesh_arrays>` **(** **)** |const| |
+---------------------------+--------------------------------------------------------------------------------------------------------+
.. rst-class:: classref-section-separator
----
.. rst-class:: classref-descriptions-group
Property Descriptions
---------------------
.. _class_PrimitiveMesh_property_add_uv2:
.. rst-class:: classref-property
:ref:`bool<class_bool>` **add_uv2** = ``false``
.. rst-class:: classref-property-setget
- void **set_add_uv2** **(** :ref:`bool<class_bool>` value **)**
- :ref:`bool<class_bool>` **get_add_uv2** **(** **)**
If set, generates UV2 UV coordinates applying a padding using the :ref:`uv2_padding<class_PrimitiveMesh_property_uv2_padding>` setting. UV2 is needed for lightmapping.
.. 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)``
.. rst-class:: classref-property-setget
- void **set_custom_aabb** **(** :ref:`AABB<class_AABB>` value **)**
- :ref:`AABB<class_AABB>` **get_custom_aabb** **(** **)**
Overrides the :ref:`AABB<class_AABB>` with one defined by user for use with frustum culling. Especially useful to avoid unexpected culling when using a shader to offset vertices.
.. rst-class:: classref-item-separator
----
.. _class_PrimitiveMesh_property_flip_faces:
.. rst-class:: classref-property
:ref:`bool<class_bool>` **flip_faces** = ``false``
.. rst-class:: classref-property-setget
- void **set_flip_faces** **(** :ref:`bool<class_bool>` value **)**
- :ref:`bool<class_bool>` **get_flip_faces** **(** **)**
If set, the order of the vertices in each triangle are reversed resulting in the backside of the mesh being drawn.
This gives the same result as using :ref:`BaseMaterial3D.CULL_FRONT<class_BaseMaterial3D_constant_CULL_FRONT>` in :ref:`BaseMaterial3D.cull_mode<class_BaseMaterial3D_property_cull_mode>`.
.. rst-class:: classref-item-separator
----
.. _class_PrimitiveMesh_property_material:
.. rst-class:: classref-property
:ref:`Material<class_Material>` **material**
.. rst-class:: classref-property-setget
- void **set_material** **(** :ref:`Material<class_Material>` value **)**
- :ref:`Material<class_Material>` **get_material** **(** **)**
The current :ref:`Material<class_Material>` of the primitive mesh.
.. rst-class:: classref-item-separator
----
.. _class_PrimitiveMesh_property_uv2_padding:
.. rst-class:: classref-property
:ref:`float<class_float>` **uv2_padding** = ``2.0``
.. rst-class:: classref-property-setget
- void **set_uv2_padding** **(** :ref:`float<class_float>` value **)**
- :ref:`float<class_float>` **get_uv2_padding** **(** **)**
If :ref:`add_uv2<class_PrimitiveMesh_property_add_uv2>` is set, specifies the padding in pixels applied along seams of the mesh. If at generation the size of the lightmap texture can't be determined, the UVs are calculated assuming a texture size of 1024x1024.
.. rst-class:: classref-section-separator
----
.. rst-class:: classref-descriptions-group
Method Descriptions
-------------------
.. _class_PrimitiveMesh_method__create_mesh_array:
.. rst-class:: classref-method
:ref:`Array<class_Array>` **_create_mesh_array** **(** **)** |virtual| |const|
.. container:: contribute
There is currently no description for this method. Please help us by :ref:`contributing one <doc_updating_the_class_reference>`!
.. rst-class:: classref-item-separator
----
.. _class_PrimitiveMesh_method_get_mesh_arrays:
.. rst-class:: classref-method
:ref:`Array<class_Array>` **get_mesh_arrays** **(** **)** |const|
Returns mesh arrays used to constitute surface of :ref:`Mesh<class_Mesh>`. The result can be passed to :ref:`ArrayMesh.add_surface_from_arrays<class_ArrayMesh_method_add_surface_from_arrays>` to create a new surface. For example:
.. 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());
.. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
.. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
.. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
.. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
.. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
.. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`