Skip to content

关节 ​

CreateDistanceJoint ​

服务端

method in mod.server.component.physxCompServer.PhysxComponentServer

  • 描述

    创建距离关节,限制两个锚点之间的距离范围,可配弹簧

  • 参数

    参数名
    数据类型
    说明
    entityId0str第一个实体id,传空字符串""表示锚定到世界
    entityId1str第二个实体id
    anchor0tuple(float,float,float)第一个Joint frame原点的世界坐标
    anchor1tuple(float,float,float)第二个Joint frame原点的世界坐标,可与anchor0不同
  • 返回值

    数据类型
    说明
    int关节id;失败返回None
  • 示例

python
import mod.server.extraServerApi as serverApi
levelComp = serverApi.GetEngineCompFactory().CreatePhysx(serverApi.GetLevelId())
jointId = levelComp.CreateDistanceJoint(entityId0, entityId1, (0, 80, 0), (0, 77, 0))
levelComp.SetDistanceJointParams(jointId, 2.0, 4.0, 200.0, 30.0, 14)

CreateFixedJoint ​

服务端

method in mod.server.component.physxCompServer.PhysxComponentServer

  • 描述

    创建固定关节,两个刚体刚性连接,无自由度

  • 参数

    参数名
    数据类型
    说明
    entityId0str第一个实体id,传空字符串""表示锚定到世界
    entityId1str第二个实体id,传空字符串""表示锚定到世界
    anchor0tuple(float,float,float)第一个Joint frame原点的世界坐标,通常与anchor1相同
    anchor1tuple(float,float,float)第二个Joint frame原点的世界坐标,通常与anchor0相同
  • 返回值

    数据类型
    说明
    int关节id;失败返回None
  • 示例

python
import mod.server.extraServerApi as serverApi
levelComp = serverApi.GetEngineCompFactory().CreatePhysx(serverApi.GetLevelId())
jointId = levelComp.CreateFixedJoint(entityId0, entityId1, (0, 80, 0), (0, 80, 0))

CreatePrismaticJoint ​

服务端

method in mod.server.component.physxCompServer.PhysxComponentServer

  • 描述

    创建滑动关节;两个刚体仅能沿指定轴相对平移,旋转被锁定,可加行程限制

  • 参数

    参数名
    数据类型
    说明
    entityId0str第一个实体id,传空字符串""表示锚定到世界
    entityId1str第二个实体id
    anchor0tuple(float,float,float)第一个Joint frame原点的世界坐标,通常与anchor1相同
    anchor1tuple(float,float,float)第二个Joint frame原点的世界坐标,通常与anchor0相同
    axistuple(float,float,float)世界坐标系滑动轴方向,无需预归一化,对应Joint frame的+X轴;零向量退化为世界+X轴
  • 返回值

    数据类型
    说明
    int关节id;失败返回None
  • 示例

python
import mod.server.extraServerApi as serverApi
levelComp = serverApi.GetEngineCompFactory().CreatePhysx(serverApi.GetLevelId())
jointId = levelComp.CreatePrismaticJoint(entityId0, entityId1, (0, 80, 0), (0, 80, 0), (1, 0, 0))

CreateRevoluteJoint ​

服务端

method in mod.server.component.physxCompServer.PhysxComponentServer

  • 描述

    创建铰链关节,绕指定轴单轴旋转,可加角度限制和电机

  • 参数

    参数名
    数据类型
    说明
    entityId0str第一个实体id,传空字符串""表示锚定到世界
    entityId1str第二个实体id
    anchor0tuple(float,float,float)第一个Joint frame原点的世界坐标,通常与anchor1相同
    anchor1tuple(float,float,float)第二个Joint frame原点的世界坐标,通常与anchor0相同
    axistuple(float,float,float)世界坐标系旋转轴方向,无需预归一化,对应Joint frame的+X轴;零向量退化为世界+X轴
  • 返回值

    数据类型
    说明
    int关节id;失败返回None
  • 示例

