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
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] ){
32 md3SurfaceData_t *pSurfData = &g_data.surfData[surfno];
41 for ( i = 0; i < 3; i++ )
49 for ( t = 0; t < pSurfData->header.numVerts; t++ )
51 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 ) {
68 // Error( "Could not ReindexTriangle, vertex not found" );
73 for ( t = 0; t < psets[i].numtriangles; t++ )
77 bTri = &g_data.surfData[i].baseTriangles[t];
79 for ( j = 0 ; j < 3 ; j++ )
84 for ( k = 0; k < g_data.surfData[i].header.numVerts; k++ )
86 if ( ( g_data.surfData[i].baseVertexes[k].st[0] == bVert->st[0] ) &&
87 ( g_data.surfData[i].baseVertexes[k].st[1] == bVert->st[1] ) &&
88 ( VectorCompare( bVert->xyz, g_data.surfData[i].baseVertexes[k].xyz ) ) &&
89 ( VectorCompare( bVert->normal, g_data.surfData[i].baseVertexes[k].normal ) ) ) {
90 break; // this vertex is already in the base vertex list
94 if ( k == g_data.surfData[i].header.numVerts ) { // new index
95 g_data.surfData[i].baseVertexes[g_data.surfData[i].header.numVerts] = *bVert;
96 g_data.surfData[i].header.numVerts++;
105 const char *FindFrameFile( const char *frame ){
108 static char retname[1024];
113 if ( strstr( frame, "." ) ) {
114 return frame; // allready in dot format
117 // split 'run1' into 'run' and '1'
118 s = frame + strlen( frame ) - 1;
120 while ( s != frame && *s >= '0' && *s <= '9' )
123 strcpy( suffix, s + 1 );
124 strcpy( base, frame );
125 base[s - frame + 1] = 0;
127 // check for 'run1.tri'
128 sprintf( file1, "%s/%s%s.tri", g_cddir, base, suffix );
129 time1 = FileTime( file1 );
131 sprintf( retname, "%s%s.tri", base, suffix );
136 sprintf( file1, "%s/%s.%s",g_cddir, base, suffix );
137 time1 = FileTime( file1 );
139 sprintf( retname, "%s.%s", base, suffix );
143 Error( "frame %s could not be found",frame );