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

	in = (void *)(mod_base + l->fileofs);
	if (l->filelen % sizeof(*in))
		ri.Sys_Error (ERR_DROP, "MOD_LoadBmodel: funny lump size in %s",loadmodel->name);
	count = l->filelen / sizeof(*in);
	out = Hunk_Alloc ( count*sizeof(*out));	

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

	currentmodel = loadmodel;

	GL_BeginBuildingLightmaps (loadmodel);

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

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

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

		ti = LittleShort (in->texinfo);
		if (ti < 0 || ti >= loadmodel->numtexinfo)
			ri.Sys_Error (ERR_DROP, "MOD_LoadBmodel: bad texinfo number");
		out->texinfo = loadmodel->texinfo + ti;

		CalcSurfaceExtents (out);
				
	// lighting info

		for (i=0 ; i<MAXLIGHTMAPS ; i++)
			out->styles[i] = in->styles[i];
		i = LittleLong(in->lightofs);
		if (i == -1)
			out->samples = NULL;
		else
			out->samples = loadmodel->lightdata + i;
		
	// set the drawing flags
		
		if (out->texinfo->flags & SURF_WARP)
		{
			out->flags |= SURF_DRAWTURB;
			for (i=0 ; i<2 ; i++)
			{
				out->extents[i] = 16384;
				out->texturemins[i] = -8192;
			}
			GL_SubdivideSurface (out);	// cut up polygon for warps
		}

		// create lightmaps and polygons
		if ( !(out->texinfo->flags & (SURF_SKY|SURF_TRANS33|SURF_TRANS66|SURF_WARP) ) )
			GL_CreateSurfaceLightmap (out);

		if (! (out->texinfo->flags & SURF_WARP) ) 
			GL_BuildPolygonFromSurface(out);

	}

	GL_EndBuildingLightmaps ();
}
Beispiel #2
0
/*
=================
Mod_LoadFaces
=================
*/
void Mod_LoadFaces (lump_t *l)
{
    dface_t		*in;
    msurface_t 	*out;
    int			i, count, surfnum;
    int			planenum, side;

    in = (void *)(mod_base + l->fileofs);
    if (l->filelen % sizeof(*in))
        Sys_Error ("MOD_LoadBmodel: 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);
        if (i == -1)
            out->samples = NULL;
        else
            out->samples = loadmodel->lightdata + i;

        // set the drawing flags flag

        if (!Q_strncmp(out->texinfo->texture->name,"sky",3))	// sky
        {
            out->flags |= (SURF_DRAWSKY | SURF_DRAWTILED);
#ifndef QUAKE2
            GL_SubdivideSurface (out);	// cut up polygon for warps
#endif
            continue;
        }

        if (!Q_strncmp(out->texinfo->texture->name,"*",1))		// 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;
        }

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

#ifdef BSP23TEST
	int size = (mod_bspversion == 23) ? 24 : sizeof(dface_t);

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

	count = l->filelen / size;
	out = Hunk_AllocName (count * sizeof(*out), mod_loadname);

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

	for (surfnum=0 ; surfnum<count ; surfnum++, out++)
	{
		out->flags = 0;

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

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

		if (mod_bspversion == 23)
		{
			out->firstedge = LittleLong(((dface23_t *)in)->firstedge);
			out->numedges = LittleShort(((dface23_t *)in)->numedges);
			out->texinfo = NULL;			/******* FIXME *******/
		// lighting info
			for (i=0 ; i<MAXLIGHTMAPS ; i++)
				out->styles[i] = ((dface23_t *)in)->styles[i];
			i = LittleLong(((dface23_t *)in)->lightofs);
		}
		else
		{
			out->firstedge = LittleLong(in->firstedge);
			out->numedges = LittleShort(in->numedges);
			out->texinfo = loadmodel->texinfo + LittleShort (in->texinfo);

			CalcSurfaceExtents (loadmodel, out);

		// lighting info
			for (i=0 ; i<MAXLIGHTMAPS ; i++)
				out->styles[i] = in->styles[i];
			i = LittleLong(in->lightofs);
		}
#else
	in = (void *)(mod_base + l->fileofs);
	if (l->filelen % sizeof(*in))
		Host_Error ("Mod_LoadFaces: funny lump size in %s", loadmodel->name);	// was Sys_Error

	count = l->filelen / sizeof(*in);
	out = Hunk_AllocName (count * sizeof(*out), mod_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;

//		out->visframe = 0;		/************ JDH ************/

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

		out->plane = loadmodel->planes + planenum;
		out->texinfo = loadmodel->texinfo + LittleShort (in->texinfo);

		CalcSurfaceExtents (loadmodel, out);

	// lighting info
		for (i=0 ; i<MAXLIGHTMAPS ; i++)
			out->styles[i] = in->styles[i];
		i = LittleLong(in->lightofs);
#endif

		//out->samples = (i == -1) ? NULL : loadmodel->lightdata + i * 3;
		out->samples = (i == -1) ? NULL : loadmodel->lightdata + i * loadmodel->lightdatadepth;

	// set the drawing flags flag
		if (ISSKYTEX(out->texinfo->texture->name))	// sky
		{
			out->flags |= (SURF_DRAWSKY | SURF_DRAWTILED);
			GL_SubdivideSurface (loadmodel, out);	// cut up polygon for warps
		}
		else 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 (loadmodel, out);	// cut up polygon for warps

		#ifdef HEXEN2_SUPPORT
			if (hexen2)
			{
				if ((!Q_strncasecmp(out->texinfo->texture->name, "*rtex078",8)) ||
					(!Q_strncasecmp(out->texinfo->texture->name, "*lowlight",9)))
					out->flags |= SURF_TRANSLUCENT;
			}
		#endif
		}

#ifdef BSP23TEST
		in = (dface_t *) ((byte *) in + size);
#endif
	}
}
#endif		//#ifndef RQM_SV_ONLY


#ifdef BSP23TEST
typedef struct
{
	int				planenum;
	short			children[2];	// negative numbers are -(leafs+1), not nodes
	float			mins[3];		// for sphere culling
	float			maxs[3];
	unsigned short	firstface;
	unsigned short	numfaces;	// counting both sides
} dnode23_t;

/*
=================
Mod_LoadNodes23
=================
*/
void Mod_LoadNodes23 (lump_t *l)
{
	int			i, j, count, p;
	dnode23_t	*in;
	mnode_t 	*out;

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

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

	loadmodel->nodes = out;
	loadmodel->numnodes = count;

	for (i=0 ; i<count ; i++, in++, out++)
	{
		for (j=0 ; j<3 ; j++)
		{
			out->minmaxs[j] = LittleFloat (in->mins[j]);
			out->minmaxs[3+j] = LittleFloat (in->maxs[j]);
		}

		p = LittleLong(in->planenum);
		out->plane = loadmodel->planes + p;

		out->firstsurface = (unsigned short) LittleShort (in->firstface);
		out->numsurfaces = (unsigned short) LittleShort (in->numfaces);

//		out->visframe = 0;	/****** JDH ******/

		for (j=0 ; j<2 ; j++)
		{
			p = LittleShort (in->children[j]);
			if (p >= 0)
				out->children[j] = loadmodel->nodes + p;
			else
				out->children[j] = (mnode_t *)(loadmodel->leafs + (-1 - p));
		}
	}

	Mod_SetParent (loadmodel->nodes, NULL);	// sets nodes and leafs
}