コード例 #1
0
ファイル: writebsp.c プロジェクト: AHPlankton/Quake-III-Arena
/*
============
EmitBrushes
============
*/
void EmitBrushes ( bspbrush_t *brushes ) {
	int				j;
	dbrush_t		*db;
	bspbrush_t		*b;
	dbrushside_t	*cp;

	for ( b = brushes ; b ; b = b->next ) {
		if ( numbrushes == MAX_MAP_BRUSHES ) {
			Error( "MAX_MAP_BRUSHES" );
		}
		b->outputNumber = numbrushes;
		db = &dbrushes[numbrushes];
		numbrushes++;

		db->shaderNum = EmitShader( b->contentShader->shader );
		db->firstSide = numbrushsides;

		// don't emit any generated backSide sides
		db->numSides = 0;
		for ( j=0 ; j<b->numsides ; j++ ) {
			if ( b->sides[j].backSide ) {
				continue;
			}
			if ( numbrushsides == MAX_MAP_BRUSHSIDES ) {
				Error( "MAX_MAP_BRUSHSIDES ");
			}
			cp = &dbrushsides[numbrushsides];
			db->numSides++;
			numbrushsides++;
			cp->planeNum = b->sides[j].planenum;
			cp->shaderNum = EmitShader( b->sides[j].shaderInfo->shader );
		}
	}

}
コード例 #2
0
ファイル: writebsp.c プロジェクト: Triang3l/netradiant
void EmitBrushes( brush_t *brushes, int *firstBrush, int *numBrushes ){
	int j;
	brush_t         *b;
	bspBrush_t      *db;
	bspBrushSide_t  *cp;


	/* set initial brush */
	if ( firstBrush != NULL ) {
		*firstBrush = numBSPBrushes;
	}
	if ( numBrushes != NULL ) {
		*numBrushes = 0;
	}

	/* walk list of brushes */
	for ( b = brushes; b != NULL; b = b->next )
	{
		/* check limits */
		AUTOEXPAND_BY_REALLOC_BSP( Brushes, 1024 );

		/* get bsp brush */
		b->outputNum = numBSPBrushes;
		db = &bspBrushes[ numBSPBrushes ];
		numBSPBrushes++;
		if ( numBrushes != NULL ) {
			( *numBrushes )++;
		}

		db->shaderNum = EmitShader( b->contentShader->shader, &b->contentShader->contentFlags, &b->contentShader->surfaceFlags );
		db->firstSide = numBSPBrushSides;

		/* walk sides */
		db->numSides = 0;
		for ( j = 0; j < b->numsides; j++ )
		{
			/* set output number to bogus initially */
			b->sides[ j ].outputNum = -1;

			/* check count */
			AUTOEXPAND_BY_REALLOC_BSP( BrushSides, 1024 );

			/* emit side */
			b->sides[ j ].outputNum = numBSPBrushSides;
			cp = &bspBrushSides[ numBSPBrushSides ];
			db->numSides++;
			numBSPBrushSides++;
			cp->planeNum = b->sides[ j ].planenum;

			/* emit shader */
			if ( b->sides[ j ].shaderInfo ) {
				cp->shaderNum = EmitShader( b->sides[ j ].shaderInfo->shader, &b->sides[ j ].shaderInfo->contentFlags, &b->sides[ j ].shaderInfo->surfaceFlags );
			}
			else{
				cp->shaderNum = EmitShader( NULL, NULL, NULL );
			}
		}
	}
}
コード例 #3
0
ファイル: writebsp.c プロジェクト: ChunHungLiu/GtkRadiant
void EmitBrushes( brush_t *brushes, int *firstBrush, int *numBrushes )
{
	int				j;
	brush_t			*b;
	bspBrush_t		*db;
	bspBrushSide_t	*cp;
	
	
	/* set initial brush */
	if( firstBrush != NULL )
		*firstBrush = numBSPBrushes;
	if( numBrushes != NULL )
		*numBrushes = 0;
	
	/* walk list of brushes */
	for( b = brushes; b != NULL; b = b->next )
	{
		/* check limits */
		if( numBSPBrushes == MAX_MAP_BRUSHES )
			Error( "MAX_MAP_BRUSHES (%d)", numBSPBrushes );
		
		/* get bsp brush */
		b->outputNum = numBSPBrushes;
		db = &bspBrushes[ numBSPBrushes ];
		numBSPBrushes++;
		if( numBrushes != NULL )
			(*numBrushes)++;
		
		db->shaderNum = EmitShader( b->contentShader->shader, &b->contentShader->contentFlags, &b->contentShader->surfaceFlags );
		db->firstSide = numBSPBrushSides;
		
		/* walk sides */
		db->numSides = 0;
		for( j = 0; j < b->numsides; j++ )
		{
			/* set output number to bogus initially */
			b->sides[ j ].outputNum = -1;
			
			/* check count */
			if( numBSPBrushSides == MAX_MAP_BRUSHSIDES )
				Error( "MAX_MAP_BRUSHSIDES ");
			
			/* emit side */
			b->sides[ j ].outputNum = numBSPBrushSides;
			cp = &bspBrushSides[ numBSPBrushSides ];
			db->numSides++;
			numBSPBrushSides++;
			cp->planeNum = b->sides[ j ].planenum;
			
			/* emit shader */
			if( b->sides[ j ].shaderInfo )
				cp->shaderNum = EmitShader( b->sides[ j ].shaderInfo->shader, &b->sides[ j ].shaderInfo->contentFlags, &b->sides[ j ].shaderInfo->surfaceFlags );
			else
				cp->shaderNum = EmitShader( NULL, NULL, NULL );
		}
	}
}
コード例 #4
0
ファイル: writebsp.c プロジェクト: Triang3l/netradiant
int EmitShader( const char *shader, int *contentFlags, int *surfaceFlags ){
	int i;
	shaderInfo_t    *si;


	/* handle special cases */
	if ( shader == NULL ) {
		shader = "noshader";
	}

	/* try to find an existing shader */
	for ( i = 0; i < numBSPShaders; i++ )
	{
		/* ydnar: handle custom surface/content flags */
		if ( surfaceFlags != NULL && bspShaders[ i ].surfaceFlags != *surfaceFlags ) {
			continue;
		}
		if ( contentFlags != NULL && bspShaders[ i ].contentFlags != *contentFlags ) {
			continue;
		}

		/* compare name */
		if ( !Q_stricmp( shader, bspShaders[ i ].shader ) ) {
			return i;
		}
	}

	// i == numBSPShaders

	/* get shaderinfo */
	si = ShaderInfoForShader( shader );

	/* emit a new shader */
	AUTOEXPAND_BY_REALLOC_BSP( Shaders, 1024 );

	numBSPShaders++;
	strcpy( bspShaders[ i ].shader, shader );
	bspShaders[ i ].surfaceFlags = si->surfaceFlags;
	bspShaders[ i ].contentFlags = si->contentFlags;

	/* handle custom content/surface flags */
	if ( surfaceFlags != NULL ) {
		bspShaders[ i ].surfaceFlags = *surfaceFlags;
	}
	if ( contentFlags != NULL ) {
		bspShaders[ i ].contentFlags = *contentFlags;
	}

	/* recursively emit any damage shaders */
	if ( si->damageShader != NULL && si->damageShader[ 0 ] != '\0' ) {
		Sys_FPrintf( SYS_VRB, "Shader %s has damage shader %s\n", si->shader, si->damageShader );
		EmitShader( si->damageShader, NULL, NULL );
	}

	/* return it */
	return i;
}
コード例 #5
0
ファイル: bsp.c プロジェクト: Teivaz/nebula2
static void FixBrushSides( entity_t *e )
{
    int                    i;
    mapDrawSurface_t    *ds;
    sideRef_t            *sideRef;
    bspBrushSide_t        *side;
    
    
    /* note it */
    Sys_FPrintf( SYS_VRB, "--- FixBrushSides ---\n" );
    
    /* walk list of drawsurfaces */
    for( i = e->firstDrawSurf; i < numMapDrawSurfs; i++ )
    {
        /* get surface and try to early out */
        ds = &mapDrawSurfs[ i ];
        if( ds->outputNum < 0 )
            continue;
        
        /* walk sideref list */
        for( sideRef = ds->sideRef; sideRef != NULL; sideRef = sideRef->next )
        {
            /* get bsp brush side */
            if( sideRef->side == NULL || sideRef->side->outputNum < 0 )
                continue;
            side = &bspBrushSides[ sideRef->side->outputNum ];
            
            /* set drawsurface */
            side->surfaceNum = ds->outputNum;
            //%    Sys_FPrintf( SYS_VRB, "DS: %7d Side: %7d     ", ds->outputNum, sideRef->side->outputNum );
            
            /* set shader */
            if( strcmp( bspShaders[ side->shaderNum ].shader, ds->shaderInfo->shader ) )
            {
                //%    Sys_FPrintf( SYS_VRB, "Remapping %s to %s\n", bspShaders[ side->shaderNum ].shader, ds->shaderInfo->shader );
                side->shaderNum = EmitShader( ds->shaderInfo->shader, &ds->shaderInfo->contentFlags, &ds->shaderInfo->surfaceFlags );
            }
        }
    }
}
コード例 #6
0
ファイル: writebsp.c プロジェクト: smokin-guns/GtkRadiant
int EmitShader( const char *shader, int *contentFlags, int *surfaceFlags ){
	int i;
	shaderInfo_t    *si;


	/* handle special cases */
	if ( shader == NULL ) {
		shader = "noshader";
	}

	/* try to find an existing shader */
	for ( i = 0; i < numBSPShaders; i++ )
	{
		/* ydnar: handle custom surface/content flags */
#ifndef SMOKINGUNS
		if ( surfaceFlags != NULL && bspShaders[ i ].surfaceFlags != *surfaceFlags ) {
			continue;
		}
		if ( contentFlags != NULL && bspShaders[ i ].contentFlags != *contentFlags ) {
			continue;
		}
#endif

		/* compare name */
		if ( !Q_stricmp( shader, bspShaders[ i ].shader ) ) {
			return i;
		}
	}

	/* get shaderinfo */
	si = ShaderInfoForShader( shader );

	/* emit a new shader */
	if ( i == MAX_MAP_SHADERS ) {
		Error( "MAX_MAP_SHADERS" );
	}
	numBSPShaders++;
	strcpy( bspShaders[ i ].shader, shader );
	bspShaders[ i ].surfaceFlags = si->surfaceFlags;
#ifdef SMOKINGUNS
	bspShaders[ i ].surfaceFlags |= GetSurfaceParm(si->shader);
#endif
	bspShaders[ i ].contentFlags = si->contentFlags;

	/* handle custom content/surface flags */
#ifndef SMOKINGUNS
	if ( surfaceFlags != NULL ) {
		bspShaders[ i ].surfaceFlags = *surfaceFlags;
	}
	if ( contentFlags != NULL ) {
		bspShaders[ i ].contentFlags = *contentFlags;
	}
#endif

	/* recursively emit any damage shaders */
	if ( si->damageShader != NULL && si->damageShader[ 0 ] != '\0' ) {
		Sys_FPrintf( SYS_VRB, "Shader %s has damage shader %s\n", si->shader, si->damageShader );
		EmitShader( si->damageShader, NULL, NULL );
	}

	/* return it */
	return i;
}