mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-02-17 01:11:45 +00:00
[qfbsp] Add an option to dump info about a bsp file
Just the header plus some basics of model info.
This commit is contained in:
parent
81f73e4524
commit
13e1682f5e
6 changed files with 81 additions and 2 deletions
|
@ -129,6 +129,8 @@ node_t *AllocNode (void);
|
|||
|
||||
extern bsp_t *bsp;
|
||||
|
||||
void bspinfo (void);
|
||||
|
||||
///@}
|
||||
|
||||
#endif//qfbsp_bsp5_h
|
||||
|
|
|
@ -43,6 +43,7 @@ typedef struct {
|
|||
qboolean noclip;
|
||||
qboolean onlyents;
|
||||
qboolean portal;
|
||||
qboolean info;
|
||||
qboolean extract;
|
||||
qboolean extract_textures;
|
||||
qboolean extract_entities;
|
||||
|
|
|
@ -8,6 +8,7 @@ bin_PROGRAMS += @QFBSP_TARGETS@
|
|||
qfbsp_SOURCES= \
|
||||
tools/qfbsp/source/brush.c \
|
||||
tools/qfbsp/source/csg4.c \
|
||||
tools/qfbsp/source/info.c \
|
||||
tools/qfbsp/source/map.c \
|
||||
tools/qfbsp/source/merge.c \
|
||||
tools/qfbsp/source/nodraw.c \
|
||||
|
|
67
tools/qfbsp/source/info.c
Normal file
67
tools/qfbsp/source/info.c
Normal file
|
@ -0,0 +1,67 @@
|
|||
#ifdef HAVE_CONFIG_H
|
||||
# include "config.h"
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_STRING_H
|
||||
# include <string.h>
|
||||
#endif
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "QF/sys.h"
|
||||
|
||||
#include "tools/qfbsp/include/brush.h"
|
||||
#include "tools/qfbsp/include/bsp5.h"
|
||||
#include "tools/qfbsp/include/draw.h"
|
||||
#include "tools/qfbsp/include/options.h"
|
||||
|
||||
typedef struct lumpinfo_s {
|
||||
const char *name;
|
||||
int size;
|
||||
} lumpinfo_t;
|
||||
|
||||
#define S(f) sizeof (*((bsp_t *)0)->f)
|
||||
static lumpinfo_t lump_info[] = {
|
||||
{ "entities", S(entdata) },
|
||||
{ "planes", S(planes) },
|
||||
{ "textures", S(texdata) },
|
||||
{ "vertices", S(vertexes) },
|
||||
{ "visibility", S(visdata) },
|
||||
{ "nodes", S(nodes) },
|
||||
{ "texinfo", S(texinfo) },
|
||||
{ "faces", S(faces) },
|
||||
{ "lighting", S(lightdata) },
|
||||
{ "clipnodes", S(clipnodes) },
|
||||
{ "leafs", S(leafs) },
|
||||
{ "marksurfaces", S(marksurfaces) },
|
||||
{ "edges", S(edges) },
|
||||
{ "surfedges", S(surfedges) },
|
||||
{ "models", S(models) },
|
||||
};
|
||||
|
||||
void
|
||||
bspinfo ()
|
||||
{
|
||||
printf ("version: %d\n", bsp->header->version);
|
||||
for (int i = 0; i < HEADER_LUMPS; i++) {
|
||||
lump_t *lump = &bsp->header->lumps[i];
|
||||
lumpinfo_t *info = &lump_info[i];
|
||||
|
||||
printf (" %-12s: %7d %7d %7d\n", info->name,
|
||||
lump->fileofs, lump->filelen, lump->filelen / info->size);
|
||||
|
||||
}
|
||||
for (int i = 0; i < bsp->nummodels; i++) {
|
||||
dmodel_t *model = &bsp->models[i];
|
||||
printf ("model: *%d\n", i);
|
||||
printf (" mins : [%g, %g, %g]\n", VectorExpand (model->mins));
|
||||
printf (" maxs : [%g, %g, %g]\n", VectorExpand (model->maxs));
|
||||
printf (" origin : [%g, %g, %g]\n", VectorExpand (model->origin));
|
||||
printf (" headnode:");
|
||||
for (int j = 0; j < MAX_MAP_HULLS; j++) {
|
||||
printf (" %d", model->headnode[j]);
|
||||
}
|
||||
printf ("\n");
|
||||
printf (" visleafs: %d\n", model->visleafs);
|
||||
printf (" faces : %7d %7d\n", model->firstface, model->numfaces);
|
||||
}
|
||||
}
|
|
@ -59,6 +59,7 @@ static struct option const long_options[] = {
|
|||
{"noclip", no_argument, 0, 'c'},
|
||||
{"onlyents", no_argument, 0, 'e'},
|
||||
{"portal", no_argument, 0, 'p'},
|
||||
{"info", no_argument, 0, 'i'},
|
||||
{"extract-textures", no_argument, 0, 256},
|
||||
{"extract-entities", no_argument, 0, 257},
|
||||
{"extract-hull", no_argument, 0, 258},
|
||||
|
@ -81,6 +82,7 @@ static const char *short_options =
|
|||
"f" // nofill
|
||||
"c" // noclip
|
||||
"e" // onlyents
|
||||
"i" // info
|
||||
"o:" // outputfile
|
||||
"p" // portal
|
||||
"u" // usehulls
|
||||
|
@ -102,6 +104,7 @@ usage (int status)
|
|||
" -v, --verbose Display more output than usual\n"
|
||||
" -h, --help Display this help and exit\n"
|
||||
" -V, --version Output version information and exit\n"
|
||||
" -i, --info Display info about the bsp\n"
|
||||
" -d, --draw\n"
|
||||
" -t, --notjunc\n"
|
||||
" -c, --noclip\n"
|
||||
|
@ -163,6 +166,10 @@ DecodeArgs (int argc, char **argv)
|
|||
case 'o':
|
||||
options.output_file = strdup (optarg);
|
||||
break;
|
||||
case 'i':
|
||||
options.extract = true;
|
||||
options.info = true;
|
||||
break;
|
||||
case 'p': // portal
|
||||
options.extract = true;
|
||||
options.portal = true;
|
||||
|
|
|
@ -404,10 +404,10 @@ CreateHulls (void)
|
|||
static void
|
||||
ProcessFile (void)
|
||||
{
|
||||
bsp = BSP_New ();
|
||||
|
||||
if (options.extract) {
|
||||
LoadBSP ();
|
||||
if (options.info)
|
||||
bspinfo ();
|
||||
if (options.portal)
|
||||
bsp2prt ();
|
||||
if (options.extract_textures)
|
||||
|
@ -420,6 +420,7 @@ ProcessFile (void)
|
|||
return;
|
||||
}
|
||||
|
||||
bsp = BSP_New ();
|
||||
// load brushes and entities
|
||||
LoadMapFile (options.mapfile);
|
||||
|
||||
|
|
Loading…
Reference in a new issue