EditorNode3DGizmo.xml 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <class name="EditorNode3DGizmo" inherits="Node3DGizmo" version="4.0">
  3. <brief_description>
  4. Gizmo for editing Node3D objects.
  5. </brief_description>
  6. <description>
  7. Gizmo that is used for providing custom visualization and editing (handles and subgizmos) for Node3D objects. Can be overridden to create custom gizmos, but for simple gizmos creating a [EditorNode3DGizmoPlugin] is usually recommended.
  8. </description>
  9. <tutorials>
  10. </tutorials>
  11. <methods>
  12. <method name="_commit_handle" qualifiers="virtual">
  13. <return type="void" />
  14. <argument index="0" name="id" type="int" />
  15. <argument index="1" name="restore" type="Variant" />
  16. <argument index="2" name="cancel" type="bool" />
  17. <description>
  18. Override this method to commit a handle being edited (handles must have been previously added by [method add_handles]). This usually means creating an [UndoRedo] action for the change, using the current handle value as "do" and the [code]restore[/code] argument as "undo".
  19. If the [code]cancel[/code] argument is [code]true[/code], the [code]restore[/code] value should be directly set, without any [UndoRedo] action.
  20. </description>
  21. </method>
  22. <method name="_commit_subgizmos" qualifiers="virtual">
  23. <return type="void" />
  24. <argument index="0" name="ids" type="PackedInt32Array" />
  25. <argument index="1" name="restores" type="Transform3D[]" />
  26. <argument index="2" name="cancel" type="bool" />
  27. <description>
  28. Override this method to commit a group of subgizmos being edited (see [method _subgizmos_intersect_ray] and [method _subgizmos_intersect_frustum]). This usually means creating an [UndoRedo] action for the change, using the current transforms as "do" and the [code]restore[/code] transforms as "undo".
  29. If the [code]cancel[/code] argument is [code]true[/code], the [code]restore[/code] transforms should be directly set, without any [UndoRedo] action.
  30. </description>
  31. </method>
  32. <method name="_get_handle_name" qualifiers="virtual const">
  33. <return type="String" />
  34. <argument index="0" name="id" type="int" />
  35. <description>
  36. Override this method to return the name of an edited handle (handles must have been previously added by [method add_handles]).
  37. Handles can be named for reference to the user when editing.
  38. </description>
  39. </method>
  40. <method name="_get_handle_value" qualifiers="virtual const">
  41. <return type="Variant" />
  42. <argument index="0" name="id" type="int" />
  43. <description>
  44. Override this method to return the current value of a handle. This value will be requested at the start of an edit and used as the [code]restore[/code] argument in [method _commit_handle].
  45. </description>
  46. </method>
  47. <method name="_get_subgizmo_transform" qualifiers="virtual const">
  48. <return type="Transform3D" />
  49. <argument index="0" name="id" type="int" />
  50. <description>
  51. Override this method to return the current transform of a subgizmo. This transform will be requested at the start of an edit and used as the [code]restore[/code] argument in [method _commit_subgizmos].
  52. </description>
  53. </method>
  54. <method name="_is_handle_highlighted" qualifiers="virtual const">
  55. <return type="bool" />
  56. <argument index="0" name="id" type="int" />
  57. <description>
  58. Override this method to return [code]true[/code] whenever the given handle should be highlighted in the editor.
  59. </description>
  60. </method>
  61. <method name="_redraw" qualifiers="virtual">
  62. <return type="void" />
  63. <description>
  64. Override this method to add all the gizmo elements whenever a gizmo update is requested. It's common to call [method clear] at the beginning of this method and then add visual elements depending on the node's properties.
  65. </description>
  66. </method>
  67. <method name="_set_handle" qualifiers="virtual">
  68. <return type="void" />
  69. <argument index="0" name="id" type="int" />
  70. <argument index="1" name="camera" type="Camera3D" />
  71. <argument index="2" name="point" type="Vector2" />
  72. <description>
  73. Override this method to update the node properties when the user drags a gizmo handle (previously added with [method add_handles]). The provided [code]point[/code] is the mouse position in screen coordinates and the [code]camera[/code] can be used to convert it to raycasts.
  74. </description>
  75. </method>
  76. <method name="_set_subgizmo_transform" qualifiers="virtual">
  77. <return type="void" />
  78. <argument index="0" name="id" type="int" />
  79. <argument index="1" name="transform" type="Transform3D" />
  80. <description>
  81. Override this method to update the node properties during subgizmo editing (see [method _subgizmos_intersect_ray] and [method _subgizmos_intersect_frustum]). The [code]transform[/code] is given in the Node3D's local coordinate system.
  82. </description>
  83. </method>
  84. <method name="_subgizmos_intersect_frustum" qualifiers="virtual const">
  85. <return type="PackedInt32Array" />
  86. <argument index="0" name="camera" type="Camera3D" />
  87. <argument index="1" name="frustum" type="Plane[]" />
  88. <description>
  89. Override this method to allow selecting subgizmos using mouse drag box selection. Given a [code]camera[/code] and a [code]frustum[/code], this method should return which subgizmos are contained within the frustum. The [code]frustum[/code] argument consists of an [code]Array[/code] with all the [code]Plane[/code]s that make up the selection frustum. The returned value should contain a list of unique subgizmo identifiers, which can have any non-negative value and will be used in other virtual methods like [method _get_subgizmo_transform] or [method _commit_subgizmos].
  90. </description>
  91. </method>
  92. <method name="_subgizmos_intersect_ray" qualifiers="virtual const">
  93. <return type="int" />
  94. <argument index="0" name="camera" type="Camera3D" />
  95. <argument index="1" name="point" type="Vector2" />
  96. <description>
  97. Override this method to allow selecting subgizmos using mouse clicks. Given a [code]camera[/code] and a [code]point[/code] in screen coordinates, this method should return which subgizmo should be selected. The returned value should be a unique subgizmo identifier, which can have any non-negative value and will be used in other virtual methods like [method _get_subgizmo_transform] or [method _commit_subgizmos].
  98. </description>
  99. </method>
  100. <method name="add_collision_segments">
  101. <return type="void" />
  102. <argument index="0" name="segments" type="PackedVector3Array" />
  103. <description>
  104. Adds the specified [code]segments[/code] to the gizmo's collision shape for picking. Call this method during [method _redraw].
  105. </description>
  106. </method>
  107. <method name="add_collision_triangles">
  108. <return type="void" />
  109. <argument index="0" name="triangles" type="TriangleMesh" />
  110. <description>
  111. Adds collision triangles to the gizmo for picking. A [TriangleMesh] can be generated from a regular [Mesh] too. Call this method during [method _redraw].
  112. </description>
  113. </method>
  114. <method name="add_handles">
  115. <return type="void" />
  116. <argument index="0" name="handles" type="PackedVector3Array" />
  117. <argument index="1" name="material" type="Material" />
  118. <argument index="2" name="ids" type="PackedInt32Array" />
  119. <argument index="3" name="billboard" type="bool" default="false" />
  120. <argument index="4" name="secondary" type="bool" default="false" />
  121. <description>
  122. Adds a list of handles (points) which can be used to edit the properties of the gizmo's Node3D. The [code]ids[/code] argument can be used to specify a custom identifier for each handle, if an empty [code]Array[/code] is passed, the ids will be assigned automatically from the [code]handles[/code] argument order.
  123. There are virtual methods which will be called upon editing of these handles. Call this method during [method _redraw].
  124. </description>
  125. </method>
  126. <method name="add_lines">
  127. <return type="void" />
  128. <argument index="0" name="lines" type="PackedVector3Array" />
  129. <argument index="1" name="material" type="Material" />
  130. <argument index="2" name="billboard" type="bool" default="false" />
  131. <argument index="3" name="modulate" type="Color" default="Color(1, 1, 1, 1)" />
  132. <description>
  133. Adds lines to the gizmo (as sets of 2 points), with a given material. The lines are used for visualizing the gizmo. Call this method during [method _redraw].
  134. </description>
  135. </method>
  136. <method name="add_mesh">
  137. <return type="void" />
  138. <argument index="0" name="mesh" type="ArrayMesh" />
  139. <argument index="1" name="material" type="Material" default="null" />
  140. <argument index="2" name="transform" type="Transform3D" default="Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0)" />
  141. <argument index="3" name="skeleton" type="SkinReference" default="null" />
  142. <description>
  143. Adds a mesh to the gizmo with the specified [code]material[/code], local [code]transform[/code] and [code]skeleton[/code]. Call this method during [method _redraw].
  144. </description>
  145. </method>
  146. <method name="add_unscaled_billboard">
  147. <return type="void" />
  148. <argument index="0" name="material" type="Material" />
  149. <argument index="1" name="default_scale" type="float" default="1" />
  150. <argument index="2" name="modulate" type="Color" default="Color(1, 1, 1, 1)" />
  151. <description>
  152. Adds an unscaled billboard for visualization and selection. Call this method during [method _redraw].
  153. </description>
  154. </method>
  155. <method name="clear">
  156. <return type="void" />
  157. <description>
  158. Removes everything in the gizmo including meshes, collisions and handles.
  159. </description>
  160. </method>
  161. <method name="get_plugin" qualifiers="const">
  162. <return type="EditorNode3DGizmoPlugin" />
  163. <description>
  164. Returns the [EditorNode3DGizmoPlugin] that owns this gizmo. It's useful to retrieve materials using [method EditorNode3DGizmoPlugin.get_material].
  165. </description>
  166. </method>
  167. <method name="get_spatial_node" qualifiers="const">
  168. <return type="Node3D" />
  169. <description>
  170. Returns the Node3D node associated with this gizmo.
  171. </description>
  172. </method>
  173. <method name="get_subgizmo_selection" qualifiers="const">
  174. <return type="PackedInt32Array" />
  175. <description>
  176. Returns a list of the currently selected subgizmos. Can be used to highlight selected elements during [method _redraw].
  177. </description>
  178. </method>
  179. <method name="is_subgizmo_selected" qualifiers="const">
  180. <return type="bool" />
  181. <argument index="0" name="id" type="int" />
  182. <description>
  183. Returns [code]true[/code] if the given subgizmo is currently selected. Can be used to highlight selected elements during [method _redraw].
  184. </description>
  185. </method>
  186. <method name="set_hidden">
  187. <return type="void" />
  188. <argument index="0" name="hidden" type="bool" />
  189. <description>
  190. Sets the gizmo's hidden state. If [code]true[/code], the gizmo will be hidden. If [code]false[/code], it will be shown.
  191. </description>
  192. </method>
  193. <method name="set_spatial_node">
  194. <return type="void" />
  195. <argument index="0" name="node" type="Node" />
  196. <description>
  197. Sets the reference [Node3D] node for the gizmo. [code]node[/code] must inherit from [Node3D].
  198. </description>
  199. </method>
  200. </methods>
  201. </class>