/*
ConvertSurface()
-converts a bsp drawsurface to an ase chunk
+converts a bsp drawsurface to an obj chunk
*/
-static void ConvertSurface( FILE *f, bspModel_t *model, int modelNum, bspDrawSurface_t *ds, int surfaceNum, vec3_t origin )
+static void ConvertSurfaceToOBJ( FILE *f, bspModel_t *model, int modelNum, bspDrawSurface_t *ds, int surfaceNum, vec3_t origin )
{
int i, v, face, a, b, c;
bspDrawVert_t *dv;
exports a bsp model to an ase chunk
*/
-static void ConvertModel( FILE *f, bspModel_t *model, int modelNum, vec3_t origin )
+static void ConvertModelToOBJ( FILE *f, bspModel_t *model, int modelNum, vec3_t origin )
{
int i, s;
bspDrawSurface_t *ds;
{
s = i + model->firstBSPSurface;
ds = &bspDrawSurfaces[ s ];
- ConvertSurface( f, model, modelNum, ds, s, origin );
+ ConvertSurfaceToOBJ( f, model, modelNum, ds, s, origin );
}
}
}
*/
-static void ConvertShader( FILE *f, bspShader_t *shader, int shaderNum )
+static void ConvertShaderToMTL( FILE *f, bspShader_t *shader, int shaderNum )
{
shaderInfo_t *si;
char *c, filename[ 1024 ];
exports an 3d studio ase file from the bsp
*/
-int ConvertBSPToASE( char *bspName )
+int ConvertBSPToOBJ( char *bspName )
{
int i, modelNum;
- FILE *f;
+ FILE *f, *fmtl;
bspShader_t *shader;
bspModel_t *model;
entity_t *e;
/* note it */
- Sys_Printf( "--- Convert BSP to ASE ---\n" );
+ Sys_Printf( "--- Convert BSP to OBJ ---\n" );
/* create the ase filename from the bsp name */
strcpy( name, bspName );
StripExtension( name );
- strcat( name, ".ase" );
+ strcat( name, ".obj" );
Sys_Printf( "writing %s\n", name );
+ strcpy( mtlname, bspName );
+ StripExtension( mtlname );
+ strcat( mtlname, ".mtl" );
+ Sys_Printf( "writing %s\n", mtlname );
ExtractFileBase( bspName, base );
strcat( base, ".bsp" );
f = fopen( name, "wb" );
if( f == NULL )
Error( "Open failed on %s\n", name );
+ fmtl = fopen( mtlname, "wb" );
+ if( fmtl == NULL )
+ Error( "Open failed on %s\n", mtlname );
/* print header */
fprintf( f, "*3DSMAX_ASCIIEXPORT\t200\r\n" );
for( i = 0; i < numBSPShaders; i++ )
{
shader = &bspShaders[ i ];
- ConvertShader( f, shader, i );
+ ConvertShaderToMTL( fmtl, shader, i );
}
fprintf( f, "}\r\n" );
GetVectorForKey( e, "origin", origin );
/* convert model */
- ConvertModel( f, model, modelNum, origin );
+ ConvertModelToOBJ( f, model, modelNum, origin );
}
/* close the file and return */
fclose( f );
+ fclose( fmtl );
/* return to sender */
return 0;