2021SC@SDUSC
本次我们继续针对flax Engine 游戏引擎中物理引擎的joints 包进行源代码的分析。上次我们分析了距离铰链和固定铰链,本次我们将针对flax Engine 中最后一个铰链 D6铰链进行源代码的分析。由于本次将会是joints 最后一个class,所以本次之后我们将针对flax Engine 游戏引擎物理引擎中其他内容进行源代码的分析。按照之前一样,由于D6joints 拥有.h 和.c文件,所以我们将分别对其进行源代码的分析工作。
在很久之前,我分析过一次flax engine游戏引擎的物理引擎的大致框架,提到过相关的内容和joints ,在那个时候我们也查阅了一些网上的资料,但我们当时无法解释D6 joints到底是干什么的,答案将在这章中揭晓。
在查看源代码后,我了解到D6 铰链是一种在轴上运行的铰链。
(一):D6Joint.h 头文件:
API_ENUM() enum class D6JointAxis
{
/// <summary>
/// Movement on the X axis.
/// </summary>
X = 0,
/// <summary>
/// Movement on the Y axis.
/// </summary>
Y = 1,
/// <summary>
/// Movement on the Z axis.
/// </summary>
Z = 2,
/// <summary>
/// Rotation around the X axis.
/// </summary>
Twist = 3,
/// <summary>
/// Rotation around the Y axis.
/// </summary>
SwingY = 4,
/// <summary>
/// Rotation around the Z axis.
/// </summary>
SwingZ = 5,
MAX
};
上述代码定义了D6 joints 的功能的参数:0:x 轴移动,1:y轴移动,2:z轴移动 3:x轴旋转 4:y轴选择 5:z轴的旋转。
API_ENUM() enum class D6JointMotion
{
/// <summary>
/// Axis is immovable.
/// </summary>
Locked,
/// <summary>
/// Axis will be constrained by the specified limits.
/// </summary>
Limited,
/// <summary>
/// Axis will not be constrained.
/// </summary>
Free,
MAX
};
上述代码表示:指定放置在特定轴上的约束类型
Locked:轴心是不动的类型
Limited:轴将受到指定限制的约束的类型
Free:轴将不受约束的类型
可用于移动或旋转连接到关节的实体的驱动器类型:
每个驱动器都是一个隐式限力阻尼弹簧:
物理公式:力=弹簧*(目标位置-位置)+阻尼*(目标速度-速度)并且仅当设置了相应的驱动标志时,线性轴才会受到驱动的影响。有两种可能的模型。
API_ENUM() enum class D6JointDriveType
{
/// <summary>
/// Linear movement on the X axis using the linear drive model.
/// </s

本文详细剖析了FlaxEngine游戏引擎中D6Joint类的源代码,涉及运动类型、约束类型、驱动参数以及构造与设置方法,揭示了D6铰链作为灵活关节在游戏物理中的应用。
最低0.47元/天 解锁文章
633

被折叠的 条评论
为什么被折叠?



