Surface Flags ... making note of certain textures

Discuss programming topics for the various GPL'd game engine sources.
Post Reply
Baker
Posts: 3666
Joined: Tue Mar 14, 2006 5:15 am

Surface Flags ... making note of certain textures

Post by Baker »

I was looking through Qrack 1.60 and found this ...

Code: Select all

static int Mod_FindSurfaceFlags(char *name)
{
	int	i;

	for (i = 0; i < numsflags; i++) {
		if (surfaceflags[i].len > 0) {
			if (!strncmp(name, surfaceflags[i].name, surfaceflags[i].len)) {
				return surfaceflags[i].flags;
			}
		} else {
			if (!strcmp(name, surfaceflags[i].name)) {
				return surfaceflags[i].flags;
			}
		}
	}
	return 0;
}
Rook is apparently using this for gl_shiny and such:

Code: Select all

static sflags_t surfaceflags[] =
{
	// mirrors
	{ "window", 6, SURF_MIRROR },
	{ "wizwin", 6, SURF_MIRROR },
	{ "window01_", 9, SURF_MIRROR },
	{ "window02_", 9, SURF_MIRROR },
	{ "window03_", 9, SURF_MIRROR },
	// Runes
	{ "rune", 4, SURF_METAL },
	// Metal misc
	{ "metal6_1", 8, SURF_METAL },
	{ "metal6_2", 8, SURF_METAL },
	{ "metal6_3", 8, SURF_METAL },
	{ "metal6_4", 8, SURF_METAL },
	{ "switch_1", 8, SURF_METAL },
	{ "wkey02_1", 8, SURF_METAL },
	{ "wkey02_2", 8, SURF_METAL },
	{ "wkey02_3", 8, SURF_METAL },
	{ "+0mtlsw", 7, SURF_METAL },
	{ "+1mtlsw", 7, SURF_METAL },
	{ "+2mtlsw", 7, SURF_METAL },
	{ "+3mtlsw", 7, SURF_METAL },
	{ "+amtlsw", 7, SURF_METAL },
	{ "arrow_m", 7, SURF_METAL },
	{ "azswitch3", 9, SURF_METAL },
	{ "key", 3, SURF_METAL },

	// end of list
	{ (NULL), 0, 0 }
};
This is where the first function gets called ...

Code: Select all

/*
=================
Mod_LoadFaces
=================
*/
void Mod_LoadFaces (lump_t *l)
{
	dface_t		*in;
	msurface_t 	*out;
	int		i, count, surfnum, planenum, side;

	in = (void *)(mod_base + l->fileofs);
	if (l->filelen % sizeof(*in))
		Sys_Error ("MOD_LoadBrushModel: funny lump size in %s", loadmodel->name);

	count = l->filelen / sizeof(*in);
	out = Hunk_AllocName (count * sizeof(*out), loadname);

	loadmodel->surfaces = out;
	loadmodel->numsurfaces = count;

	for (surfnum=0 ; surfnum<count ; surfnum++, in++, out++)
	{
		out->firstedge = LittleLong(in->firstedge);
		out->numedges = LittleShort(in->numedges);		
		out->flags = 0;

		planenum = LittleShort(in->planenum);
		side = LittleShort(in->side);

		if (side) out->flags |= SURF_PLANEBACK;			

		out->plane = loadmodel->planes + planenum;

		out->texinfo = loadmodel->texinfo + LittleShort (in->texinfo);
		CalcSurfaceExtents (out);

	// lighting info
		for (i=0 ; i<MAXLIGHTMAPS ; i++)
			out->styles[i] = in->styles[i];
		i = LittleLong(in->lightofs);
		out->samples = (i == -1) ? NULL : loadmodel->lightdata + i * 3;

	// set the drawing flags flag
		if (ISSKYTEX(out->texinfo->texture->name))	// sky
		{
			out->flags |= (SURF_DRAWSKY | SURF_DRAWTILED);
			GL_SubdivideSurface (out);	// cut up polygon for warps
			continue;
		}
		
		if (ISTURBTEX(out->texinfo->texture->name))	// turbulent
		{
			out->flags |= (SURF_DRAWTURB | SURF_DRAWTILED);
			for (i=0 ; i<2 ; i++)
			{
				out->extents[i] = 16384;
				out->texturemins[i] = -8192;
			}
			GL_SubdivideSurface (out);	// cut up polygon for warps
			continue;
		}
		// keep these flags seperate or else !!
		if (!(out->sflags = Mod_FindSurfaceFlags (out->texinfo->texture->name))) 
		{
			out->sflags |= SURF_DETAIL;
		}
	}
}
r00k
Posts: 1111
Joined: Sat Nov 13, 2004 10:39 pm

Post by r00k »

I think Reckless wrote that part..
MeTcHsteekle
Posts: 399
Joined: Thu May 15, 2008 10:46 pm
Location: its a secret

Post by MeTcHsteekle »

oooh man i LOVE gl_shiny, can we have that in proquake?
bah
revelator
Posts: 2621
Joined: Thu Jan 24, 2008 12:04 pm
Location: inside tha debugger

Post by revelator »

the actuall idea itself is from labman i just made some changes because it became a bit messy :P

actually it should be pretty easy to add scripting those shinies in ;)

(might even work for quakes mirror code).
Post Reply