void CInventoryItem::UpdateXForm () { if (0==object().H_Parent()) return; // Get access to entity and its visual CEntityAlive* E = smart_cast<CEntityAlive*>(object().H_Parent()); if (!E) return; if (E->cast_base_monster()) return; const CInventoryOwner *parent = smart_cast<const CInventoryOwner*>(E); if (parent && parent->use_simplified_visual()) return; if (parent->attached(this)) return; R_ASSERT (E); IKinematics* V = smart_cast<IKinematics*> (E->Visual()); VERIFY (V); // Get matrices int boneL = -1, boneR = -1, boneR2 = -1; E->g_WeaponBones(boneL,boneR,boneR2); if (boneR == -1) return; // if ((HandDependence() == hd1Hand) || (STATE == eReload) || (!E->g_Alive())) // boneL = boneR2; #pragma todo("TO ALL: serious performance problem") V->CalculateBones (); Fmatrix& mL = V->LL_GetTransform(u16(boneL)); Fmatrix& mR = V->LL_GetTransform(u16(boneR)); // Calculate Fmatrix mRes; Fvector R,D,N; D.sub (mL.c,mR.c); D.normalize_safe(); if(fis_zero(D.magnitude())) { mRes.set(E->XFORM()); mRes.c.set(mR.c); } else { D.normalize(); R.crossproduct (mR.j,D); N.crossproduct (D,R); N.normalize(); mRes.set (R,N,D,mR.c); mRes.mulA_43 (E->XFORM()); } // UpdatePosition (mRes); object().Position().set(mRes.c); }
void CPda::UpdateActiveContacts () { m_active_contacts.clear_not_free(); xr_vector<CObject*>::iterator it= feel_touch.begin(); for(;it!=feel_touch.end();++it){ CEntityAlive* pEA = smart_cast<CEntityAlive*>(*it); if(!!pEA->g_Alive() && !pEA->cast_base_monster()) { m_active_contacts.push_back(*it); } } }
void CHUDTarget::Render() { VERIFY (g_bRendering); CObject* O = Level().CurrentEntity(); if (0==O) return; CEntity* E = smart_cast<CEntity*>(O); if (0==E) return; Fvector p1 = Device.vCameraPosition; Fvector dir = Device.vCameraDirection; // Render cursor u32 C = C_DEFAULT; FVF::TL PT; Fvector p2; p2.mad (p1,dir,RQ.range); PT.transform (p2,Device.mFullTransform); float di_size = C_SIZE/powf(PT.p.w,.2f); CGameFont* F = HUD().Font().pFontGraffiti19Russian; F->SetAligment (CGameFont::alCenter); F->OutSetI (0.f,0.05f); if (psHUD_Flags.test(HUD_CROSSHAIR_DIST)){ F->SetColor (C); F->OutNext ("%4.1f",RQ.range); } if (psHUD_Flags.test(HUD_INFO)){ if (RQ.O){ CEntityAlive* E = smart_cast<CEntityAlive*> (RQ.O); CEntityAlive* pCurEnt = smart_cast<CEntityAlive*> (Level().CurrentEntity()); PIItem l_pI = smart_cast<PIItem> (RQ.O); if (IsGameTypeSingle()) { CInventoryOwner* our_inv_owner = smart_cast<CInventoryOwner*>(pCurEnt); if (E && E->g_Alive() && !E->cast_base_monster()) { //. CInventoryOwner* our_inv_owner = smart_cast<CInventoryOwner*>(pCurEnt); CInventoryOwner* others_inv_owner = smart_cast<CInventoryOwner*>(E); if(our_inv_owner && others_inv_owner){ switch(RELATION_REGISTRY().GetRelationType(others_inv_owner, our_inv_owner)) { case ALife::eRelationTypeEnemy: C = C_ON_ENEMY; break; case ALife::eRelationTypeNeutral: C = C_ON_NEUTRAL; break; case ALife::eRelationTypeFriend: C = C_ON_FRIEND; break; } if (fuzzyShowInfo>0.5f){ CStringTable strtbl ; F->SetColor (subst_alpha(C,u8(iFloor(255.f*(fuzzyShowInfo-0.5f)*2.f)))); F->OutNext ("%s", *strtbl.translate(others_inv_owner->Name()) ); F->OutNext ("%s", *strtbl.translate(others_inv_owner->CharacterInfo().Community().id()) ); } } fuzzyShowInfo += SHOW_INFO_SPEED*Device.fTimeDelta; } else if (l_pI && our_inv_owner && RQ.range < 2.0f*our_inv_owner->inventory().GetTakeDist()) { if (fuzzyShowInfo>0.5f){ F->SetColor (subst_alpha(C,u8(iFloor(255.f*(fuzzyShowInfo-0.5f)*2.f)))); F->OutNext ("%s",l_pI->Name/*Complex*/()); } fuzzyShowInfo += SHOW_INFO_SPEED*Device.fTimeDelta; } } else { if (E && (E->GetfHealth()>0)) { if (pCurEnt && GameID() == GAME_SINGLE){ if (GameID() == GAME_DEATHMATCH) C = C_ON_ENEMY; else{ if (E->g_Team() != pCurEnt->g_Team()) C = C_ON_ENEMY; else C = C_ON_FRIEND; }; if (RQ.range >= recon_mindist() && RQ.range <= recon_maxdist()){ float ddist = (RQ.range - recon_mindist())/(recon_maxdist() - recon_mindist()); float dspeed = recon_minspeed() + (recon_maxspeed() - recon_minspeed())*ddist; fuzzyShowInfo += Device.fTimeDelta/dspeed; }else{ if (RQ.range < recon_mindist()) fuzzyShowInfo += recon_minspeed()*Device.fTimeDelta; else fuzzyShowInfo = 0; }; if (fuzzyShowInfo>0.5f){ clamp(fuzzyShowInfo,0.f,1.f); int alpha_C = iFloor(255.f*(fuzzyShowInfo-0.5f)*2.f); u8 alpha_b = u8(alpha_C & 0x00ff); F->SetColor (subst_alpha(C,alpha_b)); F->OutNext ("%s",*RQ.O->cName()); } } }; }; }else{ fuzzyShowInfo -= HIDE_INFO_SPEED*Device.fTimeDelta; } clamp(fuzzyShowInfo,0.f,1.f); } //отрендерить кружочек или крестик if(!m_bShowCrosshair){ // actual rendering u32 vOffset; FVF::TL* pv = (FVF::TL*)RCache.Vertex.Lock(4,hGeom.stride(),vOffset); float size_x = float(Device.dwWidth) * di_size; float size_y = float(Device.dwHeight) * di_size; size_y = size_x; float w_2 = Device.fWidth_2; float h_2 = Device.fHeight_2; // Convert to screen coords float cx = (PT.p.x+1)*w_2; float cy = (PT.p.y+1)*h_2; pv->set (cx - size_x, cy + size_y, C, 0, 1); ++pv; pv->set (cx - size_x, cy - size_y, C, 0, 0); ++pv; pv->set (cx + size_x, cy + size_y, C, 1, 1); ++pv; pv->set (cx + size_x, cy - size_y, C, 1, 0); ++pv; // unlock VB and Render it as triangle LIST RCache.Vertex.Unlock(4,hGeom.stride()); RCache.set_Shader (hShader); RCache.set_Geometry (hGeom); RCache.Render (D3DPT_TRIANGLELIST,vOffset,0,4,0,2); }else{ //отрендерить прицел HUDCrosshair.cross_color = C; HUDCrosshair.OnRender (); } }