q3map2: * Valve220 mapformat autodetection and support
This commit is contained in:
parent
4cefcfb0a0
commit
a2406ea3d7
|
|
@ -1074,7 +1074,7 @@ static void ParseRawBrush( qboolean onlyLights ){
|
||||||
buildBrush->detail = qfalse;
|
buildBrush->detail = qfalse;
|
||||||
|
|
||||||
/* bp */
|
/* bp */
|
||||||
if ( g_bBrushPrimit == BPRIMIT_NEWBRUSHES ) {
|
if ( g_brushType == BPRIMIT_BP ) {
|
||||||
MatchToken( "{" );
|
MatchToken( "{" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1089,7 +1089,7 @@ static void ParseRawBrush( qboolean onlyLights ){
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ttimo : bp: here we may have to jump over brush epairs (only used in editor) */
|
/* ttimo : bp: here we may have to jump over brush epairs (only used in editor) */
|
||||||
if ( g_bBrushPrimit == BPRIMIT_NEWBRUSHES ) {
|
if ( g_brushType == BPRIMIT_BP ) {
|
||||||
while ( 1 )
|
while ( 1 )
|
||||||
{
|
{
|
||||||
if ( strcmp( token, "(" ) ) {
|
if ( strcmp( token, "(" ) ) {
|
||||||
|
|
@ -1119,7 +1119,7 @@ static void ParseRawBrush( qboolean onlyLights ){
|
||||||
Parse1DMatrix( 3, planePoints[ 2 ] );
|
Parse1DMatrix( 3, planePoints[ 2 ] );
|
||||||
|
|
||||||
/* bp: read the texture matrix */
|
/* bp: read the texture matrix */
|
||||||
if ( g_bBrushPrimit == BPRIMIT_NEWBRUSHES ) {
|
if ( g_brushType == BPRIMIT_BP ) {
|
||||||
Parse2DMatrix( 2, 3, (float*) side->texMat );
|
Parse2DMatrix( 2, 3, (float*) side->texMat );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1127,8 +1127,21 @@ static void ParseRawBrush( qboolean onlyLights ){
|
||||||
GetToken( qfalse );
|
GetToken( qfalse );
|
||||||
strcpy( name, token );
|
strcpy( name, token );
|
||||||
|
|
||||||
/* bp */
|
/* AP or 220? */
|
||||||
if ( g_bBrushPrimit == BPRIMIT_OLDBRUSHES ) {
|
if ( g_brushType == BPRIMIT_UNDEFINED ){
|
||||||
|
GetToken( qfalse );
|
||||||
|
if ( !strcmp( token, "[" ) ){
|
||||||
|
g_brushType = BPRIMIT_VALVE220;
|
||||||
|
Sys_FPrintf( SYS_VRB, "detected brushType = VALVE 220\n" );
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
g_brushType = BPRIMIT_QUAKE;
|
||||||
|
Sys_FPrintf( SYS_VRB, "detected brushType = QUAKE (Axial Projection)\n" );
|
||||||
|
}
|
||||||
|
UnGetToken();
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( g_brushType == BPRIMIT_QUAKE ) {
|
||||||
GetToken( qfalse );
|
GetToken( qfalse );
|
||||||
shift[ 0 ] = atof( token );
|
shift[ 0 ] = atof( token );
|
||||||
GetToken( qfalse );
|
GetToken( qfalse );
|
||||||
|
|
@ -1140,6 +1153,29 @@ static void ParseRawBrush( qboolean onlyLights ){
|
||||||
GetToken( qfalse );
|
GetToken( qfalse );
|
||||||
scale[ 1 ] = atof( token );
|
scale[ 1 ] = atof( token );
|
||||||
}
|
}
|
||||||
|
else if ( g_brushType == BPRIMIT_VALVE220 ){
|
||||||
|
int axis, comp;
|
||||||
|
for ( axis = 0; axis < 2; ++axis ){
|
||||||
|
MatchToken( "[" );
|
||||||
|
for ( comp = 0; comp < 4; ++comp ){
|
||||||
|
GetToken( qfalse );
|
||||||
|
side->vecs[axis][comp] = atof( token );
|
||||||
|
}
|
||||||
|
MatchToken( "]" );
|
||||||
|
}
|
||||||
|
GetToken( qfalse );
|
||||||
|
rotate = atof( token );
|
||||||
|
GetToken( qfalse );
|
||||||
|
scale[ 0 ] = atof( token );
|
||||||
|
GetToken( qfalse );
|
||||||
|
scale[ 1 ] = atof( token );
|
||||||
|
|
||||||
|
if ( !scale[0] ) scale[0] = 1.f;
|
||||||
|
if ( !scale[1] ) scale[1] = 1.f;
|
||||||
|
for ( axis = 0; axis < 2; ++axis )
|
||||||
|
for ( comp = 0; comp < 3; ++comp )
|
||||||
|
side->vecs[axis][comp] /= scale[axis];
|
||||||
|
}
|
||||||
|
|
||||||
/* set default flags and values */
|
/* set default flags and values */
|
||||||
sprintf( shader, "textures/%s", name );
|
sprintf( shader, "textures/%s", name );
|
||||||
|
|
@ -1192,13 +1228,13 @@ static void ParseRawBrush( qboolean onlyLights ){
|
||||||
side->planenum = planenum;
|
side->planenum = planenum;
|
||||||
|
|
||||||
/* bp: get the texture mapping for this texturedef / plane combination */
|
/* bp: get the texture mapping for this texturedef / plane combination */
|
||||||
if ( g_bBrushPrimit == BPRIMIT_OLDBRUSHES ) {
|
if ( g_brushType == BPRIMIT_QUAKE ) {
|
||||||
QuakeTextureVecs( &mapplanes[ planenum ], shift, rotate, scale, side->vecs );
|
QuakeTextureVecs( &mapplanes[ planenum ], shift, rotate, scale, side->vecs );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* bp */
|
/* bp */
|
||||||
if ( g_bBrushPrimit == BPRIMIT_NEWBRUSHES ) {
|
if ( g_brushType == BPRIMIT_BP ) {
|
||||||
UnGetToken();
|
UnGetToken();
|
||||||
MatchToken( "}" );
|
MatchToken( "}" );
|
||||||
MatchToken( "}" );
|
MatchToken( "}" );
|
||||||
|
|
@ -1712,23 +1748,16 @@ static qboolean ParseMapEntity( qboolean onlyLights, qboolean noCollapseGroups )
|
||||||
Sys_Printf( "WARNING: Terrain entity parsing not supported in this build.\n" ); /* ydnar */
|
Sys_Printf( "WARNING: Terrain entity parsing not supported in this build.\n" ); /* ydnar */
|
||||||
}
|
}
|
||||||
else if ( !strcmp( token, "brushDef" ) ) {
|
else if ( !strcmp( token, "brushDef" ) ) {
|
||||||
if ( g_bBrushPrimit == BPRIMIT_OLDBRUSHES ) {
|
if ( g_brushType == BPRIMIT_UNDEFINED ) {
|
||||||
Error( "Old brush format not allowed in new brush format map" );
|
Sys_FPrintf( SYS_VRB, "detected brushType = BRUSH PRIMITIVES\n" );
|
||||||
|
g_brushType = BPRIMIT_BP;
|
||||||
}
|
}
|
||||||
g_bBrushPrimit = BPRIMIT_NEWBRUSHES;
|
|
||||||
|
|
||||||
/* parse brush primitive */
|
|
||||||
ParseBrush( onlyLights, noCollapseGroups );
|
ParseBrush( onlyLights, noCollapseGroups );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if ( g_bBrushPrimit == BPRIMIT_NEWBRUSHES ) {
|
/* AP or 220 */
|
||||||
Error( "New brush format not allowed in old brush format map" );
|
UnGetToken(); // (
|
||||||
}
|
|
||||||
g_bBrushPrimit = BPRIMIT_OLDBRUSHES;
|
|
||||||
|
|
||||||
/* parse old brush format */
|
|
||||||
UnGetToken();
|
|
||||||
ParseBrush( onlyLights, noCollapseGroups );
|
ParseBrush( onlyLights, noCollapseGroups );
|
||||||
}
|
}
|
||||||
entitySourceBrushes++;
|
entitySourceBrushes++;
|
||||||
|
|
@ -1956,7 +1985,7 @@ void LoadMapFile( char *filename, qboolean onlyLights, qboolean noCollapseGroups
|
||||||
/* initial setup */
|
/* initial setup */
|
||||||
numMapDrawSurfs = 0;
|
numMapDrawSurfs = 0;
|
||||||
c_detail = 0;
|
c_detail = 0;
|
||||||
g_bBrushPrimit = BPRIMIT_UNDEFINED;
|
g_brushType = BPRIMIT_UNDEFINED;
|
||||||
|
|
||||||
/* allocate a very large temporary brush for building the brushes as they are loaded */
|
/* allocate a very large temporary brush for building the brushes as they are loaded */
|
||||||
buildBrush = AllocBrush( MAX_BUILD_SIDES );
|
buildBrush = AllocBrush( MAX_BUILD_SIDES );
|
||||||
|
|
|
||||||
|
|
@ -269,7 +269,7 @@ void ParsePatch( qboolean onlyLights ){
|
||||||
|
|
||||||
// if brush primitives format, we may have some epairs to ignore here
|
// if brush primitives format, we may have some epairs to ignore here
|
||||||
GetToken( qtrue );
|
GetToken( qtrue );
|
||||||
if ( g_bBrushPrimit != BPRIMIT_OLDBRUSHES && strcmp( token,"}" ) ) {
|
if ( strcmp( token, "}" ) && ( g_brushType == BPRIMIT_BP || g_brushType == BPRIMIT_UNDEFINED ) ) {
|
||||||
ep = ParseEPair();
|
ep = ParseEPair();
|
||||||
free( ep->key );
|
free( ep->key );
|
||||||
free( ep->value );
|
free( ep->value );
|
||||||
|
|
|
||||||
|
|
@ -208,10 +208,13 @@
|
||||||
#define PSIDE_BOTH ( PSIDE_FRONT | PSIDE_BACK )
|
#define PSIDE_BOTH ( PSIDE_FRONT | PSIDE_BACK )
|
||||||
#define PSIDE_FACING 4
|
#define PSIDE_FACING 4
|
||||||
|
|
||||||
#define BPRIMIT_UNDEFINED 0
|
typedef enum{
|
||||||
#define BPRIMIT_OLDBRUSHES 1
|
BPRIMIT_UNDEFINED = 0,
|
||||||
#define BPRIMIT_NEWBRUSHES 2
|
BPRIMIT_QUAKE,
|
||||||
|
BPRIMIT_BP,
|
||||||
|
BPRIMIT_VALVE220
|
||||||
|
}
|
||||||
|
brushType_t;
|
||||||
|
|
||||||
/* vis */
|
/* vis */
|
||||||
#define VIS_HEADER_SIZE 8
|
#define VIS_HEADER_SIZE 8
|
||||||
|
|
@ -2128,7 +2131,7 @@ Q_EXTERN fog_t mapFogs[ MAX_MAP_FOGS ];
|
||||||
Q_EXTERN entity_t *mapEnt;
|
Q_EXTERN entity_t *mapEnt;
|
||||||
Q_EXTERN brush_t *buildBrush;
|
Q_EXTERN brush_t *buildBrush;
|
||||||
Q_EXTERN int numActiveBrushes;
|
Q_EXTERN int numActiveBrushes;
|
||||||
Q_EXTERN int g_bBrushPrimit;
|
Q_EXTERN brushType_t g_brushType;
|
||||||
|
|
||||||
Q_EXTERN int numStrippedLights Q_ASSIGN( 0 );
|
Q_EXTERN int numStrippedLights Q_ASSIGN( 0 );
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -992,18 +992,8 @@ mapDrawSurface_t *DrawSurfaceForSide( entity_t *e, brush_t *b, side_t *s, windin
|
||||||
dv->st[ 1 ] = DotProduct( si->vecs[ 1 ], vTranslated );
|
dv->st[ 1 ] = DotProduct( si->vecs[ 1 ], vTranslated );
|
||||||
}
|
}
|
||||||
|
|
||||||
/* old quake-style texturing */
|
|
||||||
else if ( g_bBrushPrimit == BPRIMIT_OLDBRUSHES ) {
|
|
||||||
/* nearest-axial projection */
|
|
||||||
dv->st[ 0 ] = s->vecs[ 0 ][ 3 ] + DotProduct( s->vecs[ 0 ], vTranslated );
|
|
||||||
dv->st[ 1 ] = s->vecs[ 1 ][ 3 ] + DotProduct( s->vecs[ 1 ], vTranslated );
|
|
||||||
dv->st[ 0 ] /= si->shaderWidth;
|
|
||||||
dv->st[ 1 ] /= si->shaderHeight;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* brush primitive texturing */
|
/* brush primitive texturing */
|
||||||
else
|
else if ( g_brushType == BPRIMIT_BP ) {
|
||||||
{
|
|
||||||
/* calculate texture s/t from brush primitive texture matrix */
|
/* calculate texture s/t from brush primitive texture matrix */
|
||||||
x = DotProduct( vTranslated, texX );
|
x = DotProduct( vTranslated, texX );
|
||||||
y = DotProduct( vTranslated, texY );
|
y = DotProduct( vTranslated, texY );
|
||||||
|
|
@ -1011,6 +1001,15 @@ mapDrawSurface_t *DrawSurfaceForSide( entity_t *e, brush_t *b, side_t *s, windin
|
||||||
dv->st[ 1 ] = s->texMat[ 1 ][ 0 ] * x + s->texMat[ 1 ][ 1 ] * y + s->texMat[ 1 ][ 2 ];
|
dv->st[ 1 ] = s->texMat[ 1 ][ 0 ] * x + s->texMat[ 1 ][ 1 ] * y + s->texMat[ 1 ][ 2 ];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* old quake-style or valve 220 texturing */
|
||||||
|
else {
|
||||||
|
/* nearest-axial projection */
|
||||||
|
dv->st[ 0 ] = s->vecs[ 0 ][ 3 ] + DotProduct( s->vecs[ 0 ], vTranslated );
|
||||||
|
dv->st[ 1 ] = s->vecs[ 1 ][ 3 ] + DotProduct( s->vecs[ 1 ], vTranslated );
|
||||||
|
dv->st[ 0 ] /= si->shaderWidth;
|
||||||
|
dv->st[ 1 ] /= si->shaderHeight;
|
||||||
|
}
|
||||||
|
|
||||||
/* copy normal */
|
/* copy normal */
|
||||||
VectorCopy( mapplanes[ s->planenum ].normal, dv->normal );
|
VectorCopy( mapplanes[ s->planenum ].normal, dv->normal );
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user