Exemplo n.º 1
0
/*
================
WritePortalFile
================
*/
void WritePortalFile( tree_t *tree ) {
	char filename[1024];
	node_t *headnode;

	qprintf( "--- WritePortalFile ---\n" );

	headnode = tree->headnode;
	num_visclusters = 0;
	num_visportals = 0;

	Tree_FreePortals_r( headnode );

	MakeHeadnodePortals( tree );

	CreateVisPortals_r( headnode );

// set the cluster field in every leaf and count the total number of portals

	NumberLeafs_r( headnode );

// write the file
	sprintf( filename, "%s.prt", source );
	printf( "writing %s\n", filename );
	pf = fopen( filename, "w" );
	if ( !pf ) {
		Error( "Error opening %s", filename );
	}

	fprintf( pf, "%s\n", PORTALFILE );
	fprintf( pf, "%i\n", num_visclusters );
	fprintf( pf, "%i\n", num_visportals );

	qprintf( "%5i visclusters\n", num_visclusters );
	qprintf( "%5i visportals\n", num_visportals );

	WritePortalFile_r( headnode );

	fclose( pf );

	// we need to store the clusters out now because ordering
	// issues made us do this after writebsp...
	clusterleaf = 1;
	SaveClusters_r( headnode );
}
Exemplo n.º 2
0
/*
 * @brief
 */
void WritePortalFile(tree_t *tree) {
	char filename[MAX_OS_PATH];
	node_t *head_node;

	Com_Verbose("--- WritePortalFile ---\n");

	head_node = tree->head_node;
	num_visclusters = 0;
	num_visportals = 0;

	FreeTreePortals_r(head_node);

	MakeHeadnodePortals(tree);

	CreateVisPortals_r(head_node);

	// set the cluster field in every leaf and count the total number of portals
	NumberLeafs_r(head_node);

	// write the file
	StripExtension(map_name, filename);
	strcat(filename, ".prt");

	if (!(prtfile = Fs_OpenWrite(filename)))
		Com_Error(ERR_FATAL, "Error opening %s\n", filename);

	Fs_Print(prtfile, "%s\n", PORTALFILE);
	Fs_Print(prtfile, "%i\n", num_visclusters);
	Fs_Print(prtfile, "%i\n", num_visportals);

	Com_Verbose("%5i visclusters\n", num_visclusters);
	Com_Verbose("%5i visportals\n", num_visportals);

	WritePortalFile_r(head_node);

	Fs_Close(prtfile);

	// we need to store the clusters out now because ordering
	// issues made us do this after writebsp...
	clusterleaf = 1;
	SaveClusters_r(head_node);

	Com_Verbose("--- WritePortalFile complete ---\n");
}
Exemplo n.º 3
0
/*
================
WritePortalfile
================
*/
void WritePortalfile (node_t *headnode)
{
// set the visleafnum field in every leaf and count the total number of portals
	num_visleafs = 0;
	num_visportals = 0;
	NumberLeafs_r (headnode);
	
// write the file
	printf ("writing %s\n", portfilename);
	pf = fopen (portfilename, "w");
	if (!pf)
		Error ("Error opening %s", portfilename);
		
	fprintf (pf, "%s\n", PORTALFILE);
	fprintf (pf, "%i\n", num_visleafs);
	fprintf (pf, "%i\n", num_visportals);
	
	WritePortalFile_r (headnode);
	
	fclose (pf);
}
Exemplo n.º 4
0
/*
 * ================
 * WritePortalfile
 * ================
 */
void            WritePortalfile(node_t* headnode)
{
    // set the visleafnum field in every leaf and count the total number of portals
    num_visleafs = 0;
    num_visportals = 0;
    NumberLeafs_r(headnode);

    // write the file
    pf = fopen(g_portfilename, "w");
    if (!pf)
    {
        Error("Error writing portal file %s", g_portfilename);
    }

    fprintf(pf, "%i\n", num_visleafs);
    fprintf(pf, "%i\n", num_visportals);

    WritePortalFile_r(headnode);
    fclose(pf);
    Log("BSP generation successful, writing portal file '%s'\n", g_portfilename);
}
Exemplo n.º 5
0
/*
================
WritePortalFile
================
*/
void WritePortalFile (tree_t *tree)
{
	char	filename[1024];

	Sys_FPrintf (SYS_VRB,"--- WritePortalFile ---\n");
	
	// write the file
	sprintf (filename, "%s.prt", source);
	Sys_Printf ("writing %s\n", filename);
	pf = fopen (filename, "w");
	if (!pf)
		Error ("Error opening %s", filename);
		
	fprintf (pf, "%s\n", PORTALFILE);
	fprintf (pf, "%i\n", num_visclusters);
	fprintf (pf, "%i\n", num_visportals);
	fprintf (pf, "%i\n", num_solidfaces);

	WritePortalFile_r(tree->headnode);
	WriteFaceFile_r(tree->headnode);

	fclose (pf);
}
Exemplo n.º 6
0
/*
================
WritePortalfile
================
*/
static void
WritePortalfile(node_t *headnode)
{
    // set the visleafnum field in every leaf and count the total number of portals
    num_visleafs = 0;
    num_visportals = 0;
    NumberLeafs_r(headnode);

    // write the file
    StripExtension(options.szBSPName);
    strcat(options.szBSPName, ".prt");

    PortalFile = fopen(options.szBSPName, "wt");
    if (PortalFile == NULL)
	Message(msgError, errOpenFailed, options.szBSPName, strerror(errno));

    fprintf(PortalFile, "PRT1\n");
    fprintf(PortalFile, "%i\n", num_visleafs);
    fprintf(PortalFile, "%i\n", num_visportals);

    WritePortalFile_r(headnode);

    fclose(PortalFile);
}
Exemplo n.º 7
0
/*
=================
WritePortalFile_r
=================
*/
void WritePortalFile_r (node_t *node)
{
	int			i, s;	
	portal_t	*p;
	winding_t	*w;
	vec3_t		normal;
	vec_t		dist;

	// decision node
	if (node->planenum != PLANENUM_LEAF) {
		WritePortalFile_r (node->children[0]);
		WritePortalFile_r (node->children[1]);
		return;
	}
	
	if (node->opaque) {
		return;
	}

	for (p = node->portals ; p ; p=p->next[s])
	{
		w = p->winding;
		s = (p->nodes[1] == node);
		if (w && p->nodes[0] == node)
		{
			if (!PortalPassable(p))
				continue;
			// write out to the file
			
			// sometimes planes get turned around when they are very near
			// the changeover point between different axis.  interpret the
			// plane the same way vis will, and flip the side orders if needed
			// FIXME: is this still relevent?
			WindingPlane (w, normal, &dist);
			if ( DotProduct (p->plane.normal, normal) < 0.99 )
			{	// backwards...
				fprintf (pf,"%i %i %i ",w->numpoints, p->nodes[1]->cluster, p->nodes[0]->cluster);
			}
			else
				fprintf (pf,"%i %i %i ",w->numpoints, p->nodes[0]->cluster, p->nodes[1]->cluster);
			
			/* ydnar: added this change to make antiportals work */
			if( p->compileFlags & C_HINT )
				fprintf( pf, "1 " );
			else
				fprintf( pf, "0 " );
			
			/* write the winding */
			for (i=0 ; i<w->numpoints ; i++)
			{
				fprintf (pf,"(");
				WriteFloat (pf, w->p[i][0]);
				WriteFloat (pf, w->p[i][1]);
				WriteFloat (pf, w->p[i][2]);
				fprintf (pf,") ");
			}
			fprintf (pf,"\n");
		}
	}

}