Exemplo n.º 1
0
void Select_ShiftTexture( int x, int y )
{
	brush_s*        b;
	face_s*     f;
	
	int nFaceCount = g_ptrSelectedFaces.GetSize();
	
	if ( selected_brushes.next == &selected_brushes && nFaceCount == 0 )
		return;
		
	for ( b = selected_brushes.next ; b != &selected_brushes ; b = b->next )
	{
		for ( f = b->brush_faces ; f ; f = f->next )
		{
			if ( g_qeglobals.m_bBrushPrimitMode )
			{
				// use face normal to compute a true translation
				Select_ShiftTexture_BrushPrimit( f, x, y );
			}
			else
			{
				f->texdef.shift[0] += x;
				f->texdef.shift[1] += y;
			}
		}
		Brush_Build( b );
		if ( b->patchBrush )
		{
			//Patch_ShiftTexture(b->nPatchID, x, y);
			Patch_ShiftTexture( b->pPatch, x, y );
		}
	}
	
	if ( nFaceCount > 0 )
	{
		for ( int i = 0; i < nFaceCount; i++ )
		{
			face_s* selFace = reinterpret_cast<face_s*>( g_ptrSelectedFaces.GetAt( i ) );
			brush_s* selBrush = reinterpret_cast<brush_s*>( g_ptrSelectedFaceBrushes.GetAt( i ) );
			if ( g_qeglobals.m_bBrushPrimitMode )
			{
			
				// use face normal to compute a true translation
				// Select_ShiftTexture_BrushPrimit( selected_face, x, y );
				// use camera view to compute texture shift
				g_pParentWnd->GetCamera()->ShiftTexture_BrushPrimit( selFace, x, y );
			}
			else
			{
				selFace->texdef.shift[0] += x;
				selFace->texdef.shift[1] += y;
			}
			Brush_Build( selBrush );
		}
	}
	
	Sys_UpdateWindows( W_CAMERA );
}
Exemplo n.º 2
0
// Timo
// brush primitive texture shifting, using camera view to select translations :
void CCamWnd::ShiftTexture_BrushPrimit(face_t *f, int x, int y)
{
	vec3_t texS,texT;
	vec3_t viewX,viewY;
	int XS,XT,YS,YT;
	int outS,outT;
#ifdef _DEBUG
	if (!g_qeglobals.m_bBrushPrimitMode)
	{
		Sys_Printf("Warning : unexpected call to CCamWnd::ShiftTexture_BrushPrimit with brush primitive mode disbaled\n");
		return;
	}
#endif
	// compute face axis base
	ComputeAxisBase( f->plane.normal, texS, texT );
	// compute camera view vectors
	VectorCopy( m_Camera.vup, viewY );
	VectorCopy( m_Camera.vright, viewX );
	// compute best vectors
	ComputeBest2DVector( viewX, texS, texT, XS, XT );
	ComputeBest2DVector( viewY, texS, texT, YS, YT );
	// check this is not a degenerate case
	if ( ( XS == YS ) && ( XT == YT ) )
	{
#ifdef _DEBUG
		Sys_Printf("Warning : degenerate best vectors axis base in CCamWnd::ShiftTexture_BrushPrimit\n");
#endif
		// forget it
		Select_ShiftTexture_BrushPrimit( f, x, y );
		return;
	}
	// compute best fitted translation in face axis base
	outS = XS*x + YS*y;
	outT = XT*x + YT*y;
	// call actual texture shifting code
	Select_ShiftTexture_BrushPrimit( f, outS, outT );
}