mbspc: add -bsp2map220 switch, writting map in Valve 220 format with correct textures alignment for Quake 1/2, SiN and Half-Life BSPs
+various improvements of decompiling
This commit is contained in:
parent
a21a5c7290
commit
d1ac937b50
|
|
@ -52,11 +52,10 @@ with MBSPC:
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
When MBSPC is used for converting BSP files to MAP files, the correct
|
When MBSPC is used for converting BSP files to MAP files, the correct
|
||||||
texture name is written for every brush side. However, texture alignment
|
texture name is written for every brush side. However, correct texture alignment
|
||||||
info (shift, scale, rotation) is not written to the MAP file. It is not
|
info (shift, scale, rotation) is not written to the MAP file, when converting Quake 3 maps.
|
||||||
trivial to obtain this info from the BSP, and I did not need it when I
|
As for Quake 1/2, SiN and Half-Life, alignment info is half right for regular map format (-bsp2map)
|
||||||
coded this modification, sorry. If you need this functionality, add the
|
and is correct, when using Valve 220 one (-bsp2map220).
|
||||||
necessary code.
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
<h3>Usage</h3>
|
<h3>Usage</h3>
|
||||||
|
|
@ -100,6 +99,7 @@ List of options recognized by MBSPC:
|
||||||
onlyents file.bsp update entity list from file.ent(*) file.bsp
|
onlyents file.bsp update entity list from file.ent(*) file.bsp
|
||||||
texinfo file.bsp extract texture list file.txi
|
texinfo file.bsp extract texture list file.txi
|
||||||
bsp2map file.bsp create MAP from BSP file.map
|
bsp2map file.bsp create MAP from BSP file.map
|
||||||
|
bsp2map220 file.bsp create Valve 220 MAP from BSP file.map
|
||||||
bsp2aas file.bsp create AAS from BSP file.aas
|
bsp2aas file.bsp create AAS from BSP file.aas
|
||||||
reach file.bsp compute reachability and clusters file.aas
|
reach file.bsp compute reachability and clusters file.aas
|
||||||
cluster file.aas compute clusters file.aas
|
cluster file.aas compute clusters file.aas
|
||||||
|
|
@ -141,7 +141,7 @@ Several metacharacter may be used in the paths of the input file:
|
||||||
<p>
|
<p>
|
||||||
.pk3 files are accessed as if they are normal folders. For instance
|
.pk3 files are accessed as if they are normal folders. For instance
|
||||||
use "d:\quake3\baseq3\pak0.pk3\maps/q3dm1.bsp" to access the
|
use "d:\quake3\baseq3\pak0.pk3\maps/q3dm1.bsp" to access the
|
||||||
map q3dm1.bsp from the pak0.pk3 file.
|
map q3dm1.bsp from the pak0.pk3 file.
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
Multiple files may be listed after the switches bsp2map, bsp2aas, reach,
|
Multiple files may be listed after the switches bsp2map, bsp2aas, reach,
|
||||||
|
|
|
||||||
|
|
@ -44,6 +44,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
extern int use_nodequeue; //brushbsp.c
|
extern int use_nodequeue; //brushbsp.c
|
||||||
extern int calcgrapplereach; //be_aas_reach.c
|
extern int calcgrapplereach; //be_aas_reach.c
|
||||||
|
extern qboolean g_bsp2map220; //map.c
|
||||||
|
|
||||||
float subdivide_size = 240;
|
float subdivide_size = 240;
|
||||||
char source[1024];
|
char source[1024];
|
||||||
|
|
@ -706,8 +707,9 @@ int main (int argc, char **argv)
|
||||||
qfiles = GetArgumentFiles(argc, argv, &i, "bsp");
|
qfiles = GetArgumentFiles(argc, argv, &i, "bsp");
|
||||||
} //end else if
|
} //end else if
|
||||||
|
|
||||||
else if (!stricmp(argv[i], "-bsp2map"))
|
else if (!stricmp(argv[i], "-bsp2map") || !stricmp(argv[i], "-bsp2map220"))
|
||||||
{
|
{
|
||||||
|
g_bsp2map220 = !stricmp(argv[i], "-bsp2map220");
|
||||||
if (i + 1 >= argc) {i = 0; break;}
|
if (i + 1 >= argc) {i = 0; break;}
|
||||||
comp = COMP_BSP2MAP;
|
comp = COMP_BSP2MAP;
|
||||||
qfiles = GetArgumentFiles(argc, argv, &i, "bsp");
|
qfiles = GetArgumentFiles(argc, argv, &i, "bsp");
|
||||||
|
|
|
||||||
|
|
@ -106,19 +106,19 @@ int PlaneSignBits(vec3_t normal)
|
||||||
int PlaneTypeForNormal(vec3_t normal)
|
int PlaneTypeForNormal(vec3_t normal)
|
||||||
{
|
{
|
||||||
vec_t ax, ay, az;
|
vec_t ax, ay, az;
|
||||||
|
|
||||||
// NOTE: should these have an epsilon around 1.0?
|
// NOTE: should these have an epsilon around 1.0?
|
||||||
if (normal[0] == 1.0 || normal[0] == -1.0)
|
if (normal[0] == 1.0 || normal[0] == -1.0)
|
||||||
return PLANE_X;
|
return PLANE_X;
|
||||||
if (normal[1] == 1.0 || normal[1] == -1.0)
|
if (normal[1] == 1.0 || normal[1] == -1.0)
|
||||||
return PLANE_Y;
|
return PLANE_Y;
|
||||||
if (normal[2] == 1.0 || normal[2] == -1.0)
|
if (normal[2] == 1.0 || normal[2] == -1.0)
|
||||||
return PLANE_Z;
|
return PLANE_Z;
|
||||||
|
|
||||||
ax = fabs(normal[0]);
|
ax = fabs(normal[0]);
|
||||||
ay = fabs(normal[1]);
|
ay = fabs(normal[1]);
|
||||||
az = fabs(normal[2]);
|
az = fabs(normal[2]);
|
||||||
|
|
||||||
if (ax >= ay && ax >= az)
|
if (ax >= ay && ax >= az)
|
||||||
return PLANE_ANYX;
|
return PLANE_ANYX;
|
||||||
if (ay >= ax && ay >= az)
|
if (ay >= ax && ay >= az)
|
||||||
|
|
@ -682,6 +682,8 @@ get_shader_ptr(int bidx, int sidx)
|
||||||
|
|
||||||
return &q3_dshaders[dside->shaderNum];
|
return &q3_dshaders[dside->shaderNum];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
qboolean g_bsp2map220;
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//
|
//
|
||||||
// Parameter: -
|
// Parameter: -
|
||||||
|
|
@ -697,6 +699,7 @@ qboolean WriteMapBrush(FILE *fp, mapbrush_t *brush, vec3_t origin)
|
||||||
winding_t *w;
|
winding_t *w;
|
||||||
side_t *s;
|
side_t *s;
|
||||||
plane_t *plane;
|
plane_t *plane;
|
||||||
|
const char* defAlign = g_bsp2map220? "[ 1 0 0 0 ] [ 0 1 0 0 ] 0 1 1" : "0 0 0 1 1";
|
||||||
|
|
||||||
if (noliquids)
|
if (noliquids)
|
||||||
{
|
{
|
||||||
|
|
@ -727,7 +730,7 @@ qboolean WriteMapBrush(FILE *fp, mapbrush_t *brush, vec3_t origin)
|
||||||
{
|
{
|
||||||
planenum = s->planenum;
|
planenum = s->planenum;
|
||||||
} //end else
|
} //end else
|
||||||
//always take the first plane, then flip the points if necesary
|
//always take the first plane, then flip the points if necessary
|
||||||
plane = &mapplanes[planenum & ~1];
|
plane = &mapplanes[planenum & ~1];
|
||||||
w = BaseWindingForPlane(plane->normal, plane->dist);
|
w = BaseWindingForPlane(plane->normal, plane->dist);
|
||||||
//
|
//
|
||||||
|
|
@ -735,17 +738,17 @@ qboolean WriteMapBrush(FILE *fp, mapbrush_t *brush, vec3_t origin)
|
||||||
{
|
{
|
||||||
for (j = 0; j < 3; j++)
|
for (j = 0; j < 3; j++)
|
||||||
{
|
{
|
||||||
if (fabs(w->p[i][j]) < 0.2) w->p[i][j] = 0;
|
if (fabs(w->p[i][j]) < 0.001) w->p[i][j] = 0;
|
||||||
else if (fabs((int)w->p[i][j] - w->p[i][j]) < 0.3) w->p[i][j] = (int) w->p[i][j];
|
else if (fabs((int)w->p[i][j] - w->p[i][j]) < 0.1) w->p[i][j] = (int) w->p[i][j];
|
||||||
//w->p[i][j] = (int) (w->p[i][j] + 0.2);
|
//w->p[i][j] = (int) (w->p[i][j] + 0.2);
|
||||||
} //end for
|
} //end for
|
||||||
} //end for
|
} //end for
|
||||||
//three non-colinear points to define the plane
|
//three non-colinear points to define the plane
|
||||||
if (planenum & 1) p1 = 1;
|
if (planenum & 1) p1 = 1;
|
||||||
else p1 = 0;
|
else p1 = 0;
|
||||||
if (fprintf(fp," ( %5i %5i %5i ) ", (int)w->p[p1][0], (int)w->p[p1][1], (int)w->p[p1][2]) < 0) return false;
|
if (fprintf(fp," ( %g %g %g ) ", w->p[p1][0], w->p[p1][1], w->p[p1][2]) < 0) return false;
|
||||||
if (fprintf(fp,"( %5i %5i %5i ) ", (int)w->p[!p1][0], (int)w->p[!p1][1], (int)w->p[!p1][2]) < 0) return false;
|
if (fprintf(fp,"( %g %g %g ) ", w->p[!p1][0], w->p[!p1][1], w->p[!p1][2]) < 0) return false;
|
||||||
if (fprintf(fp,"( %5i %5i %5i ) ", (int)w->p[2][0], (int)w->p[2][1], (int)w->p[2][2]) < 0) return false;
|
if (fprintf(fp,"( %g %g %g ) ", w->p[2][0], w->p[2][1], w->p[2][2]) < 0) return false;
|
||||||
//free the winding
|
//free the winding
|
||||||
FreeWinding(w);
|
FreeWinding(w);
|
||||||
//
|
//
|
||||||
|
|
@ -756,19 +759,19 @@ qboolean WriteMapBrush(FILE *fp, mapbrush_t *brush, vec3_t origin)
|
||||||
//player clip
|
//player clip
|
||||||
if (loadedmaptype == MAPTYPE_SIN)
|
if (loadedmaptype == MAPTYPE_SIN)
|
||||||
{
|
{
|
||||||
if (fprintf(fp, "generic/misc/clip 0 0 0 1 1") < 0) return false;
|
if (fprintf(fp, "generic/misc/clip") < 0) return false;
|
||||||
} //end if
|
} //end if
|
||||||
else if (loadedmaptype == MAPTYPE_QUAKE2)
|
else if (loadedmaptype == MAPTYPE_QUAKE2)
|
||||||
{ //FIXME: don't always use e1u1
|
{ //FIXME: don't always use e1u1
|
||||||
if (fprintf(fp, "e1u1/clip 0 0 0 1 1") < 0) return false;
|
if (fprintf(fp, "e1u1/clip") < 0) return false;
|
||||||
} //end else
|
} //end else
|
||||||
else if (loadedmaptype == MAPTYPE_QUAKE3)
|
else if (loadedmaptype == MAPTYPE_QUAKE3)
|
||||||
{
|
{
|
||||||
if (fprintf(fp, "common/clip 0 0 0 1 1 1 0 0") < 0) return false;
|
if (fprintf(fp, "common/clip") < 0) return false;
|
||||||
} //end else if
|
} //end else if
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (fprintf(fp, "clip 0 0 0 1 1") < 0) return false;
|
if (fprintf(fp, "clip") < 0) return false;
|
||||||
} //end else
|
} //end else
|
||||||
} //end if
|
} //end if
|
||||||
else if (brush->contents == CONTENTS_MONSTERCLIP)
|
else if (brush->contents == CONTENTS_MONSTERCLIP)
|
||||||
|
|
@ -776,37 +779,44 @@ qboolean WriteMapBrush(FILE *fp, mapbrush_t *brush, vec3_t origin)
|
||||||
//monster clip
|
//monster clip
|
||||||
if (loadedmaptype == MAPTYPE_SIN)
|
if (loadedmaptype == MAPTYPE_SIN)
|
||||||
{
|
{
|
||||||
if (fprintf(fp, "generic/misc/monster 0 0 0 1 1") < 0) return false;
|
if (fprintf(fp, "generic/misc/monster") < 0) return false;
|
||||||
} //end if
|
} //end if
|
||||||
else if (loadedmaptype == MAPTYPE_QUAKE2)
|
else if (loadedmaptype == MAPTYPE_QUAKE2)
|
||||||
{
|
{
|
||||||
if (fprintf(fp, "e1u1/clip_mon 0 0 0 1 1") < 0) return false;
|
if (fprintf(fp, "e1u1/clip_mon") < 0) return false;
|
||||||
} //end else
|
} //end else
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (fprintf(fp, "clip 0 0 0 1 1") < 0) return false;
|
if (fprintf(fp, "clip") < 0) return false;
|
||||||
} //end else
|
} //end else
|
||||||
} //end else
|
} //end else
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (fprintf(fp, "clip 0 0 0 1 1") < 0) return false;
|
if (fprintf(fp, "clip") < 0) return false;
|
||||||
Log_Write("brush->contents = %d\n", brush->contents);
|
Log_Write("brush->contents = %d\n", brush->contents);
|
||||||
} //end else
|
} //end else
|
||||||
|
|
||||||
|
if ( fprintf( fp, " %s", defAlign ) < 0 ) return false;
|
||||||
|
|
||||||
|
if ( loadedmaptype == MAPTYPE_QUAKE3 )
|
||||||
|
if ( fprintf( fp, " 0 0 0" ) < 0 ) return false;
|
||||||
} //end if
|
} //end if
|
||||||
else if (loadedmaptype == MAPTYPE_SIN && s->texinfo == 0)
|
else if (loadedmaptype == MAPTYPE_SIN && s->texinfo == 0)
|
||||||
{
|
{
|
||||||
if (brush->contents & CONTENTS_DUMMYFENCE)
|
if (brush->contents & CONTENTS_DUMMYFENCE)
|
||||||
{
|
{
|
||||||
if (fprintf(fp, "generic/misc/fence 0 0 0 1 1") < 0) return false;
|
if (fprintf(fp, "generic/misc/fence") < 0) return false;
|
||||||
} //end if
|
} //end if
|
||||||
else if (brush->contents & CONTENTS_MIST)
|
else if (brush->contents & CONTENTS_MIST)
|
||||||
{
|
{
|
||||||
if (fprintf(fp, "generic/misc/volumetric_base 0 0 0 1 1") < 0) return false;
|
if (fprintf(fp, "generic/misc/volumetric_base") < 0) return false;
|
||||||
} //end if
|
} //end if
|
||||||
else //unknown so far
|
else //unknown so far
|
||||||
{
|
{
|
||||||
if (fprintf(fp, "generic/misc/red 0 0 0 1 1") < 0) return false;
|
if (fprintf(fp, "generic/misc/red") < 0) return false;
|
||||||
} //end else
|
} //end else
|
||||||
|
|
||||||
|
if ( fprintf( fp, " %s", defAlign ) < 0 ) return false;
|
||||||
} //end if
|
} //end if
|
||||||
else if (loadedmaptype == MAPTYPE_QUAKE3)
|
else if (loadedmaptype == MAPTYPE_QUAKE3)
|
||||||
{
|
{
|
||||||
|
|
@ -817,7 +827,7 @@ qboolean WriteMapBrush(FILE *fp, mapbrush_t *brush, vec3_t origin)
|
||||||
|
|
||||||
if (dshader == NULL)
|
if (dshader == NULL)
|
||||||
{
|
{
|
||||||
if (fprintf(fp, "***unknown*** 0 0 0 1 1 1 0 0") < 0)
|
if (fprintf(fp, "***unknown***") < 0)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
@ -827,18 +837,20 @@ qboolean WriteMapBrush(FILE *fp, mapbrush_t *brush, vec3_t origin)
|
||||||
while (*cp != '/' && *cp != 0)
|
while (*cp != '/' && *cp != 0)
|
||||||
cp++;
|
cp++;
|
||||||
|
|
||||||
if (*cp == '/')
|
if (*cp == '/' && *( cp + 1 ) != 0 )
|
||||||
{
|
{
|
||||||
cp++;
|
cp++;
|
||||||
if (fprintf(fp, "%s 0 0 0 1 1 1 0 0", cp) < 0)
|
if (fprintf(fp, "%s", cp) < 0)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (fprintf(fp, "***unknown*** 0 0 0 1 1 1 0 0") < 0)
|
if (fprintf(fp, "***unknown***") < 0)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( fprintf( fp, " %s 0 0 0", defAlign ) < 0 ) return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
|
|
@ -876,23 +888,18 @@ qboolean WriteMapBrush(FILE *fp, mapbrush_t *brush, vec3_t origin)
|
||||||
if (rotate < 0) rotate += 360;
|
if (rotate < 0) rotate += 360;
|
||||||
if (rotate >= 360) rotate -= 360;
|
if (rotate >= 360) rotate -= 360;
|
||||||
//write the texture info
|
//write the texture info
|
||||||
if (fprintf(fp, "%s %d %d %d", ti->texture, shift[0], shift[1], rotate) < 0) return false;
|
if( g_bsp2map220 ){
|
||||||
if (fabs(scale[0] - ((int) scale[0])) < 0.001)
|
if( fprintf(fp, "%s [ %g %g %g %g ] [ %g %g %g %g ] %d %g %g", ti->texture,
|
||||||
{
|
vecs[0][0], vecs[0][1], vecs[0][2], ti->vecs[0][3] - DotProduct( origin, vecs[0] ),
|
||||||
if (fprintf(fp, " %d", (int) scale[0]) < 0) return false;
|
vecs[1][0], vecs[1][1], vecs[1][2], ti->vecs[1][3] - DotProduct( origin, vecs[1] ),
|
||||||
} //end if
|
rotate, scale[0], scale[1] ) < 0 )
|
||||||
else
|
return false;
|
||||||
{
|
}
|
||||||
if (fprintf(fp, " %4f", scale[0]) < 0) return false;
|
else{
|
||||||
} //end if
|
if (fprintf(fp, "%s %d %d %d", ti->texture, shift[0], shift[1], rotate) < 0) return false;
|
||||||
if (fabs(scale[1] - ((int) scale[1])) < 0.001)
|
if (fprintf(fp, " %g %g", scale[0], scale[1]) < 0) return false;
|
||||||
{
|
}
|
||||||
if (fprintf(fp, " %d", (int) scale[1]) < 0) return false;
|
|
||||||
} //end if
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (fprintf(fp, " %4f", scale[1]) < 0) return false;
|
|
||||||
} //end else
|
|
||||||
//write the extra brush side info
|
//write the extra brush side info
|
||||||
if (loadedmaptype == MAPTYPE_QUAKE2)
|
if (loadedmaptype == MAPTYPE_QUAKE2)
|
||||||
{
|
{
|
||||||
|
|
@ -919,6 +926,7 @@ qboolean WriteOriginBrush(FILE *fp, vec3_t origin)
|
||||||
float dist;
|
float dist;
|
||||||
int i, s;
|
int i, s;
|
||||||
winding_t *w;
|
winding_t *w;
|
||||||
|
const char* defAlign = g_bsp2map220? "[ 1 0 0 0 ] [ 0 1 0 0 ] 0 1 1" : "0 0 0 1 1";
|
||||||
|
|
||||||
if (fprintf(fp, " {\n") < 0) return false;
|
if (fprintf(fp, " {\n") < 0) return false;
|
||||||
//
|
//
|
||||||
|
|
@ -943,16 +951,26 @@ qboolean WriteOriginBrush(FILE *fp, vec3_t origin)
|
||||||
// SURF_NODRAW = 128
|
// SURF_NODRAW = 128
|
||||||
if (loadedmaptype == MAPTYPE_SIN)
|
if (loadedmaptype == MAPTYPE_SIN)
|
||||||
{
|
{
|
||||||
if (fprintf(fp, "generic/misc/origin 0 0 0 1 1") < 0) return false;
|
if (fprintf(fp, "generic/misc/origin") < 0) return false;
|
||||||
} //end if
|
} //end if
|
||||||
else if (loadedmaptype == MAPTYPE_HALFLIFE)
|
else if (loadedmaptype == MAPTYPE_QUAKE2)
|
||||||
{
|
{
|
||||||
if (fprintf(fp, "origin 0 0 0 1 1") < 0) return false;
|
if (fprintf(fp, "e1u1/origin") < 0) return false;
|
||||||
} //end if
|
} //end if
|
||||||
else
|
else if (loadedmaptype == MAPTYPE_QUAKE3)
|
||||||
{
|
{
|
||||||
if (fprintf(fp, "e1u1/origin 0 0 0 1 1") < 0) return false;
|
if (fprintf(fp, "common/origin") < 0) return false;
|
||||||
|
} //end if
|
||||||
|
else //MAPTYPE_HALFLIFE (and quake1?)
|
||||||
|
{
|
||||||
|
if (fprintf(fp, "origin") < 0) return false;
|
||||||
} //end else
|
} //end else
|
||||||
|
|
||||||
|
if ( fprintf( fp, " %s", defAlign ) < 0 ) return false;
|
||||||
|
|
||||||
|
if ( loadedmaptype == MAPTYPE_QUAKE3 )
|
||||||
|
if ( fprintf( fp, " 0 0 0" ) < 0 ) return false;
|
||||||
|
|
||||||
//Quake2 extra brush side info
|
//Quake2 extra brush side info
|
||||||
if (loadedmaptype == MAPTYPE_QUAKE2)
|
if (loadedmaptype == MAPTYPE_QUAKE2)
|
||||||
{
|
{
|
||||||
|
|
@ -1464,4 +1482,4 @@ void WriteEntList(char *fname, char *ent_str, int size)
|
||||||
|
|
||||||
fputc('\n', f);
|
fputc('\n', f);
|
||||||
fclose(f);
|
fclose(f);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user