[][src]Struct gdnative::api::Curve3D

pub struct Curve3D { /* fields omitted */ }

core class Curve3D inherits Resource (reference counted).

Official documentation

See the documentation of this class in the Godot engine's official documentation.

Memory management

The lifetime of this object is automatically managed through reference counting.

Class hierarchy

Curve3D inherits methods from:

Safety

All types in the Godot API have "interior mutability" in Rust parlance. To enforce that the official thread-safety guidelines are followed, the typestate pattern is used in the Ref and TRef smart pointers, and the Instance API. The typestate Access in these types tracks whether the access is unique, shared, or exclusive to the current thread. For more information, see the type-level documentation on Ref.

Implementations

impl Curve3D[src]

pub fn new() -> Ref<Curve3D, Unique>[src]

Creates a new instance of this object.

This is a reference-counted type. The returned object is automatically managed by Ref.

pub fn add_point(
    &self,
    position: Vector3D<f32, UnknownUnit>,
    _in: Vector3D<f32, UnknownUnit>,
    out: Vector3D<f32, UnknownUnit>,
    at_position: i64
)
[src]

Adds a point to a curve at [code]position[/code], with control points [code]in[/code] and [code]out[/code].
				If [code]at_position[/code] is given, the point is inserted before the point number [code]at_position[/code], moving that point (and every point after) after the inserted point. If [code]at_position[/code] is not given, or is an illegal value ([code]at_position <0[/code] or [code]at_position >= [method get_point_count][/code]), the point will be appended at the end of the point list.

Default Arguments

  • in - Vector3( 0, 0, 0 )
  • out - Vector3( 0, 0, 0 )
  • at_position - -1

pub fn clear_points(&self)[src]

Removes all points from the curve.

pub fn bake_interval(&self) -> f64[src]

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.

pub fn get_baked_length(&self) -> f64[src]

Returns the total length of the curve, based on the cached points. Given enough density (see [member bake_interval]), it should be approximate enough.

pub fn get_baked_points(&self) -> TypedArray<Vector3D<f32, UnknownUnit>>[src]

Returns the cache of points as a [PoolVector3Array].

pub fn get_baked_tilts(&self) -> TypedArray<f32>[src]

Returns the cache of tilts as a [PoolRealArray].

pub fn get_baked_up_vectors(&self) -> TypedArray<Vector3D<f32, UnknownUnit>>[src]

Returns the cache of up vectors as a [PoolVector3Array].
				If [member up_vector_enabled] is [code]false[/code], the cache will be empty.

pub fn get_closest_offset(&self, to_point: Vector3D<f32, UnknownUnit>) -> f64[src]

Returns the closest offset to [code]to_point[/code]. This offset is meant to be used in [method interpolate_baked] or [method interpolate_baked_up_vector].
				[code]to_point[/code] must be in this curve's local space.

pub fn get_closest_point(
    &self,
    to_point: Vector3D<f32, UnknownUnit>
) -> Vector3D<f32, UnknownUnit>
[src]

