本文整理汇总了C++中Fvector::setHP方法的典型用法代码示例。如果您正苦于以下问题:C++ Fvector::setHP方法的具体用法?C++ Fvector::setHP怎么用?C++ Fvector::setHP使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Fvector
的用法示例。
在下文中一共展示了Fvector::setHP方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
void CAI_Stalker::can_kill_entity_from (const Fvector &position, Fvector direction, float distance)
{
m_pick_distance = 0.f;
rq_storage.r_clear ();
can_kill_entity (position,direction,distance,rq_storage);
if (m_can_kill_member && m_can_kill_enemy)
return;
float yaw, pitch, safety_fire_angle = 1.f*PI_DIV_8*.5f;
direction.getHP (yaw,pitch);
direction.setHP (yaw - safety_fire_angle,pitch);
can_kill_entity (position,direction,distance,rq_storage);
if (m_can_kill_member && m_can_kill_enemy)
return;
direction.setHP (yaw + safety_fire_angle,pitch);
can_kill_entity (position,direction,distance,rq_storage);
if (m_can_kill_member && m_can_kill_enemy)
return;
direction.setHP (yaw,pitch - safety_fire_angle);
can_kill_entity (position,direction,distance,rq_storage);
if (m_can_kill_member && m_can_kill_enemy)
return;
direction.setHP (yaw,pitch + safety_fire_angle);
can_kill_entity (position,direction,distance,rq_storage);
}
示例2: ai
void CLevelGraph::draw_covers ()
{
float half_size = ai().level_graph().header().cell_size()*.5f;
xr_vector<CCoverPoint*> nearest;
nearest.reserve (1000);
ai().cover_manager().covers().nearest(Device.vCameraPosition,5.f,nearest);
xr_vector<CCoverPoint*>::const_iterator I = nearest.begin();
xr_vector<CCoverPoint*>::const_iterator E = nearest.end();
for ( ; I != E; ++I) {
Fvector position = (*I)->position();
position.y += 1.f;
Level().debug_renderer().draw_aabb (position,half_size - .01f,1.f,ai().level_graph().header().cell_size()*.5f-.01f,D3DCOLOR_XRGB(0*255,255,0*255));
CVertex *v = vertex((*I)->level_vertex_id());
Fvector direction;
float best_value = -1.f;
u32 i = 0, j = 0;
for (; i<36; ++i) {
float value = cover_in_direction(float(10*i)/180.f*PI,v);
direction.setHP (float(10*i)/180.f*PI,0);
direction.normalize ();
direction.mul (value*half_size);
direction.add (position);
direction.y = position.y;
Level().debug_renderer().draw_line(Fidentity,position,direction,D3DCOLOR_XRGB(0,0,255));
value = compute_square(float(10*i)/180.f*PI,PI/2.f,v);
if (value > best_value) {
best_value = value;
j = i;
}
}
direction.set (position.x - half_size*float(v->cover(0))/15.f,position.y,position.z);
Level().debug_renderer().draw_line(Fidentity,position,direction,D3DCOLOR_XRGB(255,0,0));
direction.set (position.x,position.y,position.z + half_size*float(v->cover(1))/15.f);
Level().debug_renderer().draw_line(Fidentity,position,direction,D3DCOLOR_XRGB(255,0,0));
direction.set (position.x + half_size*float(v->cover(2))/15.f,position.y,position.z);
Level().debug_renderer().draw_line(Fidentity,position,direction,D3DCOLOR_XRGB(255,0,0));
direction.set (position.x,position.y,position.z - half_size*float(v->cover(3))/15.f);
Level().debug_renderer().draw_line(Fidentity,position,direction,D3DCOLOR_XRGB(255,0,0));
float value = cover_in_direction(float(10*j)/180.f*PI,v);
direction.setHP (float(10*j)/180.f*PI,0);
direction.normalize ();
direction.mul (value*half_size);
direction.add (position);
direction.y = position.y;
Level().debug_renderer().draw_line (Fidentity,position,direction,D3DCOLOR_XRGB(0,0,0));
}
}
示例3: get_valid_flame_position
bool CPolterFlame::get_valid_flame_position(const CObject *target_object, Fvector &res_pos)
{
const CGameObject *Obj = smart_cast<const CGameObject *>(target_object);
if (!Obj) return (false);
Fvector dir;
float h,p;
Fvector vertex_position;
Fvector new_pos;
for (u32 i=0; i<FIND_POINT_ATTEMPT_COUNT; i++) {
target_object->Direction().getHP(h,p);
h = Random.randF(0, PI_MUL_2);
dir.setHP(h,p);
dir.normalize();
vertex_position = ai().level_graph().vertex_position(Obj->ai_location().level_vertex_id());
new_pos.mad(vertex_position, dir, Random.randF(m_min_flame_dist, m_max_flame_dist));
u32 node = ai().level_graph().check_position_in_direction(Obj->ai_location().level_vertex_id(), vertex_position, new_pos);
if (node != u32(-1)) {
res_pos = ai().level_graph().vertex_position(node);
res_pos.y += Random.randF(m_min_flame_height, m_max_flame_height);
return (true);
}
}
float angle = ai().level_graph().vertex_high_cover_angle(Obj->ai_location().level_vertex_id(),PI_DIV_6,std::less<float>());
dir.set(1.f,0.f,0.f);
dir.setHP(angle + PI, 0.f);
dir.normalize();
vertex_position = ai().level_graph().vertex_position(Obj->ai_location().level_vertex_id());
new_pos.mad(vertex_position, dir, Random.randF(m_min_flame_dist, m_max_flame_dist));
u32 node = ai().level_graph().check_position_in_direction(Obj->ai_location().level_vertex_id(), vertex_position, new_pos);
if (node != u32(-1)) {
res_pos = ai().level_graph().vertex_position(node);
res_pos.y += Random.randF(m_min_flame_height, m_max_flame_height);
return (true);
}
return (false);
}
示例4:
BOOL CCameraShotEffector::Process (Fvector &p, Fvector &d, Fvector &n, float& fFov, float& fFar, float& fAspect)
{
if (bActive){
float h,p;
d.getHP (h,p);
if (bSingleShoot)
{
if (bSSActive)
d.setHP (h+fLastDeltaHorz,p+fLastDeltaVert);
}
else
d.setHP (h+fAngleHorz,p+fAngleVert);
Update ();
}
return TRUE;
}
示例5: set_rew_cur_position
void CAI_Rat::set_rew_cur_position()
{
Fvector tTemp;
tTemp.setHP(-movement().m_body.current.yaw,-movement().m_body.current.pitch);
tTemp.normalize_safe();
tTemp.mul(m_fUnderFireDistance);
m_tSpawnPosition.add(Position(),tTemp);
}
示例6: g_fireParams
void CAI_Trader::g_fireParams(const CHudItem* pHudItem, Fvector& P, Fvector& D)
{
VERIFY (inventory().ActiveItem());
if (g_Alive() && inventory().ActiveItem()) {
Center(P);
D.setHP(0,0);
D.normalize_safe();
}
}
示例7: trace_geometry
bool CSnork::trace_geometry(const Fvector &d, float &range)
{
Fvector dir;
float h, p;
Fvector Pl,Pc,Pr;
Fvector center;
Center (center);
range = trace (d);
if (range > TRACE_RANGE) return false;
float angle = asin(1.f / range);
// trace center ray
dir = d;
dir.getHP (h,p);
p += angle;
dir.setHP (h,p);
dir.normalize_safe ();
range = trace (dir);
if (range > TRACE_RANGE) return false;
Pc.mad (center, dir, range);
// trace left ray
Fvector temp_p;
temp_p.mad (Pc, XFORM().i, Radius() / 2);
dir.sub (temp_p, center);
dir.normalize_safe ();
range = trace (dir);
if (range > TRACE_RANGE) return false;
Pl.mad (center, dir, range);
// trace right ray
Fvector inv = XFORM().i;
inv.invert ();
temp_p.mad (Pc, inv, Radius() / 2);
dir.sub (temp_p, center);
dir.normalize_safe ();
range = trace (dir);
if (range > TRACE_RANGE) return false;
Pr.mad (center, dir, range);
float h1,p1,h2,p2;
Fvector().sub(Pl, Pc).getHP(h1,p1);
Fvector().sub(Pc, Pr).getHP(h2,p2);
return (fsimilar(h1,h2,0.1f) && fsimilar(p1,p2,0.1f));
}
示例8: less_cover_direction
void CMonsterCoverManager::less_cover_direction(Fvector &dir)
{
float angle = ai().level_graph().vertex_cover_angle(m_object->ai_location().level_vertex_id(),deg(10), std::greater<float>());
collide::rq_result l_rq;
float angle_from = angle_normalize(angle - ANGLE_DISP);
float angle_to = angle_normalize(angle + ANGLE_DISP);
Fvector trace_from;
m_object->Center (trace_from);
Fvector direction;
// trace discretely left
for (float ang = angle; angle_difference(ang, angle) < ANGLE_DISP; ang = angle_normalize(ang - ANGLE_DISP_STEP)) {
direction.setHP (ang, 0.f);
if (Level().ObjectSpace.RayPick(trace_from, direction, TRACE_STATIC_DIST, collide::rqtStatic, l_rq,m_object)) {
if ((l_rq.range < TRACE_STATIC_DIST)) {
angle_from = ang;
break;
}
}
}
// trace discretely right
for (float ang = angle; angle_difference(ang, angle) < ANGLE_DISP; ang = angle_normalize(ang + ANGLE_DISP_STEP)) {
direction.setHP (ang, 0.f);
if (Level().ObjectSpace.RayPick(trace_from, direction, TRACE_STATIC_DIST, collide::rqtStatic, l_rq,m_object)) {
if ((l_rq.range < TRACE_STATIC_DIST)) {
angle_to = ang;
break;
}
}
}
angle = angle_normalize(angle_from + angle_difference(angle_from,angle_to) / 2);
dir.setHP (angle,0.f);
}
示例9: death_glide_start
void CControllerPsyHit::death_glide_start()
{
if (!check_conditions_final()) {
m_man->deactivate (this);
return;
}
HUD().SetRenderable(false);
// Start effector
CEffectorCam* ce = Actor()->Cameras().GetCamEffector(eCEControllerPsyHit);
VERIFY(!ce);
Fvector src_pos = Actor()->cam_Active()->vPosition;
Fvector target_pos = m_object->Position();
target_pos.y += 1.2f;
Fvector dir;
dir.sub (target_pos,src_pos);
float dist = dir.magnitude();
dir.normalize ();
target_pos.mad (src_pos,dir,dist-4.8f);
Actor()->Cameras().AddCamEffector(new CControllerPsyHitCamEffector(eCEControllerPsyHit, src_pos,target_pos, m_man->animation().motion_time(m_stage[1], m_object->Visual())));
smart_cast<CController *>(m_object)->draw_fire_particles();
dir.sub(src_pos,target_pos);
dir.normalize();
float h,p;
dir.getHP(h,p);
dir.setHP(h,p+PI_DIV_3);
Actor()->character_physics_support()->movement()->ApplyImpulse(dir,Actor()->GetMass() * 530.f);
set_sound_state (eStart);
NET_Packet P;
Actor()->u_EventGen (P, GEG_PLAYER_WEAPON_HIDE_STATE, Actor()->ID());
P.w_u32 (INV_STATE_BLOCK_ALL);
P.w_u8 (u8(true));
Actor()->u_EventSend(P);
m_blocked = true;
//////////////////////////////////////////////////////////////////////////
// set direction
SControlDirectionData *ctrl_dir = (SControlDirectionData*)m_man->data(this, ControlCom::eControlDir);
VERIFY (ctrl_dir);
ctrl_dir->heading.target_speed = 3.f;
ctrl_dir->heading.target_angle = m_man->direction().angle_to_target(Actor()->Position());
//////////////////////////////////////////////////////////////////////////
}
示例10: init_state_under_fire
void CAI_Rat::init_state_under_fire()
{
if (!switch_if_enemy()&&get_if_dw_time()&&m_tLastSound.dwTime >= m_dwLastUpdateTime)
{
Fvector tTemp;
tTemp.setHP(-movement().m_body.current.yaw,-movement().m_body.current.pitch);
tTemp.normalize_safe();
tTemp.mul(m_fUnderFireDistance);
m_tSpawnPosition.add(Position(),tTemp);
}
m_tGoalDir = m_tSpawnPosition;
}
示例11:
Fvector CMonsterSquad::calc_monster_target_dir (CBaseMonster* monster, const CEntity* enemy)
{
VERIFY(monster);
VERIFY(enemy);
const Fvector enemy_pos = enemy->Position();
Fvector home2enemy = enemy_pos;
home2enemy.sub(monster->Home->get_home_point());
const float home2enemy_mag = home2enemy.magnitude();
// enemy pos == home pos?
const float near_zero = 0.00001f;
if ( home2enemy_mag < near_zero )
{
Fvector enemy2monster = monster->Position();
enemy2monster.sub(enemy_pos);
const float enemy2monster_mag = enemy2monster.magnitude();
// monster pos == enemy pos?
if ( enemy2monster_mag < near_zero )
{
VERIFY2(false, "Enemy and Monster should not have same pos!");
Fvector dir = { 1.f, 0.f, 0.f }; // happy with random dir then :)
return dir;
}
enemy2monster.normalize();
return enemy2monster;
}
const u8 squad_size = squad_alife_count();
VERIFY(squad_size);
u8 squad_index = get_index(monster);
if ( squad_index == -1 )
{
squad_index = 0;
}
float heading, pitch;
home2enemy.getHP(heading, pitch);
// 2pi * index/num - encircle
heading += M_PI * 2.f * squad_index / squad_size;
heading = angle_normalize(heading);
Fvector dir;
dir.setHP(heading, pitch);
dir.normalize();
return dir;
}
示例12: init_free_recoil
void CAI_Rat::init_free_recoil()
{
m_dwLostRecoilTime = Device.dwTimeGlobal;
m_tRecoilPosition = m_tLastSound.tSavedPosition;
if (!switch_if_enemy()&&!switch_if_time())
{
Fvector tTemp;
tTemp.setHP(-movement().m_body.current.yaw,-movement().m_body.current.pitch);
tTemp.normalize_safe();
tTemp.mul(m_fUnderFireDistance);
m_tSpawnPosition.add(Position(),tTemp);
}
}
示例13: OnRender
void ESceneLightTools::OnRender(int priority, bool strictB2F)
{
inherited::OnRender(priority, strictB2F);
if (m_Flags.is(flShowSun)){
if ((true==strictB2F)&&(1==priority)){
Device.SetShader (Device.m_WireShader);
RCache.set_xform_world (Fidentity);
Fvector dir;
dir.setHP(m_SunShadowDir.y,m_SunShadowDir.x);
Fvector p;
float fd = UI->ZFar()*0.95f;
p.mad (Device.vCameraPosition,dir,-fd);
DU.DrawPointLight ( p ,VIS_RADIUS*fd, 0x00FFE020);
DU.DrawLineSphere ( p, VIS_RADIUS*fd*0.3f, 0x00FF3000, false );
}
}
}
示例14: AppendFrameLight
void ESceneLightTools::AppendFrameLight(CLight* src)
{
Flight L;
ZeroMemory (&L, sizeof(Flight));
L.type = src->m_Type;
L.diffuse.mul_rgb (src->m_Color,src->m_Brightness);
L.specular.set (L.diffuse);
L.position.set (src->PPosition);
Fvector dir; dir.setHP(src->PRotation.y,src->PRotation.x);
L.direction.set (dir);
L.range = src->m_Range;
L.attenuation0 = src->m_Attenuation0+EPS_S;
L.attenuation1 = src->m_Attenuation1;
L.attenuation2 = src->m_Attenuation2;
L.phi = src->m_Cone;
L.falloff = 1.f;
Device.SetLight (frame_light.size(),L);
frame_light.push_back(src);
}
示例15: Render
void CParticleEffect::Render(float )
{
u32 dwOffset,dwCount;
// Get a pointer to the particles in gp memory
PAPI::Particle* particles;
u32 p_cnt;
ParticleManager()->GetParticles(m_HandleEffect,particles,p_cnt);
if(p_cnt>0){
if (m_Def&&m_Def->m_Flags.is(CPEDef::dfSprite)){
FVF::LIT* pv_start = (FVF::LIT*)RCache.Vertex.Lock(p_cnt*4*4,geom->vb_stride,dwOffset);
FVF::LIT* pv = pv_start;
for(u32 i = 0; i < p_cnt; i++){
PAPI::Particle &m = particles[i];
Fvector2 lt,rb;
lt.set (0.f,0.f);
rb.set (1.f,1.f);
if (m_Def->m_Flags.is(CPEDef::dfFramed)) m_Def->m_Frame.CalculateTC(iFloor(float(m.frame)/255.f),lt,rb);
float r_x = m.size.x*0.5f;
float r_y = m.size.y*0.5f;
if (m_Def->m_Flags.is(CPEDef::dfVelocityScale)){
float speed = m.vel.magnitude();
r_x += speed*m_Def->m_VelocityScale.x;
r_y += speed*m_Def->m_VelocityScale.y;
}
if (m_Def->m_Flags.is(CPEDef::dfAlignToPath)){
float speed = m.vel.magnitude();
if ((speed<EPS_S)&&m_Def->m_Flags.is(CPEDef::dfWorldAlign)){
Fmatrix M;
M.setXYZ (m_Def->m_APDefaultRotation);
if (m_RT_Flags.is(flRT_XFORM)){
Fvector p;
m_XFORM.transform_tiny(p,m.pos);
M.mulA_43 (m_XFORM);
FillSprite (pv,M.k,M.i,p,lt,rb,r_x,r_y,m.color,m.rot.x);
}else{
FillSprite (pv,M.k,M.i,m.pos,lt,rb,r_x,r_y,m.color,m.rot.x);
}
}else if ((speed>=EPS_S)&&m_Def->m_Flags.is(CPEDef::dfFaceAlign)){
Fmatrix M; M.identity();
M.k.div (m.vel,speed);
M.j.set (0,1,0); if (_abs(M.j.dotproduct(M.k))>.99f) M.j.set(0,0,1);
M.i.crossproduct (M.j,M.k); M.i.normalize ();
M.j.crossproduct (M.k,M.i); M.j.normalize ();
if (m_RT_Flags.is(flRT_XFORM)){
Fvector p;
m_XFORM.transform_tiny(p,m.pos);
M.mulA_43 (m_XFORM);
FillSprite (pv,M.j,M.i,p,lt,rb,r_x,r_y,m.color,m.rot.x);
}else{
FillSprite (pv,M.j,M.i,m.pos,lt,rb,r_x,r_y,m.color,m.rot.x);
}
}else{
Fvector dir;
if (speed>=EPS_S) dir.div (m.vel,speed);
else dir.setHP(-m_Def->m_APDefaultRotation.y,-m_Def->m_APDefaultRotation.x);
if (m_RT_Flags.is(flRT_XFORM)){
Fvector p,d;
m_XFORM.transform_tiny (p,m.pos);
m_XFORM.transform_dir (d,dir);
FillSprite (pv,p,d,lt,rb,r_x,r_y,m.color,m.rot.x);
}else{
FillSprite (pv,m.pos,dir,lt,rb,r_x,r_y,m.color,m.rot.x);
}
}
}else{
if (m_RT_Flags.is(flRT_XFORM)){
Fvector p;
m_XFORM.transform_tiny (p,m.pos);
FillSprite (pv,Device.vCameraTop,Device.vCameraRight,p,lt,rb,r_x,r_y,m.color,m.rot.x);
}else{
FillSprite (pv,Device.vCameraTop,Device.vCameraRight,m.pos,lt,rb,r_x,r_y,m.color,m.rot.x);
}
}
}
dwCount = u32(pv-pv_start);
RCache.Vertex.Unlock(dwCount,geom->vb_stride);
if (dwCount) {
RCache.set_xform_world (Fidentity);
RCache.set_Geometry (geom);
// u32 cm = RCache.get_CullMode();
RCache.set_CullMode (m_Def->m_Flags.is(CPEDef::dfCulling)?(m_Def->m_Flags.is(CPEDef::dfCullCCW)?CULL_CCW:CULL_CW):CULL_NONE);
RCache.Render (D3DPT_TRIANGLELIST,dwOffset,0,dwCount,0,dwCount/2);
RCache.set_CullMode (CULL_CCW );
}
}
}
}