mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-23 04:42:32 +00:00
add --extract-hull which produces C structures for the clipping hull (currently only hull 0)
This commit is contained in:
parent
0b1cc3d21f
commit
e2355aa357
5 changed files with 62 additions and 0 deletions
|
@ -246,6 +246,7 @@ void LoadBSP (void);
|
|||
void bsp2prt (void);
|
||||
void extract_textures (void);
|
||||
void extract_entities (void);
|
||||
void extract_hull (void);
|
||||
|
||||
//=============================================================================
|
||||
|
||||
|
|
|
@ -42,6 +42,7 @@ typedef struct {
|
|||
qboolean extract;
|
||||
qboolean extract_textures;
|
||||
qboolean extract_entities;
|
||||
qboolean extract_hull;
|
||||
qboolean usehulls;
|
||||
qboolean watervis;
|
||||
int hullnum;
|
||||
|
|
|
@ -60,6 +60,7 @@ static struct option const long_options[] = {
|
|||
{"portal", no_argument, 0, 'p'},
|
||||
{"extract-textures", no_argument, 0, 256},
|
||||
{"extract-entities", no_argument, 0, 257},
|
||||
{"extract-hull", no_argument, 0, 258},
|
||||
{"usehulls", no_argument, 0, 'u'},
|
||||
{"hullnum", required_argument, 0, 'H'},
|
||||
{"subdivide", required_argument, 0, 's'},
|
||||
|
@ -171,6 +172,10 @@ DecodeArgs (int argc, char **argv)
|
|||
options.extract = true;
|
||||
options.extract_entities = true;
|
||||
break;
|
||||
case 258: // extract-hull
|
||||
options.extract = true;
|
||||
options.extract_hull = true;
|
||||
break;
|
||||
case 'u': // usehulls
|
||||
options.usehulls = true;
|
||||
break;
|
||||
|
|
|
@ -763,6 +763,8 @@ ProcessFile (void)
|
|||
extract_textures ();
|
||||
if (options.extract_entities)
|
||||
extract_entities ();
|
||||
if (options.extract_hull)
|
||||
extract_hull ();
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -54,6 +54,7 @@ static __attribute__ ((used)) const char rcsid[] =
|
|||
#include "bsp5.h"
|
||||
#include "options.h"
|
||||
|
||||
dmodel_t *models;
|
||||
face_t *mfaces;
|
||||
node_t *nodes;
|
||||
node_t *leafs;
|
||||
|
@ -422,3 +423,55 @@ extract_entities (void)
|
|||
Qwrite (ef, bsp->entdata, i);
|
||||
Qclose (ef);
|
||||
}
|
||||
|
||||
void
|
||||
extract_hull (void)
|
||||
{
|
||||
// hullfile = output_file (".c");
|
||||
char *hullfile;
|
||||
int i, j;
|
||||
QFile *hf;
|
||||
|
||||
hullfile = output_file (".c");
|
||||
if (strcmp (hullfile, "-") == 0)
|
||||
hf = Qdopen (1, "wt");
|
||||
else
|
||||
hf = Qopen (hullfile, "wt");
|
||||
|
||||
printf ("%d\n", bsp->nummodels);
|
||||
for (i = 0; i < bsp->nummodels; i++) {
|
||||
dmodel_t *m = bsp->models + i;
|
||||
printf ("mins: (%g, %g, %g)\n", m->mins[0], m->mins[1], m->mins[2]);
|
||||
printf ("maxs: (%g, %g, %g)\n", m->maxs[0], m->maxs[1], m->maxs[2]);
|
||||
printf ("origin: (%g, %g, %g)\n",
|
||||
m->origin[0], m->origin[1], m->origin[2]);
|
||||
for (j = 0; j < MAX_MAP_HULLS; j++)
|
||||
printf ("headnodes[%d]: %d\n", j, m->headnode[j]);
|
||||
printf ("visleafs: %d\n", m->visleafs);
|
||||
printf ("firstface: %d\n", m->firstface);
|
||||
printf ("numfaces: %d\n", m->numfaces);
|
||||
printf ("\n");
|
||||
}
|
||||
Qprintf (hf, "dclipnode_t clipnodes[] = {\n");
|
||||
for (i = 0; i < bsp->numnodes; i++) {
|
||||
int c0, c1;
|
||||
c0 = bsp->nodes[i].children[0];
|
||||
c1 = bsp->nodes[i].children[1];
|
||||
if (c0 < 0)
|
||||
c0 = bsp->leafs[-1 - c0].contents;
|
||||
if (c1 < 0)
|
||||
c1 = bsp->leafs[-1 - c1].contents;
|
||||
Qprintf (hf, "\t{%d, {%d, %d}},\t// %d\n", bsp->nodes[i].planenum,
|
||||
c0, c1, i);
|
||||
}
|
||||
Qprintf (hf, "};\n");
|
||||
Qprintf (hf, "mplane_t planes[] = {\n");
|
||||
for (i = 0; i < bsp->numplanes; i++) {
|
||||
Qprintf (hf, "\t{{%g, %g, %g}, %g, %d, 0, {0, 0}},\t// %d\n",
|
||||
bsp->planes[i].normal[0], bsp->planes[i].normal[1],
|
||||
bsp->planes[i].normal[2],
|
||||
bsp->planes[i].dist, bsp->planes[i].type,
|
||||
i);
|
||||
}
|
||||
Qprintf (hf, "};\n");
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue