void CUIDragDropReferenceList::ReloadReferences(CInventoryOwner* pActor)
{
	if (!pActor)
		return;

	if(m_drag_item)
		DestroyDragItem();

	m_container->ClearAll(true);
	m_selected_item	= NULL;

	for(u8 i=0; i<m_container->CellsCapacity().x; i++)
	{
		CUIStatic* ref = m_references[i];
		LPCSTR item_name = ACTOR_DEFS::g_quick_use_slots[i];
		if(item_name && xr_strlen(item_name))
		{
			PIItem itm = pActor->inventory().GetAny(item_name);
			if(itm)
			{
				SetItem(create_cell_item(itm), Ivector2().set(i, 0));
			}
			else
			{
				LoadItemTexture(item_name, Ivector2().set(i, 0));
				ref->SetTextureColor(color_rgba(255,255,255,100));
			}
		}
		else
		{
			ref->SetTextureColor(color_rgba(255,255,255,0));
		}
	}
}
Example #2
0
void			CGameObject::dbg_DrawSkeleton	()
{
	CCF_Skeleton* Skeleton = smart_cast<CCF_Skeleton*>(collidable.model);
	if (!Skeleton) return;
	Skeleton->_dbg_refresh();

	const CCF_Skeleton::ElementVec& Elements = Skeleton->_GetElements();
	for (CCF_Skeleton::ElementVec::const_iterator I=Elements.begin(); I!=Elements.end(); I++){
		if (!I->valid())		continue;
		switch (I->type){
			case SBoneShape::stBox:{
				Fmatrix M;
				M.invert			(I->b_IM);
				Fvector h_size		= I->b_hsize;
				Level().debug_renderer().draw_obb	(M, h_size, color_rgba(0, 255, 0, 255));
								   }break;
			case SBoneShape::stCylinder:{
				Fmatrix M;
				M.c.set				(I->c_cylinder.m_center);
				M.k.set				(I->c_cylinder.m_direction);
				Fvector				h_size;
				h_size.set			(I->c_cylinder.m_radius,I->c_cylinder.m_radius,I->c_cylinder.m_height*0.5f);
				Fvector::generate_orthonormal_basis(M.k,M.j,M.i);
				Level().debug_renderer().draw_obb	(M, h_size, color_rgba(0, 127, 255, 255));
										}break;
			case SBoneShape::stSphere:{
				Fmatrix				l_ball;
				l_ball.scale		(I->s_sphere.R, I->s_sphere.R, I->s_sphere.R);
				l_ball.translate_add(I->s_sphere.P);
				Level().debug_renderer().draw_ellipse(l_ball, color_rgba(0, 255, 0, 255));
									  }break;
		};
	};	
}
Example #3
0
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));
	}
}
Example #4
0
void CUITradeWnd::ColorizeItem(CUICellItem* itm, bool b)
{
	PIItem iitem		= (PIItem)itm->m_pData;
	if(!b)
		itm->SetTextureColor		(color_rgba(255,100,100,255));
	#ifdef INV_COLORIZE
	else if (iitem->m_eItemPlace == eItemPlaceSlot || iitem->m_eItemPlace == eItemPlaceBelt)
		itm->SetTextureColor		(color_rgba(100,255,100,255));
	#endif
}
Example #5
0
void CUIActorMenu::ColorizeItem(CUICellItem* itm, bool colorize)
{
	if( colorize )
	{
		itm->SetColor( color_rgba(255,100,100,255) );
	}
	else
	{
		itm->SetColor( color_rgba(255,255,255,255) );
	}
}
Example #6
0
void CUIHudStatesWnd::UpdateActiveItemInfo( CActor* actor )
{
	PIItem item = actor->inventory().ActiveItem();
	if ( item )
	{
		if(m_b_force_update)
		{
			if(item->cast_weapon())
				item->cast_weapon()->ForceUpdateAmmo();
			m_b_force_update		= false;
		}

		item->GetBriefInfo			( m_item_info );

//		UIWeaponBack.SetText		( str_name.c_str() );
		m_fire_mode->SetText		( m_item_info.fire_mode.c_str() );
		SetAmmoIcon					( m_item_info.icon.c_str() );
		
		m_ui_weapon_cur_ammo->Show	( true );
		m_ui_weapon_fmj_ammo->Show	( true );
		m_ui_weapon_ap_ammo->Show	( true );
		m_fire_mode->Show			( true );
		m_ui_grenade->Show			( true );

		m_ui_weapon_cur_ammo->SetText	( m_item_info.cur_ammo.c_str() );
		m_ui_weapon_fmj_ammo->SetText	( m_item_info.fmj_ammo.c_str() );
		m_ui_weapon_ap_ammo->SetText	( m_item_info.ap_ammo.c_str() );
		
		m_ui_grenade->SetText	( m_item_info.grenade.c_str() );

		CWeaponMagazinedWGrenade* wpn = smart_cast<CWeaponMagazinedWGrenade*>(item);
		if(wpn && wpn->m_bGrenadeMode)
		{
			m_ui_weapon_fmj_ammo->SetTextColor(color_rgba(238,155,23,150));
			m_ui_grenade->SetTextColor(color_rgba(238,155,23,255));
		}
		else
		{
			m_ui_weapon_fmj_ammo->SetTextColor(color_rgba(238,155,23,255));
			m_ui_grenade->SetTextColor(color_rgba(238,155,23,150));
		}
	}
	else
	{
		m_ui_weapon_icon->Show		( false );

		m_ui_weapon_cur_ammo->Show	( false );
		m_ui_weapon_fmj_ammo->Show	( false );
		m_ui_weapon_ap_ammo->Show	( false );
		m_fire_mode->Show			( false );
		m_ui_grenade->Show			( false );
	}
}
Example #7
0
void CUIFactionWarWnd::set_amount_enemy_bonus( int value )
{
	for ( u32 i = 0; i < max_bonuce; ++i )
	{
		m_enemy_bonuces[i]->SetColor( color_rgba( 255, 255, 255, 70) );
	}
	u32 cr = color_rgba( 0, 255, 0, 255);
	for ( int i = 0; i < value; ++i )
	{
		m_enemy_bonuces[i]->SetColor( cr );
	}
}
Example #8
0
IC u32 it_gloss_rev		(u32 d, u32 s)	{
    return	color_rgba	(
                color_get_A(s),		// gloss
                color_get_B(d),
                color_get_G(d),
                color_get_R(d)		);
}
Example #9
0
u32 CInifile::r_color( LPCSTR S, LPCSTR L )
{
    LPCSTR		C = r_string(S,L);
    u32			r=0,g=0,b=0,a=255;
    sscanf		(C,"%d,%d,%d,%d",&r,&g,&b,&a);
    return color_rgba(r,g,b,a);
}
Example #10
0
IC u32 it_difference	(u32 d, u32 orig, u32 ucomp)	{
    return	color_rgba(
                128+(int(color_get_R(orig))-int(color_get_R(ucomp)))*2,		// R-error
                128+(int(color_get_G(orig))-int(color_get_G(ucomp)))*2,		// G-error
                128+(int(color_get_B(orig))-int(color_get_B(ucomp)))*2,		// B-error
                128+(int(color_get_A(orig))-int(color_get_A(ucomp)))*2	);	// A-error
}
Example #11
0
IC u32 it_height_rev_base(u32 d, u32 s)	{
    return	color_rgba	(
                color_get_A(d),					// diff x
                color_get_B(d),					// diff y
                color_get_G(d),					// diff z
                (color_get_R(s)+color_get_G(s)+color_get_B(s))/3	);	// height
}
void CRenderTarget::accum_direct_blend	()
{
	// blend-copy
	if (!RImplementation.o.fp16_blend)	{
		u_setrt						(rt_Accumulator,NULL,NULL,HW.pBaseZB);

		// Common calc for quad-rendering
		u32		Offset;
		u32		C					= color_rgba	(255,255,255,255);
		float	_w					= float			(Device.dwWidth);
		float	_h					= float			(Device.dwHeight);
		Fvector2					p0,p1;
		p0.set						(.5f/_w, .5f/_h);
		p1.set						((_w+.5f)/_w, (_h+.5f)/_h );
		float	d_Z	= EPS_S, d_W = 1.f;

		// Fill vertex buffer
		FVF::TL2uv* pv				= (FVF::TL2uv*) RCache.Vertex.Lock	(4,g_combine_2UV->vb_stride,Offset);
		pv->set						(EPS,			float(_h+EPS),	d_Z,	d_W, C, p0.x, p1.y, p0.x, p1.y);	pv++;
		pv->set						(EPS,			EPS,			d_Z,	d_W, C, p0.x, p0.y, p0.x, p0.y);	pv++;
		pv->set						(float(_w+EPS),	float(_h+EPS),	d_Z,	d_W, C, p1.x, p1.y, p1.x, p1.y);	pv++;
		pv->set						(float(_w+EPS),	EPS,			d_Z,	d_W, C, p1.x, p0.y, p1.x, p0.y);	pv++;
		RCache.Vertex.Unlock		(4,g_combine_2UV->vb_stride);
		RCache.set_Geometry			(g_combine_2UV);
		RCache.set_Element			(s_accum_mask->E[SE_MASK_ACCUM_2D]	);
		RCache.set_Stencil			(TRUE,D3DCMP_LESSEQUAL,dwLightMarkerID,0xff,0x00);
		RCache.Render				(D3DPT_TRIANGLELIST,Offset,0,4,0,2	);
	}
	dwLightMarkerID				+= 2;
}
Example #13
0
void CRenderTarget::reset_light_marker( bool bResetStencil)
{
    dwLightMarkerID = 5;
    if (bResetStencil)
    {
        u32		Offset;
        float	_w					= float(Device.dwWidth);
        float	_h					= float(Device.dwHeight);
        u32		C					= color_rgba	(255,255,255,255);
        float	eps					= 0;
        float	_dw					= 0.5f;
        float	_dh					= 0.5f;
        FVF::TL* pv					= (FVF::TL*) RCache.Vertex.Lock	(4,g_combine->vb_stride,Offset);
        pv->set						(-_dw,		_h-_dh,		eps,	1.f, C, 0, 0);
        pv++;
        pv->set						(-_dw,		-_dh,		eps,	1.f, C, 0, 0);
        pv++;
        pv->set						(_w-_dw,	_h-_dh,		eps,	1.f, C, 0, 0);
        pv++;
        pv->set						(_w-_dw,	-_dh,		eps,	1.f, C, 0, 0);
        pv++;
        RCache.Vertex.Unlock		(4,g_combine->vb_stride);
        RCache.set_Element			(s_occq->E[2]	);
        RCache.set_Geometry			(g_combine		);
        RCache.Render				(D3DPT_TRIANGLELIST,Offset,0,4,0,2);
    }
}
Example #14
0
IC u32 it_height_rev	(u32 d, u32 s)	{
    return	color_rgba	(
                color_get_A(d),					// diff x
                color_get_B(d),					// diff y
                color_get_G(d),					// diff z
                color_get_R(s)	);				// height
}
Example #15
0
void CEnvironment::RenderClouds			()
{
#ifndef _EDITOR
	if (0==g_pGameLevel)		return	;
#endif
	// draw clouds
	if (fis_zero(CurrentEnv.clouds_color.w,EPS_L))	return;

	::Render->rmFar				();

	Fmatrix						mXFORM, mScale;
	mScale.scale				(10,0.4f,10);
	mXFORM.rotateY				(CurrentEnv.sky_rotation);
	mXFORM.mulB_43				(mScale);
	mXFORM.translate_over		(Device.vCameraPosition);

	Fvector wd0,wd1;
	Fvector4 wind_dir;
	wd0.setHP					(PI_DIV_4,0);
	wd1.setHP					(PI_DIV_4+PI_DIV_8,0);
	wind_dir.set				(wd0.x,wd0.z,wd1.x,wd1.z).mul(0.5f).add(0.5f).mul(255.f);
	u32		i_offset,v_offset;
	u32		C0					= color_rgba(iFloor(wind_dir.x),iFloor(wind_dir.y),iFloor(wind_dir.w),iFloor(wind_dir.z));
	u32		C1					= color_rgba(iFloor(CurrentEnv.clouds_color.x*255.f),iFloor(CurrentEnv.clouds_color.y*255.f),iFloor(CurrentEnv.clouds_color.z*255.f),iFloor(CurrentEnv.clouds_color.w*255.f));

	// Fill index buffer
	u16*	pib					= RCache.Index.Lock	(CloudsIndices.size(),i_offset);
	CopyMemory					(pib,&CloudsIndices.front(),CloudsIndices.size()*sizeof(u16));
	RCache.Index.Unlock			(CloudsIndices.size());

	// Fill vertex buffer
	v_clouds* pv				= (v_clouds*)	RCache.Vertex.Lock	(CloudsVerts.size(),clouds_geom.stride(),v_offset);
	for (FvectorIt it=CloudsVerts.begin(); it!=CloudsVerts.end(); it++,pv++)
		pv->set					(*it,C0,C1);
	RCache.Vertex.Unlock		(CloudsVerts.size(),clouds_geom.stride());

	// Render
	RCache.set_xform_world		(mXFORM);
	RCache.set_Geometry			(clouds_geom);
	RCache.set_Shader			(clouds_sh);
	RCache.set_Textures			(&CurrentEnv.clouds_r_textures);
	RCache.Render				(D3DPT_TRIANGLELIST,v_offset,0,CloudsVerts.size(),i_offset,CloudsIndices.size()/3);

	::Render->rmNormal			();
}
Example #16
0
void CUIButtonHint::OnRender	()
{
    if(m_enabledOnFrame) {
        m_text->Update		();
        m_border->Update	();
        m_border->SetColor	(color_rgba(255,255,255,color_get_A(m_text->GetTextColor())));
        Draw				();
        m_enabledOnFrame	= false;
    }
}
Example #17
0
void CRender::render_menu	()
{
	//	Globals
	RCache.set_CullMode				(CULL_CCW);
	RCache.set_Stencil				(FALSE);
	RCache.set_ColorWriteEnable		();

	// Main Render
	{
		Target->u_setrt						(Target->rt_Generic_0,0,0,HW.pBaseZB);		// LDR RT
		g_pGamePersistent->OnRenderPPUI_main()	;	// PP-UI
	}
	// Distort
	{
		Target->u_setrt						(Target->rt_Generic_1,0,0,HW.pBaseZB);		// Now RT is a distortion mask
		CHK_DX(HW.pDevice->Clear			( 0L, NULL, D3DCLEAR_TARGET, color_rgba(127,127,0,127), 1.0f, 0L));
		g_pGamePersistent->OnRenderPPUI_PP	()	;	// PP-UI
	}

	// Actual Display
	Target->u_setrt					( Device.dwWidth,Device.dwHeight,HW.pBaseRT,NULL,NULL,HW.pBaseZB);
	RCache.set_Shader				( Target->s_menu	);
	RCache.set_Geometry				( Target->g_menu	);

	Fvector2						p0,p1;
	u32								Offset;
	u32		C						= color_rgba	(255,255,255,255);
	float	_w						= float(Device.dwWidth);
	float	_h						= float(Device.dwHeight);
	float	d_Z						= EPS_S;
	float	d_W						= 1.f;
	p0.set							(.5f/_w, .5f/_h);
	p1.set							((_w+.5f)/_w, (_h+.5f)/_h );

	FVF::TL* pv						= (FVF::TL*) RCache.Vertex.Lock	(4,Target->g_menu->vb_stride,Offset);
	pv->set							(EPS,			float(_h+EPS),	d_Z,	d_W, C, p0.x, p1.y);	pv++;
	pv->set							(EPS,			EPS,			d_Z,	d_W, C, p0.x, p0.y);	pv++;
	pv->set							(float(_w+EPS),	float(_h+EPS),	d_Z,	d_W, C, p1.x, p1.y);	pv++;
	pv->set							(float(_w+EPS),	EPS,			d_Z,	d_W, C, p1.x, p0.y);	pv++;
	RCache.Vertex.Unlock			(4,Target->g_menu->vb_stride);
	RCache.Render					(D3DPT_TRIANGLELIST,Offset,0,4,0,2);
}
Example #18
0
IC u32 it_gloss_rev_base(u32 d, u32 s)	{
    u32		occ		= color_get_A(d)/3;
    u32		def		= 8;
    u32		gloss	= (occ*1+def*3)/4;
    return	color_rgba	(
                gloss,			// gloss
                color_get_B(d),
                color_get_G(d),
                color_get_R(d)
            );
}
CUICellItem* CUIDragDropReferenceList::RemoveItem(CUICellItem* itm, bool force_root)
{
	Ivector2 vec2 = m_container->GetItemPos(itm);
	if(vec2.x!=-1&&vec2.y!=-1)
	{
		u8 index = u8(vec2.x);
		xr_strcpy(ACTOR_DEFS::g_quick_use_slots[index], "");
		m_references[index]->SetTextureColor(color_rgba(255,255,255,0));
	}
	inherited::RemoveItem(itm, force_root);
	return NULL;
}
Example #20
0
void CUIDragItem::Init(const ui_shader& sh, const Frect& rect, const Frect& text_rect)
{
	SetWndRect						(rect);
	m_static.SetShader				(sh);
	m_static.SetTextureRect			(text_rect);
	m_static.SetWndPos				(Fvector2().set(0.0f,0.0f));
	m_static.SetWndSize				(GetWndSize());
	m_static.TextureOn				();
	m_static.SetTextureColor		(color_rgba(255,255,255,170));
	m_static.SetStretchTexture		(true);
	m_pos_offset.sub				(rect.lt, GetUICursor().GetCursorPosition());
}
Example #21
0
void dxEnvironmentRender::RenderClouds(CEnvironment &env)
{
	::Render->rmFar				();

	Fmatrix						mXFORM, mScale;
	mScale.scale				(10,0.4f,10);
	mXFORM.rotateY				(env.CurrentEnv->sky_rotation);
	mXFORM.mulB_43				(mScale);
	mXFORM.translate_over		(Device.vCameraPosition);

	Fvector wd0,wd1;
	Fvector4 wind_dir;
	wd0.setHP					(PI_DIV_4,0);
	wd1.setHP					(PI_DIV_4+PI_DIV_8,0);
	wind_dir.set				(wd0.x,wd0.z,wd1.x,wd1.z).mul(0.5f).add(0.5f).mul(255.f);
	u32		i_offset,v_offset;
	u32		C0					= color_rgba(iFloor(wind_dir.x),iFloor(wind_dir.y),iFloor(wind_dir.w),iFloor(wind_dir.z));
	u32		C1					= color_rgba(iFloor(env.CurrentEnv->clouds_color.x*255.f),iFloor(env.CurrentEnv->clouds_color.y*255.f),iFloor(env.CurrentEnv->clouds_color.z*255.f),iFloor(env.CurrentEnv->clouds_color.w*255.f));

	// Fill index buffer
	u16*	pib					= RCache.Index.Lock	(env.CloudsIndices.size(),i_offset);
	CopyMemory					(pib,&env.CloudsIndices.front(),env.CloudsIndices.size()*sizeof(u16));
	RCache.Index.Unlock			(env.CloudsIndices.size());

	// Fill vertex buffer
	v_clouds* pv				= (v_clouds*)	RCache.Vertex.Lock	(env.CloudsVerts.size(),clouds_geom.stride(),v_offset);
	for (FvectorIt it=env.CloudsVerts.begin(); it!=env.CloudsVerts.end(); it++,pv++)
		pv->set					(*it,C0,C1);
	RCache.Vertex.Unlock		(env.CloudsVerts.size(),clouds_geom.stride());

	// Render
	RCache.set_xform_world		(mXFORM);
	RCache.set_Geometry			(clouds_geom);
	RCache.set_Shader			(clouds_sh);
	dxEnvDescriptorMixerRender	&mixRen = *(dxEnvDescriptorMixerRender*)&*env.CurrentEnv->m_pDescriptorMixer;
	RCache.set_Textures			(&mixRen.clouds_r_textures);
	RCache.Render				(D3DPT_TRIANGLELIST,v_offset,0,env.CloudsVerts.size(),i_offset,env.CloudsIndices.size()/3);

	::Render->rmNormal			();
}
Example #22
0
void ESceneObjectTools::HighlightTexture(LPCSTR tex_name, bool allow_ratio, u32 t_width, u32 t_height, BOOL mark)
{
	if (tex_name&&tex_name[0]){
        for (ObjectIt a_it=m_Objects.begin(); a_it!=m_Objects.end(); a_it++){
            CSceneObject* s_obj		= dynamic_cast<CSceneObject*>(*a_it);
            CEditableObject* e_obj	= s_obj->GetReference(); VERIFY(e_obj);
            SurfaceVec& s_vec		= e_obj->Surfaces();
            for (SurfaceIt it=s_vec.begin(); it!=s_vec.end(); it++){
                if (0==stricmp((*it)->_Texture(),tex_name)){
					Fvector 		verts[3];
					for (EditMeshIt mesh_it=e_obj->FirstMesh(); mesh_it!=e_obj->LastMesh(); mesh_it++){
                    	SurfFaces& 		surf_faces	= (*mesh_it)->GetSurfFaces();
                    	SurfFacesPairIt sf_it 		= surf_faces.find(*it);
                        if (sf_it!=surf_faces.end()){
                            IntVec& lst				= sf_it->second;
                            for (IntIt i_it=lst.begin(); i_it!=lst.end(); i_it++){
                                e_obj->GetFaceWorld	(s_obj->_Transform(),*mesh_it,*i_it,verts);
                                u32 clr	= 0x80FFFFFF;
                                if (allow_ratio){
                                	// select color
                                    const Fvector2* tc[3];
                                    Fvector 		c,e01,e02;
                                    e01.sub			(verts[1],verts[0]);
                                    e02.sub			(verts[2],verts[0]);
                                    float area		= c.crossproduct(e01,e02).magnitude()/2.f;
                                    (*mesh_it)->GetFaceTC(*i_it,tc);
                                    e01.sub			(Fvector().set(tc[1]->x,tc[1]->y,0),Fvector().set(tc[0]->x,tc[0]->y,0));
                                    e02.sub			(Fvector().set(tc[2]->x,tc[2]->y,0),Fvector().set(tc[0]->x,tc[0]->y,0));
                                    float p_area	= c.crossproduct(e01,e02).magnitude()/2.f;
                                    float ratio		= _sqrt((p_area*t_width*t_height)/area);
                                    int idx_clr		= 4;
                                    float w			= 0.f;
                                    if (ratio>=0.f && ratio<50.f) 			{idx_clr=0; w=ratio/30.f;}
                                    else if (ratio>=50.f && ratio<150.f) 	{idx_clr=1; w=(ratio-30.f)/150.f;}
                                    else if (ratio>=150.f && ratio<250.f) 	{idx_clr=2; w=(ratio-150.f)/250.f;}
                                    else if (ratio>=250.f && ratio<500.f) 	{idx_clr=3; w=(ratio-250.f)/500.f;}
                                    float inv_w		= 1.f-w;
                                    clr				= color_rgba(color_get_R(ratio_colors[idx_clr+0])*inv_w+color_get_R(ratio_colors[idx_clr+1])*w,
                                    							 color_get_G(ratio_colors[idx_clr+0])*inv_w+color_get_G(ratio_colors[idx_clr+1])*w,
                                                                 color_get_B(ratio_colors[idx_clr+0])*inv_w+color_get_B(ratio_colors[idx_clr+1])*w,
                                                                 color_get_A(ratio_colors[idx_clr+0])*inv_w+color_get_A(ratio_colors[idx_clr+1])*w);
                                }
                                Tools->m_DebugDraw.AppendSolidFace(verts[0],verts[1],verts[2],clr,false);
                                if (mark)	Tools->m_DebugDraw.AppendWireFace(verts[0],verts[1],verts[2],clr,false);
                            }
                        }
                    }
                }
            }
        }
    }
}
Example #23
0
// render
void		CWallmarksEngine::static_wm_render		(CWallmarksEngine::static_wallmark*	W, FVF::LIT* &V)
{
	float		a		= 1-(W->ttl/ps_r__WallmarkTTL);
	int			aC		= iFloor	( a * 255.f);	clamp	(aC,0,255);
	u32			C		= color_rgba(128,128,128,aC);
	FVF::LIT*	S		= &*W->verts.begin	();
	FVF::LIT*	E		= &*W->verts.end	();
	for (; S!=E; S++, V++){
		V->p.set		(S->p);
		V->color		= C;
		V->t.set		(S->t);
	}
}
Example #24
0
void CUIDragItem::Init(const ref_shader& sh, const Frect& rect, const Frect& text_rect)
{
	SetWndRect						(rect);
	m_static.SetShader				(sh);
	m_static.SetOriginalRect		(text_rect);
	m_static.SetWndPos				(0.0f,0.0f);
	m_static.SetWndSize				(GetWndSize());
	m_static.TextureAvailable		(true);
	m_static.TextureOn				();
	m_static.SetColor				(color_rgba(255,255,255,170));
	m_static.SetStretchTexture		(true);
	m_pos_offset.sub				(rect.lt, GetUICursor()->GetCursorPosition());
}
Example #25
0
void CEnvironment::RenderSky		()
{
#ifndef _EDITOR
	if (0==g_pGameLevel)		return	;
#endif
	// clouds_sh.create		("clouds","null");
	//. this is the bug-fix for the case when the sky is broken
	//. for some unknown reason the geoms happen to be invalid sometimes
	//. if vTune show this in profile, please add simple cache (move-to-forward last found) 
	//. to the following functions:
	//.		CResourceManager::_CreateDecl
	//.		CResourceManager::CreateGeom
	if(bNeed_re_create_env)
	{
		sh_2sky.create			(&m_b_skybox,"skybox_2t");
		sh_2geom.create			(v_skybox_fvf,RCache.Vertex.Buffer(), RCache.Index.Buffer());
		clouds_sh.create		("clouds","null");
		clouds_geom.create		(v_clouds_fvf,RCache.Vertex.Buffer(), RCache.Index.Buffer());
		bNeed_re_create_env		= FALSE;
	}
	::Render->rmFar				();

	// draw sky box
	Fmatrix						mSky;
	mSky.rotateY				(CurrentEnv.sky_rotation);
	mSky.translate_over			(Device.vCameraPosition);

	u32		i_offset,v_offset;
	u32		C					= color_rgba(iFloor(CurrentEnv.sky_color.x*255.f), iFloor(CurrentEnv.sky_color.y*255.f), iFloor(CurrentEnv.sky_color.z*255.f), iFloor(CurrentEnv.weight*255.f));

	// Fill index buffer
	u16*	pib					= RCache.Index.Lock	(20*3,i_offset);
	CopyMemory					(pib,hbox_faces,20*3*2);
	RCache.Index.Unlock			(20*3);

	// Fill vertex buffer
	v_skybox* pv				= (v_skybox*)	RCache.Vertex.Lock	(12,sh_2geom.stride(),v_offset);
	for (u32 v=0; v<12; v++)	pv[v].set		(hbox_verts[v*2],C,hbox_verts[v*2+1]);
	RCache.Vertex.Unlock		(12,sh_2geom.stride());

	// Render
	RCache.set_xform_world		(mSky);
	RCache.set_Geometry			(sh_2geom);
	RCache.set_Shader			(sh_2sky);
	RCache.set_Textures			(&CurrentEnv.sky_r_textures);
	RCache.Render				(D3DPT_TRIANGLELIST,v_offset,0,12,i_offset,20);

	// Sun
	::Render->rmNormal			();
	eff_LensFlare->Render		(TRUE,FALSE,FALSE);
}
Example #26
0
void lm_layer::Pack_hemi	(xr_vector<u32>& dest)	//.
{
	dest.resize			(width*height);
	xr_vector<base_color>::iterator I=surface.begin	();
	xr_vector<base_color>::iterator E=surface.end	();
	xr_vector<u32>::iterator		W=dest.begin	();
	for (; I!=E; I++)
	{
		base_color_c	C;	I->_get(C);
		u8	_d	= u8_clr	(C.sun);
		u8	_h	= u8_clr	(C.hemi);
		*W++	= color_rgba(_h,_h,_h,_d);
	}
}
void CUIColorAnimatorWrapper::Update()
{
	if (colorAnimation && !isDone)
	{
		if (!isCyclic)
		{
			if (animationTime < (colorAnimation->iFrameCount / colorAnimation->fFPS))
			{
				currColor		= colorAnimation->CalculateBGR(std::abs(animationTime - kRev), currFrame);
				//Msg("name: %s, color: %x, frame: %d", *colorAnimation->cName,currColor, currFrame);
				currColor		= color_rgba(color_get_B(currColor), color_get_G(currColor), color_get_R(currColor), color_get_A(currColor));
				// обновим время
				animationTime	+= Device.dwTimeContinual/1000.0f - prevGlobalTime;
			}
			else
			{
				// В любом случае (при любом ФПС) последним кадром должен быть последний кадр анимации
				currColor	= colorAnimation->CalculateBGR((colorAnimation->iFrameCount - 1) / colorAnimation->fFPS - kRev, currFrame);
				currColor	= color_rgba(color_get_B(currColor), color_get_G(currColor), color_get_R(currColor), color_get_A(currColor));
				// Индицируем конец анимации
				isDone = true;
			}
		}
		else
		{
			currColor	= colorAnimation->CalculateBGR(Device.dwTimeContinual/1000.0f, currFrame);
			currColor	= color_rgba(color_get_B(currColor), color_get_G(currColor), color_get_R(currColor), color_get_A(currColor));
		}

		if (color)
		{
			*color		= currColor;
		}
	}

	prevGlobalTime = Device.dwTimeContinual/1000.0f;
}
Example #28
0
File: thing.c Project: beoran/eruta
/* Draws a thing to the current active drawing target, corresponding 
to it's shape and kind and taking the camera into account.  Useful for 
checking or debugging the physics. */
void thing_draw(Thing * self, Camera * camera) {
  int cx      ; 
  int cy      ;
  int drawx, x;
  int drawy, y;
  int w, h    ;
  int sw, sh  ;
  int sx, sy  ;
  int t       = 2;
  Color color;
  // don't draw null things.
  if(!self) return;
  cx          = camera_at_x(camera);
  cy          = camera_at_y(camera);
  w           = self->size.x;
  h           = self->size.y;
  if ((self->physical) && (self->hull)) {
    x         = bumpbody_p(self->physical).x - bumphull_aabb(self->hull).hs.x;
    y         = bumpbody_p(self->physical).y - bumphull_aabb(self->hull).hs.y;
    w         = bumphull_aabb(self->hull).hs.x * 2;
    h         = bumphull_aabb(self->hull).hs.y * 2;
  } 
  
  color     = color_rgba(0xee, 0x44, 0x00, 0x88);
  t         = 8;
  /* Do not draw out of camera range. */
  if(!camera_cansee(camera, x, y, w, h)) {
    return;
  }
  drawx = x - cx;
  drawy = y - cy;
  /* Draw sprite if available... */
  if(spritestate_can_draw_p(&self->spritestate)) {
    BeVec spriteat = bevec(drawx, drawy);
    /* Draw elliptical shadow under sprite unless disabled */
    if (!(self->flags & THING_FLAGS_NO_SHADOW)) { 
      color     = color_rgbaf(0.0, 0.0, 0.0, 0.5);
      sx        = drawx + w / 2;
      sy        = drawy + ((4*h)/5);
      sw        = (4 * w) / 11;
      sh        = h / 3;
      al_draw_filled_ellipse(sx, sy, sw, sh, color);
    }
    spritestate_draw(&self->spritestate, &spriteat);
  } else {
    /* ...  otherwise debug box to alert scripters of it's absence. */
    draw_box(drawx, drawy, w, h, color, t);
  }
}
void CUIDragDropReferenceList::LoadItemTexture(LPCSTR section, Ivector2 cell_pos)
{
	CUIStatic* ref = m_references[cell_pos.x];
	ref->SetShader(InventoryUtilities::GetEquipmentIconsShader());
	Frect texture_rect;
	texture_rect.x1	= pSettings->r_float(section, "inv_grid_x")		*INV_GRID_WIDTH;
	texture_rect.y1	= pSettings->r_float(section, "inv_grid_y")		*INV_GRID_HEIGHT;
	texture_rect.x2	= pSettings->r_float(section, "inv_grid_width")	*INV_GRID_WIDTH;
	texture_rect.y2	= pSettings->r_float(section, "inv_grid_height")*INV_GRID_HEIGHT;
	texture_rect.rb.add(texture_rect.lt);
	ref->SetTextureRect(texture_rect);
	ref->TextureOn();
	ref->SetTextureColor(color_rgba(255,255,255,255));
	ref->SetStretchTexture(true);
}
Example #30
0
void lm_layer::Pack		(xr_vector<u32>& dest)	
{
	dest.resize			(width*height);
	xr_vector<base_color>::iterator I=surface.begin();
	xr_vector<base_color>::iterator E=surface.end();
	xr_vector<u32>::iterator		W=dest.begin();
	for (; I!=E; I++)
	{
		base_color_c	C; I->_get(C);
		u8	_r	= u8_clr(C.rgb.x);
		u8	_g	= u8_clr(C.rgb.y);
		u8	_b	= u8_clr(C.rgb.z);
		u8	_d	= u8_clr(C.sun);
		*W++	= color_rgba(_r,_g,_b,_d);
	}
}