曲线3d

Inherits: Resource < Reference < Object

类别: 核心

简要说明

描述三维空间中的B_zier曲线。

方法

无效

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

无效

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

无效

remove_point ( int idx )

无效

set_point_in ( int idx, Vector3 position )

无效

set_point_out ( int idx, Vector3 position )

无效

set_point_position ( int idx, Vector3 position )

无效

set_point_tilt ( int idx, float tilt )

PoolVector3Array

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

描述

此类描述三维空间中的B_zier曲线。它主要用来给 Path ,但可以手动采样以用于其他目的。

它沿着曲线保存一个预计算点的缓存,以加速进一步的计算。

属性描述

违约

0.2

设定器

设置烘焙间隔(值)

吸气剂

获取“烘焙间隔”()

两个相邻缓存点之间的距离(米)。更改它将强制在下次 get_baked_pointsget_baked_length 调用函数。距离越小,缓存中的点越多,占用的内存越多,因此请小心使用。

  • bool up_vector_enabled

违约

设定器

设置矢量启用(值)

吸气剂

是否启用了上方向矢量()。

如果 true ,曲线将烘焙用于方向的向量。在以下情况下使用 PathFollow.rotation_mode 设置为 PathFollow.ROTATION_ORIENTED . 更改它将强制重新计算缓存。

方法说明

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

在曲线上添加点 position ,带控制点 inout .

如果 at_position 如果给定,则在点编号之前插入点 at_position ,将该点(以及之后的每个点)移动到插入点之后。如果 at_position 未给定,或是非法值 (at_position <0at_position >= [method get_point_count] )点将附加在点列表的末尾。

  • void clear_points ( )

从曲线中删除所有点。

  • float get_baked_length ( ) const

基于缓存点返回曲线的总长度。给定足够的密度(见 bake_interval )应该足够近似。

将点的缓存作为 PoolVector3Array .

将倾斜缓存作为 PoolRealArray .

将向上向量的缓存作为 PoolVector3Array .

如果 up_vector_enabledfalse ,缓存将为空。

返回最接近的偏移量 to_point . 此偏移量用于 interpolate_bakedinterpolate_baked_up_vector .

to_point 必须在曲线的局部空间中。

返回最接近的点(在曲线的局部空间中)到 to_point .

to_point 必须在曲线的局部空间中。

  • int get_point_count ( ) const

返回描述曲线的点数。

返回指向顶点的控制点的位置 idx . 如果索引超出界限,函数将向控制台发送错误,并返回 (0, 0, 0) .

返回从顶点引出的控制点的位置 idx . 如果索引超出界限,函数将向控制台发送错误,并返回 (0, 0, 0) .

返回顶点的位置 idx . 如果索引超出界限,函数将向控制台发送错误,并返回 (0, 0, 0) .

  • float get_point_tilt ( int idx ) const

返回点的倾斜角度(以弧度为单位) idx . 如果索引超出界限,函数将向控制台发送错误,并返回 0 .

返回顶点之间的位置 idx 和顶点 idx + 1 在哪里 t 控制点是否为第一个顶点 (t = 0.0 )最后一个顶点 (t = 1.0 或者介于两者之间。的值 t 超出范围 (0.0 >= t <=1 )给出奇怪但可预测的结果。

如果 idx 超出界限,将截断到第一个或最后一个顶点,并且 t 被忽略。如果曲线没有点,函数将向控制台发送一个错误,并返回 (0, 0, 0) .

返回曲线中位置处的点 offset 在哪里 offset 以沿曲线的像素距离测量。

为此,它会找到两个缓存点, offset 介于两者之间,然后插入值。这个插值是三次的,如果 cubic 设置为 true ,或线性(如果设置为) false .

三次插值倾向于更好地跟踪曲线,但线性插值更快(而且通常足够精确)。

  • Vector3 interpolate_baked_up_vector ( float offset, bool apply_tilt=false ) const

返回曲线中位置处的上方向向量 offset 在哪里 offset 沿曲线以三维单位测量的距离。

为此,它找到两个缓存向量,其中 offset 介于两者之间,然后插入值。如果 apply_tilttrue 将插值倾斜应用于插值的上方向向量。

如果曲线没有上方向向量,函数将向控制台发送一个错误,并返回 (0, 1, 0) .

返回顶点位置 fofs . 它调用 interpolate 使用的整数部分 fofs 作为 idx ,其分数部分为 t .

  • void remove_point ( int idx )

删除点 idx 从曲线上看。在以下情况下向控制台发送错误: idx 超出界限。

设置指向顶点的控制点的位置 idx . 如果索引超出界限,函数将向控制台发送错误。

  • void set_point_out ( int idx, Vector3 position )

设置从顶点引出的控制点的位置 idx . 如果索引超出界限,函数将向控制台发送错误。

  • void set_point_position ( int idx, Vector3 position )

设置顶点的位置 idx . 如果索引超出界限,函数将向控制台发送错误。

  • void set_point_tilt ( int idx, float tilt )

以弧度为单位设置点的倾斜角度 idx . 如果索引超出界限,函数将向控制台发送错误。

倾斜控制着物体沿其路径的观察轴的旋转。如果曲线控制 PathFollow ,此倾斜度是相对于自然倾斜度的偏移量 PathFollow 计算。

返回曲线上具有曲率控制的点密度的点列表。也就是说,曲线部分比直线部分有更多的点。

这种近似使每个点之间的直线段,然后细分这些段,直到得到的形状足够相似。

max_stages 控制曲线段在被认为足够近似之前可能面对的细分数目。每个细分将分段分割为两半,因此默认的5个阶段可能意味着每个曲线分段最多32个细分。小心增加!

tolerance_degrees 控制细分段之前,段的中点可能偏离实际曲线的角度。