/*
-Copyright (C) 1999-2006 Id Software, Inc. and contributors.
-For a list of contributors, see the accompanying CONTRIBUTORS file.
+ Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+ For a list of contributors, see the accompanying CONTRIBUTORS file.
-This file is part of GtkRadiant.
+ This file is part of GtkRadiant.
-GtkRadiant is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
+ GtkRadiant is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
-GtkRadiant is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
+ GtkRadiant is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
-You should have received a copy of the GNU General Public License
-along with GtkRadiant; if not, write to the Free Software
-Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-*/
+ You should have received a copy of the GNU General Public License
+ along with GtkRadiant; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
#include <assert.h>
#ifdef WIN32
#endif
#include "md3lib.h"
-#if defined (__linux__) || defined (__APPLE__)
+#if defined ( __linux__ ) || defined ( __APPLE__ )
#define filelength Q_filelength
#endif
/*
** MD3_ComputeTagFromTri
*/
-void MD3_ComputeTagFromTri( md3Tag_t *pTag, const float pTri[3][3] )
-{
- float len[3];
- vec3_t axes[3], sides[3];
- int longestSide, shortestSide, hypotSide;
- int origin;
- int j;
- float d;
+void MD3_ComputeTagFromTri( md3Tag_t *pTag, const float pTri[3][3] ){
+ float len[3];
+ vec3_t axes[3], sides[3];
+ int longestSide, shortestSide, hypotSide;
+ int origin;
+ int j;
+ float d;
memset( axes, 0, sizeof( axes ) );
memset( sides, 0, sizeof( sides ) );
//
for ( j = 0; j < 3; j++ )
{
- sides[j][0] = pTri[(j+1)%3][0] - pTri[j][0];
- sides[j][1] = pTri[(j+1)%3][1] - pTri[j][1];
- sides[j][2] = pTri[(j+1)%3][2] - pTri[j][2];
+ sides[j][0] = pTri[( j + 1 ) % 3][0] - pTri[j][0];
+ sides[j][1] = pTri[( j + 1 ) % 3][1] - pTri[j][1];
+ sides[j][2] = pTri[( j + 1 ) % 3][2] - pTri[j][2];
len[j] = ( float ) sqrt( DotProduct( sides[j], sides[j] ) );
}
#if 0
- if ( len[0] > len[1] && len[0] > len[2] )
- {
+ if ( len[0] > len[1] && len[0] > len[2] ) {
longestSide = 0; shortestSide = 1; origin = 2;
}
- else if ( len[1] > len[0] && len[1] > len[2] )
- {
+ else if ( len[1] > len[0] && len[1] > len[2] ) {
longestSide = 1; shortestSide = 2; origin = 0;
}
- else if ( len[2] > len[0] && len[2] > len[1] )
- {
+ else if ( len[2] > len[0] && len[2] > len[1] ) {
longestSide = 2; shortestSide = 0; origin = 1;
}
else
if ( len[0] > len[1] && len[0] > len[2] ) {
hypotSide = 0;
origin = 2;
- } else if ( len[1] > len[0] && len[1] > len[2] ) {
+ }
+ else if ( len[1] > len[0] && len[1] > len[2] ) {
hypotSide = 1;
origin = 0;
- } else if ( len[2] > len[0] && len[2] > len[1] ) {
+ }
+ else if ( len[2] > len[0] && len[2] > len[1] ) {
hypotSide = 2;
origin = 1;
}
if ( len[0] > len[1] && len[0] > len[2] ) {
longestSide = 0;
- } else if ( len[1] > len[0] && len[1] > len[2] ) {
+ }
+ else if ( len[1] > len[0] && len[1] > len[2] ) {
longestSide = 1;
- } else if ( len[2] > len[0] && len[2] > len[1] ) {
+ }
+ else if ( len[2] > len[0] && len[2] > len[1] ) {
longestSide = 2;
}
len[longestSide] = -1;
if ( len[0] > len[1] && len[0] > len[2] ) {
shortestSide = 0;
- } else if ( len[1] > len[0] && len[1] > len[2] ) {
+ }
+ else if ( len[1] > len[0] && len[1] > len[2] ) {
shortestSide = 1;
- } else if ( len[2] > len[0] && len[2] > len[1] ) {
+ }
+ else if ( len[2] > len[0] && len[2] > len[1] ) {
shortestSide = 2;
}
len[shortestSide] = -1;
}
/*
-==============
-MD3_Dump
-==============
-*/
-void MD3_Dump( const char *filename )
-{
+ ==============
+ MD3_Dump
+ ==============
+ */
+void MD3_Dump( const char *filename ){
md3Header_t header;
md3Tag_t *pTag;
md3Surface_t *pSurface;
long fileSize;
int i;
- if ( ( fp = fopen( filename, "rb" ) ) == 0 )
- {
+ if ( ( fp = fopen( filename, "rb" ) ) == 0 ) {
Error( "Unable to open '%s'\n", filename );
}
buffer = ( char * ) _buffer;
header = *( md3Header_t * ) _buffer;
- if ( header.ident != MD3_IDENT )
- {
+ if ( header.ident != MD3_IDENT ) {
Error( "Incorrect ident for '%s'\n", filename );
}
printf( " num tags: %d\n", header.numTags );
printf( " num surfaces: %d\n", header.numSurfaces );
printf( " num skins: %d\n", header.numSkins );
- printf( " file size: %d\n", fileSize );
+ printf( " file size: %ld\n", fileSize );
printf( "--- TAGS ---\n" );
pTag = ( md3Tag_t * ) ( ( ( char * ) buffer ) + header.ofsTags );
printf( " num tris: %d\n", pSurface->numTriangles );
printf( " num verts: %d\n", pSurface->numVerts );
- if ( pSurface->numShaders > 0 )
- {
+ if ( pSurface->numShaders > 0 ) {
printf( " --- SHADERS ---\n" );
for ( j = 0; j < pSurface->numShaders; j++, pShader++ )
free( _buffer );
}
-