| 1 | <?xml version="1.0" encoding="UTF-8" ?> |
| 2 | <class name="Curve3D" inherits="Resource" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd"> |
| 3 | <brief_description> |
| 4 | Describes a Bézier curve in 3D space. |
| 5 | </brief_description> |
| 6 | <description> |
| 7 | This class describes a Bézier curve in 3D space. It is mainly used to give a shape to a [Path3D], but can be manually sampled for other purposes. |
| 8 | It keeps a cache of precalculated points along the curve, to speed up further calculations. |
| 9 | </description> |
| 10 | <tutorials> |
| 11 | </tutorials> |
| 12 | <methods> |
| 13 | <method name="add_point"> |
| 14 | <return type="void" /> |
| 15 | <param index="0" name="position" type="Vector3" /> |
| 16 | <param index="1" name="in" type="Vector3" default="Vector3(0, 0, 0)" /> |
| 17 | <param index="2" name="out" type="Vector3" default="Vector3(0, 0, 0)" /> |
| 18 | <param index="3" name="index" type="int" default="-1" /> |
| 19 | <description> |
| 20 | Adds a point with the specified [param position] relative to the curve's own position, with control points [param in] and [param out]. Appends the new point at the end of the point list. |
| 21 | If [param index] is given, the new point is inserted before the existing point identified by index [param index]. Every existing point starting from [param index] is shifted further down the list of points. The index must be greater than or equal to [code]0[/code] and must not exceed the number of existing points in the line. See [member point_count]. |
| 22 | </description> |
| 23 | </method> |
| 24 | <method name="clear_points"> |
| 25 | <return type="void" /> |
| 26 | <description> |
| 27 | Removes all points from the curve. |
| 28 | </description> |
| 29 | </method> |
| 30 | <method name="get_baked_length" qualifiers="const"> |
| 31 | <return type="float" /> |
| 32 | <description> |
| 33 | Returns the total length of the curve, based on the cached points. Given enough density (see [member bake_interval]), it should be approximate enough. |
| 34 | </description> |
| 35 | </method> |
| 36 | <method name="get_baked_points" qualifiers="const"> |
| 37 | <return type="PackedVector3Array" /> |
| 38 | <description> |
| 39 | Returns the cache of points as a [PackedVector3Array]. |
| 40 | </description> |
| 41 | </method> |
| 42 | <method name="get_baked_tilts" qualifiers="const"> |
| 43 | <return type="PackedFloat32Array" /> |
| 44 | <description> |
| 45 | Returns the cache of tilts as a [PackedFloat32Array]. |
| 46 | </description> |
| 47 | </method> |
| 48 | <method name="get_baked_up_vectors" qualifiers="const"> |
| 49 | <return type="PackedVector3Array" /> |
| 50 | <description> |
| 51 | Returns the cache of up vectors as a [PackedVector3Array]. |
| 52 | If [member up_vector_enabled] is [code]false[/code], the cache will be empty. |
| 53 | </description> |
| 54 | </method> |
| 55 | <method name="get_closest_offset" qualifiers="const"> |
| 56 | <return type="float" /> |
| 57 | <param index="0" name="to_point" type="Vector3" /> |
| 58 | <description> |
| 59 | Returns the closest offset to [param to_point]. This offset is meant to be used in [method sample_baked] or [method sample_baked_up_vector]. |
| 60 | [param to_point] must be in this curve's local space. |
| 61 | </description> |
| 62 | </method> |
| 63 | <method name="get_closest_point" qualifiers="const"> |
| 64 | <return type="Vector3" /> |
| 65 | <param index="0" name="to_point" type="Vector3" /> |
| 66 | <description> |
| 67 | Returns the closest point on baked segments (in curve's local space) to [param to_point]. |
| 68 | [param to_point] must be in this curve's local space. |
| 69 | </description> |
| 70 | </method> |
| 71 | <method name="get_point_in" qualifiers="const"> |
| 72 | <return type="Vector3" /> |
| 73 | <param index="0" name="idx" type="int" /> |
| 74 | <description> |
| 75 | Returns the position of the control point leading to the vertex [param idx]. The returned position is relative to the vertex [param idx]. If the index is out of bounds, the function sends an error to the console, and returns [code](0, 0, 0)[/code]. |
| 76 | </description> |
| 77 | </method> |
| 78 | <method name="get_point_out" qualifiers="const"> |
| 79 | <return type="Vector3" /> |
| 80 | <param index="0" name="idx" type="int" /> |
| 81 | <description> |
| 82 | Returns the position of the control point leading out of the vertex [param idx]. The returned position is relative to the vertex [param idx]. If the index is out of bounds, the function sends an error to the console, and returns [code](0, 0, 0)[/code]. |
| 83 | </description> |
| 84 | </method> |
| 85 | <method name="get_point_position" qualifiers="const"> |
| 86 | <return type="Vector3" /> |
| 87 | <param index="0" name="idx" type="int" /> |
| 88 | <description> |
| 89 | Returns the position of the vertex [param idx]. If the index is out of bounds, the function sends an error to the console, and returns [code](0, 0, 0)[/code]. |
| 90 | </description> |
| 91 | </method> |
| 92 | <method name="get_point_tilt" qualifiers="const"> |
| 93 | <return type="float" /> |
| 94 | <param index="0" name="idx" type="int" /> |
| 95 | <description> |
| 96 | Returns the tilt angle in radians for the point [param idx]. If the index is out of bounds, the function sends an error to the console, and returns [code]0[/code]. |
| 97 | </description> |
| 98 | </method> |
| 99 | <method name="remove_point"> |
| 100 | <return type="void" /> |
| 101 | <param index="0" name="idx" type="int" /> |
| 102 | <description> |
| 103 | Deletes the point [param idx] from the curve. Sends an error to the console if [param idx] is out of bounds. |
| 104 | </description> |
| 105 | </method> |
| 106 | <method name="sample" qualifiers="const"> |
| 107 | <return type="Vector3" /> |
| 108 | <param index="0" name="idx" type="int" /> |
| 109 | <param index="1" name="t" type="float" /> |
| 110 | <description> |
| 111 | Returns the position between the vertex [param idx] and the vertex [code]idx + 1[/code], where [param t] controls if the point is the first vertex ([code]t = 0.0[/code]), the last vertex ([code]t = 1.0[/code]), or in between. Values of [param t] outside the range ([code]0.0 >= t <=1[/code]) give strange, but predictable results. |
| 112 | If [param idx] is out of bounds it is truncated to the first or last vertex, and [param t] is ignored. If the curve has no points, the function sends an error to the console, and returns [code](0, 0, 0)[/code]. |
| 113 | </description> |
| 114 | </method> |
| 115 | <method name="sample_baked" qualifiers="const"> |
| 116 | <return type="Vector3" /> |
| 117 | <param index="0" name="offset" type="float" default="0.0" /> |
| 118 | <param index="1" name="cubic" type="bool" default="false" /> |
| 119 | <description> |
| 120 | Returns a point within the curve at position [param offset], where [param offset] is measured as a distance in 3D units along the curve. To do that, it finds the two cached points where the [param offset] lies between, then interpolates the values. This interpolation is cubic if [param cubic] is set to [code]true[/code], or linear if set to [code]false[/code]. |
| 121 | Cubic interpolation tends to follow the curves better, but linear is faster (and often, precise enough). |
| 122 | </description> |
| 123 | </method> |
| 124 | <method name="sample_baked_up_vector" qualifiers="const"> |
| 125 | <return type="Vector3" /> |
| 126 | <param index="0" name="offset" type="float" /> |
| 127 | <param index="1" name="apply_tilt" type="bool" default="false" /> |
| 128 | <description> |
| 129 | Returns an up vector within the curve at position [param offset], where [param offset] is measured as a distance in 3D units along the curve. To do that, it finds the two cached up vectors where the [param offset] lies between, then interpolates the values. If [param apply_tilt] is [code]true[/code], an interpolated tilt is applied to the interpolated up vector. |
| 130 | If the curve has no up vectors, the function sends an error to the console, and returns [code](0, 1, 0)[/code]. |
| 131 | </description> |
| 132 | </method> |
| 133 | <method name="sample_baked_with_rotation" qualifiers="const"> |
| 134 | <return type="Transform3D" /> |
| 135 | <param index="0" name="offset" type="float" default="0.0" /> |
| 136 | <param index="1" name="cubic" type="bool" default="false" /> |
| 137 | <param index="2" name="apply_tilt" type="bool" default="false" /> |
| 138 | <description> |
| 139 | Returns a [Transform3D] with [code]origin[/code] as point position, [code]basis.x[/code] as sideway vector, [code]basis.y[/code] as up vector, [code]basis.z[/code] as forward vector. When the curve length is 0, there is no reasonable way to calculate the rotation, all vectors aligned with global space axes. See also [method sample_baked]. |
| 140 | </description> |
| 141 | </method> |
| 142 | <method name="samplef" qualifiers="const"> |
| 143 | <return type="Vector3" /> |
| 144 | <param index="0" name="fofs" type="float" /> |
| 145 | <description> |
| 146 | Returns the position at the vertex [param fofs]. It calls [method sample] using the integer part of [param fofs] as [code]idx[/code], and its fractional part as [code]t[/code]. |
| 147 | </description> |
| 148 | </method> |
| 149 | <method name="set_point_in"> |
| 150 | <return type="void" /> |
| 151 | <param index="0" name="idx" type="int" /> |
| 152 | <param index="1" name="position" type="Vector3" /> |
| 153 | <description> |
| 154 | Sets the position of the control point leading to the vertex [param idx]. If the index is out of bounds, the function sends an error to the console. The position is relative to the vertex. |
| 155 | </description> |
| 156 | </method> |
| 157 | <method name="set_point_out"> |
| 158 | <return type="void" /> |
| 159 | <param index="0" name="idx" type="int" /> |
| 160 | <param index="1" name="position" type="Vector3" /> |
| 161 | <description> |
| 162 | Sets the position of the control point leading out of the vertex [param idx]. If the index is out of bounds, the function sends an error to the console. The position is relative to the vertex. |
| 163 | </description> |
| 164 | </method> |
| 165 | <method name="set_point_position"> |
| 166 | <return type="void" /> |
| 167 | <param index="0" name="idx" type="int" /> |
| 168 | <param index="1" name="position" type="Vector3" /> |
| 169 | <description> |
| 170 | Sets the position for the vertex [param idx]. If the index is out of bounds, the function sends an error to the console. |
| 171 | </description> |
| 172 | </method> |
| 173 | <method name="set_point_tilt"> |
| 174 | <return type="void" /> |
| 175 | <param index="0" name="idx" type="int" /> |
| 176 | <param index="1" name="tilt" type="float" /> |
| 177 | <description> |
| 178 | Sets the tilt angle in radians for the point [param idx]. If the index is out of bounds, the function sends an error to the console. |
| 179 | The tilt controls the rotation along the look-at axis an object traveling the path would have. In the case of a curve controlling a [PathFollow3D], this tilt is an offset over the natural tilt the [PathFollow3D] calculates. |
| 180 | </description> |
| 181 | </method> |
| 182 | <method name="tessellate" qualifiers="const"> |
| 183 | <return type="PackedVector3Array" /> |
| 184 | <param index="0" name="max_stages" type="int" default="5" /> |
| 185 | <param index="1" name="tolerance_degrees" type="float" default="4" /> |
| 186 | <description> |
| 187 | Returns a list of points along the curve, with a curvature controlled point density. That is, the curvier parts will have more points than the straighter parts. |
| 188 | This approximation makes straight segments between each point, then subdivides those segments until the resulting shape is similar enough. |
| 189 | [param max_stages] controls how many subdivisions a curve segment may face before it is considered approximate enough. Each subdivision splits the segment in half, so the default 5 stages may mean up to 32 subdivisions per curve segment. Increase with care! |
| 190 | [param tolerance_degrees] controls how many degrees the midpoint of a segment may deviate from the real curve, before the segment has to be subdivided. |
| 191 | </description> |
| 192 | </method> |
| 193 | <method name="tessellate_even_length" qualifiers="const"> |
| 194 | <return type="PackedVector3Array" /> |
| 195 | <param index="0" name="max_stages" type="int" default="5" /> |
| 196 | <param index="1" name="tolerance_length" type="float" default="0.2" /> |
| 197 | <description> |
| 198 | Returns a list of points along the curve, with almost uniform density. [param max_stages] controls how many subdivisions a curve segment may face before it is considered approximate enough. Each subdivision splits the segment in half, so the default 5 stages may mean up to 32 subdivisions per curve segment. Increase with care! |
| 199 | [param tolerance_length] controls the maximal distance between two neighboring points, before the segment has to be subdivided. |
| 200 | </description> |
| 201 | </method> |
| 202 | </methods> |
| 203 | <members> |
| 204 | <member name="bake_interval" type="float" setter="set_bake_interval" getter="get_bake_interval" default="0.2"> |
| 205 | The distance in meters between two adjacent cached points. Changing it forces the cache to be recomputed the next time the [method get_baked_points] or [method get_baked_length] function is called. The smaller the distance, the more points in the cache and the more memory it will consume, so use with care. |
| 206 | </member> |
| 207 | <member name="closed" type="bool" setter="set_closed" getter="is_closed" default="false"> |
| 208 | If [code]true[/code], and the curve has more than 2 control points, the last point and the first one will be connected in a loop. |
| 209 | </member> |
| 210 | <member name="point_count" type="int" setter="set_point_count" getter="get_point_count" default="0"> |
| 211 | The number of points describing the curve. |
| 212 | </member> |
| 213 | <member name="up_vector_enabled" type="bool" setter="set_up_vector_enabled" getter="is_up_vector_enabled" default="true"> |
| 214 | If [code]true[/code], the curve will bake up vectors used for orientation. This is used when [member PathFollow3D.rotation_mode] is set to [constant PathFollow3D.ROTATION_ORIENTED]. Changing it forces the cache to be recomputed. |
| 215 | </member> |
| 216 | </members> |
| 217 | </class> |