本文整理汇总了C++中Fvector::getH方法的典型用法代码示例。如果您正苦于以下问题:C++ Fvector::getH方法的具体用法?C++ Fvector::getH怎么用?C++ Fvector::getH使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Fvector
的用法示例。
在下文中一共展示了Fvector::getH方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: UpdateBarrelDir
void CWeaponStatMgun::UpdateBarrelDir()
{
IKinematics* K = smart_cast<IKinematics*>(Visual());
m_fire_bone_xform = K->LL_GetTransform(m_fire_bone);
m_fire_bone_xform.mulA_43 (XFORM());
m_fire_pos.set (0,0,0);
m_fire_bone_xform.transform_tiny(m_fire_pos);
m_fire_dir.set (0,0,1);
m_fire_bone_xform.transform_dir (m_fire_dir);
m_allow_fire = true;
Fmatrix XFi;
XFi.invert (XFORM());
Fvector dep;
XFi.transform_dir (dep,m_destEnemyDir);
{// x angle
m_i_bind_x_xform.transform_dir(dep); dep.normalize();
m_tgt_x_rot = angle_normalize_signed(m_bind_x_rot-dep.getP());
float sv_x = m_tgt_x_rot;
clamp (m_tgt_x_rot,-m_lim_x_rot.y,-m_lim_x_rot.x);
if (!fsimilar(sv_x,m_tgt_x_rot,EPS_L)) m_allow_fire=FALSE;
}
{// y angle
m_i_bind_y_xform.transform_dir(dep); dep.normalize();
m_tgt_y_rot = angle_normalize_signed(m_bind_y_rot-dep.getH());
float sv_y = m_tgt_y_rot;
clamp (m_tgt_y_rot,-m_lim_y_rot.y,-m_lim_y_rot.x);
if (!fsimilar(sv_y,m_tgt_y_rot,EPS_L)) m_allow_fire=FALSE;
}
m_cur_x_rot = angle_inertion_var(m_cur_x_rot,m_tgt_x_rot,0.5f,3.5f,PI_DIV_6,Device.fTimeDelta);
m_cur_y_rot = angle_inertion_var(m_cur_y_rot,m_tgt_y_rot,0.5f,3.5f,PI_DIV_6,Device.fTimeDelta);
}
示例2: check_jump_over_physics
void CControlManagerCustom::check_jump_over_physics()
{
if (!m_man->path_builder().is_moving_on_path()) return;
if (!m_man->check_start_conditions(ControlCom::eControlJump)) return;
if (!m_object->check_start_conditions(ControlCom::eControlJump)) return;
if (m_object->GetScriptControl()) return;
Fvector prev_pos = m_object->Position();
float dist_sum = 0.f;
for(u32 i = m_man->path_builder().detail().curr_travel_point_index(); i<m_man->path_builder().detail().path().size();i++) {
const DetailPathManager::STravelPathPoint &travel_point = m_man->path_builder().detail().path()[i];
// получить список объектов вокруг врага
m_nearest.clear_not_free ();
Level().ObjectSpace.GetNearest (m_nearest,travel_point.position, m_object->Radius(), NULL);
for (u32 k=0;k<m_nearest.size();k++) {
CPhysicsShellHolder *obj = smart_cast<CPhysicsShellHolder *>(m_nearest[k]);
if (!obj || !obj->PPhysicsShell() || !obj->PPhysicsShell()->isActive() || (obj->Radius() < 0.5f)) continue;
if (m_object->Position().distance_to(obj->Position()) < MAX_DIST_SUM / 2) continue;
Fvector dir = Fvector().sub(travel_point.position, m_object->Position());
// проверка на Field-Of-View
float my_h = m_object->Direction().getH();
float h = dir.getH();
float from = angle_normalize(my_h - deg(8));
float to = angle_normalize(my_h + deg(8));
if (!is_angle_between(h, from, to)) continue;
dir = Fvector().sub(obj->Position(), m_object->Position());
// вычислить целевую позицию для прыжка
Fvector target;
obj->Center(target);
target.y += obj->Radius();
// --------------------------------------------------------
m_jump->setup_data().flags.set (SControlJumpData::ePrepareSkip, true);
m_jump->setup_data().target_object = 0;
m_jump->setup_data().target_position = target;
jump(m_jump->setup_data());
return;
}
dist_sum += prev_pos.distance_to(travel_point.position);
if (dist_sum > MAX_DIST_SUM) break;
prev_pos = travel_point.position;
}
}
示例3:
SHitMark::SHitMark( const ui_shader& sh, const Fvector& dir )
{
m_StartTime = Device.fTimeGlobal;
m_lanim = LALib.FindItem( "hud_hit_mark" );
m_HitDirection = dir.getH();
m_UIStaticItem = xr_new<CUIStaticItem>();
m_UIStaticItem->SetShader ( sh );
m_UIStaticItem->SetPos ( 256.0f, 128.0f );
m_UIStaticItem->SetSize (Fvector2().set( 512.0f, 512.0f) );
}
示例4: UpdateBarrelDir
void CCarWeapon::UpdateBarrelDir()
{
CKinematics* K = smart_cast<CKinematics*>(m_object->Visual());
m_fire_bone_xform = K->LL_GetTransform(m_fire_bone);
m_fire_bone_xform.mulA_43(m_object->XFORM());
m_fire_pos.set(0,0,0);
m_fire_bone_xform.transform_tiny(m_fire_pos);
m_fire_dir.set(0,0,1);
m_fire_bone_xform.transform_dir(m_fire_dir);
m_fire_norm.set(0,1,0);
m_fire_bone_xform.transform_dir(m_fire_norm);
m_allow_fire = true;
Fmatrix XFi;
XFi.invert (m_object->XFORM());
Fvector dep;
XFi.transform_dir (dep,m_destEnemyDir);
{// x angle
m_i_bind_x_xform.transform_dir(dep); dep.normalize();
m_tgt_x_rot = angle_normalize_signed(m_bind_x_rot-dep.getP());
clamp (m_tgt_x_rot,-m_lim_x_rot.y,-m_lim_x_rot.x);
}
{// y angle
m_i_bind_y_xform.transform_dir(dep); dep.normalize();
m_tgt_y_rot = angle_normalize_signed(m_bind_y_rot-dep.getH());
clamp (m_tgt_y_rot,-m_lim_y_rot.y,-m_lim_y_rot.x);
}
m_cur_x_rot = angle_inertion_var(m_cur_x_rot,m_tgt_x_rot,m_min_gun_speed,m_max_gun_speed,PI,Device.fTimeDelta);
m_cur_y_rot = angle_inertion_var(m_cur_y_rot,m_tgt_y_rot,m_min_gun_speed,m_max_gun_speed,PI,Device.fTimeDelta);
static float dir_eps = deg2rad(5.0f);
if( !fsimilar(m_cur_x_rot,m_tgt_x_rot,dir_eps)|| !fsimilar(m_cur_y_rot,m_tgt_y_rot,dir_eps))
m_allow_fire=FALSE;
#if (0)
if(Device.dwFrame%200==0){
Msg("m_cur_x_rot=[%f]",m_cur_x_rot);
Msg("m_cur_y_rot=[%f]",m_cur_y_rot);
}
#endif
}
示例5: HitEntity
void CBaseMonster::HitEntity(const CEntity *pEntity, float fDamage, float impulse, Fvector &dir, ALife::EHitType hit_type, bool draw_hit_marks)
{
if (!g_Alive()) return;
if (!pEntity || pEntity->getDestroy()) return;
if (!EnemyMan.get_enemy()) return;
if (EnemyMan.get_enemy() == pEntity) {
Fvector position_in_bone_space;
position_in_bone_space.set(0.f,0.f,0.f);
// перевод из локальных координат в мировые вектора направления импульса
Fvector hit_dir;
XFORM().transform_dir (hit_dir,dir);
hit_dir.normalize ();
CEntity *pEntityNC = const_cast<CEntity*>(pEntity);
VERIFY (pEntityNC);
NET_Packet l_P;
SHit HS;
HS.GenHeader(GE_HIT, pEntityNC->ID()); // u_EventGen (l_P,GE_HIT, pEntityNC->ID());
HS.whoID = (ID()); // l_P.w_u16 (ID());
HS.weaponID = (ID()); // l_P.w_u16 (ID());
HS.dir = (hit_dir); // l_P.w_dir (hit_dir);
HS.power = (fDamage); // l_P.w_float (fDamage);
HS.boneID = (smart_cast<IKinematics*>(pEntityNC->Visual())->LL_GetBoneRoot());// l_P.w_s16 (smart_cast<IKinematics*>(pEntityNC->Visual())->LL_GetBoneRoot());
HS.p_in_bone_space = (position_in_bone_space); // l_P.w_vec3 (position_in_bone_space);
HS.impulse = (impulse); // l_P.w_float (impulse);
HS.hit_type = hit_type; // l_P.w_u16 ( u16(ALife::eHitTypeWound) );
HS.Write_Packet(l_P);
u_EventSend (l_P);
if (pEntityNC == Actor() && draw_hit_marks) {
START_PROFILE("BaseMonster/Animation/HitEntity");
SDrawStaticStruct* s = CurrentGameUI()->AddCustomStatic("monster_claws", false);
float h1,p1;
Device.vCameraDirection.getHP (h1,p1);
Fvector hd = hit_dir;
hd.mul (-1);
float d = -h1 + hd.getH ();
s->wnd()->SetHeading (d);
Fvector2 wnd_pos = s->wnd()->GetWndPos();
wnd_pos.y += 400.0f*_cos(d);
wnd_pos.x += 500.0f*_sin(d);
s->wnd()->SetWndPos(wnd_pos);
STOP_PROFILE;
//SetAttackEffector ();
float time_to_lock = fDamage * MAX_LOCK_TIME;
clamp (time_to_lock, 0.f, MAX_LOCK_TIME);
Actor()->lock_accel_for (int(time_to_lock * 1000));
//////////////////////////////////////////////////////////////////////////
//
//////////////////////////////////////////////////////////////////////////
CEffectorCam* ce = Actor()->Cameras().GetCamEffector((ECamEffectorType)effBigMonsterHit);
if(!ce)
{
const shared_str& eff_sect = pSettings->r_string(cNameSect(), "actor_hit_effect");
if(eff_sect.c_str())
{
int id = -1;
Fvector cam_pos,cam_dir,cam_norm;
Actor()->cam_Active()->Get (cam_pos,cam_dir,cam_norm);
cam_dir.normalize_safe ();
dir.normalize_safe ();
float ang_diff = angle_difference (cam_dir.getH(), dir.getH());
Fvector cp;
cp.crossproduct (cam_dir,dir);
bool bUp =(cp.y>0.0f);
Fvector cross;
cross.crossproduct (cam_dir, dir);
VERIFY (ang_diff>=0.0f && ang_diff<=PI);
float _s1 = PI_DIV_8;
float _s2 = _s1+PI_DIV_4;
float _s3 = _s2+PI_DIV_4;
float _s4 = _s3+PI_DIV_4;
if(ang_diff<=_s1){
id = 2;
}else {
if(ang_diff>_s1 && ang_diff<=_s2){
id = (bUp)?5:7;
}else
if(ang_diff>_s2 && ang_diff<=_s3){
id = (bUp)?3:1;
}else
if(ang_diff>_s3 && ang_diff<=_s4){
id = (bUp)?4:6;
}else
if(ang_diff>_s4){
//.........这里部分代码省略.........
示例6: Cameras
void CActor::HitMark (float P,
Fvector dir,
CObject* who,
s16 element,
Fvector position_in_bone_space,
float impulse,
ALife::EHitType hit_type)
{
// hit marker
if ( (hit_type==ALife::eHitTypeFireWound||hit_type==ALife::eHitTypeWound_2) && g_Alive() && Local() && /*(this!=who) && */(Level().CurrentEntity()==this) )
{
HUD().Hit(0, P, dir);
{
CEffectorCam* ce = Cameras().GetCamEffector((ECamEffectorType)effFireHit);
if(!ce)
{
int id = -1;
Fvector cam_pos,cam_dir,cam_norm;
cam_Active()->Get (cam_pos,cam_dir,cam_norm);
cam_dir.normalize_safe ();
dir.normalize_safe ();
float ang_diff = angle_difference (cam_dir.getH(), dir.getH());
Fvector cp;
cp.crossproduct (cam_dir,dir);
bool bUp =(cp.y>0.0f);
Fvector cross;
cross.crossproduct (cam_dir, dir);
VERIFY (ang_diff>=0.0f && ang_diff<=PI);
float _s1 = PI_DIV_8;
float _s2 = _s1+PI_DIV_4;
float _s3 = _s2+PI_DIV_4;
float _s4 = _s3+PI_DIV_4;
if(ang_diff<=_s1){
id = 2;
}else
if(ang_diff>_s1 && ang_diff<=_s2){
id = (bUp)?5:7;
}else
if(ang_diff>_s2 && ang_diff<=_s3){
id = (bUp)?3:1;
}else
if(ang_diff>_s3 && ang_diff<=_s4){
id = (bUp)?4:6;
}else
if(ang_diff>_s4){
id = 0;
}else{
VERIFY(0);
}
string64 sect_name;
sprintf(sect_name,"effector_fire_hit_%d",id);
AddEffector(this, effFireHit, sect_name, P/100.0f);
}
}
}
}