class_primitivemesh.rst 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. :github_url: hide
  2. .. DO NOT EDIT THIS FILE!!!
  3. .. Generated automatically from Godot engine sources.
  4. .. Generator: https://github.com/godotengine/godot/tree/master/doc/tools/make_rst.py.
  5. .. XML source: https://github.com/godotengine/godot/tree/master/doc/classes/PrimitiveMesh.xml.
  6. .. _class_PrimitiveMesh:
  7. PrimitiveMesh
  8. =============
  9. **Inherits:** :ref:`Mesh<class_Mesh>` **<** :ref:`Resource<class_Resource>` **<** :ref:`RefCounted<class_RefCounted>` **<** :ref:`Object<class_Object>`
  10. **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>`
  11. Base class for all primitive meshes. Handles applying a :ref:`Material<class_Material>` to a primitive mesh.
  12. .. rst-class:: classref-introduction-group
  13. Description
  14. -----------
  15. 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>`.
  16. .. rst-class:: classref-reftable-group
  17. Properties
  18. ----------
  19. .. table::
  20. :widths: auto
  21. +---------------------------------+--------------------------------------------------------------+----------------------------+
  22. | :ref:`bool<class_bool>` | :ref:`add_uv2<class_PrimitiveMesh_property_add_uv2>` | ``false`` |
  23. +---------------------------------+--------------------------------------------------------------+----------------------------+
  24. | :ref:`AABB<class_AABB>` | :ref:`custom_aabb<class_PrimitiveMesh_property_custom_aabb>` | ``AABB(0, 0, 0, 0, 0, 0)`` |
  25. +---------------------------------+--------------------------------------------------------------+----------------------------+
  26. | :ref:`bool<class_bool>` | :ref:`flip_faces<class_PrimitiveMesh_property_flip_faces>` | ``false`` |
  27. +---------------------------------+--------------------------------------------------------------+----------------------------+
  28. | :ref:`Material<class_Material>` | :ref:`material<class_PrimitiveMesh_property_material>` | |
  29. +---------------------------------+--------------------------------------------------------------+----------------------------+
  30. | :ref:`float<class_float>` | :ref:`uv2_padding<class_PrimitiveMesh_property_uv2_padding>` | ``2.0`` |
  31. +---------------------------------+--------------------------------------------------------------+----------------------------+
  32. .. rst-class:: classref-reftable-group
  33. Methods
  34. -------
  35. .. table::
  36. :widths: auto
  37. +---------------------------+----------------------------------------------------------------------------------------------------------+
  38. | :ref:`Array<class_Array>` | :ref:`_create_mesh_array<class_PrimitiveMesh_private_method__create_mesh_array>`\ (\ ) |virtual| |const| |
  39. +---------------------------+----------------------------------------------------------------------------------------------------------+
  40. | :ref:`Array<class_Array>` | :ref:`get_mesh_arrays<class_PrimitiveMesh_method_get_mesh_arrays>`\ (\ ) |const| |
  41. +---------------------------+----------------------------------------------------------------------------------------------------------+
  42. | |void| | :ref:`request_update<class_PrimitiveMesh_method_request_update>`\ (\ ) |
  43. +---------------------------+----------------------------------------------------------------------------------------------------------+
  44. .. rst-class:: classref-section-separator
  45. ----
  46. .. rst-class:: classref-descriptions-group
  47. Property Descriptions
  48. ---------------------
  49. .. _class_PrimitiveMesh_property_add_uv2:
  50. .. rst-class:: classref-property
  51. :ref:`bool<class_bool>` **add_uv2** = ``false`` :ref:`🔗<class_PrimitiveMesh_property_add_uv2>`
  52. .. rst-class:: classref-property-setget
  53. - |void| **set_add_uv2**\ (\ value\: :ref:`bool<class_bool>`\ )
  54. - :ref:`bool<class_bool>` **get_add_uv2**\ (\ )
  55. 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.
  56. .. rst-class:: classref-item-separator
  57. ----
  58. .. _class_PrimitiveMesh_property_custom_aabb:
  59. .. rst-class:: classref-property
  60. :ref:`AABB<class_AABB>` **custom_aabb** = ``AABB(0, 0, 0, 0, 0, 0)`` :ref:`🔗<class_PrimitiveMesh_property_custom_aabb>`
  61. .. rst-class:: classref-property-setget
  62. - |void| **set_custom_aabb**\ (\ value\: :ref:`AABB<class_AABB>`\ )
  63. - :ref:`AABB<class_AABB>` **get_custom_aabb**\ (\ )
  64. 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.
  65. .. rst-class:: classref-item-separator
  66. ----
  67. .. _class_PrimitiveMesh_property_flip_faces:
  68. .. rst-class:: classref-property
  69. :ref:`bool<class_bool>` **flip_faces** = ``false`` :ref:`🔗<class_PrimitiveMesh_property_flip_faces>`
  70. .. rst-class:: classref-property-setget
  71. - |void| **set_flip_faces**\ (\ value\: :ref:`bool<class_bool>`\ )
  72. - :ref:`bool<class_bool>` **get_flip_faces**\ (\ )
  73. If set, the order of the vertices in each triangle are reversed resulting in the backside of the mesh being drawn.
  74. 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>`.
  75. .. rst-class:: classref-item-separator
  76. ----
  77. .. _class_PrimitiveMesh_property_material:
  78. .. rst-class:: classref-property
  79. :ref:`Material<class_Material>` **material** :ref:`🔗<class_PrimitiveMesh_property_material>`
  80. .. rst-class:: classref-property-setget
  81. - |void| **set_material**\ (\ value\: :ref:`Material<class_Material>`\ )
  82. - :ref:`Material<class_Material>` **get_material**\ (\ )
  83. The current :ref:`Material<class_Material>` of the primitive mesh.
  84. .. rst-class:: classref-item-separator
  85. ----
  86. .. _class_PrimitiveMesh_property_uv2_padding:
  87. .. rst-class:: classref-property
  88. :ref:`float<class_float>` **uv2_padding** = ``2.0`` :ref:`🔗<class_PrimitiveMesh_property_uv2_padding>`
  89. .. rst-class:: classref-property-setget
  90. - |void| **set_uv2_padding**\ (\ value\: :ref:`float<class_float>`\ )
  91. - :ref:`float<class_float>` **get_uv2_padding**\ (\ )
  92. If :ref:`add_uv2<class_PrimitiveMesh_property_add_uv2>` is set, specifies the padding in pixels applied along seams of the mesh. Lower padding values allow making better use of the lightmap texture (resulting in higher texel density), but may introduce visible lightmap bleeding along edges.
  93. If the size of the lightmap texture can't be determined when generating the mesh, UV2 is calculated assuming a texture size of 1024x1024.
  94. .. rst-class:: classref-section-separator
  95. ----
  96. .. rst-class:: classref-descriptions-group
  97. Method Descriptions
  98. -------------------
  99. .. _class_PrimitiveMesh_private_method__create_mesh_array:
  100. .. rst-class:: classref-method
  101. :ref:`Array<class_Array>` **_create_mesh_array**\ (\ ) |virtual| |const| :ref:`🔗<class_PrimitiveMesh_private_method__create_mesh_array>`
  102. Override this method to customize how this primitive mesh should be generated. Should return an :ref:`Array<class_Array>` where each element is another Array of values required for the mesh (see the :ref:`ArrayType<enum_Mesh_ArrayType>` constants).
  103. .. rst-class:: classref-item-separator
  104. ----
  105. .. _class_PrimitiveMesh_method_get_mesh_arrays:
  106. .. rst-class:: classref-method
  107. :ref:`Array<class_Array>` **get_mesh_arrays**\ (\ ) |const| :ref:`🔗<class_PrimitiveMesh_method_get_mesh_arrays>`
  108. Returns the mesh arrays used to make up the surface of this primitive mesh.
  109. \ **Example:** Pass the result to :ref:`ArrayMesh.add_surface_from_arrays()<class_ArrayMesh_method_add_surface_from_arrays>` to create a new surface:
  110. .. tabs::
  111. .. code-tab:: gdscript
  112. var c = CylinderMesh.new()
  113. var arr_mesh = ArrayMesh.new()
  114. arr_mesh.add_surface_from_arrays(Mesh.PRIMITIVE_TRIANGLES, c.get_mesh_arrays())
  115. .. code-tab:: csharp
  116. var c = new CylinderMesh();
  117. var arrMesh = new ArrayMesh();
  118. arrMesh.AddSurfaceFromArrays(Mesh.PrimitiveType.Triangles, c.GetMeshArrays());
  119. .. rst-class:: classref-item-separator
  120. ----
  121. .. _class_PrimitiveMesh_method_request_update:
  122. .. rst-class:: classref-method
  123. |void| **request_update**\ (\ ) :ref:`🔗<class_PrimitiveMesh_method_request_update>`
  124. Request an update of this primitive mesh based on its properties.
  125. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  126. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  127. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  128. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  129. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  130. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`
  131. .. |bitfield| replace:: :abbr:`BitField (This value is an integer composed as a bitmask of the following flags.)`
  132. .. |void| replace:: :abbr:`void (No return value.)`