python
import mod.server.extraServerApi as serverApi
levelComp = serverApi.GetEngineCompFactory().CreatePhysx(serverApi.GetLevelId())
jointId = levelComp.CreateRevoluteJoint(entityId0, entityId1, (0, 80, 0), (0, 80, 0), (0, 1, 0))

CreateSphericalJoint ​

服务端

method in mod.server.component.physxCompServer.PhysxComponentServer

  • 描述

    创建球窝关节,允许三轴旋转,可加锥形角度限制

  • 参数

    参数名
    数据类型
    说明
    entityId0str第一个实体id,传空字符串""表示锚定到世界
    entityId1str第二个实体id
    anchor0tuple(float,float,float)第一个Joint frame原点的世界坐标,通常与anchor1相同
    anchor1tuple(float,float,float)第二个Joint frame原点的世界坐标,通常与anchor0相同
  • 返回值

    数据类型
    说明
    int关节id;失败返回None
  • 示例

python
import mod.server.extraServerApi as serverApi
levelComp = serverApi.GetEngineCompFactory().CreatePhysx(serverApi.GetLevelId())
jointId = levelComp.CreateSphericalJoint(entityId0, entityId1, (0, 80, 0), (0, 80, 0))

DestroyAllJoints ​

服务端

method in mod.server.component.physxCompServer.PhysxComponentServer

  • 描述

    销毁所有关节

  • 参数

    无

  • 返回值

    无

  • 示例

python
import mod.server.extraServerApi as serverApi
levelComp = serverApi.GetEngineCompFactory().CreatePhysx(serverApi.GetLevelId())
levelComp.DestroyAllJoints()

DestroyJoint ​

服务端

method in mod.server.component.physxCompServer.PhysxComponentServer

  • 描述

    销毁关节

  • 参数

    参数名
    数据类型
    说明
    jointIdint关节id
  • 返回值

    数据类型
    说明
    bool是否成功
  • 示例

python
import mod.server.extraServerApi as serverApi
levelComp = serverApi.GetEngineCompFactory().CreatePhysx(serverApi.GetLevelId())
levelComp.DestroyJoint(jointId)

DestroyJointsForEntity ​

服务端

method in mod.server.component.physxCompServer.PhysxComponentServer

  • 描述

    销毁指定实体上所有关联的关节,应在实体销毁前调用

  • 参数

    参数名
    数据类型
    说明
    entityIdstr实体id
  • 返回值

    数据类型
    说明
    int销毁的关节数量
  • 示例

python
import mod.server.extraServerApi as serverApi
levelComp = serverApi.GetEngineCompFactory().CreatePhysx(serverApi.GetLevelId())
destroyedCount = levelComp.DestroyJointsForEntity(entityId)

GetJointBreakForce ​

服务端

method in mod.server.component.physxCompServer.PhysxComponentServer

  • 描述

    获取关节的断裂力和断裂扭矩

  • 参数

    参数名
    数据类型
    说明
    jointIdint关节id
  • 返回值

    数据类型
    说明
    tuple(float,float)(force, torque);无效关节返回None
  • 示例

python
import mod.server.extraServerApi as serverApi
levelComp = serverApi.GetEngineCompFactory().CreatePhysx(serverApi.GetLevelId())
print levelComp.GetJointBreakForce(jointId)

GetJointFrames ​

服务端

method in mod.server.component.physxCompServer.PhysxComponentServer

  • 描述

    获取关节两端当前的本地frame和世界frame

  • 参数

    参数名
    数据类型
    说明
    jointIdint关节id
  • 返回值

    数据类型
    说明
    dictlocalFrame0/localFrame1/worldFrame0/worldFrame1各包含position和rotation;actor0IsWorld/actor1IsWorld表示该端是否为世界锚点;无效id返回None
  • 示例

python
import mod.server.extraServerApi as serverApi
levelComp = serverApi.GetEngineCompFactory().CreatePhysx(serverApi.GetLevelId())
print levelComp.GetJointFrames(jointId)

