Curve3D
Inherits: Resource < Reference < Object Describes a Bézier curve in 3D space.
Description
Path, but can be manually sampled for other purposes. It keeps a cache of precalculated points along the curve, to speed up further calculations.
Properties
Methods
Property Descriptions
- float bake_interval get_baked_points or 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.
- bool up_vector_enabled
true, the curve will bake up vectors used for orientation. This is used when PathFollow.rotation_mode is set to PathFollow.ROTATION_ORIENTED. Changing it forces the cache to be recomputed.Method Descriptions
- add_point ( Vector3 position, Vector3 in=Vector3( 0, 0, 0 ), Vector3 out=Vector3( 0, 0, 0 ), int at_position=-1 )
positionrelative to theCurve3D‘s position, with control pointsinandout.at_positionis given, the point is inserted before the point numberat_position, moving that point (and every point after) after the inserted point. Ifat_positionis not given, or is an illegal value (at_position <0orat_position >= [method get_point_count]), the point will be appended at the end of the point list.
- clear_points ( ) Removes all points from the curve.
- float get_baked_length ( ) const bake_interval), it should be approximate enough.
- PoolVector3Array get_baked_points ( ) const PoolVector3Array.
- PoolRealArray get_baked_tilts ( ) const PoolRealArray.
- PoolVector3Array get_baked_up_vectors ( ) const
PoolVector3Array.
up_vector_enabled is
false, the cache will be empty.
- float get_closest_offset ( Vector3 to_point ) const
to_point. This offset is meant to be used in interpolate_baked or interpolate_baked_up_vector.to_pointmust be in this curve’s local space.
- Vector3 get_closest_point ( Vector3 to_point ) const
to_point.to_pointmust be in this curve’s local space.
- int get_point_count ( ) const Returns the number of points describing the curve.
- Vector3 get_point_in ( int idx ) const
idx. The returned position is relative to the vertexidx. If the index is out of bounds, the function sends an error to the console, and returns(0, 0, 0).
- Vector3 get_point_out ( int idx ) const
idx. The returned position is relative to the vertexidx. If the index is out of bounds, the function sends an error to the console, and returns(0, 0, 0).
- Vector3 get_point_position ( int idx ) const
idx. If the index is out of bounds, the function sends an error to the console, and returns(0, 0, 0).
- float get_point_tilt ( int idx ) const
idx. If the index is out of bounds, the function sends an error to the console, and returns0.
- Vector3 interpolate ( int idx, float t ) const
idxand the vertexidx + 1, wheretcontrols if the point is the first vertex (t = 0.0), the last vertex (t = 1.0), or in between. Values oftoutside the range (0.0 >= t <=1) give strange, but predictable results.idxis out of bounds it is truncated to the first or last vertex, andtis ignored. If the curve has no points, the function sends an error to the console, and returns(0, 0, 0).
- Vector3 interpolate_baked ( float offset, bool cubic=false ) const
offset, whereoffsetis measured as a distance in 3D units along the curve.offsetlies between, then interpolates the values. This interpolation is cubic ifcubicis set totrue, or linear if set tofalse. Cubic interpolation tends to follow the curves better, but linear is faster (and often, precise enough).
- Vector3 interpolate_baked_up_vector ( float offset, bool apply_tilt=false ) const
offset, whereoffsetis measured as a distance in 3D units along the curve.offsetlies between, then interpolates the values. Ifapply_tiltistrue, an interpolated tilt is applied to the interpolated up vector.(0, 1, 0).
- Vector3 interpolatef ( float fofs ) const
fofs. It calls interpolate using the integer part offofsasidx, and its fractional part ast.
- remove_point ( int idx )
idxfrom the curve. Sends an error to the console ifidxis out of bounds.
- set_point_in ( int idx, Vector3 position )
idx. If the index is out of bounds, the function sends an error to the console. The position is relative to the vertex.
- set_point_out ( int idx, Vector3 position )
idx. If the index is out of bounds, the function sends an error to the console. The position is relative to the vertex.
- set_point_position ( int idx, Vector3 position )
idx. If the index is out of bounds, the function sends an error to the console.
- set_point_tilt ( int idx, float tilt )
idx. If the index is out of bounds, the function sends an error to the console. PathFollow, this tilt is an offset over the natural tilt the PathFollow calculates.
- PoolVector3Array tessellate ( int max_stages=5, float tolerance_degrees=4 ) const
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.
This approximation makes straight segments between each point, then subdivides those segments until the resulting shape is similar enough.
max_stagescontrols 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!tolerance_degreescontrols how many degrees the midpoint of a segment may deviate from the real curve, before the segment has to be subdivided.
