class_csgpolygon.rst 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358
  1. :github_url: hide
  2. .. Generated automatically by doc/tools/make_rst.py in Godot's source tree.
  3. .. DO NOT EDIT THIS FILE, but the CSGPolygon.xml source instead.
  4. .. The source is found in doc/classes or modules/<name>/doc_classes.
  5. .. _class_CSGPolygon:
  6. CSGPolygon
  7. ==========
  8. **Inherits:** :ref:`CSGPrimitive<class_CSGPrimitive>` **<** :ref:`CSGShape<class_CSGShape>` **<** :ref:`GeometryInstance<class_GeometryInstance>` **<** :ref:`VisualInstance<class_VisualInstance>` **<** :ref:`CullInstance<class_CullInstance>` **<** :ref:`Spatial<class_Spatial>` **<** :ref:`Node<class_Node>` **<** :ref:`Object<class_Object>`
  9. Extrudes a 2D polygon shape to create a 3D mesh.
  10. Description
  11. -----------
  12. An array of 2D points is extruded to quickly and easily create a variety of 3D meshes. See also :ref:`CSGMesh<class_CSGMesh>` for using 3D meshes as CSG nodes.
  13. **Note:** CSG nodes are intended to be used for level prototyping. Creating CSG nodes has a significant CPU cost compared to creating a :ref:`MeshInstance<class_MeshInstance>` with a :ref:`PrimitiveMesh<class_PrimitiveMesh>`. Moving a CSG node within another CSG node also has a significant CPU cost, so it should be avoided during gameplay.
  14. Tutorials
  15. ---------
  16. - `Prototyping levels with CSG <$DOCS_URL/tutorials/3d/csg_tools.html>`__
  17. Properties
  18. ----------
  19. +-----------------------------------------------------------+---------------------------------------------------------------------------+------------------------------------------------+
  20. | :ref:`float<class_float>` | :ref:`depth<class_CSGPolygon_property_depth>` | ``1.0`` |
  21. +-----------------------------------------------------------+---------------------------------------------------------------------------+------------------------------------------------+
  22. | :ref:`Material<class_Material>` | :ref:`material<class_CSGPolygon_property_material>` | |
  23. +-----------------------------------------------------------+---------------------------------------------------------------------------+------------------------------------------------+
  24. | :ref:`Mode<enum_CSGPolygon_Mode>` | :ref:`mode<class_CSGPolygon_property_mode>` | ``0`` |
  25. +-----------------------------------------------------------+---------------------------------------------------------------------------+------------------------------------------------+
  26. | :ref:`bool<class_bool>` | :ref:`path_continuous_u<class_CSGPolygon_property_path_continuous_u>` | |
  27. +-----------------------------------------------------------+---------------------------------------------------------------------------+------------------------------------------------+
  28. | :ref:`float<class_float>` | :ref:`path_interval<class_CSGPolygon_property_path_interval>` | |
  29. +-----------------------------------------------------------+---------------------------------------------------------------------------+------------------------------------------------+
  30. | :ref:`PathIntervalType<enum_CSGPolygon_PathIntervalType>` | :ref:`path_interval_type<class_CSGPolygon_property_path_interval_type>` | |
  31. +-----------------------------------------------------------+---------------------------------------------------------------------------+------------------------------------------------+
  32. | :ref:`bool<class_bool>` | :ref:`path_joined<class_CSGPolygon_property_path_joined>` | |
  33. +-----------------------------------------------------------+---------------------------------------------------------------------------+------------------------------------------------+
  34. | :ref:`bool<class_bool>` | :ref:`path_local<class_CSGPolygon_property_path_local>` | |
  35. +-----------------------------------------------------------+---------------------------------------------------------------------------+------------------------------------------------+
  36. | :ref:`NodePath<class_NodePath>` | :ref:`path_node<class_CSGPolygon_property_path_node>` | |
  37. +-----------------------------------------------------------+---------------------------------------------------------------------------+------------------------------------------------+
  38. | :ref:`PathRotation<enum_CSGPolygon_PathRotation>` | :ref:`path_rotation<class_CSGPolygon_property_path_rotation>` | |
  39. +-----------------------------------------------------------+---------------------------------------------------------------------------+------------------------------------------------+
  40. | :ref:`float<class_float>` | :ref:`path_simplify_angle<class_CSGPolygon_property_path_simplify_angle>` | |
  41. +-----------------------------------------------------------+---------------------------------------------------------------------------+------------------------------------------------+
  42. | :ref:`float<class_float>` | :ref:`path_u_distance<class_CSGPolygon_property_path_u_distance>` | |
  43. +-----------------------------------------------------------+---------------------------------------------------------------------------+------------------------------------------------+
  44. | :ref:`PoolVector2Array<class_PoolVector2Array>` | :ref:`polygon<class_CSGPolygon_property_polygon>` | ``PoolVector2Array( 0, 0, 0, 1, 1, 1, 1, 0 )`` |
  45. +-----------------------------------------------------------+---------------------------------------------------------------------------+------------------------------------------------+
  46. | :ref:`bool<class_bool>` | :ref:`smooth_faces<class_CSGPolygon_property_smooth_faces>` | ``false`` |
  47. +-----------------------------------------------------------+---------------------------------------------------------------------------+------------------------------------------------+
  48. | :ref:`float<class_float>` | :ref:`spin_degrees<class_CSGPolygon_property_spin_degrees>` | |
  49. +-----------------------------------------------------------+---------------------------------------------------------------------------+------------------------------------------------+
  50. | :ref:`int<class_int>` | :ref:`spin_sides<class_CSGPolygon_property_spin_sides>` | |
  51. +-----------------------------------------------------------+---------------------------------------------------------------------------+------------------------------------------------+
  52. Enumerations
  53. ------------
  54. .. _enum_CSGPolygon_Mode:
  55. .. _class_CSGPolygon_constant_MODE_DEPTH:
  56. .. _class_CSGPolygon_constant_MODE_SPIN:
  57. .. _class_CSGPolygon_constant_MODE_PATH:
  58. enum **Mode**:
  59. - **MODE_DEPTH** = **0** --- The :ref:`polygon<class_CSGPolygon_property_polygon>` shape is extruded along the negative Z axis.
  60. - **MODE_SPIN** = **1** --- The :ref:`polygon<class_CSGPolygon_property_polygon>` shape is extruded by rotating it around the Y axis.
  61. - **MODE_PATH** = **2** --- The :ref:`polygon<class_CSGPolygon_property_polygon>` shape is extruded along the :ref:`Path<class_Path>` specified in :ref:`path_node<class_CSGPolygon_property_path_node>`.
  62. ----
  63. .. _enum_CSGPolygon_PathRotation:
  64. .. _class_CSGPolygon_constant_PATH_ROTATION_POLYGON:
  65. .. _class_CSGPolygon_constant_PATH_ROTATION_PATH:
  66. .. _class_CSGPolygon_constant_PATH_ROTATION_PATH_FOLLOW:
  67. enum **PathRotation**:
  68. - **PATH_ROTATION_POLYGON** = **0** --- The :ref:`polygon<class_CSGPolygon_property_polygon>` shape is not rotated.
  69. **Note:** Requires the path's Z coordinates to continually decrease to ensure viable shapes.
  70. - **PATH_ROTATION_PATH** = **1** --- The :ref:`polygon<class_CSGPolygon_property_polygon>` shape is rotated along the path, but it is not rotated around the path axis.
  71. **Note:** Requires the path's Z coordinates to continually decrease to ensure viable shapes.
  72. - **PATH_ROTATION_PATH_FOLLOW** = **2** --- The :ref:`polygon<class_CSGPolygon_property_polygon>` shape follows the path and its rotations around the path axis.
  73. ----
  74. .. _enum_CSGPolygon_PathIntervalType:
  75. .. _class_CSGPolygon_constant_PATH_INTERVAL_DISTANCE:
  76. .. _class_CSGPolygon_constant_PATH_INTERVAL_SUBDIVIDE:
  77. enum **PathIntervalType**:
  78. - **PATH_INTERVAL_DISTANCE** = **0** --- When :ref:`mode<class_CSGPolygon_property_mode>` is set to :ref:`MODE_PATH<class_CSGPolygon_constant_MODE_PATH>`, :ref:`path_interval<class_CSGPolygon_property_path_interval>` will determine the distance, in meters, each interval of the path will extrude.
  79. - **PATH_INTERVAL_SUBDIVIDE** = **1** --- When :ref:`mode<class_CSGPolygon_property_mode>` is set to :ref:`MODE_PATH<class_CSGPolygon_constant_MODE_PATH>`, :ref:`path_interval<class_CSGPolygon_property_path_interval>` will subdivide the polygons along the path.
  80. Property Descriptions
  81. ---------------------
  82. .. _class_CSGPolygon_property_depth:
  83. - :ref:`float<class_float>` **depth**
  84. +-----------+------------------+
  85. | *Default* | ``1.0`` |
  86. +-----------+------------------+
  87. | *Setter* | set_depth(value) |
  88. +-----------+------------------+
  89. | *Getter* | get_depth() |
  90. +-----------+------------------+
  91. When :ref:`mode<class_CSGPolygon_property_mode>` is :ref:`MODE_DEPTH<class_CSGPolygon_constant_MODE_DEPTH>`, the depth of the extrusion.
  92. ----
  93. .. _class_CSGPolygon_property_material:
  94. - :ref:`Material<class_Material>` **material**
  95. +----------+---------------------+
  96. | *Setter* | set_material(value) |
  97. +----------+---------------------+
  98. | *Getter* | get_material() |
  99. +----------+---------------------+
  100. Material to use for the resulting mesh. The UV maps the top half of the material to the extruded shape (U along the the length of the extrusions and V around the outline of the :ref:`polygon<class_CSGPolygon_property_polygon>`), the bottom-left quarter to the front end face, and the bottom-right quarter to the back end face.
  101. ----
  102. .. _class_CSGPolygon_property_mode:
  103. - :ref:`Mode<enum_CSGPolygon_Mode>` **mode**
  104. +-----------+-----------------+
  105. | *Default* | ``0`` |
  106. +-----------+-----------------+
  107. | *Setter* | set_mode(value) |
  108. +-----------+-----------------+
  109. | *Getter* | get_mode() |
  110. +-----------+-----------------+
  111. The :ref:`mode<class_CSGPolygon_property_mode>` used to extrude the :ref:`polygon<class_CSGPolygon_property_polygon>`.
  112. ----
  113. .. _class_CSGPolygon_property_path_continuous_u:
  114. - :ref:`bool<class_bool>` **path_continuous_u**
  115. +----------+------------------------------+
  116. | *Setter* | set_path_continuous_u(value) |
  117. +----------+------------------------------+
  118. | *Getter* | is_path_continuous_u() |
  119. +----------+------------------------------+
  120. When :ref:`mode<class_CSGPolygon_property_mode>` is :ref:`MODE_PATH<class_CSGPolygon_constant_MODE_PATH>`, by default, the top half of the :ref:`material<class_CSGPolygon_property_material>` is stretched along the entire length of the extruded shape. If ``false`` the top half of the material is repeated every step of the extrusion.
  121. ----
  122. .. _class_CSGPolygon_property_path_interval:
  123. - :ref:`float<class_float>` **path_interval**
  124. +----------+--------------------------+
  125. | *Setter* | set_path_interval(value) |
  126. +----------+--------------------------+
  127. | *Getter* | get_path_interval() |
  128. +----------+--------------------------+
  129. When :ref:`mode<class_CSGPolygon_property_mode>` is :ref:`MODE_PATH<class_CSGPolygon_constant_MODE_PATH>`, the path interval or ratio of path points to extrusions.
  130. ----
  131. .. _class_CSGPolygon_property_path_interval_type:
  132. - :ref:`PathIntervalType<enum_CSGPolygon_PathIntervalType>` **path_interval_type**
  133. +----------+-------------------------------+
  134. | *Setter* | set_path_interval_type(value) |
  135. +----------+-------------------------------+
  136. | *Getter* | get_path_interval_type() |
  137. +----------+-------------------------------+
  138. When :ref:`mode<class_CSGPolygon_property_mode>` is :ref:`MODE_PATH<class_CSGPolygon_constant_MODE_PATH>`, this will determine if the interval should be by distance (:ref:`PATH_INTERVAL_DISTANCE<class_CSGPolygon_constant_PATH_INTERVAL_DISTANCE>`) or subdivision fractions (:ref:`PATH_INTERVAL_SUBDIVIDE<class_CSGPolygon_constant_PATH_INTERVAL_SUBDIVIDE>`).
  139. ----
  140. .. _class_CSGPolygon_property_path_joined:
  141. - :ref:`bool<class_bool>` **path_joined**
  142. +----------+------------------------+
  143. | *Setter* | set_path_joined(value) |
  144. +----------+------------------------+
  145. | *Getter* | is_path_joined() |
  146. +----------+------------------------+
  147. When :ref:`mode<class_CSGPolygon_property_mode>` is :ref:`MODE_PATH<class_CSGPolygon_constant_MODE_PATH>`, if ``true`` the ends of the path are joined, by adding an extrusion between the last and first points of the path.
  148. ----
  149. .. _class_CSGPolygon_property_path_local:
  150. - :ref:`bool<class_bool>` **path_local**
  151. +----------+-----------------------+
  152. | *Setter* | set_path_local(value) |
  153. +----------+-----------------------+
  154. | *Getter* | is_path_local() |
  155. +----------+-----------------------+
  156. When :ref:`mode<class_CSGPolygon_property_mode>` is :ref:`MODE_PATH<class_CSGPolygon_constant_MODE_PATH>`, if ``true`` the :ref:`Transform<class_Transform>` of the ``CSGPolygon`` is used as the starting point for the extrusions, not the :ref:`Transform<class_Transform>` of the :ref:`path_node<class_CSGPolygon_property_path_node>`.
  157. ----
  158. .. _class_CSGPolygon_property_path_node:
  159. - :ref:`NodePath<class_NodePath>` **path_node**
  160. +----------+----------------------+
  161. | *Setter* | set_path_node(value) |
  162. +----------+----------------------+
  163. | *Getter* | get_path_node() |
  164. +----------+----------------------+
  165. When :ref:`mode<class_CSGPolygon_property_mode>` is :ref:`MODE_PATH<class_CSGPolygon_constant_MODE_PATH>`, the location of the :ref:`Path<class_Path>` object used to extrude the :ref:`polygon<class_CSGPolygon_property_polygon>`.
  166. ----
  167. .. _class_CSGPolygon_property_path_rotation:
  168. - :ref:`PathRotation<enum_CSGPolygon_PathRotation>` **path_rotation**
  169. +----------+--------------------------+
  170. | *Setter* | set_path_rotation(value) |
  171. +----------+--------------------------+
  172. | *Getter* | get_path_rotation() |
  173. +----------+--------------------------+
  174. When :ref:`mode<class_CSGPolygon_property_mode>` is :ref:`MODE_PATH<class_CSGPolygon_constant_MODE_PATH>`, the :ref:`PathRotation<enum_CSGPolygon_PathRotation>` method used to rotate the :ref:`polygon<class_CSGPolygon_property_polygon>` as it is extruded.
  175. ----
  176. .. _class_CSGPolygon_property_path_simplify_angle:
  177. - :ref:`float<class_float>` **path_simplify_angle**
  178. +----------+--------------------------------+
  179. | *Setter* | set_path_simplify_angle(value) |
  180. +----------+--------------------------------+
  181. | *Getter* | get_path_simplify_angle() |
  182. +----------+--------------------------------+
  183. When :ref:`mode<class_CSGPolygon_property_mode>` is :ref:`MODE_PATH<class_CSGPolygon_constant_MODE_PATH>`, extrusions that are less than this angle, will be merged together to reduce polygon count.
  184. ----
  185. .. _class_CSGPolygon_property_path_u_distance:
  186. - :ref:`float<class_float>` **path_u_distance**
  187. +----------+----------------------------+
  188. | *Setter* | set_path_u_distance(value) |
  189. +----------+----------------------------+
  190. | *Getter* | get_path_u_distance() |
  191. +----------+----------------------------+
  192. When :ref:`mode<class_CSGPolygon_property_mode>` is :ref:`MODE_PATH<class_CSGPolygon_constant_MODE_PATH>`, this is the distance along the path, in meters, the texture coordinates will tile. When set to 0, texture coordinates will match geometry exactly with no tiling.
  193. ----
  194. .. _class_CSGPolygon_property_polygon:
  195. - :ref:`PoolVector2Array<class_PoolVector2Array>` **polygon**
  196. +-----------+------------------------------------------------+
  197. | *Default* | ``PoolVector2Array( 0, 0, 0, 1, 1, 1, 1, 0 )`` |
  198. +-----------+------------------------------------------------+
  199. | *Setter* | set_polygon(value) |
  200. +-----------+------------------------------------------------+
  201. | *Getter* | get_polygon() |
  202. +-----------+------------------------------------------------+
  203. The point array that defines the 2D polygon that is extruded. This can be a convex or concave polygon with 3 or more points. The polygon must *not* have any intersecting edges. Otherwise, triangulation will fail and no mesh will be generated.
  204. **Note:** If only 1 or 2 points are defined in :ref:`polygon<class_CSGPolygon_property_polygon>`, no mesh will be generated.
  205. ----
  206. .. _class_CSGPolygon_property_smooth_faces:
  207. - :ref:`bool<class_bool>` **smooth_faces**
  208. +-----------+-------------------------+
  209. | *Default* | ``false`` |
  210. +-----------+-------------------------+
  211. | *Setter* | set_smooth_faces(value) |
  212. +-----------+-------------------------+
  213. | *Getter* | get_smooth_faces() |
  214. +-----------+-------------------------+
  215. If ``true``, applies smooth shading to the extrusions.
  216. ----
  217. .. _class_CSGPolygon_property_spin_degrees:
  218. - :ref:`float<class_float>` **spin_degrees**
  219. +----------+-------------------------+
  220. | *Setter* | set_spin_degrees(value) |
  221. +----------+-------------------------+
  222. | *Getter* | get_spin_degrees() |
  223. +----------+-------------------------+
  224. When :ref:`mode<class_CSGPolygon_property_mode>` is :ref:`MODE_SPIN<class_CSGPolygon_constant_MODE_SPIN>`, the total number of degrees the :ref:`polygon<class_CSGPolygon_property_polygon>` is rotated when extruding.
  225. ----
  226. .. _class_CSGPolygon_property_spin_sides:
  227. - :ref:`int<class_int>` **spin_sides**
  228. +----------+-----------------------+
  229. | *Setter* | set_spin_sides(value) |
  230. +----------+-----------------------+
  231. | *Getter* | get_spin_sides() |
  232. +----------+-----------------------+
  233. When :ref:`mode<class_CSGPolygon_property_mode>` is :ref:`MODE_SPIN<class_CSGPolygon_constant_MODE_SPIN>`, the number of extrusions made.
  234. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  235. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  236. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`