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); }
void Face_GetScale_BrushPrimit(face_t *face, float *s, float *t, float *rot) { idVec3D texS, texT; ComputeAxisBase(face->plane.Normal(), texS, texT); if (face == NULL || face->face_winding == NULL) { return; } // find ST coordinates for the center of the face double Os = 0, Ot = 0; for (int i = 0; i < face->face_winding->GetNumPoints(); i++) { Os += DotProduct((*face->face_winding)[i], texS); Ot += DotProduct((*face->face_winding)[i], texT); } Os /= face->face_winding->GetNumPoints(); Ot /= face->face_winding->GetNumPoints(); brushprimit_texdef_t *pBP = &face->brushprimit_texdef; // here we have a special case, M is a translation and it's inverse is easy float BPO[2][3]; float aux[2][3]; float m[2][3]; memset(&m, 0, sizeof (float) *6); m[0][0] = 1; m[1][1] = 1; m[0][2] = -Os; m[1][2] = -Ot; BPMatMul(m, pBP->coords, aux); m[0][2] = Os; m[1][2] = Ot; // now M^-1 BPMatMul(aux, m, BPO); // apply a given scale (on S and T) ConvertTexMatWithQTexture(BPO, face->d_texture, aux, NULL); *s = idMath::Sqrt(aux[0][0] * aux[0][0] + aux[1][0] * aux[1][0]); *t = idMath::Sqrt(aux[0][1] * aux[0][1] + aux[1][1] * aux[1][1]); // compute rotate value if (idMath::Fabs(face->brushprimit_texdef.coords[0][0]) < ZERO_EPSILON) { // rotate is +-90 if (face->brushprimit_texdef.coords[1][0] > 0) { *rot = 90.0f; } else { *rot = -90.0f; } } else { *rot = RAD2DEG(atan2(face->brushprimit_texdef.coords[1][0] / (*s) ? (*s) : 1.0f, face->brushprimit_texdef.coords[0][0] / (*t) ? (*t) : 1.0f)); } }
/* ============ Select_Ray If the origin is inside a brush, that brush will be ignored. ============ */ void Select_Ray( vec3_t origin, vec3_t dir, int flags ) { trace_t t; t = Test_Ray( origin, dir, flags ); if ( !t.brush ) return; if ( flags == SF_SINGLEFACE ) { int nCount = g_SelectedFaces.GetSize(); bool bOk = true; for ( int i = 0; i < nCount; i++ ) { if ( t.face == reinterpret_cast<face_s*>( g_SelectedFaces.GetAt( i ) ) ) { bOk = false; // need to move remove i'th entry g_SelectedFaces.RemoveAt( i, 1 ); g_SelectedFaceBrushes.RemoveAt( i, 1 ); } } if ( bOk ) { g_SelectedFaces.Add( t.face ); g_SelectedFaceBrushes.Add( t.brush ); } //selected_face = t.face; //selected_face_brush = t.brush; Sys_UpdateWindows( W_ALL ); clearSelection(); // Texture_SetTexture requires a brushprimit_texdef fitted to the default width=2 height=2 texture brushprimit_texdef_s brushprimit_texdef; ConvertTexMatWithQTexture( &t.face->brushprimit_texdef, t.face->d_texture, &brushprimit_texdef, NULL ); Texture_SetTexture( &t.face->texdef, &brushprimit_texdef, false, false ); UpdateSurfaceDialog(); return; } // move the brush to the other list clearSelection(); if ( t.selected ) { Brush_RemoveFromList( t.brush ); Brush_AddToList( t.brush, &active_brushes ); UpdatePatchInspector(); } else { Select_Brush( t.brush, !( GetKeyState( VK_MENU ) & 0x8000 ) ); } Sys_UpdateWindows( W_ALL ); }
// // ======================================================================================================================= // compute texture coordinates for the winding points // ======================================================================================================================= // void EmitBrushPrimitTextureCoordinates(face_t *f, idWinding *w, patchMesh_t *patch) { idVec3D texX, texY; double x, y; if (f== NULL || (w == NULL && patch == NULL)) { return; } // compute axis base ComputeAxisBase(f->plane.Normal(), texX, texY); // // in case the texcoords matrix is empty, build a default one same behaviour as if // scale[0]==0 && scale[1]==0 in old code // if ( f->brushprimit_texdef.coords[0][0] == 0 && f->brushprimit_texdef.coords[1][0] == 0 && f->brushprimit_texdef.coords[0][1] == 0 && f->brushprimit_texdef.coords[1][1] == 0 ) { f->brushprimit_texdef.coords[0][0] = 1.0f; f->brushprimit_texdef.coords[1][1] = 1.0f; ConvertTexMatWithQTexture(&f->brushprimit_texdef, NULL, &f->brushprimit_texdef, f->d_texture); } int i; if (w) { for (i = 0; i < w->GetNumPoints(); i++) { x = DotProduct((*w)[i], texX); y = DotProduct((*w)[i], texY); (*w)[i][3] = f->brushprimit_texdef.coords[0][0] * x + f->brushprimit_texdef.coords[0][1] * y + f->brushprimit_texdef.coords[0][2]; (*w)[i][4] = f->brushprimit_texdef.coords[1][0] * x + f->brushprimit_texdef.coords[1][1] * y + f->brushprimit_texdef.coords[1][2]; } } if (patch) { int j; for ( i = 0; i < patch->width; i++ ) { for ( j = 0; j < patch->height; j++ ) { x = DotProduct(patch->ctrl(i, j).xyz, texX); y = DotProduct(patch->ctrl(i, j).xyz, texY); patch->ctrl(i, j).st.x = f->brushprimit_texdef.coords[0][0] * x + f->brushprimit_texdef.coords[0][1] * y + f->brushprimit_texdef.coords[0][2]; patch->ctrl(i, j).st.y = f->brushprimit_texdef.coords[1][0] * x + f->brushprimit_texdef.coords[1][1] * y + f->brushprimit_texdef.coords[1][2]; } } } }
/* ================ Drag_Begin ================ */ void Drag_Begin( int x, int y, int buttons, const idVec3 &xaxis, const idVec3 &yaxis, const idVec3 &origin, const idVec3 &dir ) { qertrace_t t; drag_ok = false; VectorCopy(vec3_origin, pressdelta); VectorCopy(vec3_origin, vPressStart); drag_first = true; // shift LBUTTON = select entire brush if (buttons == (MK_LBUTTON | MK_SHIFT) && g_qeglobals.d_select_mode != sel_curvepoint) { int nFlag = ( ::GetAsyncKeyState( VK_MENU ) != 0 ) ? SF_CYCLE : 0; if (dir[0] == 0 || dir[1] == 0 || dir[2] == 0) { // extremely low chance of this happening from camera Select_Ray(origin, dir, nFlag | SF_ENTITIES_FIRST); // hack for XY } else { Select_Ray(origin, dir, nFlag); } return; } // ctrl-shift LBUTTON = select single face if (buttons == (MK_LBUTTON | MK_CONTROL | MK_SHIFT) && g_qeglobals.d_select_mode != sel_curvepoint) { if ( radiant_entityMode.GetBool() ) { return; } // _D3XP disabled //Select_Deselect( ( ::GetAsyncKeyState( VK_MENU ) == 0 ) ); Select_Ray(origin, dir, SF_SINGLEFACE); return; } // LBUTTON + all other modifiers = manipulate selection if (buttons & MK_LBUTTON) { Drag_Setup(x, y, buttons, xaxis, yaxis, origin, dir); return; } if ( radiant_entityMode.GetBool() ) { return; } int nMouseButton = g_PrefsDlg.m_nMouseButtons == 2 ? MK_RBUTTON : MK_MBUTTON; // middle button = grab texture if (buttons == nMouseButton) { t = Test_Ray(origin, dir, false); if (t.face) { g_qeglobals.d_new_brush_bottom = t.brush->mins; g_qeglobals.d_new_brush_top = t.brush->maxs; // use a local brushprimit_texdef fitted to a default 2x2 texture brushprimit_texdef_t bp_local; if (t.brush && t.brush->pPatch) { texdef_t localtd; memset(&bp_local.coords, 0, sizeof(bp_local.coords)); bp_local.coords[0][0] = 1.0f; bp_local.coords[1][1] = 1.0f; localtd.SetName(t.brush->pPatch->d_texture->GetName()); Texture_SetTexture(&localtd, &bp_local, false, true); Select_CopyPatchTextureCoords ( t.brush->pPatch ); } else { Select_ProjectFaceOntoPatch( t.face ); ConvertTexMatWithQTexture(&t.face->brushprimit_texdef, t.face->d_texture, &bp_local, NULL); Texture_SetTexture(&t.face->texdef, &bp_local, false, true); } UpdateSurfaceDialog(); UpdatePatchInspector(); UpdateLightInspector(); } else { Sys_Status("Did not select a texture\n"); } return; } // ctrl-middle button = set entire brush to texture if (buttons == (nMouseButton | MK_CONTROL)) { t = Test_Ray(origin, dir, false); if (t.brush) { if (t.brush->brush_faces->texdef.name[0] == '(') { Sys_Status("Can't change an entity texture\n"); } else { Brush_SetTexture ( t.brush, &g_qeglobals.d_texturewin.texdef, &g_qeglobals.d_texturewin.brushprimit_texdef, false ); Sys_UpdateWindows(W_ALL); } } else { Sys_Status("Didn't hit a btrush\n"); } return; } // ctrl-shift-middle button = set single face to texture if (buttons == (nMouseButton | MK_SHIFT | MK_CONTROL)) { t = Test_Ray(origin, dir, false); if (t.brush) { if (t.brush->brush_faces->texdef.name[0] == '(') { Sys_Status("Can't change an entity texture\n"); } else { SetFaceTexdef ( t.brush, t.face, &g_qeglobals.d_texturewin.texdef, &g_qeglobals.d_texturewin.brushprimit_texdef ); Brush_Build(t.brush); Sys_UpdateWindows(W_ALL); } } else { Sys_Status("Didn't hit a btrush\n"); } return; } if (buttons == (nMouseButton | MK_SHIFT)) { Sys_Status("Set brush face texture info\n"); t = Test_Ray(origin, dir, false); if (t.brush && !t.brush->owner->eclass->fixedsize) { /* if (t.brush->brush_faces->texdef.name[0] == '(') { if (t.brush->owner->eclass->nShowFlags & ECLASS_LIGHT) { CString strBuff; idMaterial *pTex = declManager->FindMaterial(g_qeglobals.d_texturewin.texdef.name); if (pTex) { idVec3 vColor = pTex->getColor(); float fLargest = 0.0f; for (int i = 0; i < 3; i++) { if (vColor[i] > fLargest) { fLargest = vColor[i]; } } if (fLargest == 0.0f) { vColor[0] = vColor[1] = vColor[2] = 1.0f; } else { float fScale = 1.0f / fLargest; for (int i = 0; i < 3; i++) { vColor[i] *= fScale; } } strBuff.Format("%f %f %f", pTex->getColor().x, pTex->getColor().y, pTex->getColor().z); SetKeyValue(t.brush->owner, "_color", strBuff.GetBuffer(0)); Sys_UpdateWindows(W_ALL); } } else { Sys_Status("Can't select an entity brush face\n"); } } else { */ // strcpy(t.face->texdef.name,g_qeglobals.d_texturewin.texdef.name); t.face->texdef.SetName(g_qeglobals.d_texturewin.texdef.name); Brush_Build(t.brush); Sys_UpdateWindows(W_ALL); // } } else { Sys_Status("Didn't hit a brush\n"); } return; } }
/* ======================================================================================================================= ======================================================================================================================= */ void ConvertTexMatWithQTexture(brushprimit_texdef_t *texMat1, const idMaterial *qtex1, brushprimit_texdef_t *texMat2, const idMaterial *qtex2, float sScale, float tScale) { ConvertTexMatWithQTexture(texMat1->coords, qtex1, texMat2->coords, qtex2, sScale, tScale); }
/* ======================================================================================================================= ======================================================================================================================= */ void Face_SetExplicitScale_BrushPrimit(face_t *face, float s, float t) { idVec3D texS, texT; ComputeAxisBase(face->plane.Normal(), texS, texT); // find ST coordinates for the center of the face double Os = 0, Ot = 0; for (int i = 0; i < face->face_winding->GetNumPoints(); i++) { Os += DotProduct((*face->face_winding)[i], texS); Ot += DotProduct((*face->face_winding)[i], texT); } Os /= face->face_winding->GetNumPoints(); Ot /= face->face_winding->GetNumPoints(); brushprimit_texdef_t *pBP = &face->brushprimit_texdef; // here we have a special case, M is a translation and it's inverse is easy float BPO[2][3]; float aux[2][3]; float m[2][3]; memset(&m, 0, sizeof (float) *6); m[0][0] = 1; m[1][1] = 1; m[0][2] = -Os; m[1][2] = -Ot; BPMatMul(m, pBP->coords, aux); m[0][2] = Os; m[1][2] = Ot; // now M^-1 BPMatMul(aux, m, BPO); // apply a given scale (on S and T) ConvertTexMatWithQTexture(BPO, face->d_texture, aux, NULL); // reset the scale (normalize the matrix) double v1, v2; v1 = idMath::Sqrt(aux[0][0] * aux[0][0] + aux[1][0] * aux[1][0]); v2 = idMath::Sqrt(aux[0][1] * aux[0][1] + aux[1][1] * aux[1][1]); if (s == 0.0) { s = v1; } if (t == 0.0) { t = v2; } double sS, sT; // put the values for scale on S and T here: sS = s / v1; sT = t / v2; aux[0][0] *= sS; aux[1][0] *= sS; aux[0][1] *= sT; aux[1][1] *= sT; ConvertTexMatWithQTexture(aux, NULL, BPO, face->d_texture); BPMatMul(m, BPO, aux); // m is M^-1 m[0][2] = -Os; m[1][2] = -Ot; BPMatMul(aux, m, pBP->coords); // now emit the coordinates on the winding EmitBrushPrimitTextureCoordinates(face, face->face_winding); }
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 ); }
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; } }
/* ============== 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(); }
/* =========== Drag_Begin //++timo test three button mouse and three button emulation here ? =========== */ void Drag_Begin (int x, int y, int buttons, vec3_t xaxis, vec3_t yaxis, vec3_t origin, vec3_t dir) { trace_t t; drag_ok = false; VectorCopy (vec3_origin, pressdelta); VectorCopy (vec3_origin, vPressStart); drag_first = true; peLink = NULL; // shift LBUTTON = select entire brush if (buttons == (MK_LBUTTON | MK_SHIFT) && g_qeglobals.d_select_mode != sel_curvepoint) { int nFlag = (static_cast<bool>(::GetAsyncKeyState(VK_MENU))) ? SF_CYCLE : 0; if (dir[0] == 0 || dir[1] == 0 || dir[2] == 0) // extremely low chance of this happening from camera Select_Ray (origin, dir, nFlag | SF_ENTITIES_FIRST); // hack for XY else Select_Ray (origin, dir, nFlag); return; } // ctrl-shift LBUTTON = select single face if (buttons == (MK_LBUTTON | MK_CONTROL | MK_SHIFT) && g_qeglobals.d_select_mode != sel_curvepoint) { Sys_Printf ("Face Selection?\n"); Select_Deselect (!static_cast<bool>(::GetAsyncKeyState(VK_MENU))); Select_Ray (origin, dir, SF_SINGLEFACE); return; } // LBUTTON + all other modifiers = manipulate selection if (buttons & MK_LBUTTON) { // Drag_Setup (x, y, buttons, xaxis, yaxis, origin, dir); return; } // JONATHAN: stuff to add here int nMouseButton = g_PrefsDlg.m_nMouseButtons == 2 ? MK_RBUTTON : MK_MBUTTON; // middle button = grab texture if (buttons == nMouseButton) { t = Test_Ray (origin, dir, false); if (t.face) { //++timo clean #if 0 // g_qeglobals.d_new_brush_bottom_z = t.brush->mins[2]; // g_qeglobals.d_new_brush_top_z = t.brush->maxs[2]; // g_pParentWnd->ActiveXY()->GetViewType() // cf VIEWTYPE definition: enum VIEWTYPE {YZ, XZ, XY}; // we fit our work zone to the brush int nViewType = g_pParentWnd->ActiveXY()->GetViewType(); int nDim1 = (nViewType == YZ) ? 1 : 0; int nDim2 = (nViewType == XY) ? 1 : 2; g_qeglobals.d_work_min[nDim1] = t.brush->mins[nDim1]; g_qeglobals.d_work_max[nDim1] = t.brush->maxs[nDim1]; g_qeglobals.d_work_min[nDim2] = t.brush->mins[nDim2]; g_qeglobals.d_work_max[nDim2] = t.brush->maxs[nDim2]; #endif // JONATHAN:: On ALT-Middle mouse // Fit texture to face SHORT altdown = (GetKeyState(VK_MENU) & 0x8000); if (altdown) { // Fit Texture to brush face Face_FitTexture(t.face, 1, 1); // Build Brush to apply update Brush_Build(t.brush); //? // Update Camera View Sys_UpdateWindows (W_CAMERA); } else { UpdateWorkzone_ForBrush( t.brush ); // use a local brushprimit_texdef fitted to a default 2x2 texture brushprimit_texdef_t bp_local; ConvertTexMatWithQTexture( &t.face->brushprimit_texdef, t.face->d_texture, &bp_local, NULL ); Texture_SetTexture ( &t.face->texdef, &bp_local, false, GETPLUGINTEXDEF(t.face)); UpdateSurfaceDialog(); UpdatePatchInspector(); } } else Sys_Printf ("Did not select a texture\n"); return; } // ctrl-middle button = set entire brush to texture if (buttons == (nMouseButton|MK_CONTROL) ) { t = Test_Ray (origin, dir, false); if (t.brush) { if (t.brush->brush_faces->texdef.name[0] == '(') Sys_Printf ("Can't change an entity texture\n"); else { Brush_SetTexture (t.brush, &g_qeglobals.d_texturewin.texdef, &g_qeglobals.d_texturewin.brushprimit_texdef, false, static_cast<IPluginTexdef *>( g_qeglobals.d_texturewin.pTexdef ) ); Sys_UpdateWindows (W_ALL); } } else Sys_Printf ("Didn't hit a btrush\n"); return; } // JONATHAN:HERE // ctrl-shift-middle button = set single face to texture if (buttons == (nMouseButton|MK_SHIFT|MK_CONTROL) ) { t = Test_Ray (origin, dir, false); if (t.brush) { if (t.brush->brush_faces->texdef.name[0] == '(') Sys_Printf ("Can't change an entity texture\n"); else { SetFaceTexdef (t.brush, t.face, &g_qeglobals.d_texturewin.texdef, &g_qeglobals.d_texturewin.brushprimit_texdef); Brush_Build( t.brush ); Sys_UpdateWindows (W_ALL); } } else Sys_Printf ("Didn't hit a btrush\n"); return; } if (buttons == (nMouseButton | MK_SHIFT)) { Sys_Printf("Set brush face texture info\n"); t = Test_Ray (origin, dir, false); if (t.brush) { if (t.brush->brush_faces->texdef.name[0] == '(') { if (t.brush->owner->eclass->nShowFlags & ECLASS_LIGHT) { CString strBuff; qtexture_t* pTex = g_qeglobals.d_texturewin.pShader->getTexture(); if (pTex) { vec3_t vColor; VectorCopy(pTex->color, vColor); float fLargest = 0.0f; for (int i = 0; i < 3; i++) { if (vColor[i] > fLargest) fLargest = vColor[i]; } if (fLargest == 0.0f) { vColor[0] = vColor[1] = vColor[2] = 1.0f; } else { float fScale = 1.0f / fLargest; for (int i = 0; i < 3; i++) { vColor[i] *= fScale; } } strBuff.Format("%f %f %f",pTex->color[0], pTex->color[1], pTex->color[2]); SetKeyValue(t.brush->owner, "_color", strBuff.GetBuffer(0)); Sys_UpdateWindows (W_ALL); } } else { Sys_Printf ("Can't select an entity brush face\n"); } } else { //strcpy(t.face->texdef.name,g_qeglobals.d_texturewin.texdef.name); t.face->texdef.SetName(g_qeglobals.d_texturewin.texdef.name); Brush_Build(t.brush); Sys_UpdateWindows (W_ALL); } } else Sys_Printf ("Didn't hit a brush\n"); return; } }
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; }
// experimental stuff, work directly on BP static void OnTest( GtkWidget *widget, gpointer data ){ if ( !g_qeglobals.m_bBrushPrimitMode ) { Sys_FPrintf( SYS_WRN, "BP mode required\n" ); return; } if ( g_ptrSelectedFaces.GetSize() != 1 ) { Sys_FPrintf( SYS_WRN, "Expected single face selection\n" ); return; } brush_t *b = reinterpret_cast<brush_t*>( g_ptrSelectedFaceBrushes.GetAt( 0 ) ); face_t *selFace = reinterpret_cast<face_t*>( g_ptrSelectedFaces.GetAt( 0 ) ); // get the ST axis base for the face vec3_t texS,texT; ComputeAxisBase( selFace->plane.normal, texS, texT ); // find ST coordinates for the center of the face float Os = 0,Ot = 0; int i; for ( i = 0; i < selFace->face_winding->numpoints; i++ ) { Os += DotProduct( selFace->face_winding->points[i],texS ); Ot += DotProduct( selFace->face_winding->points[i],texT ); } Os /= selFace->face_winding->numpoints; Ot /= selFace->face_winding->numpoints; brushprimit_texdef_t *pBP = &selFace->brushprimit_texdef; // (FIXME: initial version, before axis base change optimize) // we need to compute our BP matrix in this new axis base (O,texS,texT) // the general case if BPO = M * BP * M^-1 // where BPO is transformation expressed in (O,texS,texT) // M is the axis base change from (origin,texS,texT) to (O,texS,texT) // here we have a special case, M is a translation and it's inverse is easy vec_t BPO[2][3]; vec_t aux[2][3]; vec_t m[2][3]; memset( &m, 0, sizeof( vec_t ) * 6 ); m[0][0] = 1; m[1][1] = 1; m[0][2] = -Os; m[1][2] = -Ot; BPMatMul( m, pBP->coords, aux ); m[0][2] = Os; m[1][2] = Ot; // now M^-1 BPMatMul( aux, m, BPO ); #if 0 // apply a scaling // scale factors against S and T axis, we apply on top of the existing matrix // <1 will decrease the texel/world resolution, >1 will increase float sS = 1.025,sT = 1.025; BPMatScale( BPO,sS,sT ); #endif #if 0 // apply a rotation float theta = 5; BPMatRotate( BPO,theta ); #endif #if 0 // read the scale ConvertTexMatWithQTexture( BPO, selFace->d_texture, aux, NULL ); // reset the scale (normalize the matrix) vec_t v1,v2; v1 = sqrt( aux[0][0] * aux[0][0] + aux[1][0] * aux[1][0] ); v2 = sqrt( aux[0][1] * aux[0][1] + aux[1][1] * aux[1][1] ); // if reading the scale values, we have them here: Sys_Printf( "Current Scale: S: %g T: %g\n", v1, v2 ); return; #endif #if 1 // apply a given scale (on S and T) ConvertTexMatWithQTexture( BPO, selFace->d_texture, aux, NULL ); // reset the scale (normalize the matrix) vec_t v1,v2; v1 = sqrt( aux[0][0] * aux[0][0] + aux[1][0] * aux[1][0] ); v2 = sqrt( aux[0][1] * aux[0][1] + aux[1][1] * aux[1][1] ); vec_t sS,sT; // put the values for scale on S and T here: sS = 1.2 / v1; sT = 0.8 / v2; aux[0][0] *= sS; aux[1][0] *= sS; aux[0][1] *= sT; aux[1][1] *= sT; ConvertTexMatWithQTexture( aux, NULL, BPO, selFace->d_texture ); #endif // now BPO must be expressed back in (origin,texS,texT) axis base BP = M^-1 * BPO * M BPMatMul( m, BPO, aux ); // m is M^-1 m[0][2] = -Os; m[1][2] = -Ot; BPMatMul( aux, m, pBP->coords ); // now emit the coordinates on the winding EmitBrushPrimitTextureCoordinates( selFace, selFace->face_winding ); Sys_UpdateWindows( W_CAMERA ); }
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); }
/* ============== 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); //} }
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); }