Esempio n. 1
0
void CLightmap::Capture		(CDeflector *D, int b_u, int b_v, int s_u, int s_v, BOOL bRotated)
{
	// Allocate 512x512 texture if needed
	if (lm.surface.empty())	lm.create(c_LMAP_size,c_LMAP_size);
	
	// Addressing
	xr_vector<UVtri>	tris;
	D->RemapUV			(tris,b_u+BORDER,b_v+BORDER,s_u-2*BORDER,s_v-2*BORDER,c_LMAP_size,c_LMAP_size,bRotated);
	
	// Capture faces and setup their coords
	for (UVIt T=tris.begin(); T!=tris.end(); T++)
	{
		UVtri&	P			= *T;
		Face	*F			= P.owner;
		F->lmap_layer		= this;
		F->AddChannel		(P.uv[0], P.uv[1], P.uv[2]);
	}
	
	// Perform BLIT
	lm_layer&	L		=	D->layer;
	if (!bRotated) 
	{
		u32 real_H	= (L.height	+ 2*BORDER);
		u32 real_W	= (L.width	+ 2*BORDER);
		blit	(lm,c_LMAP_size,c_LMAP_size,L,real_W,real_H,b_u,b_v,254-BORDER);
	} else {
		u32 real_H	= (L.height	+ 2*BORDER);
		u32 real_W	= (L.width	+ 2*BORDER);
		blit_r	(lm,c_LMAP_size,c_LMAP_size,L,real_W,real_H,b_u,b_v,254-BORDER);
	}
}