骑砍战团MOD开发(38)-物理碰撞&速度&重力系统

发布时间:2024年01月15日

一.骑砍中静态模型分类

? ? 地形:terrain? 人物:agent? 物品:item 场景物:scene_prop

? ? 不同种类静态模型存在物理碰撞,场景物和人物还存在速度和重力。

二.地形高度图

? ? ?为了解决人物和场景物在地形平面上的物理碰撞,实现高低起伏的奔跑和行走,将地形平面中每个网格的X,Y和对应高度Height进行预先处理,形成平面(X,Y)和高度Height的映射表。系统提供API实现获取人物或者场景物距离地形平面高度:

#大地图军队获取地形高度
party_get_current_terrain  = 1608  # (party_get_current_terrain, <destination>, <party_id>),

#场景获取距离地形高度
position_get_distance_to_terrain  =  792  # (position_get_distance_to_terrain, <destination_fixed_point>, <position>),

?

三.人物position

? ? <1.物理碰撞:将场景中人物抽象为一个一个position,通过计算position和地形,场景物的距离实现物理碰撞.

? ? 系统提供去除人物物理碰撞的接口,实现人物的飞行和遁地.

# Makes the agent stand on the spot (value = 1) or move normally (value = 0). When frozen on the spot the agent can still turn around and fight if necessary. Used in Native for the wedding scene (required for cut-scenes). Agent will have collision and physics disabled on it if dynamics are turned off, allowing for (agent_set_position) to teleport them to any location, as well as allowing for a scripted no clipping flight mode ala Half-Life.

agent_set_no_dynamics = 1762  # (agent_set_no_dynamics, <agent_id>, <value>),

? <2.物理速度:

#人物马匹物理运动速度最大值
agent_set_horse_speed_factor  = 1734

#人物物理运动速度最大值
agent_set_speed_limit  = 1736

#人物物理运动速度
agent_set_speed_modifier = 2093

? <3.物理重力:从高处落下动作,受到伤害,速度

? ? ?由MOD设计,可根据高度不同设置伤害值和飞行速度以及相关动作.

三.物品item

? ? 一般和人物强绑定,碰撞检测根据不同类型物品而不同,如马匹,食物,武器等都是引擎内置的固定碰撞检测.

四.场景物碰撞体

? ? <1.物理碰撞:静态模型碰撞体实现物理碰撞检测,在OpenBrf中可新建静态模型bo_castle碰撞体,在scene_prop配置"bo_castle"实现对应模型碰撞体检测.

("rock_bridge_a",0,"rock_bridge_a","bo_rock_bridge_a", []),

<2.?重力,速度,加速度,旋转速度

? ? MOD自行设计.系统预制了默认的一类场景物,如攻城云梯,可实现动态控制速度,加速度,旋转速度等物理参数.

#场景物标识sokf_moveable|sokf_dynamic_physics

("box_a_dynamic",sokf_moveable|sokf_dynamic_physics,"box_a","bo_box_a", []),

prop_instance_enable_physics  = 1864  # (prop_instance_enable_physics, <scene_prop_id>, <value>),


#设置加速度,速度,角速度等物理参数
prop_instance_dynamics_set_properties  = 1871 
 
prop_instance_dynamics_set_velocity = 1872  # (prop_instance_dynamics_set_velocity, <scene_prop_id>, <position>),

prop_instance_dynamics_set_omega  = 1873  # (prop_instance_dynamics_set_omega, <scene_prop_id>, <position>),

prop_instance_dynamics_apply_impulse   = 1874  # (prop_instance_dynamics_apply_impulse, <scene_prop_id>, <position>),

文章来源:https://blog.csdn.net/qq_35829452/article/details/135603311
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。