Beispiel #1
0
void CSurfaceDlg::OnBtnPatchnatural() {
	Select_SetTexture (&g_qeglobals.d_texturewin.texdef, &g_qeglobals.d_texturewin.brushprimit_texdef, false);
	Patch_NaturalizeSelected();
	g_pParentWnd->GetCamera()->MarkWorldDirty ();
	g_changed_surface = true;
	Sys_UpdateWindows(W_ALL);
}
Beispiel #2
0
void CSurfaceDlg::OnBtnAxial() 
{
  Select_SetTexture (&g_qeglobals.d_texturewin.texdef, &g_qeglobals.d_texturewin.brushprimit_texdef, true);
	g_changed_surface = true;
  SetTexMods();
  Sys_UpdateWindows(W_ALL);
}
Beispiel #3
0
void Texture_SetTexture(texdef_t *texdef, brushprimit_texdef_t	*brushprimit_texdef, bool bFitScale, bool bSetSelection) {
	
	if (texdef->name[0] == '(') {
		Sys_Status("Can't select an entity texture\n", 0);
		return;
	}

	g_qeglobals.d_texturewin.texdef = *texdef;

	//
	// store the texture coordinates for new brush primitive mode be sure that all the
	// callers are using the default 2x2 texture
	//
	if (g_qeglobals.m_bBrushPrimitMode) {
		g_qeglobals.d_texturewin.brushprimit_texdef = *brushprimit_texdef;
	}

	g_dlgFind.updateTextures(texdef->name);
	
	if (!g_dlgFind.isOpen() && bSetSelection) {
		Select_SetTexture(texdef, brushprimit_texdef, bFitScale);
	}

	g_Inspectors->texWnd.EnsureTextureIsVisible(texdef->name);

	if ( g_Inspectors->mediaDlg.IsWindowVisible() ) {
		g_Inspectors->mediaDlg.SelectCurrentItem(true, g_qeglobals.d_texturewin.texdef.name, CDialogTextures::MATERIALS);
	}

	g_qeglobals.d_texturewin.texdef = *texdef;
	// store the texture coordinates for new brush primitive mode be sure that all the
	// callers are using the default 2x2 texture
	//
	if (g_qeglobals.m_bBrushPrimitMode) {
		g_qeglobals.d_texturewin.brushprimit_texdef = *brushprimit_texdef;
	}


	Sys_UpdateWindows(W_TEXTURE);


}
Beispiel #4
0
/*
   ==============
   GetTexMods

   Reads the fields to get the current texdef (i.e. widgets -> MAP)
   in brush primitive mode, grab the fake shift scale rot and compute a new texture matrix
   ===============
 */