GetJointType ​

服务端

method in mod.server.component.physxCompServer.PhysxComponentServer

  • 描述

    查询关节类型

  • 参数

    参数名
    数据类型
    说明
    jointIdint关节id
  • 返回值

    数据类型
    说明
    int0=Fixed, 1=Distance, 2=Spherical, 3=Revolute, 4=Prismatic;无效关节返回None
  • 示例

python
import mod.server.extraServerApi as serverApi
levelComp = serverApi.GetEngineCompFactory().CreatePhysx(serverApi.GetLevelId())
print levelComp.GetJointType(jointId)

GetRevoluteJointAngle ​

服务端

method in mod.server.component.physxCompServer.PhysxComponentServer

  • 描述

    获取铰链关节当前相对于创建零位的旋转角度。仅对RevoluteJoint有效

  • 参数

    参数名
    数据类型
    说明
    jointIdint关节id
  • 返回值

    数据类型
    说明
    float当前角度(rad);非RevoluteJoint或无效id返回None
  • 示例

python
import mod.server.extraServerApi as serverApi
levelComp = serverApi.GetEngineCompFactory().CreatePhysx(serverApi.GetLevelId())
print levelComp.GetRevoluteJointAngle(jointId)

GetRevoluteJointVelocity ​

服务端

method in mod.server.component.physxCompServer.PhysxComponentServer

  • 描述

    获取铰链关节当前角速度。仅对RevoluteJoint有效

  • 参数

    参数名
    数据类型
    说明
    jointIdint关节id
  • 返回值

    数据类型
    说明
    float当前角速度(rad/s);非RevoluteJoint或无效id返回None
  • 示例

python
import mod.server.extraServerApi as serverApi
levelComp = serverApi.GetEngineCompFactory().CreatePhysx(serverApi.GetLevelId())
print levelComp.GetRevoluteJointVelocity(jointId)

IsJointBroken ​

服务端

method in mod.server.component.physxCompServer.PhysxComponentServer

  • 描述

    查询关节是否已断裂

  • 参数

    参数名
    数据类型
    说明
    jointIdint关节id
  • 返回值

    数据类型
    说明
    bool是否已断裂;无效关节返回None
  • 示例

python
import mod.server.extraServerApi as serverApi
levelComp = serverApi.GetEngineCompFactory().CreatePhysx(serverApi.GetLevelId())
print levelComp.IsJointBroken(jointId)

SetDistanceJointParams ​

服务端

method in mod.server.component.physxCompServer.PhysxComponentServer

  • 描述

    设置距离关节参数

  • 参数

    参数名
    数据类型
    说明
    jointIdint关节id
    minDistfloat最小距离
    maxDistfloat最大距离
    stiffnessfloat弹簧刚度
    dampingfloat弹簧阻尼
    flagsint距离关节flag位组合(2=eMAX_DISTANCE_ENABLED, 4=eMIN_DISTANCE_ENABLED, 8=eSPRING_ENABLED)
  • 返回值

    数据类型
    说明
    bool是否成功
  • 示例

python
import mod.server.extraServerApi as serverApi
levelComp = serverApi.GetEngineCompFactory().CreatePhysx(serverApi.GetLevelId())
# 2=最大距离,4=最小距离,8=弹簧;14 表示三项全部开启
levelComp.SetDistanceJointParams(jointId, 2.0, 4.0, 200.0, 30.0, 14)

SetJointBreakForce ​

服务端

method in mod.server.component.physxCompServer.PhysxComponentServer

  • 描述

    设置关节可承受的约束力/约束扭矩阈值;PhysX求解出的实际约束载荷超过任一阈值时自动断裂。冲量(eIMPULSE,单位N·s)不能直接与力阈值(N)比较

  • 参数

    参数名
    数据类型
    说明
    jointIdint关节id
    forcefloat最大允许约束力(N);必须为非负有限数,-1 表示不可断裂
    torquefloat最大允许约束扭矩(N·m);必须为非负有限数,-1 表示不可断裂
  • 返回值

    数据类型
    说明
    bool是否成功
  • 示例

