HL2: Load BSP from Vampire the Masquerade: Bloodlines, truly flag SKY/TURB surfaces, basic decals
This commit is contained in:
parent
a6fca4638f
commit
bf6ddf21ae
3 changed files with 175 additions and 25 deletions
|
@ -631,7 +631,7 @@ void Mod_ClipDecal(struct model_s *mod, vec3_t center, vec3_t normal, vec3_t tan
|
||||||
Q1BSP_ClipDecalToNodes(mod, &dec, mod->rootnode);
|
Q1BSP_ClipDecalToNodes(mod, &dec, mod->rootnode);
|
||||||
#endif
|
#endif
|
||||||
#ifdef Q3BSPS
|
#ifdef Q3BSPS
|
||||||
else if (mod->fromgame == fg_quake3 || mod->fromgame == fg_quake2)
|
else if (mod->fromgame == fg_quake3 || mod->fromgame == fg_quake2 || mod->fromgame == fg_new)
|
||||||
{
|
{
|
||||||
if (mod->submodelof)
|
if (mod->submodelof)
|
||||||
{
|
{
|
||||||
|
|
|
@ -43,6 +43,7 @@ typedef struct
|
||||||
char additive;
|
char additive;
|
||||||
char translucent;
|
char translucent;
|
||||||
char selfillum;
|
char selfillum;
|
||||||
|
char decal;
|
||||||
char nofog;
|
char nofog;
|
||||||
char mod2x; /* modulate only */
|
char mod2x; /* modulate only */
|
||||||
char water_cheap; /* water only */
|
char water_cheap; /* water only */
|
||||||
|
@ -228,7 +229,7 @@ static char *VMT_ParseBlock(const char *fname, vmtstate_t *st, char *line)
|
||||||
else if (!Q_strcasecmp(key, "$vertexalpha"))
|
else if (!Q_strcasecmp(key, "$vertexalpha"))
|
||||||
st->vertexalpha = 1;
|
st->vertexalpha = 1;
|
||||||
else if (!Q_strcasecmp(key, "$decal"))
|
else if (!Q_strcasecmp(key, "$decal"))
|
||||||
Con_DPrintf("%s: %s \"%s\"\n", fname, key, value);
|
st->decal = atoi(value);
|
||||||
else if (!Q_strcasecmp(key, "$decalscale"))
|
else if (!Q_strcasecmp(key, "$decalscale"))
|
||||||
Con_DPrintf("%s: %s \"%s\"\n", fname, key, value);
|
Con_DPrintf("%s: %s \"%s\"\n", fname, key, value);
|
||||||
else if (!Q_strcasecmp(key, "$decalsize"))
|
else if (!Q_strcasecmp(key, "$decalsize"))
|
||||||
|
@ -479,9 +480,11 @@ static void Shader_GenerateFromVMT(parsestate_t *ps, vmtstate_t *st, const char
|
||||||
Q_strlcatfz(script, &offset, sizeof(script), "\tprogram \"%s%s\"\n", st->type, progargs);
|
Q_strlcatfz(script, &offset, sizeof(script), "\tprogram \"%s%s\"\n", st->type, progargs);
|
||||||
Q_strlcatfz(script, &offset, sizeof(script), "\tdiffusemap \"%s%s.vtf\"\n", strcmp(st->tex[0].name, "materials/")?"materials/":"", st->tex[0].name);
|
Q_strlcatfz(script, &offset, sizeof(script), "\tdiffusemap \"%s%s.vtf\"\n", strcmp(st->tex[0].name, "materials/")?"materials/":"", st->tex[0].name);
|
||||||
Q_strlcatfz(script, &offset, sizeof(script), "\tpolygonOffset 1\n");
|
Q_strlcatfz(script, &offset, sizeof(script), "\tpolygonOffset 1\n");
|
||||||
|
st->decal = 0;
|
||||||
}
|
}
|
||||||
else if (!Q_strcasecmp(st->type, "DecalModulate"))
|
else if (!Q_strcasecmp(st->type, "DecalModulate"))
|
||||||
{
|
{
|
||||||
|
Q_strlcatfz(script, &offset, sizeof(script), "\tpolygonOffset 1\n");
|
||||||
Q_strlcatfz(script, &offset, sizeof(script), "\t{\n");
|
Q_strlcatfz(script, &offset, sizeof(script), "\t{\n");
|
||||||
Q_strlcatfz(script, &offset, sizeof(script), "\t\tmap \"%s%s.vtf\"\n", strcmp(st->tex[0].name, "materials/")?"materials/":"", st->tex[0].name);
|
Q_strlcatfz(script, &offset, sizeof(script), "\t\tmap \"%s%s.vtf\"\n", strcmp(st->tex[0].name, "materials/")?"materials/":"", st->tex[0].name);
|
||||||
|
|
||||||
|
@ -492,7 +495,8 @@ static void Shader_GenerateFromVMT(parsestate_t *ps, vmtstate_t *st, const char
|
||||||
}
|
}
|
||||||
|
|
||||||
Q_strlcatfz(script, &offset, sizeof(script), "\t}\n");
|
Q_strlcatfz(script, &offset, sizeof(script), "\t}\n");
|
||||||
Q_strlcatfz(script, &offset, sizeof(script), "\tpolygonOffset 1\n");
|
st->decal = 0;
|
||||||
|
st->translucent = 0;
|
||||||
}
|
}
|
||||||
else if (!Q_strcasecmp(st->type, "Modulate"))
|
else if (!Q_strcasecmp(st->type, "Modulate"))
|
||||||
{
|
{
|
||||||
|
@ -505,8 +509,10 @@ static void Shader_GenerateFromVMT(parsestate_t *ps, vmtstate_t *st, const char
|
||||||
} else {
|
} else {
|
||||||
Q_strlcatfz(script, &offset, sizeof(script),"\t\tblendFunc gl_dst_color gl_one_minus_src_alpha\n");
|
Q_strlcatfz(script, &offset, sizeof(script),"\t\tblendFunc gl_dst_color gl_one_minus_src_alpha\n");
|
||||||
}
|
}
|
||||||
|
Q_strlcatfz(script, &offset, sizeof(script), "\trgbGen vertex\n");
|
||||||
|
|
||||||
Q_strlcatfz(script, &offset, sizeof(script), "\t}\n");
|
Q_strlcatfz(script, &offset, sizeof(script), "\t}\n");
|
||||||
|
st->translucent = 0;
|
||||||
}
|
}
|
||||||
else if (!Q_strcasecmp(st->type, "Water"))
|
else if (!Q_strcasecmp(st->type, "Water"))
|
||||||
{
|
{
|
||||||
|
@ -541,15 +547,9 @@ static void Shader_GenerateFromVMT(parsestate_t *ps, vmtstate_t *st, const char
|
||||||
|
|
||||||
Q_strlcatfz(script, &offset, sizeof(script), "\tnormalmap \"%s%s.vtf\"\n", strcmp(st->normalmap, "materials/")?"materials/":"", st->normalmap);
|
Q_strlcatfz(script, &offset, sizeof(script), "\tnormalmap \"%s%s.vtf\"\n", strcmp(st->normalmap, "materials/")?"materials/":"", st->normalmap);
|
||||||
}
|
}
|
||||||
else if (!Q_strcasecmp(st->type, "VertexlitGeneric"))
|
else if (!Q_strcasecmp(st->type, "VertexlitGeneric") || st->decal)
|
||||||
{
|
{
|
||||||
if (st->translucent) {
|
|
||||||
Q_strlcatfz(script, &offset, sizeof(script),
|
|
||||||
"\t{\n"
|
|
||||||
"\t\tprogram \"vmt/vertexlit%s\"\n"
|
|
||||||
"\t\tblendFunc gl_src_alpha gl_one_minus_src_alpha\n"
|
|
||||||
"\t}\n", progargs);
|
|
||||||
} else {
|
|
||||||
if (*st->envmap && st->envfrombase)
|
if (*st->envmap && st->envfrombase)
|
||||||
{
|
{
|
||||||
if (st->halflambert)
|
if (st->halflambert)
|
||||||
|
@ -573,7 +573,7 @@ static void Shader_GenerateFromVMT(parsestate_t *ps, vmtstate_t *st, const char
|
||||||
}
|
}
|
||||||
|
|
||||||
Q_strlcatfz(script, &offset, sizeof(script), "\tprogram \"%s%s%s%s\"\n", st->type, progargs, envmaptint, envmapsat);
|
Q_strlcatfz(script, &offset, sizeof(script), "\tprogram \"%s%s%s%s\"\n", st->type, progargs, envmaptint, envmapsat);
|
||||||
}
|
|
||||||
|
|
||||||
Q_strlcatfz(script, &offset, sizeof(script), "\tdiffusemap \"%s%s.vtf\"\n", strcmp(st->tex[0].name, "materials/")?"materials/":"", st->tex[0].name);
|
Q_strlcatfz(script, &offset, sizeof(script), "\tdiffusemap \"%s%s.vtf\"\n", strcmp(st->tex[0].name, "materials/")?"materials/":"", st->tex[0].name);
|
||||||
|
|
||||||
|
@ -593,13 +593,7 @@ static void Shader_GenerateFromVMT(parsestate_t *ps, vmtstate_t *st, const char
|
||||||
else if (!Q_strcasecmp(st->type, "LightmappedGeneric"))
|
else if (!Q_strcasecmp(st->type, "LightmappedGeneric"))
|
||||||
{
|
{
|
||||||
/* reflectmask from diffuse map alpha */
|
/* reflectmask from diffuse map alpha */
|
||||||
if (st->translucent) {
|
|
||||||
Q_strlcatfz(script, &offset, sizeof(script),
|
|
||||||
"\t{\n"
|
|
||||||
"\t\tprogram \"vmt/vertexlit%s\"\n"
|
|
||||||
"\t\tblendFunc gl_src_alpha gl_one_minus_src_alpha\n"
|
|
||||||
"\t}\n", progargs);
|
|
||||||
} else {
|
|
||||||
if (*st->envmap && st->envfrombase)
|
if (*st->envmap && st->envfrombase)
|
||||||
Q_strlcpy(st->type, "vmt/lightmapped#ENVFROMBASE", sizeof(st->type));
|
Q_strlcpy(st->type, "vmt/lightmapped#ENVFROMBASE", sizeof(st->type));
|
||||||
else if (*st->envmap && st->envfromnorm)
|
else if (*st->envmap && st->envfromnorm)
|
||||||
|
@ -610,7 +604,7 @@ static void Shader_GenerateFromVMT(parsestate_t *ps, vmtstate_t *st, const char
|
||||||
Q_strlcpy(st->type, "vmt/lightmapped", sizeof(st->type));
|
Q_strlcpy(st->type, "vmt/lightmapped", sizeof(st->type));
|
||||||
|
|
||||||
Q_strlcatfz(script, &offset, sizeof(script), "\tprogram \"%s%s%s%s\"\n", st->type, progargs, envmaptint, envmapsat);
|
Q_strlcatfz(script, &offset, sizeof(script), "\tprogram \"%s%s%s%s\"\n", st->type, progargs, envmaptint, envmapsat);
|
||||||
}
|
|
||||||
|
|
||||||
Q_strlcatfz(script, &offset, sizeof(script), "\tdiffusemap \"%s%s.vtf\"\n", strcmp(st->tex[0].name, "materials/")?"materials/":"", st->tex[0].name);
|
Q_strlcatfz(script, &offset, sizeof(script), "\tdiffusemap \"%s%s.vtf\"\n", strcmp(st->tex[0].name, "materials/")?"materials/":"", st->tex[0].name);
|
||||||
|
|
||||||
|
@ -635,6 +629,14 @@ static void Shader_GenerateFromVMT(parsestate_t *ps, vmtstate_t *st, const char
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (st->translucent) {
|
||||||
|
st->blendfunc = "src_alpha one_minus_src_alpha";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (st->decal) {
|
||||||
|
Q_strlcatfz(script, &offset, sizeof(script), "\tpolygonOffset 1\n");
|
||||||
|
Q_strlcatfz(script, &offset, sizeof(script), "\trgbGen vertex\n");
|
||||||
|
}
|
||||||
|
|
||||||
if (*st->fullbrightmap)
|
if (*st->fullbrightmap)
|
||||||
Q_strlcatfz(script, &offset, sizeof(script), "\tfullbrightmap \"%s%s.vtf\"\n", strcmp(st->fullbrightmap, "materials/")?"materials/":"", st->fullbrightmap);
|
Q_strlcatfz(script, &offset, sizeof(script), "\tfullbrightmap \"%s%s.vtf\"\n", strcmp(st->fullbrightmap, "materials/")?"materials/":"", st->fullbrightmap);
|
||||||
|
|
|
@ -1138,8 +1138,8 @@ typedef struct
|
||||||
#define TIHL2_NOPORTAL 0x20
|
#define TIHL2_NOPORTAL 0x20
|
||||||
#define TIHL2_TRIGGER 0x40
|
#define TIHL2_TRIGGER 0x40
|
||||||
#define TIHL2_NODRAW TI_NODRAW
|
#define TIHL2_NODRAW TI_NODRAW
|
||||||
//#define TIHL2_HINT 0x100
|
#define TIHL2_HINT 0x100
|
||||||
//#define TIHL2_SKIP 0x200
|
#define TIHL2_SKIP 0x200
|
||||||
#define TIHL2_NOLIGHT 0x400
|
#define TIHL2_NOLIGHT 0x400
|
||||||
//#define TIHL2_BUMPLIGHT 0x800
|
//#define TIHL2_BUMPLIGHT 0x800
|
||||||
//#define TIHL2_NOSHADOWS 0x1000
|
//#define TIHL2_NOSHADOWS 0x1000
|
||||||
|
@ -1209,10 +1209,24 @@ static qboolean VBSP_LoadTexInfo (model_t *mod, qbyte *mod_base, vlump_t *lumps,
|
||||||
// else if (out->flags & (TIHL2_WARP))
|
// else if (out->flags & (TIHL2_WARP))
|
||||||
// Q_strncatz(sname, "#ALPHA=1", sizeof(sname));
|
// Q_strncatz(sname, "#ALPHA=1", sizeof(sname));
|
||||||
|
|
||||||
out->flags = 0;
|
if (flags & (TIHL2_SKYBOX|TIHL2_SKYROOM))
|
||||||
|
out->flags |= TI_SKY;
|
||||||
|
|
||||||
|
if (flags & (TIHL2_WARP))
|
||||||
|
out->flags |= TI_WARP;
|
||||||
|
|
||||||
if (flags & TIHL2_NOLIGHT)
|
if (flags & TIHL2_NOLIGHT)
|
||||||
out->flags |= TEX_SPECIAL;
|
out->flags |= TEX_SPECIAL;
|
||||||
|
|
||||||
|
if (flags & TIHL2_NODRAW)
|
||||||
|
out->flags |= TI_NODRAW;
|
||||||
|
|
||||||
|
// if (flags & TIHL2_HINT)
|
||||||
|
// out->flags |= TI_HINT;
|
||||||
|
|
||||||
|
// if (flags & TIHL2_SKIP)
|
||||||
|
// out->flags |= TI_SKIP;
|
||||||
|
|
||||||
//compact the textures.
|
//compact the textures.
|
||||||
for (j=0; j < texcount; j++)
|
for (j=0; j < texcount; j++)
|
||||||
{
|
{
|
||||||
|
@ -1733,6 +1747,135 @@ typedef struct
|
||||||
unsigned short firstprim;
|
unsigned short firstprim;
|
||||||
unsigned int smoothinggroup;
|
unsigned int smoothinggroup;
|
||||||
} hl2dface_t;
|
} hl2dface_t;
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
int padding[8];
|
||||||
|
short planenum;
|
||||||
|
qbyte side;
|
||||||
|
qbyte onnode; //o.O
|
||||||
|
|
||||||
|
int firstedge; // we must support > 64k edges
|
||||||
|
unsigned short numedges;
|
||||||
|
unsigned short texinfo;
|
||||||
|
|
||||||
|
unsigned short dispinfo;
|
||||||
|
short fogvolume;
|
||||||
|
|
||||||
|
// lighting info
|
||||||
|
qbyte styles[8];
|
||||||
|
qbyte day[8];
|
||||||
|
qbyte night[8];
|
||||||
|
int lightofs; // start of [numstyles*surfsize] samples
|
||||||
|
float surfacearea;
|
||||||
|
int extents_min[2];
|
||||||
|
int extents_size[2];
|
||||||
|
|
||||||
|
int origface;
|
||||||
|
unsigned int smoothinggroup;
|
||||||
|
} vampiredface_t;
|
||||||
|
|
||||||
|
static qboolean VBSP_LoadFaces_Vampire (model_t *mod, qbyte *mod_base, vlump_t *lumps, int version)
|
||||||
|
{
|
||||||
|
vbspinfo_t *prv = (vbspinfo_t*)mod->meshinfo;
|
||||||
|
vlump_t *l = &lumps[VLUMP_FACES_LDR];
|
||||||
|
vampiredface_t *in;
|
||||||
|
msurface_t *out;
|
||||||
|
int i, count, surfnum;
|
||||||
|
int planenum;
|
||||||
|
int ti, st;
|
||||||
|
int lumpsize = sizeof(*in);
|
||||||
|
|
||||||
|
mesh_t *meshes;
|
||||||
|
|
||||||
|
in = (void *)(mod_base + l->fileofs);
|
||||||
|
if (l->filelen % lumpsize)
|
||||||
|
{
|
||||||
|
Con_Printf ("VBSP_LoadFaces_Vampire: funny lump size in %s\n",mod->name);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
count = l->filelen / lumpsize;
|
||||||
|
out = plugfuncs->GMalloc(&mod->memgroup, count*sizeof(*out));
|
||||||
|
prv->surfdisp = plugfuncs->GMalloc(&mod->memgroup, count * sizeof(*prv->surfdisp));
|
||||||
|
|
||||||
|
meshes = plugfuncs->GMalloc(&mod->memgroup, count*sizeof(*meshes));
|
||||||
|
|
||||||
|
mod->surfaces = out;
|
||||||
|
mod->numsurfaces = count;
|
||||||
|
|
||||||
|
mod->lightmaps.surfstyles = 1;
|
||||||
|
|
||||||
|
for ( surfnum=0 ; surfnum<count ; surfnum++, in = (void*)((qbyte*)in+lumpsize), out++)
|
||||||
|
{
|
||||||
|
out->firstedge = LittleLong(in->firstedge);
|
||||||
|
out->numedges = (unsigned short)LittleShort(in->numedges);
|
||||||
|
out->flags = 0;
|
||||||
|
out->mesh = meshes+surfnum;
|
||||||
|
out->mesh->numvertexes = out->numedges;
|
||||||
|
out->mesh->numindexes = (out->mesh->numvertexes-2)*3;
|
||||||
|
|
||||||
|
planenum = (unsigned short)LittleShort(in->planenum);
|
||||||
|
if (in->side)
|
||||||
|
out->flags |= SURF_PLANEBACK;
|
||||||
|
if (!in->onnode)
|
||||||
|
out->flags |= SURF_OFFNODE;
|
||||||
|
|
||||||
|
out->plane = mod->planes + planenum;
|
||||||
|
|
||||||
|
ti = (unsigned short)LittleShort (in->texinfo);
|
||||||
|
if (ti < 0 || ti >= mod->numtexinfo)
|
||||||
|
{
|
||||||
|
Con_Printf (CON_ERROR "VBSP_LoadFaces: bad texinfo number\n");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
out->texinfo = mod->texinfo + ti;
|
||||||
|
|
||||||
|
if (out->texinfo->flags & TI_SKY)
|
||||||
|
{
|
||||||
|
out->flags |= SURF_DRAWSKY|SURF_DRAWTILED;
|
||||||
|
}
|
||||||
|
if (out->texinfo->flags & TI_WARP)
|
||||||
|
{
|
||||||
|
out->flags |= SURF_DRAWTURB|SURF_DRAWTILED;
|
||||||
|
}
|
||||||
|
|
||||||
|
out->lmshift = 0;
|
||||||
|
out->texturemins[0] = in->extents_min[0];
|
||||||
|
out->texturemins[1] = in->extents_min[1];
|
||||||
|
out->extents[0] = in->extents_size[0];
|
||||||
|
out->extents[1] = in->extents_size[1];
|
||||||
|
|
||||||
|
// lighting info
|
||||||
|
|
||||||
|
for (i=0 ; i<Q1Q2BSP_STYLESPERSURF ; i++)
|
||||||
|
{
|
||||||
|
st = in->styles[i];
|
||||||
|
if (st == 255)
|
||||||
|
st = INVALID_LIGHTSTYLE;
|
||||||
|
else if (mod->lightmaps.maxstyle < st)
|
||||||
|
mod->lightmaps.maxstyle = st;
|
||||||
|
out->styles[i] = st;
|
||||||
|
}
|
||||||
|
for (; i<MAXCPULIGHTMAPS ; i++)
|
||||||
|
out->styles[i] = INVALID_LIGHTSTYLE;
|
||||||
|
for (i = 0; i<MAXRLIGHTMAPS ; i++)
|
||||||
|
out->vlstyles[i] = INVALID_VLIGHTSTYLE;
|
||||||
|
i = LittleLong(in->lightofs);
|
||||||
|
if (i == -1 || !mod->lightdata)
|
||||||
|
out->samples = NULL;
|
||||||
|
else
|
||||||
|
out->samples = mod->lightdata + i;
|
||||||
|
|
||||||
|
// set the drawing flags
|
||||||
|
|
||||||
|
if (out->texinfo->flags & TI_WARP)
|
||||||
|
out->flags |= SURF_DRAWTURB;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
static qboolean VBSP_LoadFaces (model_t *mod, qbyte *mod_base, vlump_t *lumps, int version)
|
static qboolean VBSP_LoadFaces (model_t *mod, qbyte *mod_base, vlump_t *lumps, int version)
|
||||||
{
|
{
|
||||||
vbspinfo_t *prv = (vbspinfo_t*)mod->meshinfo;
|
vbspinfo_t *prv = (vbspinfo_t*)mod->meshinfo;
|
||||||
|
@ -1747,6 +1890,11 @@ static qboolean VBSP_LoadFaces (model_t *mod, qbyte *mod_base, vlump_t *lumps, i
|
||||||
|
|
||||||
mesh_t *meshes;
|
mesh_t *meshes;
|
||||||
|
|
||||||
|
if (version == 17)
|
||||||
|
{
|
||||||
|
return VBSP_LoadFaces_Vampire(mod, mod_base, lumps, version);
|
||||||
|
}
|
||||||
|
|
||||||
if (l2->filelen && !(hl2_favour_ldr->ival && lumps[VLUMP_LIGHTING_LDR].filelen))
|
if (l2->filelen && !(hl2_favour_ldr->ival && lumps[VLUMP_LIGHTING_LDR].filelen))
|
||||||
l = l2;
|
l = l2;
|
||||||
|
|
||||||
|
@ -3766,7 +3914,7 @@ static void VBSP_LoadLeafLight (model_t *mod, qbyte *mod_base, vlump_t *hdridx,
|
||||||
unsigned short *in;
|
unsigned short *in;
|
||||||
qbyte *inpoint;
|
qbyte *inpoint;
|
||||||
|
|
||||||
if (version == 19)
|
if (version == 17 || version == 19)
|
||||||
return; //nope. this info is in the leafs.
|
return; //nope. this info is in the leafs.
|
||||||
|
|
||||||
if (hdridx && hdrvals)
|
if (hdridx && hdrvals)
|
||||||
|
@ -4072,7 +4220,7 @@ static qboolean VBSP_LoadMap (model_t *mod, void *filein, size_t filelen)
|
||||||
|
|
||||||
switch(header.version)
|
switch(header.version)
|
||||||
{
|
{
|
||||||
//case 17: //
|
case 17: //vampire
|
||||||
case 18: //beta
|
case 18: //beta
|
||||||
case 19: //hl2,cs:s,hl2dm
|
case 19: //hl2,cs:s,hl2dm
|
||||||
case 20: //portal, l4d, hl2ep2
|
case 20: //portal, l4d, hl2ep2
|
||||||
|
|
Loading…
Reference in a new issue