本文整理汇总了C++中world::add_missile方法的典型用法代码示例。如果您正苦于以下问题:C++ world::add_missile方法的具体用法?C++ world::add_missile怎么用?C++ world::add_missile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类world
的用法示例。
在下文中一共展示了world::add_missile方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: update
//.........这里部分代码省略.........
else if (!m_follow.expired())
{
has_target = true;
auto f = m_follow.lock();
target_dir = f->get_pos() + f->get_rot().rotate(m_formation_offset) - (get_pos() + get_vel() * kdt);
//+ f->get_vel() * kdt //player's plane is already updated, ToDo
}
else
not_path_not_follow = true;
if (!m_target.expired())
{
auto t = m_target.lock();
const auto dir = t->get_pos() + t->get_rot().rotate(vec3(0, 0, -20.0)) - (get_pos() + get_vel() * kdt);
if (not_path_not_follow)
{
target_dir = dir;
has_target = true;
}
for (auto &wp: m_weapons)
{
if (wp.cooldown > 0)
{
wp.cooldown -= dt;
continue;
}
if (dir.length() > wp.params.lockon_range)
continue;
wp.cooldown = wp.params.reload_time;
auto m = w.add_missile(wp.params.id.c_str(), wp.mdl);
if (!m)
continue;
m->phys->pos = get_pos();
m->phys->rot = get_rot();
m->phys->vel = get_vel();
m->phys->target_dir = dir;
m->target = m_target;
}
}
if (has_target)
{
const float eps=1.0e-6f;
const float target_dist = target_dir.length();
const vec3 v=target_dir / target_dist;
const float xz_sqdist=v.x*v.x+v.z*v.z;
const auto rot = get_rot();
const auto pyr = rot.get_euler();
const nya_math::angle_rad new_yaw=(xz_sqdist>eps*eps)? (atan2(v.x,v.z)) : pyr.y;
nya_math::angle_rad new_pitch=(fabsf(v.y)>eps)? (-atan2(v.y,sqrtf(xz_sqdist))) : 0.0f;
nya_math::angle_rad new_roll;
if (!m_follow.expired())
new_roll = m_follow.lock()->get_rot().get_euler().z;
vec3 pos = get_pos() + m_vel * kdt;
const float h = w.get_height(pos.x, pos.z);
if ((new_pitch > 0.0f && pos.y <= h + m_params.height_min) || (new_pitch < 0.0f && pos.y >= h + m_params.height_max))
new_pitch = 0.0f;