2 Copyright (C) 1999-2006 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
27 ** Given a triangle_t, find which indices match into the associated
28 ** surface's base triangles.
30 static void ReindexTriangle( int surfno, triangle_t *pTri, int indices[3] )
33 md3SurfaceData_t *pSurfData = &g_data.surfData[surfno];
42 for ( i = 0; i < 3; i++ )
50 for ( t = 0; t < pSurfData->header.numVerts; t++ )
52 if ( !VectorCompare( pTri->verts[i], pSurfData->baseVertexes[t].xyz ) )
56 if ( !VectorCompare( pTri->normals[i], pSurfData->baseVertexes[t].normal ) )
58 if ( pTri->texcoords[i][0] != pSurfData->baseVertexes[t].st[0] )
60 if ( pTri->texcoords[i][1] != pSurfData->baseVertexes[t].st[1] )
64 matches[i][numMatches++] = t;
67 if ( indices[i] == -1 )
69 // Error( "Could not ReindexTriangle, vertex not found" );
74 for ( t = 0; t < psets[i].numtriangles; t++ )
78 bTri = &g_data.surfData[i].baseTriangles[t];
85 for ( k = 0; k < g_data.surfData[i].header.numVerts; k++ )
87 if ( ( g_data.surfData[i].baseVertexes[k].st[0] == bVert->st[0] ) &&
88 ( g_data.surfData[i].baseVertexes[k].st[1] == bVert->st[1] ) &&
89 ( VectorCompare (bVert->xyz, g_data.surfData[i].baseVertexes[k].xyz) ) &&
90 ( VectorCompare (bVert->normal, g_data.surfData[i].baseVertexes[k].normal) ) )
92 break; // this vertex is already in the base vertex list
96 if (k == g_data.surfData[i].header.numVerts) { // new index
97 g_data.surfData[i].baseVertexes[g_data.surfData[i].header.numVerts] = *bVert;
98 g_data.surfData[i].header.numVerts++;
107 const char *FindFrameFile (const char *frame)
111 static char retname[1024];
116 if (strstr (frame, "."))
117 return frame; // allready in dot format
119 // split 'run1' into 'run' and '1'
120 s = frame + strlen(frame)-1;
122 while (s != frame && *s >= '0' && *s <= '9')
125 strcpy (suffix, s+1);
126 strcpy (base, frame);
129 // check for 'run1.tri'
130 sprintf (file1, "%s/%s%s.tri", g_cddir, base, suffix);
131 time1 = FileTime (file1);
134 sprintf (retname, "%s%s.tri", base, suffix);
139 sprintf (file1, "%s/%s.%s",g_cddir, base, suffix);
140 time1 = FileTime (file1);
143 sprintf (retname, "%s.%s", base, suffix);
147 Error ("frame %s could not be found",frame);