class_csgshape3d.rst 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371
  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/modules/csg/doc_classes/CSGShape3D.xml.
  6. .. _class_CSGShape3D:
  7. CSGShape3D
  8. ==========
  9. **Inherits:** :ref:`GeometryInstance3D<class_GeometryInstance3D>` **<** :ref:`VisualInstance3D<class_VisualInstance3D>` **<** :ref:`Node3D<class_Node3D>` **<** :ref:`Node<class_Node>` **<** :ref:`Object<class_Object>`
  10. **Inherited By:** :ref:`CSGCombiner3D<class_CSGCombiner3D>`, :ref:`CSGPrimitive3D<class_CSGPrimitive3D>`
  11. The CSG base class.
  12. .. rst-class:: classref-introduction-group
  13. Description
  14. -----------
  15. This is the CSG base class that provides CSG operation support to the various CSG nodes in Godot.
  16. \ **Performance:** CSG nodes are only intended for prototyping as they have a significant CPU performance cost.
  17. Consider baking final CSG operation results into static geometry that replaces the CSG nodes.
  18. Individual CSG root node results can be baked to nodes with static resources with the editor menu that appears when a CSG root node is selected.
  19. Individual CSG root nodes can also be baked to static resources with scripts by calling :ref:`bake_static_mesh<class_CSGShape3D_method_bake_static_mesh>` for the visual mesh or :ref:`bake_collision_shape<class_CSGShape3D_method_bake_collision_shape>` for the physics collision.
  20. Entire scenes of CSG nodes can be baked to static geometry and exported with the editor gltf scene exporter.
  21. .. rst-class:: classref-introduction-group
  22. Tutorials
  23. ---------
  24. - :doc:`Prototyping levels with CSG <../tutorials/3d/csg_tools>`
  25. .. rst-class:: classref-reftable-group
  26. Properties
  27. ----------
  28. .. table::
  29. :widths: auto
  30. +---------------------------------------------+-------------------------------------------------------------------------+-----------+
  31. | :ref:`bool<class_bool>` | :ref:`calculate_tangents<class_CSGShape3D_property_calculate_tangents>` | ``true`` |
  32. +---------------------------------------------+-------------------------------------------------------------------------+-----------+
  33. | :ref:`int<class_int>` | :ref:`collision_layer<class_CSGShape3D_property_collision_layer>` | ``1`` |
  34. +---------------------------------------------+-------------------------------------------------------------------------+-----------+
  35. | :ref:`int<class_int>` | :ref:`collision_mask<class_CSGShape3D_property_collision_mask>` | ``1`` |
  36. +---------------------------------------------+-------------------------------------------------------------------------+-----------+
  37. | :ref:`float<class_float>` | :ref:`collision_priority<class_CSGShape3D_property_collision_priority>` | ``1.0`` |
  38. +---------------------------------------------+-------------------------------------------------------------------------+-----------+
  39. | :ref:`Operation<enum_CSGShape3D_Operation>` | :ref:`operation<class_CSGShape3D_property_operation>` | ``0`` |
  40. +---------------------------------------------+-------------------------------------------------------------------------+-----------+
  41. | :ref:`float<class_float>` | :ref:`snap<class_CSGShape3D_property_snap>` | ``0.001`` |
  42. +---------------------------------------------+-------------------------------------------------------------------------+-----------+
  43. | :ref:`bool<class_bool>` | :ref:`use_collision<class_CSGShape3D_property_use_collision>` | ``false`` |
  44. +---------------------------------------------+-------------------------------------------------------------------------+-----------+
  45. .. rst-class:: classref-reftable-group
  46. Methods
  47. -------
  48. .. table::
  49. :widths: auto
  50. +-----------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  51. | :ref:`ConcavePolygonShape3D<class_ConcavePolygonShape3D>` | :ref:`bake_collision_shape<class_CSGShape3D_method_bake_collision_shape>`\ (\ ) |
  52. +-----------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  53. | :ref:`ArrayMesh<class_ArrayMesh>` | :ref:`bake_static_mesh<class_CSGShape3D_method_bake_static_mesh>`\ (\ ) |
  54. +-----------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  55. | :ref:`bool<class_bool>` | :ref:`get_collision_layer_value<class_CSGShape3D_method_get_collision_layer_value>`\ (\ layer_number\: :ref:`int<class_int>`\ ) |const| |
  56. +-----------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  57. | :ref:`bool<class_bool>` | :ref:`get_collision_mask_value<class_CSGShape3D_method_get_collision_mask_value>`\ (\ layer_number\: :ref:`int<class_int>`\ ) |const| |
  58. +-----------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  59. | :ref:`Array<class_Array>` | :ref:`get_meshes<class_CSGShape3D_method_get_meshes>`\ (\ ) |const| |
  60. +-----------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  61. | :ref:`bool<class_bool>` | :ref:`is_root_shape<class_CSGShape3D_method_is_root_shape>`\ (\ ) |const| |
  62. +-----------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  63. | |void| | :ref:`set_collision_layer_value<class_CSGShape3D_method_set_collision_layer_value>`\ (\ layer_number\: :ref:`int<class_int>`, value\: :ref:`bool<class_bool>`\ ) |
  64. +-----------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  65. | |void| | :ref:`set_collision_mask_value<class_CSGShape3D_method_set_collision_mask_value>`\ (\ layer_number\: :ref:`int<class_int>`, value\: :ref:`bool<class_bool>`\ ) |
  66. +-----------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  67. .. rst-class:: classref-section-separator
  68. ----
  69. .. rst-class:: classref-descriptions-group
  70. Enumerations
  71. ------------
  72. .. _enum_CSGShape3D_Operation:
  73. .. rst-class:: classref-enumeration
  74. enum **Operation**: :ref:`🔗<enum_CSGShape3D_Operation>`
  75. .. _class_CSGShape3D_constant_OPERATION_UNION:
  76. .. rst-class:: classref-enumeration-constant
  77. :ref:`Operation<enum_CSGShape3D_Operation>` **OPERATION_UNION** = ``0``
  78. Geometry of both primitives is merged, intersecting geometry is removed.
  79. .. _class_CSGShape3D_constant_OPERATION_INTERSECTION:
  80. .. rst-class:: classref-enumeration-constant
  81. :ref:`Operation<enum_CSGShape3D_Operation>` **OPERATION_INTERSECTION** = ``1``
  82. Only intersecting geometry remains, the rest is removed.
  83. .. _class_CSGShape3D_constant_OPERATION_SUBTRACTION:
  84. .. rst-class:: classref-enumeration-constant
  85. :ref:`Operation<enum_CSGShape3D_Operation>` **OPERATION_SUBTRACTION** = ``2``
  86. The second shape is subtracted from the first, leaving a dent with its shape.
  87. .. rst-class:: classref-section-separator
  88. ----
  89. .. rst-class:: classref-descriptions-group
  90. Property Descriptions
  91. ---------------------
  92. .. _class_CSGShape3D_property_calculate_tangents:
  93. .. rst-class:: classref-property
  94. :ref:`bool<class_bool>` **calculate_tangents** = ``true`` :ref:`🔗<class_CSGShape3D_property_calculate_tangents>`
  95. .. rst-class:: classref-property-setget
  96. - |void| **set_calculate_tangents**\ (\ value\: :ref:`bool<class_bool>`\ )
  97. - :ref:`bool<class_bool>` **is_calculating_tangents**\ (\ )
  98. Calculate tangents for the CSG shape which allows the use of normal maps. This is only applied on the root shape, this setting is ignored on any child.
  99. .. rst-class:: classref-item-separator
  100. ----
  101. .. _class_CSGShape3D_property_collision_layer:
  102. .. rst-class:: classref-property
  103. :ref:`int<class_int>` **collision_layer** = ``1`` :ref:`🔗<class_CSGShape3D_property_collision_layer>`
  104. .. rst-class:: classref-property-setget
  105. - |void| **set_collision_layer**\ (\ value\: :ref:`int<class_int>`\ )
  106. - :ref:`int<class_int>` **get_collision_layer**\ (\ )
  107. The physics layers this area is in.
  108. Collidable objects can exist in any of 32 different layers. These layers work like a tagging system, and are not visual. A collidable can use these layers to select with which objects it can collide, using the collision_mask property.
  109. A contact is detected if object A is in any of the layers that object B scans, or object B is in any layer scanned by object A. See `Collision layers and masks <../tutorials/physics/physics_introduction.html#collision-layers-and-masks>`__ in the documentation for more information.
  110. .. rst-class:: classref-item-separator
  111. ----
  112. .. _class_CSGShape3D_property_collision_mask:
  113. .. rst-class:: classref-property
  114. :ref:`int<class_int>` **collision_mask** = ``1`` :ref:`🔗<class_CSGShape3D_property_collision_mask>`
  115. .. rst-class:: classref-property-setget
  116. - |void| **set_collision_mask**\ (\ value\: :ref:`int<class_int>`\ )
  117. - :ref:`int<class_int>` **get_collision_mask**\ (\ )
  118. The physics layers this CSG shape scans for collisions. Only effective if :ref:`use_collision<class_CSGShape3D_property_use_collision>` is ``true``. See `Collision layers and masks <../tutorials/physics/physics_introduction.html#collision-layers-and-masks>`__ in the documentation for more information.
  119. .. rst-class:: classref-item-separator
  120. ----
  121. .. _class_CSGShape3D_property_collision_priority:
  122. .. rst-class:: classref-property
  123. :ref:`float<class_float>` **collision_priority** = ``1.0`` :ref:`🔗<class_CSGShape3D_property_collision_priority>`
  124. .. rst-class:: classref-property-setget
  125. - |void| **set_collision_priority**\ (\ value\: :ref:`float<class_float>`\ )
  126. - :ref:`float<class_float>` **get_collision_priority**\ (\ )
  127. The priority used to solve colliding when occurring penetration. Only effective if :ref:`use_collision<class_CSGShape3D_property_use_collision>` is ``true``. The higher the priority is, the lower the penetration into the object will be. This can for example be used to prevent the player from breaking through the boundaries of a level.
  128. .. rst-class:: classref-item-separator
  129. ----
  130. .. _class_CSGShape3D_property_operation:
  131. .. rst-class:: classref-property
  132. :ref:`Operation<enum_CSGShape3D_Operation>` **operation** = ``0`` :ref:`🔗<class_CSGShape3D_property_operation>`
  133. .. rst-class:: classref-property-setget
  134. - |void| **set_operation**\ (\ value\: :ref:`Operation<enum_CSGShape3D_Operation>`\ )
  135. - :ref:`Operation<enum_CSGShape3D_Operation>` **get_operation**\ (\ )
  136. The operation that is performed on this shape. This is ignored for the first CSG child node as the operation is between this node and the previous child of this nodes parent.
  137. .. rst-class:: classref-item-separator
  138. ----
  139. .. _class_CSGShape3D_property_snap:
  140. .. rst-class:: classref-property
  141. :ref:`float<class_float>` **snap** = ``0.001`` :ref:`🔗<class_CSGShape3D_property_snap>`
  142. .. rst-class:: classref-property-setget
  143. - |void| **set_snap**\ (\ value\: :ref:`float<class_float>`\ )
  144. - :ref:`float<class_float>` **get_snap**\ (\ )
  145. Snap makes the mesh vertices snap to a given distance so that the faces of two meshes can be perfectly aligned. A lower value results in greater precision but may be harder to adjust. The top-level CSG shape's snap value is used for the entire CSG tree.
  146. .. rst-class:: classref-item-separator
  147. ----
  148. .. _class_CSGShape3D_property_use_collision:
  149. .. rst-class:: classref-property
  150. :ref:`bool<class_bool>` **use_collision** = ``false`` :ref:`🔗<class_CSGShape3D_property_use_collision>`
  151. .. rst-class:: classref-property-setget
  152. - |void| **set_use_collision**\ (\ value\: :ref:`bool<class_bool>`\ )
  153. - :ref:`bool<class_bool>` **is_using_collision**\ (\ )
  154. Adds a collision shape to the physics engine for our CSG shape. This will always act like a static body. Note that the collision shape is still active even if the CSG shape itself is hidden. See also :ref:`collision_mask<class_CSGShape3D_property_collision_mask>` and :ref:`collision_priority<class_CSGShape3D_property_collision_priority>`.
  155. .. rst-class:: classref-section-separator
  156. ----
  157. .. rst-class:: classref-descriptions-group
  158. Method Descriptions
  159. -------------------
  160. .. _class_CSGShape3D_method_bake_collision_shape:
  161. .. rst-class:: classref-method
  162. :ref:`ConcavePolygonShape3D<class_ConcavePolygonShape3D>` **bake_collision_shape**\ (\ ) :ref:`🔗<class_CSGShape3D_method_bake_collision_shape>`
  163. Returns a baked physics :ref:`ConcavePolygonShape3D<class_ConcavePolygonShape3D>` of this node's CSG operation result. Returns an empty shape if the node is not a CSG root node or has no valid geometry.
  164. \ **Performance:** If the CSG operation results in a very detailed geometry with many faces physics performance will be very slow. Concave shapes should in general only be used for static level geometry and not with dynamic objects that are moving.
  165. .. rst-class:: classref-item-separator
  166. ----
  167. .. _class_CSGShape3D_method_bake_static_mesh:
  168. .. rst-class:: classref-method
  169. :ref:`ArrayMesh<class_ArrayMesh>` **bake_static_mesh**\ (\ ) :ref:`🔗<class_CSGShape3D_method_bake_static_mesh>`
  170. Returns a baked static :ref:`ArrayMesh<class_ArrayMesh>` of this node's CSG operation result. Materials from involved CSG nodes are added as extra mesh surfaces. Returns an empty mesh if the node is not a CSG root node or has no valid geometry.
  171. .. rst-class:: classref-item-separator
  172. ----
  173. .. _class_CSGShape3D_method_get_collision_layer_value:
  174. .. rst-class:: classref-method
  175. :ref:`bool<class_bool>` **get_collision_layer_value**\ (\ layer_number\: :ref:`int<class_int>`\ ) |const| :ref:`🔗<class_CSGShape3D_method_get_collision_layer_value>`
  176. Returns whether or not the specified layer of the :ref:`collision_layer<class_CSGShape3D_property_collision_layer>` is enabled, given a ``layer_number`` between 1 and 32.
  177. .. rst-class:: classref-item-separator
  178. ----
  179. .. _class_CSGShape3D_method_get_collision_mask_value:
  180. .. rst-class:: classref-method
  181. :ref:`bool<class_bool>` **get_collision_mask_value**\ (\ layer_number\: :ref:`int<class_int>`\ ) |const| :ref:`🔗<class_CSGShape3D_method_get_collision_mask_value>`
  182. Returns whether or not the specified layer of the :ref:`collision_mask<class_CSGShape3D_property_collision_mask>` is enabled, given a ``layer_number`` between 1 and 32.
  183. .. rst-class:: classref-item-separator
  184. ----
  185. .. _class_CSGShape3D_method_get_meshes:
  186. .. rst-class:: classref-method
  187. :ref:`Array<class_Array>` **get_meshes**\ (\ ) |const| :ref:`🔗<class_CSGShape3D_method_get_meshes>`
  188. Returns an :ref:`Array<class_Array>` with two elements, the first is the :ref:`Transform3D<class_Transform3D>` of this node and the second is the root :ref:`Mesh<class_Mesh>` of this node. Only works when this node is the root shape.
  189. .. rst-class:: classref-item-separator
  190. ----
  191. .. _class_CSGShape3D_method_is_root_shape:
  192. .. rst-class:: classref-method
  193. :ref:`bool<class_bool>` **is_root_shape**\ (\ ) |const| :ref:`🔗<class_CSGShape3D_method_is_root_shape>`
  194. Returns ``true`` if this is a root shape and is thus the object that is rendered.
  195. .. rst-class:: classref-item-separator
  196. ----
  197. .. _class_CSGShape3D_method_set_collision_layer_value:
  198. .. rst-class:: classref-method
  199. |void| **set_collision_layer_value**\ (\ layer_number\: :ref:`int<class_int>`, value\: :ref:`bool<class_bool>`\ ) :ref:`🔗<class_CSGShape3D_method_set_collision_layer_value>`
  200. Based on ``value``, enables or disables the specified layer in the :ref:`collision_layer<class_CSGShape3D_property_collision_layer>`, given a ``layer_number`` between 1 and 32.
  201. .. rst-class:: classref-item-separator
  202. ----
  203. .. _class_CSGShape3D_method_set_collision_mask_value:
  204. .. rst-class:: classref-method
  205. |void| **set_collision_mask_value**\ (\ layer_number\: :ref:`int<class_int>`, value\: :ref:`bool<class_bool>`\ ) :ref:`🔗<class_CSGShape3D_method_set_collision_mask_value>`
  206. Based on ``value``, enables or disables the specified layer in the :ref:`collision_mask<class_CSGShape3D_property_collision_mask>`, given a ``layer_number`` between 1 and 32.
  207. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  208. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  209. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  210. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  211. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  212. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`
  213. .. |bitfield| replace:: :abbr:`BitField (This value is an integer composed as a bitmask of the following flags.)`
  214. .. |void| replace:: :abbr:`void (No return value.)`