python
import mod.server.extraServerApi as serverApi
levelComp = serverApi.GetEngineCompFactory().CreatePhysx(serverApi.GetLevelId())
levelComp.SetJointBreakForce(jointId, 500.0, 100.0)

SetJointCollisionEnabled ​

服务端

method in mod.server.component.physxCompServer.PhysxComponentServer

  • 描述

    设置关节关联的两个刚体之间是否发生碰撞,适用于所有关节类型

  • 参数

    参数名
    数据类型
    说明
    jointIdint关节id
    enabledboolTrue表示允许碰撞,False表示忽略相互碰撞
  • 返回值

    数据类型
    说明
    bool是否成功
  • 示例

python
import mod.server.extraServerApi as serverApi
levelComp = serverApi.GetEngineCompFactory().CreatePhysx(serverApi.GetLevelId())
levelComp.SetJointCollisionEnabled(jointId, False)

SetPrismaticJointLimit ​

服务端

method in mod.server.component.physxCompServer.PhysxComponentServer

  • 描述

    设置滑动关节的行程限制并启用

  • 参数

    参数名
    数据类型
    说明
    jointIdint关节id
    lowerfloat沿滑动轴的下限距离(格)
    upperfloat沿滑动轴的上限距离(格)
  • 返回值

    数据类型
    说明
    bool是否成功;要求下限不大于上限
  • 示例

python
import mod.server.extraServerApi as serverApi
levelComp = serverApi.GetEngineCompFactory().CreatePhysx(serverApi.GetLevelId())
levelComp.SetPrismaticJointLimit(jointId, -3.0, 3.0)

SetRevoluteJointDrive ​

服务端

method in mod.server.component.physxCompServer.PhysxComponentServer

  • 描述

    设置铰链关节的电机并启用

  • 参数

    参数名
    数据类型
    说明
    jointIdint关节id
    velocityfloat目标角速度(rad/s)
    forceLimitfloat最大扭矩
  • 返回值

    数据类型
    说明
    bool是否成功
  • 示例

python
import mod.server.extraServerApi as serverApi
levelComp = serverApi.GetEngineCompFactory().CreatePhysx(serverApi.GetLevelId())
levelComp.SetRevoluteJointDrive(jointId, 1.5, 100000.0)

SetRevoluteJointLimit ​

服务端

method in mod.server.component.physxCompServer.PhysxComponentServer

  • 描述

    设置铰链关节的角度限制并启用

  • 参数

    参数名
    数据类型
    说明
    jointIdint关节id
    lowerfloat下限角度(弧度)
    upperfloat上限角度(弧度)
  • 返回值

    数据类型
    说明
    bool是否成功
  • 示例

python
import math
import mod.server.extraServerApi as serverApi
levelComp = serverApi.GetEngineCompFactory().CreatePhysx(serverApi.GetLevelId())
levelComp.SetRevoluteJointLimit(jointId, -math.pi / 3.0, math.pi / 3.0)

SetSphericalJointLimitCone ​

服务端

method in mod.server.component.physxCompServer.PhysxComponentServer

  • 描述

    设置球窝关节的锥形角度限制并启用

  • 参数

    参数名
    数据类型
    说明
    jointIdint关节id
    yAnglefloatY轴方向最大摆角(弧度)
    zAnglefloatZ轴方向最大摆角(弧度)
  • 返回值

    数据类型
    说明
    bool是否成功
  • 示例

python
import math
import mod.server.extraServerApi as serverApi
levelComp = serverApi.GetEngineCompFactory().CreatePhysx(serverApi.GetLevelId())
levelComp.SetSphericalJointLimitCone(jointId, math.pi / 4.0, math.pi / 4.0)