void SurfaceDlg::GetTexMods(){
	char buffer[1024];
	texdef_t *pt;

#ifdef DBG_SI
	Sys_Printf( "SurfaceDlg::GetTexMods\n" );
#endif

	if ( g_ptrSelectedFaces.GetSize() > 0 ) {
		//++timo just a test, we disable the undo when working on selected faces
		m_nUndoId = 0;
		face_t *selFace = reinterpret_cast<face_t*>( g_ptrSelectedFaces.GetAt( 0 ) );
		g_qeglobals.d_texturewin.texdef = selFace->texdef;
#ifdef DBG_SI
		Sys_Printf( "g_qeglobals.d_texturewin.texdef = selFace->texdef\n" );
#endif
	}
//  else
//  {
	pt = &g_qeglobals.d_texturewin.texdef;
#ifdef DBG_SI
	Sys_Printf( "pt = &g_qeglobals.d_texturewin.texdef\n" );
#endif
//  }

	const char* text = gtk_entry_get_text( GTK_ENTRY( GetDlgWidget( "texture" ) ) );

#ifdef DBG_SI
	Sys_Printf( "pt->SetName(%s)\n", text );
#endif

	// TTimo: detect and refuse invalid texture names (at least the ones with spaces)
	if ( text[0] <= ' ' || strchr( text, ' ' ) ) {
		Sys_FPrintf( SYS_WRN, "WARNING: spaces in shader names are not allowed, ignoring '%s'\n", text );
		pt->SetName( SHADER_NOT_FOUND );
		gtk_entry_set_text( GTK_ENTRY( GetDlgWidget( "texture" ) ), pt->GetName() );
	}
	else
	{
		strcpy( buffer, "textures/" );
		strcpy( buffer + 9, text );
		pt->SetName( buffer );
	}


	( g_qeglobals.m_bBrushPrimitMode ? m_shift[0] : pt->shift[0] ) =
		gtk_spin_button_get_value_as_float( GTK_SPIN_BUTTON( GetDlgWidget( "hshift" ) ) );
	( g_qeglobals.m_bBrushPrimitMode ? m_shift[1] : pt->shift[1] ) =
		gtk_spin_button_get_value_as_float( GTK_SPIN_BUTTON( GetDlgWidget( "vshift" ) ) );
	( g_qeglobals.m_bBrushPrimitMode ? m_scale[0] : pt->scale[0] ) =
		gtk_spin_button_get_value_as_float( GTK_SPIN_BUTTON( GetDlgWidget( "hscale" ) ) );
	( g_qeglobals.m_bBrushPrimitMode ? m_scale[1] : pt->scale[1] ) =
		gtk_spin_button_get_value_as_float( GTK_SPIN_BUTTON( GetDlgWidget( "vscale" ) ) );
	( g_qeglobals.m_bBrushPrimitMode ? m_rotate : pt->rotate ) =
		gtk_spin_button_get_value_as_float( GTK_SPIN_BUTTON( GetDlgWidget( "rotate" ) ) );

	// a local copy of the texture matrix, given for a qtexture_t with width=2 height=2
	brushprimit_texdef_t local_bp;
	brushprimit_texdef_t  *bpt;
	if ( g_qeglobals.m_bBrushPrimitMode ) {
		face_t *selFace = NULL;
		if ( g_ptrSelectedFaces.GetSize() > 0 ) {
			selFace = reinterpret_cast<face_t*>( g_ptrSelectedFaces.GetAt( 0 ) );
			bpt = &selFace->brushprimit_texdef;
		}
		else
		{
			bpt = &g_qeglobals.d_texturewin.brushprimit_texdef;
		}
		// compute texture matrix
		// the matrix returned must be understood as a qtexture_t with width=2 height=2
		FakeTexCoordsToTexMat( m_shift, m_rotate, m_scale, local_bp.coords );
		// copy the texture matrix in the global struct
		// fit the qtexture if we have a face selected, otherwise g_qeglobals.d_texturewin.brushprimit_texdef uses the basic qtexture_t with width=2 height=2

		ConvertTexMatWithQTexture( &local_bp, NULL, bpt, ( ( selFace ) ? selFace->d_texture : NULL ) );
	}
	// we are gonna do stuff, if we own the last do we undo it first
	if ( m_nUndoId != 0 ) {
		// check the do we're about to undo is the one we pushed earlier
		if ( m_nUndoId == Undo_GetUndoId() ) {
#ifdef DBG_SI
			Sys_Printf( "GetTexMods calling Undo_Undo (silent)\n" );
#endif
			g_bListenUpdate = false;
			Undo_Undo( true );
			g_bListenUpdate = true;
		}
	}
	Select_SetTexture( pt,&local_bp );
	m_nUndoId = Undo_GetUndoId();
}
Beispiel #5
0
static void OnBtnAxial( GtkWidget *widget, gpointer data ){
	Select_SetTexture( &g_qeglobals.d_texturewin.texdef, &g_qeglobals.d_texturewin.brushprimit_texdef, true );
	g_dlgSurface.SetTexMods();
	Sys_UpdateWindows( W_ALL );
}
Beispiel #6
0
void CSurfaceDlg::UpdateSpinners(bool bUp, int nID)
{
	texdef_t *pt;
  texdef_t td;

  if (m_bPatchMode)
  {
    td.rotate = 0.0;
    td.scale[0] = td.scale[1] = 0.0;
    td.shift[0] = td.shift[1] = 0.0;
    GrabPatchMods();

    pt = &g_patch_texdef;
    td.contents = pt->contents;
    td.flags = pt->flags;
    td.value = pt->value;

    if (nID == IDC_SPIN_ROTATE)
	  {
		  if (bUp)
			  td.rotate = pt->rotate;
		  else
			  td.rotate = -pt->rotate;
	  }
    else if (nID == IDC_SPIN_HSCALE)
	  {
		  if (bUp)
			  td.scale[0] = 1-pt->scale[0];
		  else
			  td.scale[0] = 1+pt->scale[0];
	  }
    else if (nID == IDC_SPIN_VSCALE)
	  {
		  if (bUp)
			  td.scale[1] = 1-pt->scale[1];
		  else
			  td.scale[1] = 1+pt->scale[1];
	  } 
	  
    else if (nID == IDC_SPIN_HSHIFT)
	  {
		  if (bUp)
			  td.shift[0] = pt->shift[0];
		  else
			  td.shift[0] = -pt->shift[0];
	  }
    else if (nID == IDC_SPIN_VSHIFT)
	  {
		  if (bUp)
			  td.shift[1] = pt->shift[1];
		  else
			  td.shift[1] = -pt->shift[1];
	  }
    pt = &g_qeglobals.d_texturewin.texdef;
    Patch_SetTextureInfo(&td);
  }
	else
	{
		// in brush primitive mode, will read up-to-date m_shift m_rotate m_scale
		GetTexMods ();
		if (g_bNewFace && g_ptrSelectedFaces.GetSize() > 0)
    {
      face_t *selFace = reinterpret_cast<face_t*>(g_ptrSelectedFaces.GetAt(0));
			pt = &selFace->texdef;
    }
		else
    {
			pt = &g_qeglobals.d_texturewin.texdef;
    }
		if (nID == IDC_SPIN_ROTATE)
		{
			if (g_qeglobals.m_bBrushPrimitMode)
			{
				if (bUp)
					m_rotate += 45;
				else
					m_rotate -= 45;
			}
			else
			{
				if (bUp)
					pt->rotate += 45;
				else
					pt->rotate -= 45;
				if (pt->rotate < 0)
					pt->rotate += 360;
				if (pt->rotate >= 360)
					pt->rotate -= 360;
			}
		}
		else if (nID == IDC_SPIN_HSCALE)
		{
			if (g_qeglobals.m_bBrushPrimitMode)
			{
				if (bUp)
					m_scale[0] += 0.1;
				else
					m_scale[0] -= 0.1;
			}
			else
			{
				if (bUp)
					pt->scale[0] += 0.1;
				else
					pt->scale[0] -= 0.1;
			}
		}
		else if (nID == IDC_SPIN_VSCALE)
		{
			if (g_qeglobals.m_bBrushPrimitMode)
			{
				if (bUp)
					m_scale[1] += 0.1;
				else
					m_scale[1] -= 0.1;
			}
			else
			{
				if (bUp)
					pt->scale[1] += 0.1;
				else
					pt->scale[1] -= 0.1;
			}
		}
		else if (nID == IDC_SPIN_HSHIFT)
		{
			if (g_qeglobals.m_bBrushPrimitMode)
			{
				if (bUp)
					m_shift[0] += 8;
				else
					m_shift[0] -= 8;
			}
			else
			{
				if (bUp)
					pt->shift[0] += 8;
				else
					pt->shift[0] -= 8;
			}
		}
		else if (nID == IDC_SPIN_VSHIFT)
		{
			if (g_qeglobals.m_bBrushPrimitMode)
			{
				if (bUp)
					m_shift[1] += 8;
				else
					m_shift[1] -= 8;
			}
			else
			{
				if (bUp)
					pt->shift[1] += 8;
				else
					pt->shift[1] -= 8;
			}
		}
	}
	// a local copy of the texture matrix, given for a qtexture_t with width=2 height=2
	brushprimit_texdef_t	local_bp;
	brushprimit_texdef_t	*bpt;
	if (g_qeglobals.m_bBrushPrimitMode)
	{
    face_t *selFace = NULL;
		if (g_bNewFace && g_ptrSelectedFaces.GetSize() > 0)
    {
      selFace = reinterpret_cast<face_t*>(g_ptrSelectedFaces.GetAt(0));
			bpt = &selFace->brushprimit_texdef;
    }
		else
    {
			bpt = &g_qeglobals.d_texturewin.brushprimit_texdef;
    }
		// compute texture matrix
		// the matrix returned must be understood as a qtexture_t with width=2 height=2
		FakeTexCoordsToTexMat( m_shift, m_rotate, m_scale, local_bp.coords );
		// copy the texture matrix in the global struct
		// fit the qtexture if we have a face selected, otherwise g_qeglobals.d_texturewin.brushprimit_texdef uses the basic qtexture_t with width=2 height=2
		ConvertTexMatWithQTexture( &local_bp, NULL, bpt, ( ( g_bNewFace && selFace ) ? selFace->d_texture : NULL ) );
	}
	// brush primit : will update the widgets after reading back texture matrix and computing fake shift scale rot
	SetTexMods();
	g_changed_surface = true;
	Select_SetTexture(pt,&local_bp);
}
Beispiel #7
0
/*
==============
GetTexMods

Reads the fields to get the current texdef
in brush primitive mode, grab the fake shift scale rot and compute a new texture matrix
===============
*/
void CSurfaceDlg::GetTexMods()
{
	char	sz[128];
	texdef_t *pt;
	int		b;
	int		i;

	m_bPatchMode = false;

	if (OnlyPatchesSelected())
	{
		pt = &g_qeglobals.d_texturewin.texdef;
		m_bPatchMode = true;
	}
	else
	{
		if (g_bNewFace && g_ptrSelectedFaces.GetSize() > 0)
    {
      face_t *selFace = reinterpret_cast<face_t*>(g_ptrSelectedFaces.GetAt(0));
			pt = &selFace->texdef;
    }
		else
    {
			pt = &g_qeglobals.d_texturewin.texdef;
    }
	}

	::GetWindowText (GetDlgItem(IDC_TEXTURE)->GetSafeHwnd(), sz, 127);
	//strncpy (pt->name, sz, sizeof(pt->name)-1);
	pt->SetName(sz);
	if (pt->name[0] <= ' ')
	{
		//strcpy (pt->name, "none");
		pt->SetName("none");
		::SetWindowText(GetDlgItem(IDC_TEXTURE)->GetSafeHwnd(), pt->name);
	}

	::GetWindowText (GetDlgItem(IDC_HSHIFT)->GetSafeHwnd(), sz, 127);
	( g_qeglobals.m_bBrushPrimitMode ? m_shift[0] : pt->shift[0] ) = atof(sz);

	::GetWindowText (GetDlgItem(IDC_VSHIFT)->GetSafeHwnd(), sz, 127);
	( g_qeglobals.m_bBrushPrimitMode ? m_shift[1] : pt->shift[1] ) = atof(sz);

	::GetWindowText(GetDlgItem(IDC_HSCALE)->GetSafeHwnd(), sz, 127);
	( g_qeglobals.m_bBrushPrimitMode ? m_scale[0] : pt->scale[0] ) = atof(sz);

	::GetWindowText(GetDlgItem(IDC_VSCALE)->GetSafeHwnd(), sz, 127);
	( g_qeglobals.m_bBrushPrimitMode ? m_scale[1] : pt->scale[1] ) = atof(sz);

	::GetWindowText(GetDlgItem(IDC_ROTATE)->GetSafeHwnd(), sz, 127);
	( g_qeglobals.m_bBrushPrimitMode ? m_rotate : pt->rotate ) = atof(sz);

	::GetWindowText(GetDlgItem(IDC_VALUE)->GetSafeHwnd(), sz, 127);
	pt->value = atof(sz);

	pt->flags = 0;
	for (i=0 ; i<32 ; i++)
	{
		b = ::SendMessage(GetDlgItem(g_checkboxes[i])->GetSafeHwnd(), BM_GETCHECK, 0, 0);
		if (b != 1 && b != 0)
			continue;
		pt->flags |= b<<i;
	}

	pt->contents = 0;
	for (i=0 ; i<32 ; i++)
	{
		b = ::SendMessage(GetDlgItem(g_checkboxes[32+i])->GetSafeHwnd(), BM_GETCHECK, 0, 0);
		if (b != 1 && b != 0)
			continue;
		pt->contents |= b<<i;
	}

	g_changed_surface = true;

	// a local copy of the texture matrix, given for a qtexture_t with width=2 height=2
	brushprimit_texdef_t	local_bp;
	brushprimit_texdef_t	*bpt;
	if (g_qeglobals.m_bBrushPrimitMode)
	{
    face_t *selFace = NULL;
		if (g_bNewFace && g_ptrSelectedFaces.GetSize() > 0)
    {
      selFace = reinterpret_cast<face_t*>(g_ptrSelectedFaces.GetAt(0));
			bpt = &selFace->brushprimit_texdef;
    }
		else
    {
			bpt = &g_qeglobals.d_texturewin.brushprimit_texdef;
    }
		// compute texture matrix
		// the matrix returned must be understood as a qtexture_t with width=2 height=2
		FakeTexCoordsToTexMat( m_shift, m_rotate, m_scale, local_bp.coords );
		// copy the texture matrix in the global struct
		// fit the qtexture if we have a face selected, otherwise g_qeglobals.d_texturewin.brushprimit_texdef uses the basic qtexture_t with width=2 height=2

		ConvertTexMatWithQTexture( &local_bp, NULL, bpt, ( ( g_bNewFace && selFace ) ? selFace->d_texture : NULL ) );
	}
	Select_SetTexture(pt,&local_bp);

  //if (m_bPatchMode)
  //{
  //  Patch_SetTextureInfo(pt);
  //}

}
Beispiel #8
0
BOOL CALLBACK SurfaceDlgProc (
    HWND hwndDlg,	// handle to dialog box
    UINT uMsg,	// message
    WPARAM wParam,	// first message parameter
    LPARAM lParam 	// second message parameter
   )
{
	switch (uMsg)
    {
	case WM_INITDIALOG:
		g_surfwin = hwndDlg;
		SetTexMods ();
		return FALSE;

	case WM_COMMAND: 
		switch (LOWORD(wParam)) { 
		
		case IDOK:
			GetTexMods ();
			EndDialog(hwndDlg, 1);
		break;

		case IDAPPLY:
			GetTexMods ();
			InvalidateRect(g_qeglobals.d_hwndCamera, NULL, false);
			UpdateWindow (g_qeglobals.d_hwndCamera);
		break;
// FIT:
		case IDC_FIT:
		{
			char	sz[128];

			GetWindowText(GetDlgItem(g_surfwin, IDC_HFIT), sz, 127);
			m_nHeight = atof(sz);
			GetWindowText(GetDlgItem(g_surfwin, IDC_WFIT), sz, 127);
			m_nWidth = atof(sz);

			Select_FitTexture(m_nHeight, m_nWidth);

			sprintf(sz, "%d", (int)m_nHeight);
			SetWindowText(GetDlgItem(g_surfwin, IDC_HFIT), sz);
			sprintf(sz, "%d", (int)m_nWidth);
			SetWindowText(GetDlgItem(g_surfwin, IDC_WFIT), sz);

			InvalidateRect(g_qeglobals.d_hwndCamera, NULL, false);
			UpdateWindow (g_qeglobals.d_hwndCamera);
		}
		break;
//
		case IDCANCEL:
			g_qeglobals.d_texturewin.texdef = g_old_texdef;
			if (g_changed_surface)
				Select_SetTexture(&g_qeglobals.d_texturewin.texdef);
			EndDialog(hwndDlg, 0);
		break;
		}	
		break;

	case WM_HSCROLL:
	case WM_VSCROLL:
		UpdateSpinners(uMsg, wParam, lParam);
		InvalidateRect(g_qeglobals.d_hwndCamera, NULL, false);
		UpdateWindow (g_qeglobals.d_hwndCamera);
		return 0;

	default:
		return FALSE;
	}
	return FALSE; //eerie
}
Beispiel #9
0
/*
=================
UpdateSpinners
=================
*/
void UpdateSpinners(unsigned uMsg, WPARAM wParam, LPARAM lParam)
{
	int nScrollCode;

	HWND hwnd;
	texdef_t *pt;

	pt = &g_qeglobals.d_texturewin.texdef;

	nScrollCode = (int) LOWORD(wParam);  // scroll bar value 
	hwnd = (HWND) lParam;       // handle of scroll bar 

	if ((nScrollCode != SB_LINEUP) && (nScrollCode != SB_LINEDOWN))
		return;
	
	if (hwnd == GetDlgItem(g_surfwin, IDC_ROTATEA))
	{
		if (nScrollCode == SB_LINEUP)
			pt->rotate += 45;
		else
			pt->rotate -= 45;

		if (pt->rotate < 0)
			pt->rotate += 360;

		if (pt->rotate >= 360)
			pt->rotate -= 360;
	}

	else if (hwnd == GetDlgItem(g_surfwin, IDC_HSCALEA))
	{
		if (nScrollCode == SB_LINEDOWN)
			pt->scale[0] -= (float)0.1;
		else
			pt->scale[0] += (float)0.1;
	}
	
	else if (hwnd == GetDlgItem(g_surfwin, IDC_VSCALEA))
	{
		if (nScrollCode == SB_LINEUP)
			pt->scale[1] += (float)0.1;
		else
			pt->scale[1] -= (float)0.1;
	} 
	
	else if (hwnd == GetDlgItem(g_surfwin, IDC_HSHIFTA))
	{
		if (nScrollCode == SB_LINEDOWN)
			pt->shift[0] -= 8;
		else
			pt->shift[0] += 8;
	}
	
	else if (hwnd == GetDlgItem(g_surfwin, IDC_VSHIFTA))
	{
		if (nScrollCode == SB_LINEUP)
			pt->shift[1] += 8;
		else
			pt->shift[1] -= 8;
	}
// FIT:
	else if (hwnd == GetDlgItem(g_surfwin, IDC_HFITA))
	{
		if (nScrollCode == SB_LINEDOWN)
			m_nHeight -= 1;
		else
			m_nHeight += 1;
	}

	else if (hwnd == GetDlgItem(g_surfwin, IDC_WFITA))
	{
		if (nScrollCode == SB_LINEUP)
			m_nWidth += 1;
		else
			m_nWidth -= 1;
	}
//

	SetTexMods();
	g_changed_surface = true;
	Select_SetTexture(pt);
}
Beispiel #10
0
/*
==============
GetTexMods

Reads the fields to get the current texdef
===============
*/
void GetTexMods(void)
{
	char	sz[128];
	texdef_t *pt;
//	int		b;
//	int		i;

	pt = &g_qeglobals.d_texturewin.texdef;

	GetWindowText (GetDlgItem(g_surfwin, IDC_TEXTURE), sz, 127);
	strncpy (pt->name, sz, sizeof(pt->name)-1);
	if (pt->name[0] <= ' ')
	{
		strcpy (pt->name, "none");
		SetWindowText(GetDlgItem(g_surfwin, IDC_TEXTURE), pt->name);
	}

	GetWindowText (GetDlgItem(g_surfwin, IDC_HSHIFT), sz, 127);
	pt->shift[0] = atof(sz);

	GetWindowText (GetDlgItem(g_surfwin, IDC_VSHIFT), sz, 127);
	pt->shift[1] = atof(sz);

	GetWindowText(GetDlgItem(g_surfwin, IDC_HSCALE), sz, 127);
	pt->scale[0] = atof(sz);

	GetWindowText(GetDlgItem(g_surfwin, IDC_VSCALE), sz, 127);
	pt->scale[1] = atof(sz);

	GetWindowText(GetDlgItem(g_surfwin, IDC_ROTATE), sz, 127);
	pt->rotate = atof(sz);

// FIT:
	GetWindowText(GetDlgItem(g_surfwin, IDC_HFIT), sz, 127);
	m_nHeight = atof(sz);

	GetWindowText(GetDlgItem(g_surfwin, IDC_WFIT), sz, 127);
	m_nWidth = atof(sz);
//

//	GetWindowText(GetDlgItem(g_surfwin, IDC_VALUE), sz, 127);
//	pt->value = atof(sz);
/*
	pt->flags = 0;
	for (i=0 ; i<32 ; i++)
	{
		b = SendMessage(GetDlgItem(g_surfwin, g_checkboxes[i]), BM_GETCHECK, 0, 0);
		if (b != 1 && b != 0)
			continue;
		pt->flags |= b<<i;
	}

	pt->contents = 0;
	for (i=0 ; i<32 ; i++)
	{
		b = SendMessage(GetDlgItem(g_surfwin, g_checkboxes[32+i]), BM_GETCHECK, 0, 0);
		if (b != 1 && b != 0)
			continue;
		pt->contents |= b<<i;
	}
*/
	g_changed_surface = true;
	Select_SetTexture(pt);
}