void CGameObject::OnRender () { if (!ai().get_level_graph()) return; CDebugRenderer &renderer = Level().debug_renderer(); if (/**bDebug && /**/Visual()) { float half_cell_size = 1.f*ai().level_graph().header().cell_size()*.5f; Fvector additional = Fvector().set(half_cell_size,half_cell_size,half_cell_size); render_box (Visual(),XFORM(),Fvector().set(0.f,0.f,0.f),true,color_rgba(0,0,255,255)); render_box (Visual(),XFORM(),additional,false,color_rgba(0,255,0,255)); } if (0) { Fvector bc,bd; Visual()->getVisData().box.get_CD (bc,bd); Fmatrix M = Fidentity; float half_cell_size = ai().level_graph().header().cell_size()*.5f; bd.add (Fvector().set(half_cell_size,half_cell_size,half_cell_size)); M.scale (bd); Fmatrix T = XFORM(); T.c.add (bc); renderer.draw_obb (T,bd,color_rgba(255,255,255,255)); } }
void CPhysicObject::create_collision_model ( ) { xr_delete( collidable.model ); VERIFY( Visual() ); IKinematics *K = Visual()->dcast_PKinematics (); VERIFY( K ); CInifile* ini = K->LL_UserData(); if( ini && ini->section_exist( "collide" ) && ini->line_exist("collide", "mesh" ) && ini->r_bool("collide", "mesh" ) ) { collidable.model = xr_new<CCF_DynamicMesh>( this ); return; } collidable.model = xr_new<CCF_Skeleton>(this); /* switch(m_type) { case epotBox: case epotFixedChain: case epotFreeChain : case epotSkeleton : collidable.model = xr_new<CCF_Skeleton>(this); break; default: NODEFAULT; } */ }
void CGameObject::renderable_Render () { inherited::renderable_Render(); ::Render->set_Transform (&XFORM()); ::Render->add_Visual (Visual()); Visual()->getVisData().hom_frame = Device.dwFrame; }
void CPhysicsShellHolder::activate_physic_shell() { VERIFY (!m_pPhysicsShell); create_physic_shell (); Fvector l_fw, l_up; l_fw.set (XFORM().k); l_up.set (XFORM().j); l_fw.mul (2.f); l_up.mul (2.f); Fmatrix l_p1, l_p2; l_p1.set (XFORM()); l_p2.set (XFORM()); l_fw.mul (2.f); l_p2.c.add (l_fw); m_pPhysicsShell->Activate (l_p1, 0, l_p2); if(H_Parent()&&H_Parent()->Visual()) { smart_cast<CKinematics*>(H_Parent()->Visual())->CalculateBones_Invalidate (); smart_cast<CKinematics*>(H_Parent()->Visual())->CalculateBones (); } smart_cast<CKinematics*>(Visual())->CalculateBones_Invalidate (); smart_cast<CKinematics*>(Visual())->CalculateBones(); if(!IsGameTypeSingle()) { if(!smart_cast<CCustomRocket*>(this)&&!smart_cast<CGrenade*>(this)) PPhysicsShell()->SetIgnoreDynamic(); } // XFORM().set (l_p1); correct_spawn_pos(); m_pPhysicsShell->set_LinearVel(l_fw); m_pPhysicsShell->GetGlobalTransformDynamic(&XFORM()); }
THuiRealRect CHuiLayout::BoundingRect() const { THuiRealPoint min; THuiRealPoint max; min.iX = 0; min.iY = 0; max.iX = 0; max.iY = 0; TInt count = Count(); if(count > 0) { min = Visual(0).Pos().Target(); max = min + Visual(0).Size().Target(); } for(TInt i = 1; i < count; ++i) { THuiRealPoint tl = Visual(i).Pos().Target(); THuiRealPoint br = tl + Visual(i).Size().Target(); min.iX = Min(min.iX, tl.iX); min.iY = Min(min.iY, tl.iY); max.iX = Max(max.iX, br.iX); max.iY = Max(max.iY, br.iY); } return THuiRealRect(min, max); }
void CCar::CreateSkeleton(CSE_Abstract *po) { if (!Visual()) return; IRenderVisual *pVis = Visual(); IKinematics* pK = smart_cast<IKinematics*>(pVis); IKinematicsAnimated* pKA = smart_cast<IKinematicsAnimated*>(pVis); if(pKA) { pKA->PlayCycle ("idle"); pK->CalculateBones (TRUE); } phys_shell_verify_object_model ( *this ); #pragma todo(" replace below by P_build_Shell or call inherited") m_pPhysicsShell = P_create_Shell(); m_pPhysicsShell->build_FromKinematics(pK,&bone_map); m_pPhysicsShell->set_PhysicsRefObject(this); m_pPhysicsShell->mXFORM.set(XFORM()); m_pPhysicsShell->Activate(true); m_pPhysicsShell->SetAirResistance(0.f,0.f); m_pPhysicsShell->SetPrefereExactIntegration(); ApplySpawnIniToPhysicShell(&po->spawn_ini(),m_pPhysicsShell,false); ApplySpawnIniToPhysicShell(pK->LL_UserData(),m_pPhysicsShell,false); }
void CGameObject::SetKinematicsCallback (bool set) { if(!Visual()) return; if (set) smart_cast<IKinematics*>(Visual())->Callback(VisualCallback,this); else smart_cast<IKinematics*>(Visual())->Callback(0,0); };
void CAI_Rat::SelectAnimation(const Fvector& /**_view/**/, const Fvector& /**_move/**/, float /**speed/**/) { IKinematicsAnimated *tpVisualObject = smart_cast<IKinematicsAnimated*>(Visual()); MotionID tpGlobalAnimation; if (!g_Alive()) { for (int i=0 ;i<2; ++i) { if (m_tRatAnimations.tNormal.tGlobal.tpaDeath[i] == m_tpCurrentGlobalAnimation) { tpGlobalAnimation = m_tpCurrentGlobalAnimation; break; } } if (!tpGlobalAnimation) { if (m_tpCurrentGlobalAnimation == m_tRatAnimations.tNormal.tGlobal.tpaIdle[1]) tpGlobalAnimation = m_tRatAnimations.tNormal.tGlobal.tpaDeath[0]; else tpGlobalAnimation = m_tRatAnimations.tNormal.tGlobal.tpaDeath[::Random.randI(0,2)]; } } else { if (m_bFiring) tpGlobalAnimation = m_tRatAnimations.tNormal.tGlobal.tpaAttack[2]; else if (angle_difference(movement().m_body.target.yaw,movement().m_body.current.yaw) <= MIN_TURN_ANGLE) if (m_fSpeed < 0.2f) { if (m_bStanding) tpGlobalAnimation = m_tRatAnimations.tNormal.tGlobal.tpaIdle[1]; else tpGlobalAnimation = m_tRatAnimations.tNormal.tGlobal.tpaIdle[0]; } else if (_abs(m_fSpeed - m_fAttackSpeed) < EPS_L) tpGlobalAnimation = m_tRatAnimations.tNormal.tGlobal.tRunAttack; else if (_abs(m_fSpeed - m_fMaxSpeed) < EPS_L) tpGlobalAnimation = m_tRatAnimations.tNormal.tGlobal.tRun.fwd; else tpGlobalAnimation = m_tRatAnimations.tNormal.tGlobal.tWalk.fwd; else { if (left_angle(-movement().m_body.target.yaw,-movement().m_body.current.yaw)) // tpGlobalAnimation = m_tRatAnimations.tNormal.tGlobal.tpaIdle[0]; tpGlobalAnimation = m_tRatAnimations.tNormal.tGlobal.tpTurnLeft; else // tpGlobalAnimation = m_tRatAnimations.tNormal.tGlobal.tpaIdle[0]; tpGlobalAnimation = m_tRatAnimations.tNormal.tGlobal.tpTurnRight; } } if (tpGlobalAnimation != m_tpCurrentGlobalAnimation) m_tpCurrentGlobalBlend = tpVisualObject->PlayCycle(m_tpCurrentGlobalAnimation = tpGlobalAnimation); #ifdef DEBUG if (psAI_Flags.is(aiAnimation)) { IKinematicsAnimated *skeleton_animated = smart_cast<IKinematicsAnimated*>(Visual()); Msg ("%6d %s animation : %s (%f,%f)",Device.dwTimeGlobal,"Global",skeleton_animated->LL_MotionDefName_dbg(m_tpCurrentGlobalAnimation),movement().m_body.current.yaw,movement().m_body.target.yaw); } #endif }
void CPhysicObject::CreateSkeleton(CSE_ALifeObjectPhysic* po) { if(m_pPhysicsShell) return; if(!Visual()) return; LPCSTR fixed_bones=*po->fixed_bones; m_pPhysicsShell=P_build_Shell(this,!po->_flags.test(CSE_PHSkeleton::flActive),fixed_bones); ApplySpawnIniToPhysicShell(&po->spawn_ini(),m_pPhysicsShell,fixed_bones[0]!='\0'); ApplySpawnIniToPhysicShell(smart_cast<IKinematics*>(Visual())->LL_UserData(),m_pPhysicsShell,fixed_bones[0]!='\0'); }
void CWeaponStatMgun::ResetBoneCallbacks() { CBoneInstance& biX = smart_cast<IKinematics*>(Visual())->LL_GetBoneInstance(m_rotate_x_bone); biX.reset_callback (); CBoneInstance& biY = smart_cast<IKinematics*>(Visual())->LL_GetBoneInstance(m_rotate_y_bone); biY.reset_callback (); m_pPhysicsShell->EnabledCallbacks(TRUE); }
void CHangingLamp::TurnOff () { light_render->set_active (false); if (glow_render) glow_render->set_active (false); if (light_ambient) light_ambient->set_active (false); if (Visual()) smart_cast<CKinematics*>(Visual())->LL_SetBoneVisible(light_bone, FALSE, TRUE); if(!PPhysicsShell())//if we have physiccs_shell it will call processing deactivate when disable processing_deactivate (); }
void CPhysicsShellHolder::setup_physic_shell () { VERIFY (!m_pPhysicsShell); create_physic_shell (); m_pPhysicsShell->Activate (XFORM(),0,XFORM()); smart_cast<CKinematics*>(Visual())->CalculateBones_Invalidate (); smart_cast<CKinematics*>(Visual())->CalculateBones(); m_pPhysicsShell->GetGlobalTransformDynamic(&XFORM()); }
void CWeaponStatMgun::SetBoneCallbacks() { m_pPhysicsShell->EnabledCallbacks(FALSE); CBoneInstance& biX = smart_cast<IKinematics*>(Visual())->LL_GetBoneInstance(m_rotate_x_bone); biX.set_callback (bctCustom,BoneCallbackX,this); CBoneInstance& biY = smart_cast<IKinematics*>(Visual())->LL_GetBoneInstance(m_rotate_y_bone); biY.set_callback (bctCustom,BoneCallbackY,this); }
void CHangingLamp::RespawnInit() { Init(); if(Visual()){ CKinematics* K = smart_cast<CKinematics*>(Visual()); K->LL_SetBonesVisible(u64(-1)); K->CalculateBones_Invalidate(); K->CalculateBones (); } }
void CHangingLamp::SpawnInitPhysics (CSE_Abstract *D) { CSE_ALifeObjectHangingLamp *lamp = smart_cast<CSE_ALifeObjectHangingLamp*>(D); if (lamp->flags.is(CSE_ALifeObjectHangingLamp::flPhysic)) CreateBody(lamp); if (smart_cast<CKinematics*>(Visual())){ smart_cast<CKinematics*> (Visual())->CalculateBones_Invalidate (); smart_cast<CKinematics*> (Visual())->CalculateBones(); //.intepolate_pos } }
void CActor::steer_Vehicle(float angle) { if(!m_holder) return; CCar* car = smart_cast<CCar*>(m_holder); u16 anim_type = car->DriverAnimationType(); SVehicleAnimCollection& anims=m_vehicle_anims->m_vehicles_type_collections[anim_type]; if(angle==0.f) smart_cast<CKinematicsAnimated*> (Visual())->PlayCycle(anims.idles[0]); else if(angle>0.f) smart_cast<CKinematicsAnimated*> (Visual())->PlayCycle(anims.steer_right); else smart_cast<CKinematicsAnimated*> (Visual())->PlayCycle(anims.steer_left); }
void CHelicopter::UpdateCL() { inherited::UpdateCL (); CExplosive::UpdateCL(); if(PPhysicsShell() && (state() == CHelicopter::eDead) ) { PPhysicsShell()->InterpolateGlobalTransform(&XFORM()); IKinematics* K = smart_cast<IKinematics*>(Visual()); K->CalculateBones (); //smoke UpdateHeliParticles(); if(m_brokenSound._feedback()) m_brokenSound.set_position(XFORM().c); return; } else PPhysicsShell()->SetTransform(XFORM(), mh_unspecified ); m_movement.Update(); m_stepRemains+=Device.fTimeDelta; while(m_stepRemains>STEP) { MoveStep(); m_stepRemains-=STEP; } #ifdef DEBUG if(bDebug) { CGameFont* F = UI().Font().pFontDI; F->SetAligment (CGameFont::alCenter); // F->SetSizeI (0.02f); F->OutSetI (0.f,-0.8f); F->SetColor (0xffffffff); F->OutNext ("Heli: speed=%4.4f acc=%4.4f dist=%4.4f",m_movement.curLinearSpeed, m_movement.curLinearAcc, m_movement.GetDistanceToDestPosition()); } #endif if(m_engineSound._feedback()) m_engineSound.set_position(XFORM().c); m_enemy.Update(); //weapon UpdateWeapons(); UpdateHeliParticles(); IKinematics* K = smart_cast<IKinematics*>(Visual()); K->CalculateBones (); }
void CHangingLamp::UpdateCL () { inherited::UpdateCL (); if(m_pPhysicsShell) m_pPhysicsShell->InterpolateGlobalTransform(&XFORM()); if (Alive() && light_render->get_active()){ if(Visual()) PKinematics(Visual())->CalculateBones(); // update T&R from light (main) bone Fmatrix xf; if (light_bone!=BI_NONE){ Fmatrix& M = smart_cast<CKinematics*>(Visual())->LL_GetTransform(light_bone); xf.mul (XFORM(),M); VERIFY(!fis_zero(DET(xf))); }else{ xf.set (XFORM()); } light_render->set_rotation (xf.k,xf.i); light_render->set_position (xf.c); if (glow_render)glow_render->set_position (xf.c); // update T&R from ambient bone if (light_ambient){ if (ambient_bone!=light_bone){ if (ambient_bone!=BI_NONE){ Fmatrix& M = smart_cast<CKinematics*>(Visual())->LL_GetTransform(ambient_bone); xf.mul (XFORM(),M); VERIFY(!fis_zero(DET(xf))); }else{ xf.set (XFORM()); } } light_ambient->set_rotation (xf.k,xf.i); light_ambient->set_position (xf.c); } if (lanim){ int frame; u32 clr = lanim->CalculateBGR(Device.fTimeGlobal,frame); // возвращает в формате BGR Fcolor fclr; fclr.set ((float)color_get_B(clr),(float)color_get_G(clr),(float)color_get_R(clr),1.f); fclr.mul_rgb (fBrightness/255.f); light_render->set_color (fclr); if (glow_render) glow_render->set_color (fclr); if (light_ambient) { fclr.mul_rgb (ambient_power); light_ambient->set_color(fclr); } } } }
void CHangingLamp::TurnOn () { light_render->set_active (true); if (glow_render) glow_render->set_active (true); if (light_ambient) light_ambient->set_active (true); if (Visual()){ CKinematics* K = smart_cast<CKinematics*>(Visual()); K->LL_SetBoneVisible (light_bone, TRUE, TRUE); K->CalculateBones_Invalidate(); K->CalculateBones (); } processing_activate (); }
void CHangingLamp::CreateBody(CSE_ALifeObjectHangingLamp *lamp) { if (!Visual()) return; if (m_pPhysicsShell) return; CKinematics* pKinematics= smart_cast<CKinematics*> (Visual()); m_pPhysicsShell = P_create_Shell(); bone_map .clear(); LPCSTR fixed_bones=*lamp->fixed_bones; if(fixed_bones){ int count = _GetItemCount(fixed_bones); for (int i=0 ;i<count; ++i){ string64 fixed_bone ; _GetItem (fixed_bones,i,fixed_bone) ; u16 fixed_bone_id=pKinematics->LL_BoneID(fixed_bone) ; R_ASSERT2(BI_NONE!=fixed_bone_id,"wrong fixed bone") ; bone_map.insert(mk_pair(fixed_bone_id,physicsBone())) ; } }else{ bone_map.insert(mk_pair(pKinematics->LL_GetBoneRoot(),physicsBone())) ; } m_pPhysicsShell->build_FromKinematics(pKinematics,&bone_map); m_pPhysicsShell->set_PhysicsRefObject(this); m_pPhysicsShell->mXFORM.set(XFORM()); m_pPhysicsShell->Activate(true);//, //m_pPhysicsShell->SmoothElementsInertia(0.3f); m_pPhysicsShell->SetAirResistance();//0.0014f,1.5f ///////////////////////////////////////////////////////////////////////////// BONE_P_PAIR_IT i=bone_map.begin(),e=bone_map.end(); for(;i!=e;i++){ CPhysicsElement* fixed_element=i->second.element; ///R_ASSERT2(fixed_element,"fixed bone has no physics"); if(fixed_element)fixed_element->Fix(); } m_pPhysicsShell->mXFORM.set(XFORM()); m_pPhysicsShell->SetAirResistance(0.001f, 0.02f); SAllDDOParams disable_params; disable_params.Load(smart_cast<CKinematics*>(Visual())->LL_UserData()); m_pPhysicsShell->set_DisableParams(disable_params); ApplySpawnIniToPhysicShell(&lamp->spawn_ini(),m_pPhysicsShell,fixed_bones[0]!='\0'); }
void CActor::HitSignal(float perc, Fvector& vLocalDir, CObject* who, s16 element) { if (g_Alive()) { // stop-motion if (character_physics_support()->movement()->Environment()==CPHMovementControl::peOnGround || character_physics_support()->movement()->Environment()==CPHMovementControl::peAtWall) { Fvector zeroV; zeroV.set (0,0,0); character_physics_support()->movement()->SetVelocity(zeroV); } // check damage bone Fvector D; XFORM().transform_dir(D,vLocalDir); float yaw, pitch; D.getHP(yaw,pitch); CKinematicsAnimated *tpKinematics = smart_cast<CKinematicsAnimated*>(Visual()); VERIFY(tpKinematics); #pragma todo("Dima to Dima : forward-back bone impulse direction has been determined incorrectly!") MotionID motion_ID = m_anims->m_normal.m_damage[iFloor(tpKinematics->LL_GetBoneInstance(element).get_param(1) + (angle_difference(r_model_yaw + r_model_yaw_delta,yaw) <= PI_DIV_2 ? 0 : 1))]; float power_factor = perc/100.f; clamp(power_factor,0.f,1.f); VERIFY(motion_ID.valid()); tpKinematics->PlayFX(motion_ID,power_factor); } }
void CPhysicsShellHolder::PHLoadState(IReader &P) { // Flags8 lflags; CKinematics* K=smart_cast<CKinematics*>(Visual()); // P.r_u8 (lflags.flags); if(K) { K->LL_SetBonesVisible(P.r_u64()); K->LL_SetBoneRoot(P.r_u16()); } Fvector min=P.r_vec3(); Fvector max=P.r_vec3(); VERIFY(!min.similar(max)); u16 bones_number=P.r_u16(); R_ASSERT3(bones_number <= 64, "CPhysicsShellHolder::PHLoadState", cNameVisual().c_str()); for(u16 i=0;i<bones_number;i++) { SPHNetState state; state.net_Load(P,min,max); PHGetSyncItem(i)->set_State(state); } }
void CHangingLamp::CopySpawnInit () { CPHSkeleton::CopySpawnInit(); CKinematics* K=smart_cast<CKinematics*>(Visual()); if(!K->LL_GetBoneVisible(light_bone)) TurnOff(); }
BOOL CObject::net_Spawn (CSE_Abstract* data) { PositionStack.clear (); VERIFY (_valid(renderable.xform)); if (0==Visual() && pSettings->line_exist( cNameSect(), "visual" ) ) cNameVisual_set (pSettings->r_string( cNameSect(), "visual" ) ); if (0==collidable.model) { if (pSettings->line_exist(cNameSect(),"cform")) { //LPCSTR cf = pSettings->r_string (*cNameSect(), "cform"); VERIFY3 (*NameVisual, "Model isn't assigned for object, but cform requisted",*cName()); collidable.model = xr_new<CCF_Skeleton> (this); } } R_ASSERT(spatial.space); spatial_register(); if (register_schedule()) shedule_register (); // reinitialize flags //. Props.bActiveCounter = 0; processing_activate (); setDestroy (false); MakeMeCrow (); return TRUE ; }
// animations void CAI_Rat::load_animations () { IKinematicsAnimated* tpVisualObject = smart_cast<IKinematicsAnimated*>(Visual()); // loading normal animations m_tRatAnimations.tNormal.tGlobal.tpaDeath[0] = tpVisualObject->ID_Cycle("norm_death"); m_tRatAnimations.tNormal.tGlobal.tpaDeath[1] = tpVisualObject->ID_Cycle("norm_death_2"); m_tRatAnimations.tNormal.tGlobal.tpaAttack[0] = tpVisualObject->ID_Cycle("attack_1"); m_tRatAnimations.tNormal.tGlobal.tpaAttack[1] = tpVisualObject->ID_Cycle("attack_2"); m_tRatAnimations.tNormal.tGlobal.tpaAttack[2] = tpVisualObject->ID_Cycle("attack_3"); m_tRatAnimations.tNormal.tGlobal.tpaIdle[0] = tpVisualObject->ID_Cycle("norm_idle_1"); m_tRatAnimations.tNormal.tGlobal.tpaIdle[1] = tpVisualObject->ID_Cycle("norm_idle_2"); m_tRatAnimations.tNormal.tGlobal.tpTurnLeft = tpVisualObject->ID_Cycle("norm_turn_ls"); m_tRatAnimations.tNormal.tGlobal.tpTurnRight = tpVisualObject->ID_Cycle("norm_turn_rs"); m_tRatAnimations.tNormal.tGlobal.tWalk.Create(tpVisualObject, "norm_walk"); m_tRatAnimations.tNormal.tGlobal.tRun.Create(tpVisualObject, "norm_run"); m_tRatAnimations.tNormal.tGlobal.tRunAttack = tpVisualObject->ID_Cycle("norm_run_fwd_1"); tpVisualObject->PlayCycle(m_tRatAnimations.tNormal.tGlobal.tpaIdle[0]); }
void CAI_Crow::switch2_DeathFall() { Fvector V; V.mul(XFORM().k,fSpeed); // m_PhysicMovementControl->SetVelocity(V); smart_cast<CKinematicsAnimated*>(Visual())->PlayCycle (m_Anims.m_death.GetRandom(),TRUE,cb_OnHitEndPlaying,this); }
void CActor::attach_Vehicle(CHolderCustom* vehicle) { if(!vehicle) return; if(m_holder) return; PickupModeOff (); m_holder=vehicle; CKinematicsAnimated* V = smart_cast<CKinematicsAnimated*>(Visual()); R_ASSERT(V); if(!m_holder->attach_Actor(this)){ m_holder=NULL; return; } // temp play animation CCar* car = smart_cast<CCar*>(m_holder); u16 anim_type = car->DriverAnimationType(); SVehicleAnimCollection& anims = m_vehicle_anims->m_vehicles_type_collections[anim_type]; V->PlayCycle (anims.idles[0],FALSE); ResetCallbacks (); u16 head_bone = V->LL_BoneID("bip01_head"); V->LL_GetBoneInstance (u16(head_bone)).set_callback (bctPhysics, VehicleHeadCallback,this); character_physics_support ()->movement()->DestroyCharacter(); mstate_wishful = 0; m_holderID=car->ID (); SetWeaponHideState (INV_STATE_CAR, true); CStepManager::on_animation_start(MotionID(), 0); }
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); }
void CBaseMonster::update_eyes_visibility () { if ( !m_left_eye_bone_name ) { return; } IKinematics* const skeleton = smart_cast<IKinematics*>(Visual()); if ( !skeleton ) { return; } u16 const left_eye_bone_id = skeleton->LL_BoneID(m_left_eye_bone_name); u16 const right_eye_bone_id = skeleton->LL_BoneID(m_right_eye_bone_name); R_ASSERT (left_eye_bone_id != u16(-1) && right_eye_bone_id != u16(-1)); bool eyes_visible = !g_Alive() || get_screen_space_coverage_diagonal() > 0.05f; bool const was_visible = !!skeleton->LL_GetBoneVisible (left_eye_bone_id); skeleton->LL_SetBoneVisible (left_eye_bone_id, eyes_visible, true); skeleton->LL_SetBoneVisible (right_eye_bone_id, eyes_visible, true); if ( !was_visible && eyes_visible ) { skeleton->CalculateBones_Invalidate(); skeleton->CalculateBones (); } }
void CActor::detach_Vehicle() { if(!m_holder) return; CCar* car=smart_cast<CCar*>(m_holder); if(!car)return; CPHShellSplitterHolder*sh= car->PPhysicsShell()->SplitterHolder(); if(sh)sh->Deactivate(); if(!character_physics_support()->movement()->ActivateBoxDynamic(0)) { if(sh)sh->Activate(); return; } if(sh)sh->Activate(); m_holder->detach_Actor();// character_physics_support()->movement()->SetPosition(m_holder->ExitPosition()); character_physics_support()->movement()->SetVelocity(m_holder->ExitVelocity()); r_model_yaw=-m_holder->Camera()->yaw; r_torso.yaw=r_model_yaw; r_model_yaw_dest=r_model_yaw; m_holder=NULL; SetCallbacks (); CKinematicsAnimated* V= smart_cast<CKinematicsAnimated*>(Visual()); R_ASSERT(V); V->PlayCycle (m_anims->m_normal.legs_idle); V->PlayCycle (m_anims->m_normal.m_torso_idle); m_holderID=u16(-1); //. SetWeaponHideState(whs_CAR, FALSE); SetWeaponHideState(INV_STATE_CAR, false); }