Curve3D

Inherits: Resource < Reference < Object

Describe una curva de Bézier en el espacio 3D.

Descripción

This class describes a Bézier curve in 3D space. It is mainly used to give a shape to a Path, but can be manually sampled for other purposes.

It keeps a cache of precalculated points along the curve, to speed up further calculations.

Propiedades

float

bake_interval

0.2

bool

up_vector_enabled

true

Métodos

void

add_point ( Vector3 position, Vector3 in=Vector3( 0, 0, 0 ), Vector3 out=Vector3( 0, 0, 0 ), int at_position=-1 )

void

clear_points ( )

float

get_baked_length ( ) const

PoolVector3Array

get_baked_points ( ) const

PoolRealArray

get_baked_tilts ( ) const

PoolVector3Array

get_baked_up_vectors ( ) const

float

get_closest_offset ( Vector3 to_point ) const

Vector3

get_closest_point ( Vector3 to_point ) const

int

get_point_count ( ) const

Vector3

get_point_in ( int idx ) const

Vector3

get_point_out ( int idx ) const

Vector3

get_point_position ( int idx ) const

float

get_point_tilt ( int idx ) const

Vector3

interpolate ( int idx, float t ) const

Vector3

interpolate_baked ( float offset, bool cubic=false ) const

Vector3

interpolate_baked_up_vector ( float offset, bool apply_tilt=false ) const

Vector3

interpolatef ( float fofs ) const

void

remove_point ( int idx )

void

set_point_in ( int idx, Vector3 position )

void

set_point_out ( int idx, Vector3 position )

void

set_point_position ( int idx, Vector3 position )

void

set_point_tilt ( int idx, float tilt )

PoolVector3Array

tessellate ( int max_stages=5, float tolerance_degrees=4 ) const

Descripciones de Propiedades

Default

0.2

Setter

set_bake_interval(value)

Getter

get_bake_interval()

La distancia en metros entre dos puntos cacheados adyacentes. Cambiarlo obliga a recomponer la caché la próxima vez que se llame a la función get_baked_points o get_baked_length. Cuanto más pequeña sea la distancia, más puntos en el cache y más memoria consumirá, así que úsala con cuidado.


  • bool up_vector_enabled

Default

true

Setter

set_up_vector_enabled(value)

Getter

is_up_vector_enabled()

If 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.

Descripciones de Métodos

  • void add_point ( Vector3 position, Vector3 in=Vector3( 0, 0, 0 ), Vector3 out=Vector3( 0, 0, 0 ), int at_position=-1 )

Añade un punto a una curva en la posición position, con puntos de control in y out.

Si se da at_position, el punto se inserta antes del número de punto at_position, desplazando ese punto (y todos los puntos posteriores) después del punto insertado. Si no se da at_position, o es un valor ilegal (at_position <0 o at_position >= [method get_point_count]), el punto se añadirá al final de la lista de puntos.


  • void clear_points ( )

Elimina todos los puntos de la curva.


  • float get_baked_length ( ) const

Devuelve la longitud total de la curva, basada en los puntos cacheados. Si se le da suficiente densidad (ver bake_interval), debe ser bastante aproximada.


Returns the cache of points as a PoolVector3Array.


Returns the cache of tilts as a PoolRealArray.


Returns the cache of up vectors as a PoolVector3Array.

If up_vector_enabled is false, the cache will be empty.


Devuelve el desplazamiento más cercano a to_point. Este desplazamiento está destinado a ser utilizado en interpolate_baked o interpolate_baked_up_vector.

to_point debe estar en el espacio local de esta curva.


Returns the closest baked point (in curve's local space) to to_point.

to_point must be in this curve's local space.


  • int get_point_count ( ) const

Devuelve el número de puntos que describen la curva.


Returns the position of the control point leading to the vertex idx. The returned position is relative to the vertex idx. If the index is out of bounds, the function sends an error to the console, and returns (0, 0, 0).


Returns the position of the control point leading out of the vertex idx. The returned position is relative to the vertex idx. If the index is out of bounds, the function sends an error to the console, and returns (0, 0, 0).


Devuelve la posición del vértice idx. Si el índice está fuera de los límites, la función envía un error a la consola, y devuelve (0, 0, 0).


  • float get_point_tilt ( int idx ) const

Devuelve el ángulo de inclinación en radianes para el punto idx. Si el índice está fuera de los límites, la función envía un error a la consola, y devuelve 0.


Devuelve la posición entre el vértice idx y el vértice idx + 1, donde t controla si el punto es el primer vértice (t = 0.0), el último vértice (t = 1.0), o en medio. Los valores de t fuera del rango (0.0 >= t <=1) dan resultados extraños, pero predecibles.

Si idx está fuera de los límites se trunca al primer o último vértice, y t se ignora. Si la curva no tiene puntos, la función envía un error a la consola, y devuelve (0, 0, 0).


Returns a point within the curve at position offset, where offset is measured as a distance in 3D units along the curve.

To do that, it finds the two cached points where the offset lies between, then interpolates the values. This interpolation is cubic if cubic is set to true, or linear if set to false.

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

Devuelve un vector ascendente dentro de la curva en la posición offset, donde offset se mide como una distancia en unidades 3D a lo largo de la curva.

Para ello, encuentra los dos vectores ascendentes donde se encuentra el offset entre ellos, y luego interpola los valores. Si apply_tilt es true, se aplica una inclinación interpolada al vector interpolado hacia arriba.

Si la curva no tiene vectores ascendentes, la función envía un error a la consola, y devuelve (0, 1, 0).


Devuelve la posición en el vértice fofs. Llama a interpolate usando la parte entera de fofs como idx, y su parte fraccionaria como t.


  • void remove_point ( int idx )

Suprime el punto idx de la curva. Envía un error a la consola si idx está fuera de los límites.


Sets the position of the control point leading to the vertex idx. If the index is out of bounds, the function sends an error to the console. The position is relative to the vertex.


  • void set_point_out ( int idx, Vector3 position )

Sets the position of the control point leading out of the vertex idx. If the index is out of bounds, the function sends an error to the console. The position is relative to the vertex.


  • void set_point_position ( int idx, Vector3 position )

Establece la posición del vértice idx. Si el índice está fuera de los límites, la función envía un error a la consola.


  • void set_point_tilt ( int idx, float tilt )

Sets the tilt angle in radians for the point idx. 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.


Devuelve una lista de puntos a lo largo de la curva, con una densidad de puntos controlada por la curvatura. Es decir, las partes más curvadas tendrán más puntos que las partes más rectas.

Esta aproximación hace segmentos rectos entre cada punto, luego subdivide esos segmentos hasta que la forma resultante es lo suficientemente similar.

max_stages controla cuántas subdivisiones puede afrontar un segmento de curva antes de que se considere suficientemente aproximado. Cada subdivisión divide el segmento por la mitad, por lo que las 5 etapas predeterminadas pueden significar hasta 32 subdivisiones por segmento de curva. Aumenta con cuidado!

tolerance_degrees controla cuántos grados puede desviarse el punto medio de un segmento de la curva real, antes de que el segmento tenga que ser subdividido.