Exemplo n.º 1
0
/*
===============
WriteNode_r

===============
*/
static void WriteNode_r( node_t *node ) {
	int		child[2];
	int		i;
	idPlane	*plane;

	if ( node->planenum == PLANENUM_LEAF ) {
		// we shouldn't get here unless the entire world
		// was a single leaf
		procFile->WriteFloatString( "/* node 0 */ ( 0 0 0 0 ) -1 -1\n" );
		return;
	}

	for ( i = 0 ; i < 2 ; i++ ) {
		if ( node->children[i]->planenum == PLANENUM_LEAF ) {
			child[i] = -1 - node->children[i]->area;
		} else {
			child[i] = node->children[i]->nodeNumber;
		}
	}

	plane = &dmapGlobals.mapPlanes[node->planenum];

	procFile->WriteFloatString( "/* node %i */ ", node->nodeNumber  );
	Write1DMatrix( procFile, 4, plane->ToFloatPtr() );
	procFile->WriteFloatString( "%i %i\n", child[0], child[1] );

	if ( child[0] > 0 ) {
		WriteNode_r( node->children[0] );
	}
	if ( child[1] > 0 ) {
		WriteNode_r( node->children[1] );
	}
}
Exemplo n.º 2
0
/*
====================
WriteUTriangles

Writes text verts and indexes to procfile
====================
*/
static void WriteUTriangles( const srfTriangles_t *uTris )
{
    int			col;
    int			i;

    // emit this chain
    procFile->WriteFloatString( "/* numVerts = */ %i /* numIndexes = */ %i\n",
                                uTris->numVerts, uTris->numIndexes );

    // verts
    col = 0;
    for ( i = 0 ; i < uTris->numVerts ; i++ )
    {
        float	vec[8];
        const idDrawVert *dv;

        dv = &uTris->verts[i];

        vec[0] = dv->xyz[0];
        vec[1] = dv->xyz[1];
        vec[2] = dv->xyz[2];
        vec[3] = dv->st[0];
        vec[4] = dv->st[1];
        vec[5] = dv->normal[0];
        vec[6] = dv->normal[1];
        vec[7] = dv->normal[2];
        Write1DMatrix( procFile, 8, vec );

        if ( ++col == 3 )
        {
            col = 0;
            procFile->WriteFloatString( "\n" );
        }
    }
    if ( col != 0 )
    {
        procFile->WriteFloatString( "\n" );
    }

    // indexes
    col = 0;
    for ( i = 0 ; i < uTris->numIndexes ; i++ )
    {
        procFile->WriteFloatString( "%i ", uTris->indexes[i] );

        if ( ++col == 18 )
        {
            col = 0;
            procFile->WriteFloatString( "\n" );
        }
    }
    if ( col != 0 )
    {
        procFile->WriteFloatString( "\n" );
    }
}
Exemplo n.º 3
0
void Write2DMatrix (FILE *f, int y, int x, vec_t *m) {
	int		i;

	fprintf (f, "( ");
	for (i = 0 ; i < y ; i++) {
		Write1DMatrix (f, x, m + i*x);
		fprintf (f, " ");
	}
	fprintf (f, ")\n");
}
Exemplo n.º 4
0
void Write2DMatrix (CMemFile *f, int y, int x, float *m) {
	int		i;

	MemFile_fprintf (f, "( ");
	for (i = 0 ; i < y ; i++) {
		Write1DMatrix (f, x, m + i*x);
		MemFile_fprintf (f, " ");
	}
	MemFile_fprintf (f, ")\n");
}
Exemplo n.º 5
0
/*
====================
WriteUTriangles

Writes text verts and indexes to procfile
====================
*/
static void WriteUTriangles( const srfTriangles_t *uTris ) {
	int			col;
	int			i;

	// emit this chain
	procFile->WriteFloatString( "/* numVerts = */ %i /* numIndexes = */ %i\n", 
		uTris->numVerts, uTris->numIndexes );

	// verts
	col = 0;
	for ( i = 0 ; i < uTris->numVerts ; i++ ) {
		float	vec[8];
		const idDrawVert *dv;

		dv = &uTris->verts[i];

		vec[0] = dv->xyz[0];
		vec[1] = dv->xyz[1];
		vec[2] = dv->xyz[2];
// jmarshall
		idVec2 st = dv->GetTexCoord();
		vec[3] = st.x;
		vec[4] = st.y;

		idVec3 normal = dv->GetNormal();
		vec[5] = normal.x;
		vec[6] = normal.y;
		vec[7] = normal.z;
// jmarshall end
		Write1DMatrix( procFile, 8, vec );

		if ( ++col == 3 ) {
			col = 0;
			procFile->WriteFloatString( "\n" );
		}
	}
	if ( col != 0 ) {
		procFile->WriteFloatString( "\n" );
	}

	// indexes
	col = 0;
	for ( i = 0 ; i < uTris->numIndexes ; i++ ) {
		procFile->WriteFloatString( "%i ", uTris->indexes[i] );

		if ( ++col == 18 ) {
			col = 0;
			procFile->WriteFloatString( "\n" );
		}
	}
	if ( col != 0 ) {
		procFile->WriteFloatString( "\n" );
	}
}
Exemplo n.º 6
0
/*
====================
WriteShadowTriangles

Writes text verts and indexes to procfile
====================
*/
static void WriteShadowTriangles( const srfTriangles_t *tri )
{
    int			col;
    int			i;

    // emit this chain
    procFile->WriteFloatString( "/* numVerts = */ %i /* noCaps = */ %i /* noFrontCaps = */ %i /* numIndexes = */ %i /* planeBits = */ %i\n",
                                tri->numVerts, tri->numShadowIndexesNoCaps, tri->numShadowIndexesNoFrontCaps, tri->numIndexes, tri->shadowCapPlaneBits );

    // verts
    col = 0;
    for ( i = 0 ; i < tri->numVerts ; i++ )
    {
        Write1DMatrix( procFile, 3, &tri->shadowVertexes[i].xyz[0] );

        if ( ++col == 5 )
        {
            col = 0;
            procFile->WriteFloatString( "\n" );
        }
    }
    if ( col != 0 )
    {
        procFile->WriteFloatString( "\n" );
    }

    // indexes
    col = 0;
    for ( i = 0 ; i < tri->numIndexes ; i++ )
    {
        procFile->WriteFloatString( "%i ", tri->indexes[i] );

        if ( ++col == 18 )
        {
            col = 0;
            procFile->WriteFloatString( "\n" );
        }
    }
    if ( col != 0 )
    {
        procFile->WriteFloatString( "\n" );
    }
}
Exemplo n.º 7
0
/*
====================
WriteOutputPortals
====================
*/
static void WriteOutputPortals( uEntity_t *e ) {
	int			i, j;
	interAreaPortal_t	*iap;
	idWinding			*w;

	procFile->WriteFloatString( "interAreaPortals { /* numAreas = */ %i /* numIAP = */ %i\n\n", 
		e->numAreas, numInterAreaPortals );
	procFile->WriteFloatString( "/* interAreaPortal format is: numPoints positiveSideArea negativeSideArea ( point) ... */\n" );
	for ( i = 0 ; i < numInterAreaPortals ; i++ ) {
		iap = &interAreaPortals[i];
		w = iap->side->winding;
		procFile->WriteFloatString("/* iap %i */ %i %i %i ", i, w->GetNumPoints(), iap->area0, iap->area1 );
		for ( j = 0 ; j < w->GetNumPoints() ; j++ ) {
			Write1DMatrix( procFile, 3, (*w)[j].ToFloatPtr() );
		}
		procFile->WriteFloatString("\n" );
	}

	procFile->WriteFloatString( "}\n\n" );
}
Exemplo n.º 8
0
/*
==================
WriteMapFile
==================
*/
static void WriteMapFile(char *filename)
{
	FILE           *f;
	int             i, j, k, l;
	entity_t       *entity;
	epair_t        *ep;
	bspBrush_t     *brush;
	side_t         *side;
	plane_t        *plane;
	parseMesh_t    *pm;

//  winding_t      *w;
	shaderInfo_t   *si;

	Sys_Printf("writing %s\n", filename);
	f = fopen(filename, "wb");
	if(!f)
		Error("Can't write %s\b", filename);

	fprintf(f, "Version 2\n");

	for(i = 0; i < numEntities; i++)
	{
		entity = &entities[i];

		// write entity header
		fprintf(f, "// entity %i\n", i);
		fprintf(f, "{\n");

		// write epairs
		for(ep = entity->epairs; ep; ep = ep->next)
		{
			fprintf(f, "\"%s\" \"%s\"\n", ep->key, ep->value);
		}

		// write brush list
		for(j = 0, brush = entity->brushes; brush; j++, brush = brush->next)
		{
			fprintf(f, "// brush %i\n", j);
			fprintf(f, "{\n");
			fprintf(f, "brushDef3\n");
			fprintf(f, "{\n");
			for(k = 0, side = brush->sides; k < brush->numsides; k++, side++)
			{
				// write plane equation
				plane = &mapPlanes[side->planenum];

				fprintf(f, "( %f %f %f %f ) ", plane->normal[0], plane->normal[1], plane->normal[2], -plane->dist);

				// write texture matrix
				Write2DMatrix(f, 2, 3, (float *)side->texMat);

				si = side->shaderInfo;
				fprintf(f, " \"%s\"", si->shader);

				// support detail flags
				if(side->contents & CONTENTS_DETAIL)
					fprintf(f, " %i 0 0\n", CONTENTS_DETAIL);
				else
					fprintf(f, " 0 0 0\n");

			}
			fprintf(f, "}\n");
			fprintf(f, "}\n");
		}

		// write patch list
		for(j = 0, pm = entity->patches; pm; j++, pm = pm->next)
		{

			fprintf(f, "// patch %i\n", j);
			fprintf(f, "{\n");

			if(pm->patchDef3)
				fprintf(f, "patchDef3\n");
			else
				fprintf(f, "patchDef2\n");

			fprintf(f, "{\n");

			// write shader
			si = pm->shaderInfo;
			fprintf(f, "\"%s\"\n", si->shader);

			// write patch dimensions
			if(pm->patchDef3)
				fprintf(f, "( %i %i %i %i %i %i %i )\n", (int)pm->info[0], (int)pm->info[1], (int)pm->info[2], (int)pm->info[3],
						(int)pm->info[4], (int)pm->info[5], (int)pm->info[6]);
			else

				fprintf(f, "( %i %i %i %i %i )\n", (int)pm->info[0], (int)pm->info[1], (int)pm->info[2], (int)pm->info[3],
						(int)pm->info[4]);

			fprintf(f, "(\n");
			for(k = 0; k < pm->mesh.width; k++)
			{
				fprintf(f, "(");
				for(l = 0; l < pm->mesh.height; l++)
				{
					// write drawVert_t::xyz + st
					Write1DMatrix(f, 5, pm->mesh.verts[l * pm->mesh.width + k].xyz);
				}
				fprintf(f, ")\n");
			}
			fprintf(f, ")\n");

			fprintf(f, "}\n");
			fprintf(f, "}\n");
		}

		fprintf(f, "}\n");
	}

	fclose(f);
}