2 Copyright (C) 1999-2007 id Software, Inc. and contributors.
3 For a list of contributors, see the accompanying CONTRIBUTORS file.
5 This file is part of GtkRadiant.
7 GtkRadiant is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 GtkRadiant is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GtkRadiant; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 //-----------------------------------------------------------------------------
25 // Quick interface hack for selected face interface
26 // this one really needs more work, but I'm in a hurry with TexTool
30 int WINAPI QERApp_GetSelectedFaceCount()
32 return g_ptrSelectedFaces.GetSize();
35 face_t* WINAPI QERApp_GetSelectedFace(int iface)
37 if (iface>=g_ptrSelectedFaces.GetSize())
39 Sys_FPrintf (SYS_ERR, "QERApp_GetFace: selected faces count exceeded\n");
42 return reinterpret_cast<face_t*>(g_ptrSelectedFaces.GetAt(iface));
45 brush_t* WINAPI QERApp_GetSelectedFaceBrush(int iface)
47 if (iface>=g_ptrSelectedFaceBrushes.GetSize())
49 Sys_FPrintf (SYS_ERR, "QERApp_GetFace: selected faces count exceeded\n");
52 return reinterpret_cast<brush_t*>(g_ptrSelectedFaceBrushes.GetAt(iface));
55 // NOTE: we expect pWinding to have MAX_POINTS_ON_WINDING points ready for writing
56 int WINAPI QERApp_GetFaceInfo(int iface, _QERFaceData *pFaceData, winding_t *pWinding)
60 if (iface>=g_ptrSelectedFaces.GetSize())
62 Sys_FPrintf (SYS_ERR, "QERApp_GetFaceInfo: selected faces count exceeded\n");
65 if (!g_qeglobals.m_bBrushPrimitMode)
67 Sys_Printf("Warning: unexpected QERApp_GetFaceInfo out of brush primitive mode\n");
70 face_t *selFace = reinterpret_cast<face_t*>(g_ptrSelectedFaces.GetAt(iface));
71 strcpy( pFaceData->m_TextureName, selFace->texdef.GetName() );
72 VectorCopy( selFace->planepts[0], pFaceData->m_v1 );
73 VectorCopy( selFace->planepts[1], pFaceData->m_v2 );
74 VectorCopy( selFace->planepts[2], pFaceData->m_v3 );
75 pFaceData->m_bBPrimit = true;
76 memcpy( &pFaceData->brushprimit_texdef, &selFace->brushprimit_texdef, sizeof(brushprimit_texdef_t) );
77 size = (size_t)((winding_t *)0)->points[selFace->face_winding->numpoints];
78 memcpy( pWinding, selFace->face_winding, size );
82 int WINAPI QERApp_SetFaceInfo(int iface, _QERFaceData *pFaceData)
84 if (iface>=g_ptrSelectedFaces.GetSize())
86 Sys_FPrintf (SYS_ERR, "QERApp_SetFaceInfo: selected faces count exceeded\n");
89 if (!g_qeglobals.m_bBrushPrimitMode)
91 Sys_Printf("Warning: unexpected QERApp_SetFaceInfo out of brush primitive mode\n");
94 face_t *selFace = reinterpret_cast<face_t*>(g_ptrSelectedFaces.GetAt(iface));
95 brush_t *selBrush = reinterpret_cast<brush_t*>(g_ptrSelectedFaceBrushes.GetAt(iface));
96 //strcpy( selected_face->texdef.name, pFaceData->m_TextureName );
97 selFace->texdef.SetName(pFaceData->m_TextureName);
98 VectorCopy( pFaceData->m_v1, selFace->planepts[0] );
99 VectorCopy( pFaceData->m_v2, selFace->planepts[1] );
100 VectorCopy( pFaceData->m_v3, selFace->planepts[2] );
101 memcpy( &selFace->brushprimit_texdef, &pFaceData->brushprimit_texdef, sizeof(brushprimit_texdef_t) );
102 Brush_Build( selBrush );
103 Sys_UpdateWindows(W_ALL);
107 int WINAPI QERApp_ISelectedFace_GetTextureNumber(int iface)
109 if (iface>=g_ptrSelectedFaces.GetSize())
111 Sys_FPrintf (SYS_ERR, "QERApp_ISelectedFace_GetTextureNumber: selected faces count exceeded\n");
114 face_t *selFace = reinterpret_cast<face_t*>(g_ptrSelectedFaces.GetAt(iface));
115 return selFace->d_texture->texture_number;
118 void WINAPI QERApp_GetTextureSize (int iface, int Size[2])
120 if (iface>=g_ptrSelectedFaces.GetSize())
122 Sys_FPrintf (SYS_ERR, "QERApp_GetTextureSize: selected faces count exceeded\n");
125 face_t *selFace = reinterpret_cast<face_t*>(g_ptrSelectedFaces.GetAt(iface));
126 Size[0] = selFace->d_texture->width;
127 Size[1] = selFace->d_texture->height;