float GetSurfaceExtraLongestCurve( int num ) { surfaceExtra_t *se = GetSurfaceExtra( num ); return se->longestCurve; }
int GetSurfaceExtraRecvShadows( int num ) { surfaceExtra_t *se = GetSurfaceExtra( num ); return se->recvShadows; }
int GetSurfaceExtraSampleSize( int num ) { surfaceExtra_t *se = GetSurfaceExtra( num ); return se->sampleSize; }
int GetSurfaceExtraEntityNum( int num ) { surfaceExtra_t *se = GetSurfaceExtra( num ); return se->entityNum; }
int GetSurfaceExtraCastShadows( int num ) { surfaceExtra_t *se = GetSurfaceExtra( num ); return se->castShadows; }
int GetSurfaceExtraParentSurfaceNum( int num ) { return GetSurfaceExtra( num )->parentSurfaceNum; }
int GetSurfaceExtraParentSurfaceNum( int num ) { surfaceExtra_t *se = GetSurfaceExtra( num ); return se->parentSurfaceNum; }
void GetSurfaceExtraLightmapAxis( int num, vec3_t lightmapAxis ) { VectorCopy( GetSurfaceExtra( num )->lightmapAxis, lightmapAxis ); }
/* ================= WriteSurfaceExtraFile writes out a surface info file (<map>.srf) ================= */ void WriteSurfaceExtraFile( const char *path ) { char srfPath[MAX_SYSPATH]; file_t *sf; surfaceExtra_t *se; int i; if( path == NULL || path[0] == '\0' ) return; MsgDev( D_NOTE, "--- WriteSurfaceExtraFile ---\n" ); com.snprintf( srfPath, sizeof( srfPath ), "maps/%s", path ); FS_StripExtension( srfPath ); FS_DefaultExtension( srfPath, ".srf" ); Msg( "Writing %s\n", srfPath ); sf = FS_Open( srfPath, "w" ); if( !sf ) Sys_Error( "Error opening %s for writing", srfPath ); for( i = -1; i < numSurfaceExtras; i++ ) { se = GetSurfaceExtra( i ); if( i < 0 ) FS_Printf( sf, "default" ); else FS_Printf( sf, "%d", i ); if( se->mds == NULL ) FS_Printf( sf, "\n" ); else { FS_Printf( sf, " // %s V: %d I: %d %s\n", surfaceTypes[se->mds->type], se->mds->numVerts, se->mds->numIndexes, (se->mds->planar ? "planar" : "")); } FS_Printf( sf, "{\n" ); if( se->si != NULL ) FS_Printf( sf, "\tshader %s\n", se->si->shader ); if( se->parentSurfaceNum != seDefault.parentSurfaceNum ) FS_Printf( sf, "\tparent %d\n", se->parentSurfaceNum ); if( se->entityNum != seDefault.entityNum ) FS_Printf( sf, "\tentity %d\n", se->entityNum ); if( se->castShadows != seDefault.castShadows || se == &seDefault ) FS_Printf( sf, "\tcastShadows %d\n", se->castShadows ); if( se->recvShadows != seDefault.recvShadows || se == &seDefault ) FS_Printf( sf, "\treceiveShadows %d\n", se->recvShadows ); if( se->sampleSize != seDefault.sampleSize || se == &seDefault ) FS_Printf( sf, "\tsampleSize %d\n", se->sampleSize ); if( se->longestCurve != seDefault.longestCurve || se == &seDefault ) FS_Printf( sf, "\tlongestCurve %f\n", se->longestCurve ); if( VectorCompare( se->lightmapAxis, seDefault.lightmapAxis ) == false ) FS_Printf( sf, "\tlightmapAxis ( %f %f %f )\n", se->lightmapAxis[0], se->lightmapAxis[1], se->lightmapAxis[2] ); FS_Printf( sf, "}\n\n" ); } FS_Close( sf ); }
int GetSurfaceExtraSampleSize( int num ) { return GetSurfaceExtra( num )->sampleSize; }
float GetSurfaceExtraLongestCurve( int num ) { return GetSurfaceExtra( num )->longestCurve; }
int GetSurfaceExtraRecvShadows( int num ) { return GetSurfaceExtra( num )->recvShadows; }
int GetSurfaceExtraCastShadows( int num ) { return GetSurfaceExtra( num )->castShadows; }
int GetSurfaceExtraEntityNum( int num ) { return GetSurfaceExtra( num )->entityNum; }
void GetSurfaceExtraLightmapAxis( int num, vec3_t lightmapAxis ) { surfaceExtra_t *se = GetSurfaceExtra( num ); VectorCopy( se->lightmapAxis, lightmapAxis ); }
shaderInfo_t *GetSurfaceExtraShaderInfo( int num ) { surfaceExtra_t *se = GetSurfaceExtra( num ); return se->si; }
void WriteSurfaceExtraFile( const char *path ) { char srfPath[ 1024 ]; FILE *sf; surfaceExtra_t *se; int i; /* dummy check */ if( path == NULL || path[ 0 ] == '\0' ) return; /* note it */ Sys_Printf( "--- WriteSurfaceExtraFile ---\n" ); /* open the file */ strcpy( srfPath, path ); StripExtension( srfPath ); strcat( srfPath, ".srf" ); Sys_Printf( "Writing %s\n", srfPath ); sf = fopen( srfPath, "w" ); if( sf == NULL ) Error( "Error opening %s for writing", srfPath ); /* lap through the extras list */ for( i = -1; i < numSurfaceExtras; i++ ) { /* get extra */ se = GetSurfaceExtra( i ); /* default or surface num? */ if( i < 0 ) fprintf( sf, "default" ); else fprintf( sf, "%d", i ); /* valid map drawsurf? */ if( se->mds == NULL ) fprintf( sf, "\n" ); else { fprintf( sf, " // %s V: %d I: %d %s\n", surfaceTypes[ se->mds->type ], se->mds->numVerts, se->mds->numIndexes, (se->mds->planar ? "planar" : "") ); } /* open braces */ fprintf( sf, "{\n" ); /* shader */ if( se->si != NULL ) fprintf( sf, "\tshader %s\n", se->si->shader ); /* parent surface number */ if( se->parentSurfaceNum != seDefault.parentSurfaceNum ) fprintf( sf, "\tparent %d\n", se->parentSurfaceNum ); /* entity number */ if( se->entityNum != seDefault.entityNum ) fprintf( sf, "\tentity %d\n", se->entityNum ); /* cast shadows */ if( se->castShadows != seDefault.castShadows || se == &seDefault ) fprintf( sf, "\tcastShadows %d\n", se->castShadows ); /* recv shadows */ if( se->recvShadows != seDefault.recvShadows || se == &seDefault ) fprintf( sf, "\treceiveShadows %d\n", se->recvShadows ); /* lightmap sample size */ if( se->sampleSize != seDefault.sampleSize || se == &seDefault ) fprintf( sf, "\tsampleSize %d\n", se->sampleSize ); /* longest curve */ if( se->longestCurve != seDefault.longestCurve || se == &seDefault ) fprintf( sf, "\tlongestCurve %f\n", se->longestCurve ); /* lightmap axis vector */ if( VectorCompare( se->lightmapAxis, seDefault.lightmapAxis ) == qfalse ) fprintf( sf, "\tlightmapAxis ( %f %f %f )\n", se->lightmapAxis[ 0 ], se->lightmapAxis[ 1 ], se->lightmapAxis[ 2 ] ); /* close braces */ fprintf( sf, "}\n\n" ); } /* close the file */ fclose( sf ); }
shaderInfo_t *GetSurfaceExtraShaderInfo( int num ) { return GetSurfaceExtra( num )->si; }