Пример #1
0
void SI_FaceList_FitTexture(texdef_to_face_t* si_texdef_face_list, int nHeight, int nWidth)
{
    texdef_to_face_t* temp_texdef_face_list;
    brushprimit_texdef_t bp;

    if (!si_texdef_face_list)
        return;

    for (temp_texdef_face_list = si_texdef_face_list; temp_texdef_face_list; temp_texdef_face_list = temp_texdef_face_list->next)
    {
        Face_FitTexture(temp_texdef_face_list->face, nHeight, nWidth);
        Brush_Build(temp_texdef_face_list->brush,true,true,false,false);
        // Write changes to our working Texdef list

        if(g_qeglobals.m_bBrushPrimitMode)
        {
            ConvertTexMatWithQTexture(&temp_texdef_face_list->face->brushprimit_texdef, QERApp_Shader_ForName( temp_texdef_face_list->face->texdef.GetName() )->getTexture(), &bp, NULL);
            TexMatToFakeTexCoords(bp.coords, temp_texdef_face_list->face->texdef.shift, &temp_texdef_face_list->face->texdef.rotate, temp_texdef_face_list->face->texdef.scale);
        }
        temp_texdef_face_list->texdef = temp_texdef_face_list->face->texdef;
    }

    Sys_UpdateWindows (W_CAMERA);

}
Пример #2
0
void Select_RotateTexture( int amt )
{
	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 )
			{
				// apply same scale as the spinner button of the surface inspector
				float   shift[2];
				float   rotate;
				float   scale[2];
				brushprimit_texdef_s bp;
				// compute normalized texture matrix
				ConvertTexMatWithQTexture( &f->brushprimit_texdef, f->d_texture, &bp, NULL );
				// compute fake shift scale rot
				TexMatToFakeTexCoords( bp.coords, shift, &rotate, scale );
				// update
				rotate += amt;
				// compute new normalized texture matrix
				FakeTexCoordsToTexMat( shift, rotate, scale, bp.coords );
				// apply to face texture matrix
				ConvertTexMatWithQTexture( &bp, NULL, &f->brushprimit_texdef, f->d_texture );
			}
			else
			{
				f->texdef.rotate += amt;
				f->texdef.rotate = static_cast<int>( f->texdef.rotate ) % 360;
			}
		}
		Brush_Build( b );
		if ( b->patchBrush )
		{
			//Patch_RotateTexture(b->nPatchID, amt);
			Patch_RotateTexture( b->pPatch, amt );
		}
	}
	
	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 )
			{
				float   shift[2];
				float   rotate;
				float   scale[2];
				brushprimit_texdef_s bp;
				ConvertTexMatWithQTexture( &selFace->brushprimit_texdef, selFace->d_texture, &bp, NULL );
				TexMatToFakeTexCoords( bp.coords, shift, &rotate, scale );
				rotate += amt;
				FakeTexCoordsToTexMat( shift, rotate, scale, bp.coords );
				ConvertTexMatWithQTexture( &bp, NULL, &selFace->brushprimit_texdef, selFace->d_texture );
			}
			else
			{
				selFace->texdef.rotate += amt;
				selFace->texdef.rotate = static_cast<int>( selFace->texdef.rotate ) % 360;
			}
			Brush_Build( selBrush );
		}
	}
	
	Sys_UpdateWindows( W_CAMERA );
}
Пример #3
0
void SI_GetSelFacesTexdef(texdef_to_face_t *allocd_block_texdef)
{
    int		i;
    face_t	*f;
    brush_t	*b;
    texdef_to_face_t *position, *prev_pos;
    brushprimit_texdef_t bp;

    if(selected_brushes.next != &selected_brushes)
    {
        prev_pos = position = allocd_block_texdef;
        for(b=selected_brushes.next; b!=&selected_brushes; b=b->next)
        {
            if ( !(b->patchBrush) )
            {
                for(f=b->brush_faces; f ; f = f->next)
                {
                    position->face = f;
                    position->brush = b;
                    position->texdef = f->texdef;
                    if(g_qeglobals.m_bBrushPrimitMode)
                    {
                        ConvertTexMatWithQTexture(&f->brushprimit_texdef, QERApp_Shader_ForName( f->texdef.GetName() )->getTexture(), &bp, NULL);
                        TexMatToFakeTexCoords(bp.coords, position->texdef.shift, &position->texdef.rotate, position->texdef.scale);
                        position->orig_bp_texdef = bp;
                    }
                    position->orig_texdef = position->texdef;
                    prev_pos->next = position;
                    prev_pos = position;
                    position++;
                }
                prev_pos->next = NULL;
            }
        }
    }
    else if(g_ptrSelectedFaces.GetSize() != 0)
    {
        f = (face_t *) g_ptrSelectedFaces.GetAt(0);
        b = (brush_t *) g_ptrSelectedFaceBrushes.GetAt(0);
        position = (texdef_to_face_t*) allocd_block_texdef;
        position->face = f;
        position->brush = b;
        position->texdef = f->texdef;
        if(g_qeglobals.m_bBrushPrimitMode)
        {
            ConvertTexMatWithQTexture(&f->brushprimit_texdef, QERApp_Shader_ForName( f->texdef.GetName() )->getTexture(), &bp, NULL);
            TexMatToFakeTexCoords(bp.coords, position->texdef.shift, &position->texdef.rotate, position->texdef.scale);
            position->orig_bp_texdef = bp;
        }
        position->orig_texdef = position->texdef;
        prev_pos = position;
        for(i=1; i<g_ptrSelectedFaces.GetSize(); i++)
        {
            f = (face_t *) g_ptrSelectedFaces.GetAt(i);
            b = (brush_t *) g_ptrSelectedFaceBrushes.GetAt(i);
            position = allocd_block_texdef + i;
            position->face = f;
            position->brush = b;
            position->texdef = f->texdef;
            if(g_qeglobals.m_bBrushPrimitMode)
            {
                ConvertTexMatWithQTexture(&f->brushprimit_texdef, QERApp_Shader_ForName( f->texdef.GetName() )->getTexture(), &bp, NULL);
                TexMatToFakeTexCoords(bp.coords, position->texdef.shift, &position->texdef.rotate, position->texdef.scale);
                position->orig_bp_texdef = bp;
            }
            position->orig_texdef = position->texdef;
            prev_pos->next = position;
            prev_pos = position;
        }
        position->next = NULL;
    }

}
Пример #4
0
void SurfaceDlg::SetTexMods(){
	texdef_t *pt;
	brushprimit_texdef_t  *bpt;
	// local copy if a width=2 height=2 qtetxture_t is needed
	brushprimit_texdef_t local_bp;

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

	if ( !g_surfwin ) {
		return;
	}

	if ( g_ptrSelectedFaces.GetSize() > 0 ) {
		face_t *selFace = reinterpret_cast<face_t*>( g_ptrSelectedFaces.GetAt( 0 ) );
		pt = &selFace->texdef;
		if ( g_qeglobals.m_bBrushPrimitMode ) {
			// compute a texture matrix related to the default matrix width=2 height=2
			ConvertTexMatWithQTexture( &selFace->brushprimit_texdef, selFace->d_texture, &local_bp, NULL );
			bpt = &local_bp;
		}
	}
	else
	{
		pt = &g_qeglobals.d_texturewin.texdef;
		if ( g_qeglobals.m_bBrushPrimitMode ) {
			bpt = &g_qeglobals.d_texturewin.brushprimit_texdef;
		}
	}
	// brush primitive mode : compute fake shift scale rot representation
	if ( g_qeglobals.m_bBrushPrimitMode ) {
		TexMatToFakeTexCoords( bpt->coords, m_shift, &m_rotate, m_scale );
	}

	g_bListenChanged = false;

	if ( strncmp( pt->GetName(), "textures/", 9 ) != 0 ) {
		pt->SetName( SHADER_NOT_FOUND );
	}
	gtk_entry_set_text( GTK_ENTRY( GetDlgWidget( "texture" ) ), pt->GetName() + 9 );

	GtkSpinButton *spin;
	spin = GTK_SPIN_BUTTON( GetDlgWidget( "hshift" ) );
	gtk_spin_button_set_digits( spin, 2 );
	if ( g_qeglobals.m_bBrushPrimitMode ) {
		gtk_spin_button_set_value( spin, m_shift[0] );
	}
	else{
		gtk_spin_button_set_value( spin, pt->shift[0] );
	}
	GtkAdjustment *adjust = gtk_spin_button_get_adjustment( GTK_SPIN_BUTTON( spin ) );
	adjust->step_increment = l_pIncrement->shift[0];
	char buf[10]; // got into snprintf paranoia after BoundChecker detected a stack overrun
#ifdef _WIN32
	// TTimo: THIS IS UGLY
#define snprintf _snprintf
#endif
	snprintf( buf, 10, "%g", l_pIncrement->shift[0] );
	gtk_entry_set_text( GTK_ENTRY( GetDlgWidget( "hshift_inc" ) ), buf );

	spin = GTK_SPIN_BUTTON( GetDlgWidget( "vshift" ) );
	gtk_spin_button_set_digits( spin, 2 );
	if ( g_qeglobals.m_bBrushPrimitMode ) {
		gtk_spin_button_set_value( spin, m_shift[1] );
	}
	else{
		gtk_spin_button_set_value( spin, pt->shift[1] );
	}
	adjust = gtk_spin_button_get_adjustment( GTK_SPIN_BUTTON( spin ) );
	adjust->step_increment = l_pIncrement->shift[1];
	snprintf( buf, 10, "%g", l_pIncrement->shift[1] );
	gtk_entry_set_text( GTK_ENTRY( GetDlgWidget( "vshift_inc" ) ), buf );

	spin = GTK_SPIN_BUTTON( GetDlgWidget( "hscale" ) );
	gtk_spin_button_set_digits( spin, 5 );
	gtk_spin_button_set_value( spin, g_qeglobals.m_bBrushPrimitMode ? m_scale[0] : pt->scale[0] );

	adjust = gtk_spin_button_get_adjustment( GTK_SPIN_BUTTON( spin ) );
	adjust->step_increment = l_pIncrement->scale[0];
	snprintf( buf, 10, "%g", l_pIncrement->scale[0] );
	gtk_entry_set_text( GTK_ENTRY( GetDlgWidget( "hscale_inc" ) ), buf );

	spin = GTK_SPIN_BUTTON( GetDlgWidget( "vscale" ) );
	gtk_spin_button_set_digits( spin, 5 );
	gtk_spin_button_set_value( spin, g_qeglobals.m_bBrushPrimitMode ? m_scale[1] : pt->scale[1] );

	adjust = gtk_spin_button_get_adjustment( GTK_SPIN_BUTTON( spin ) );
	adjust->step_increment = l_pIncrement->scale[1];
	snprintf( buf, 10, "%g", l_pIncrement->scale[1] );
	gtk_entry_set_text( GTK_ENTRY( GetDlgWidget( "vscale_inc" ) ), buf );

	//++timo compute BProtate as int ..
	spin = GTK_SPIN_BUTTON( GetDlgWidget( "rotate" ) );
	gtk_spin_button_set_digits( spin, 2 );
	gtk_spin_button_set_value( spin, g_qeglobals.m_bBrushPrimitMode ? m_rotate : pt->rotate );

	adjust = gtk_spin_button_get_adjustment( GTK_SPIN_BUTTON( spin ) );
	adjust->step_increment = l_pIncrement->rotate;
	snprintf( buf, 10, "%g", l_pIncrement->rotate );
	gtk_entry_set_text( GTK_ENTRY( GetDlgWidget( "rotate_inc" ) ), buf );

	g_bListenChanged = true;

	// undo tricks: set the undo id to zero so we don't attempt to undo something that does not belong to us
	m_nUndoId = 0;
	// store the current texdef as our escape route if user hits OnCancel
	g_old_texdef = g_qeglobals.d_texturewin.texdef;
	// reset the Enter key behaviour flag
	m_bEditingTextureWidget = false;
}
Пример #5
0
void CSurfaceDlg::SetTexMods()
{
	char	sz[128];
	texdef_t *pt;
	brushprimit_texdef_t	*bpt;
	// local copy if a width=2 height=2 qtetxture_t is needed
	brushprimit_texdef_t	local_bp;
	int		i;

	if (!g_surfwin)
		return;

	m_bPatchMode = false;

	if (OnlyPatchesSelected())
	{
		pt = &g_qeglobals.d_texturewin.texdef;
		if (QE_SingleBrush())
    {
			//strcpy(g_patch_texdef.name, Patch_GetTextureName());
			g_patch_texdef.SetName(Patch_GetTextureName());
    }
		else
    {
			//strcpy(g_patch_texdef.name, pt->name);
			g_patch_texdef.SetName(pt->name);
    }
		g_patch_texdef.contents = pt->contents;
		g_patch_texdef.flags = pt->flags;
		g_patch_texdef.value = pt->value;
		pt = &g_patch_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;
			if (g_qeglobals.m_bBrushPrimitMode)
			{
				// compute a texture matrix related to the default matrix width=2 height=2
				ConvertTexMatWithQTexture( &selFace->brushprimit_texdef, selFace->d_texture, &local_bp, NULL );
				bpt = &local_bp;
			}
		}
		else
		{
			pt = &g_qeglobals.d_texturewin.texdef;
			if (g_qeglobals.m_bBrushPrimitMode)
			{
				bpt = &g_qeglobals.d_texturewin.brushprimit_texdef;
			}
		}
		// brush primitive mode : compute fake shift scale rot representation
		if (g_qeglobals.m_bBrushPrimitMode)
			TexMatToFakeTexCoords( bpt->coords, m_shift, &m_rotate, m_scale );
	}

	SendMessage (WM_SETREDRAW, 0, 0);

	::SetWindowText(GetDlgItem(IDC_TEXTURE)->GetSafeHwnd(), pt->name);

	if (m_bPatchMode)
		sprintf(sz, "%4.6f", pt->shift[0]);
	else
		if (g_qeglobals.m_bBrushPrimitMode)
			sprintf(sz, "%d", (int)m_shift[0]);
		else
			sprintf(sz, "%d", (int)pt->shift[0]);
	::SetWindowText(GetDlgItem(IDC_HSHIFT)->GetSafeHwnd(), sz);

	if (m_bPatchMode)
		sprintf(sz, "%4.6f", pt->shift[1]);
	else
		if (g_qeglobals.m_bBrushPrimitMode)
			sprintf(sz, "%d", (int)m_shift[1]);
		else
			sprintf(sz, "%d", (int)pt->shift[1]);
	::SetWindowText(GetDlgItem(IDC_VSHIFT)->GetSafeHwnd(), sz);

	sprintf(sz, m_bPatchMode ? "%4.6f" : "%4.6f", g_qeglobals.m_bBrushPrimitMode ? m_scale[0] : pt->scale[0]);
	::SetWindowText(GetDlgItem(IDC_HSCALE)->GetSafeHwnd(), sz);

	sprintf(sz, m_bPatchMode ? "%4.6f" : "%4.6f", g_qeglobals.m_bBrushPrimitMode ? m_scale[1] : pt->scale[1]);
	::SetWindowText(GetDlgItem(IDC_VSCALE)->GetSafeHwnd(), sz);

	//++timo compute BProtate as int ..
	sprintf(sz, "%d", g_qeglobals.m_bBrushPrimitMode ? (int)m_rotate : (int)pt->rotate);
	::SetWindowText(GetDlgItem(IDC_ROTATE)->GetSafeHwnd(), sz);

	sprintf(sz, "%d", (int)pt->value);
	::SetWindowText(GetDlgItem(IDC_VALUE)->GetSafeHwnd(), sz);

	for (i=0 ; i<32 ; i++)
		::SendMessage(GetDlgItem(g_checkboxes[i])->GetSafeHwnd(), BM_SETCHECK, !!(pt->flags&(1<<i)), 0 );
	for (i=0 ; i<32 ; i++)
		::SendMessage(GetDlgItem(g_checkboxes[32+i])->GetSafeHwnd(), BM_SETCHECK, !!(pt->contents&(1<<i)), 0 );

	SendMessage (WM_SETREDRAW, 1, 0);
	InvalidateRect (NULL, true);
}