Example #1
0
void CTLSprite::Render(Fvector &pos, u32 color, float radius, float angle)
{
	FVF::TL			P;

	P.transform     (pos, Device.mFullTransform);
    if (P.p.w<=0) 	return;

	float cx		= Device._x2real(P.p.x);
	float cy		= Device._y2real(P.p.y);

	float sz		= (UI->GetRenderWidth()*radius)/P.p.w;
	if (sz<1.5f) 	return;

	// Rotation
	float			_sin1=_sin(angle),_cos1=_cos(angle);
    float			_sin2=_sin(angle+PI_DIV_2),_cos2=_cos(angle+PI_DIV_2);

	mesh.m[0].p.x = cx+sz*_sin1;	mesh.m[0].p.y = cy+sz*_cos1;
	mesh.m[1].p.x = cx-sz*_sin2;	mesh.m[1].p.y = cy-sz*_cos2;
	mesh.m[2].p.x = cx+sz*_sin2;	mesh.m[2].p.y = cy+sz*_cos2;
	mesh.m[3].p.x = cx-sz*_sin1;	mesh.m[3].p.y = cy-sz*_cos1;

	mesh.setdepth	(P.p.z, P.p.w);
	mesh.setcolor	(color);

    DU_impl.DrawPrimitiveTL(D3DPT_TRIANGLESTRIP,2,(FVF::TL*)&mesh,4,false,false);
}
Example #2
0
void CDrawUtilities::DrawAxis(const Fmatrix& T)
{
	_VertexStream*	Stream	= &RCache.Vertex;
    Fvector p[6];
    u32 	c[6];

    // colors
    c[0]=c[2]=c[4]=0x00222222; c[1]=0x00FF0000; c[3]=0x0000FF00; c[5]=0x000000FF;

    // position
  	p[0].mad(T.c,T.k,0.25f);
    p[1].set(p[0]); p[1].x+=.015f;
    p[2].set(p[0]);
    p[3].set(p[0]); p[3].y+=.015f;
    p[4].set(p[0]);
    p[5].set(p[0]); p[5].z+=.015f;

    u32 vBase;
	FVF::TL* pv	= (FVF::TL*)Stream->Lock(6,vs_TL->vb_stride,vBase);
    // transform to screen
    float dx=-float(Device.dwWidth)/2.2f;
    float dy=float(Device.dwHeight)/2.25f;

    for (int i=0; i<6; i++,pv++){
	    pv->color = c[i]; pv->transform(p[i],Device.mFullTransform);
	    pv->p.set((float)iFloor(_x2real(pv->p.x)+dx),(float)iFloor(_y2real(pv->p.y)+dy),0,1);
        p[i].set(pv->p.x,pv->p.y,0);
    }

	// unlock VB and Render it as triangle list
	Stream->Unlock(6,vs_TL->vb_stride);
	DU_DRAW_RS(D3DRS_SHADEMODE,D3DSHADE_GOURAUD);
	DU_DRAW_SH(dxRenderDeviceRender::Instance().m_WireShader);
    DU_DRAW_DP(D3DPT_LINELIST,vs_TL,vBase,3);
	DU_DRAW_RS(D3DRS_SHADEMODE,SHADE_MODE);

    m_Font->SetColor(0xFF909090);
    m_Font->Out(p[1].x,p[1].y,"x");
    m_Font->Out(p[3].x,p[3].y,"y");
    m_Font->Out(p[5].x,p[5].y,"z");
    m_Font->SetColor(0xFF000000);
    m_Font->Out(p[1].x-1,p[1].y-1,"x");
    m_Font->Out(p[3].x-1,p[3].y-1,"y");
    m_Font->Out(p[5].x-1,p[5].y-1,"z");
}
Example #3
0
void CTLSprite::Render(Fvector &pos, float radius, bool bFixedSize, u32 clr)
{
	FVF::TL			P;
    float 			cx,cy,sz;

	P.transform		( pos, Device.mFullTransform );
    cx				= Device._x2real(P.p.x);
    cy				= Device._y2real(P.p.y);
    if (bFixedSize) sz = Device._x2real(radius)-Device._x2real(0);
    else			sz = UI->GetRenderWidth()*radius/P.p.w;
    mesh.m[0].p.x = cx-sz;	mesh.m[0].p.y = cy+sz;
    mesh.m[1].p.x = cx-sz;	mesh.m[1].p.y = cy-sz;
    mesh.m[3].p.x = cx+sz;	mesh.m[3].p.y = cy-sz;
    mesh.m[2].p.x = cx+sz;	mesh.m[2].p.y = cy+sz;
    mesh.setdepth	( P.p.z, P.p.w );
    mesh.setcolor	( clr );

    DU_impl.DrawPrimitiveTL(D3DPT_TRIANGLESTRIP,2,(FVF::TL*)&mesh,4,false,false);
}
Example #4
0
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		();
	}
}