Returns the closest point (in curve's local space) to [code]to_point[/code].
				[code]to_point[/code] must be in this curve's local space.

pub fn get_point_count(&self) -> i64[src]

Returns the number of points describing the curve.

pub fn get_point_in(&self, idx: i64) -> Vector3D<f32, UnknownUnit>[src]

Returns the position of the control point leading to the vertex [code]idx[/code]. If the index is out of bounds, the function sends an error to the console, and returns [code](0, 0, 0)[/code].

pub fn get_point_out(&self, idx: i64) -> Vector3D<f32, UnknownUnit>[src]

Returns the position of the control point leading out of the vertex [code]idx[/code]. If the index is out of bounds, the function sends an error to the console, and returns [code](0, 0, 0)[/code].

pub fn get_point_position(&self, idx: i64) -> Vector3D<f32, UnknownUnit>[src]

Returns the position of the vertex [code]idx[/code]. If the index is out of bounds, the function sends an error to the console, and returns [code](0, 0, 0)[/code].

pub fn get_point_tilt(&self, idx: i64) -> f64[src]

Returns the tilt angle in radians for the point [code]idx[/code]. If the index is out of bounds, the function sends an error to the console, and returns [code]0[/code].

pub fn interpolate(&self, idx: i64, t: f64) -> Vector3D<f32, UnknownUnit>[src]

Returns the position between the vertex [code]idx[/code] and the vertex [code]idx + 1[/code], where [code]t[/code] 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 [code]t[/code] outside the range ([code]0.0 >= t <=1[/code]) give strange, but predictable results.
				If [code]idx[/code] is out of bounds it is truncated to the first or last vertex, and [code]t[/code] is ignored. If the curve has no points, the function sends an error to the console, and returns [code](0, 0, 0)[/code].

pub fn interpolate_baked(
    &self,
    offset: f64,
    cubic: bool
) -> Vector3D<f32, UnknownUnit>
[src]

Returns a point within the curve at position [code]offset[/code], where [code]offset[/code] is measured as a pixel distance along the curve.
				To do that, it finds the two cached points where the [code]offset[/code] lies between, then interpolates the values. This interpolation is cubic if [code]cubic[/code] is set to [code]true[/code], or linear if set to [code]false[/code].
				Cubic interpolation tends to follow the curves better, but linear is faster (and often, precise enough).

Default Arguments

  • cubic - false

pub fn interpolate_baked_up_vector(
    &self,
    offset: f64,
    apply_tilt: bool
) -> Vector3D<f32, UnknownUnit>
[src]

Returns an up vector within the curve at position [code]offset[/code], where [code]offset[/code] is measured as a distance in 3D units along the curve.
				To do that, it finds the two cached up vectors where the [code]offset[/code] lies between, then interpolates the values. If [code]apply_tilt[/code] is [code]true[/code], an interpolated tilt is applied to the interpolated up vector.
				If the curve has no up vectors, the function sends an error to the console, and returns [code](0, 1, 0)[/code].

Default Arguments

  • apply_tilt - false

pub fn interpolatef(&self, fofs: f64) -> Vector3D<f32, UnknownUnit>[src]

Returns the position at the vertex [code]fofs[/code]. It calls [method interpolate] using the integer part of [code]fofs[/code] as [code]idx[/code], and its fractional part as [code]t[/code].

pub fn is_up_vector_enabled(&self) -> bool[src]

If [code]true[/code], the curve will bake up vectors used for orientation. This is used when [member PathFollow.rotation_mode] is set to [constant PathFollow.ROTATION_ORIENTED]. Changing it forces the cache to be recomputed.

pub fn remove_point(&self, idx: i64)[src]

Deletes the point [code]idx[/code] from the curve. Sends an error to the console if [code]idx[/code] is out of bounds.

pub fn set_bake_interval(&self, distance: f64)[src]

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.

pub fn set_point_in(&self, idx: i64, position: Vector3D<f32, UnknownUnit>)[src]

Sets the position of the control point leading to the vertex [code]idx[/code]. If the index is out of bounds, the function sends an error to the console.

pub fn set_point_out(&self, idx: i64, position: Vector3D<f32, UnknownUnit>)[src]

Sets the position of the control point leading out of the vertex [code]idx[/code]. If the index is out of bounds, the function sends an error to the console.

pub fn set_point_position(&self, idx: i64, position: Vector3D<f32, UnknownUnit>)[src]

Sets the position for the vertex [code]idx[/code]. If the index is out of bounds, the function sends an error to the console.

pub fn set_point_tilt(&self, idx: i64, tilt: f64)[src]

Sets the tilt angle in radians for the point [code]idx[/code]. If the index is out of bounds, the function sends an error to the console.
				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 [PathFollow], this tilt is an offset over the natural tilt the [PathFollow] calculates.

pub fn set_up_vector_enabled(&self, enable: bool)[src]

If [code]true[/code], the curve will bake up vectors used for orientation. This is used when [member PathFollow.rotation_mode] is set to [constant PathFollow.ROTATION_ORIENTED]. Changing it forces the cache to be recomputed.

pub fn tessellate(
    &self,
    max_stages: i64,
    tolerance_degrees: f64
) -> TypedArray<Vector3D<f32, UnknownUnit>>
[src]

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.
				[code]max_stages[/code] 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!
				[code]tolerance_degrees[/code] controls how many degrees the midpoint of a segment may deviate from the real curve, before the segment has to be subdivided.

Default Arguments

  • max_stages - 5
  • tolerance_degrees - 4

Methods from Deref<Target = Resource>

pub fn duplicate(&self, subresources: bool) -> Option<Ref<Resource, Shared>>[src]

Duplicates the resource, returning a new resource. By default, sub-resources are shared between resource copies for efficiency. This can be changed by passing [code]true[/code] to the [code]subresources[/code] argument which will copy the subresources.
				[b]Note:[/b] If [code]subresources[/code] is [code]true[/code], this method will only perform a shallow copy. Nested resources within subresources will not be duplicated and will still be shared.

Default Arguments

  • subresources - false

pub fn get_local_scene(&self) -> Option<Ref<Node, Shared>>[src]

If [member resource_local_to_scene] is enabled and the resource was loaded from a [PackedScene] instantiation, returns the local scene where this resource's unique copy is in use. Otherwise, returns [code]null[/code].

pub fn name(&self) -> GodotString[src]

The name of the resource. This is an optional identifier.

pub fn path(&self) -> GodotString[src]

The path to the resource. In case it has its own file, it will return its filepath. If it's tied to the scene, it will return the scene's path, followed by the resource's index.

pub fn get_rid(&self) -> Rid[src]

Returns the RID of the resource (or an empty RID). Many resources (such as [Texture], [Mesh], etc) are high-level abstractions of resources stored in a server, so this function will return the original RID.

pub fn is_local_to_scene(&self) -> bool[src]

If [code]true[/code], the resource will be made unique in each instance of its local scene. It can thus be modified in a scene instance without impacting other instances of that same scene.

pub fn set_local_to_scene(&self, enable: bool)[src]

If [code]true[/code], the resource will be made unique in each instance of its local scene. It can thus be modified in a scene instance without impacting other instances of that same scene.

pub fn set_name(&self, name: impl Into<GodotString>)[src]

The name of the resource. This is an optional identifier.

pub fn set_path(&self, path: impl Into<GodotString>)[src]

The path to the resource. In case it has its own file, it will return its filepath. If it's tied to the scene, it will return the scene's path, followed by the resource's index.

pub fn setup_local_to_scene(&self)[src]

This method is called when a resource with [member resource_local_to_scene] enabled is loaded from a [PackedScene] instantiation. Its behavior can be customized by overriding [method _setup_local_to_scene] from script.
				For most resources, this method performs no base logic. [ViewportTexture] performs custom logic to properly set the proxy texture and flags in the local viewport.

pub fn take_over_path(&self, path: impl Into<GodotString>)[src]

Sets the path of the resource, potentially overriding an existing cache entry for this path. This differs from setting [member resource_path], as the latter would error out if another resource was already cached for the given path.

Trait Implementations

impl Debug for Curve3D[src]

impl Deref for Curve3D[src]

type Target = Resource

The resulting type after dereferencing.

impl DerefMut for Curve3D[src]

impl GodotObject for Curve3D[src]

type RefKind = RefCounted

The memory management kind of this type. This modifies the behavior of the Ref smart pointer. See its type-level documentation for more information. Read more

impl Instanciable for Curve3D[src]

impl SubClass<Object> for Curve3D[src]

impl SubClass<Reference> for Curve3D[src]

impl SubClass<Resource> for Curve3D[src]

Auto Trait Implementations

impl RefUnwindSafe for Curve3D

impl !Send for Curve3D

impl !Sync for Curve3D

impl Unpin for Curve3D

impl UnwindSafe for Curve3D

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> SubClass<T> for T where
    T: GodotObject
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.