allow non-uniform -scale
git-svn-id: svn://svn.icculus.org/netradiant/trunk@192 61c419a2-8eb2-4b30-bcec-8cead039b335
This commit is contained in:
parent
e7f13faa4b
commit
d17571c17c
|
|
@ -380,9 +380,11 @@ amaze and confuse your enemies with wierd scaled maps!
|
||||||
int ScaleBSPMain( int argc, char **argv )
|
int ScaleBSPMain( int argc, char **argv )
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
float f, scale;
|
float f, a;
|
||||||
|
vec3_t scale;
|
||||||
vec3_t vec;
|
vec3_t vec;
|
||||||
char str[ 1024 ];
|
char str[ 1024 ];
|
||||||
|
int uniform;
|
||||||
|
|
||||||
|
|
||||||
/* arg checking */
|
/* arg checking */
|
||||||
|
|
@ -393,10 +395,17 @@ int ScaleBSPMain( int argc, char **argv )
|
||||||
}
|
}
|
||||||
|
|
||||||
/* get scale */
|
/* get scale */
|
||||||
scale = atof( argv[ argc - 2 ] );
|
scale[2] = scale[1] = scale[0] = atof( argv[ argc - 2 ] );
|
||||||
if( scale == 0.0f )
|
if(argc >= 3)
|
||||||
|
scale[1] = scale[0] = atof( argv[ argc - 3 ] );
|
||||||
|
if(argc >= 4)
|
||||||
|
scale[0] = atof( argv[ argc - 4 ] );
|
||||||
|
|
||||||
|
uniform = ((scale[0] == scale[1]) && (scale[1] == scale[2]));
|
||||||
|
|
||||||
|
if( scale[0] == 0.0f || scale[1] == 0.0f || scale[2] == 0.0f )
|
||||||
{
|
{
|
||||||
Sys_Printf( "Usage: q3map -scale <value> [-v] <mapname>\n" );
|
Sys_Printf( "Usage: q3map -scale <value> <mapname>\n" );
|
||||||
Sys_Printf( "Non-zero scale value required.\n" );
|
Sys_Printf( "Non-zero scale value required.\n" );
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -420,18 +429,26 @@ int ScaleBSPMain( int argc, char **argv )
|
||||||
{
|
{
|
||||||
/* scale origin */
|
/* scale origin */
|
||||||
GetVectorForKey( &entities[ i ], "origin", vec );
|
GetVectorForKey( &entities[ i ], "origin", vec );
|
||||||
if( (vec[ 0 ] + vec[ 1 ] + vec[ 2 ]) )
|
if( (vec[ 0 ] || vec[ 1 ] || vec[ 2 ]) )
|
||||||
{
|
{
|
||||||
VectorScale( vec, scale, vec );
|
vec[0] *= scale[0];
|
||||||
|
vec[1] *= scale[1];
|
||||||
|
vec[2] *= scale[2];
|
||||||
sprintf( str, "%f %f %f", vec[ 0 ], vec[ 1 ], vec[ 2 ] );
|
sprintf( str, "%f %f %f", vec[ 0 ], vec[ 1 ], vec[ 2 ] );
|
||||||
SetKeyValue( &entities[ i ], "origin", str );
|
SetKeyValue( &entities[ i ], "origin", str );
|
||||||
}
|
}
|
||||||
|
|
||||||
/* scale door lip */
|
/* scale door lip */
|
||||||
f = FloatForKey( &entities[ i ], "lip" );
|
f = FloatForKey( &entities[ i ], "lip" );
|
||||||
|
a = FloatForKey( &entities[ i ], "angle" );
|
||||||
if( f )
|
if( f )
|
||||||
{
|
{
|
||||||
f *= scale;
|
if(a == -1 || a == -2) // z scale
|
||||||
|
f *= scale[2];
|
||||||
|
else if(fabs(sin(DEG2RAD(a))) < 0.707)
|
||||||
|
f *= scale[0];
|
||||||
|
else
|
||||||
|
f *= scale[1];
|
||||||
sprintf( str, "%f", f );
|
sprintf( str, "%f", f );
|
||||||
SetKeyValue( &entities[ i ], "lip", str );
|
SetKeyValue( &entities[ i ], "lip", str );
|
||||||
}
|
}
|
||||||
|
|
@ -440,37 +457,76 @@ int ScaleBSPMain( int argc, char **argv )
|
||||||
/* scale models */
|
/* scale models */
|
||||||
for( i = 0; i < numBSPModels; i++ )
|
for( i = 0; i < numBSPModels; i++ )
|
||||||
{
|
{
|
||||||
VectorScale( bspModels[ i ].mins, scale, bspModels[ i ].mins );
|
bspModels[ i ].mins[0] *= scale[0];
|
||||||
VectorScale( bspModels[ i ].maxs, scale, bspModels[ i ].maxs );
|
bspModels[ i ].mins[1] *= scale[1];
|
||||||
|
bspModels[ i ].mins[2] *= scale[2];
|
||||||
|
bspModels[ i ].maxs[0] *= scale[0];
|
||||||
|
bspModels[ i ].maxs[1] *= scale[1];
|
||||||
|
bspModels[ i ].maxs[2] *= scale[2];
|
||||||
}
|
}
|
||||||
|
|
||||||
/* scale nodes */
|
/* scale nodes */
|
||||||
for( i = 0; i < numBSPNodes; i++ )
|
for( i = 0; i < numBSPNodes; i++ )
|
||||||
{
|
{
|
||||||
VectorScale( bspNodes[ i ].mins, scale, bspNodes[ i ].mins );
|
bspNodes[ i ].mins[0] *= scale[0];
|
||||||
VectorScale( bspNodes[ i ].maxs, scale, bspNodes[ i ].maxs );
|
bspNodes[ i ].mins[1] *= scale[1];
|
||||||
|
bspNodes[ i ].mins[2] *= scale[2];
|
||||||
|
bspNodes[ i ].maxs[0] *= scale[0];
|
||||||
|
bspNodes[ i ].maxs[1] *= scale[1];
|
||||||
|
bspNodes[ i ].maxs[2] *= scale[2];
|
||||||
}
|
}
|
||||||
|
|
||||||
/* scale leafs */
|
/* scale leafs */
|
||||||
for( i = 0; i < numBSPLeafs; i++ )
|
for( i = 0; i < numBSPLeafs; i++ )
|
||||||
{
|
{
|
||||||
VectorScale( bspLeafs[ i ].mins, scale, bspLeafs[ i ].mins );
|
bspLeafs[ i ].mins[0] *= scale[0];
|
||||||
VectorScale( bspLeafs[ i ].maxs, scale, bspLeafs[ i ].maxs );
|
bspLeafs[ i ].mins[1] *= scale[1];
|
||||||
|
bspLeafs[ i ].mins[2] *= scale[2];
|
||||||
|
bspLeafs[ i ].maxs[0] *= scale[0];
|
||||||
|
bspLeafs[ i ].maxs[1] *= scale[1];
|
||||||
|
bspLeafs[ i ].maxs[2] *= scale[2];
|
||||||
}
|
}
|
||||||
|
|
||||||
/* scale drawverts */
|
/* scale drawverts */
|
||||||
for( i = 0; i < numBSPDrawVerts; i++ )
|
for( i = 0; i < numBSPDrawVerts; i++ )
|
||||||
VectorScale( bspDrawVerts[ i ].xyz, scale, bspDrawVerts[ i ].xyz );
|
{
|
||||||
|
bspDrawVerts[i].xyz[0] *= scale[0];
|
||||||
|
bspDrawVerts[i].xyz[1] *= scale[1];
|
||||||
|
bspDrawVerts[i].xyz[2] *= scale[2];
|
||||||
|
bspDrawVerts[i].normal[0] /= scale[0];
|
||||||
|
bspDrawVerts[i].normal[1] /= scale[1];
|
||||||
|
bspDrawVerts[i].normal[2] /= scale[2];
|
||||||
|
VectorNormalize(bspDrawVerts[i].normal, bspDrawVerts[i].normal);
|
||||||
|
}
|
||||||
|
|
||||||
/* scale planes */
|
/* scale planes */
|
||||||
for( i = 0; i < numBSPPlanes; i++ )
|
if(uniform)
|
||||||
bspPlanes[ i ].dist *= scale;
|
{
|
||||||
|
for( i = 0; i < numBSPPlanes; i++ )
|
||||||
|
{
|
||||||
|
bspPlanes[ i ].dist *= scale[0];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for( i = 0; i < numBSPPlanes; i++ )
|
||||||
|
{
|
||||||
|
bspPlanes[ i ].normal[0] /= scale[0];
|
||||||
|
bspPlanes[ i ].normal[1] /= scale[1];
|
||||||
|
bspPlanes[ i ].normal[2] /= scale[2];
|
||||||
|
f = 1/VectorLength(bspPlanes[i].normal);
|
||||||
|
VectorScale(bspPlanes[i].normal, f, bspPlanes[i].normal);
|
||||||
|
bspPlanes[ i ].dist *= f;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* scale gridsize */
|
/* scale gridsize */
|
||||||
GetVectorForKey( &entities[ 0 ], "gridsize", vec );
|
GetVectorForKey( &entities[ 0 ], "gridsize", vec );
|
||||||
if( (vec[ 0 ] + vec[ 1 ] + vec[ 2 ]) == 0.0f )
|
if( (vec[ 0 ] + vec[ 1 ] + vec[ 2 ]) == 0.0f )
|
||||||
VectorCopy( gridSize, vec );
|
VectorCopy( gridSize, vec );
|
||||||
VectorScale( vec, scale, vec );
|
vec[0] *= scale[0];
|
||||||
|
vec[1] *= scale[1];
|
||||||
|
vec[2] *= scale[2];
|
||||||
sprintf( str, "%f %f %f", vec[ 0 ], vec[ 1 ], vec[ 2 ] );
|
sprintf( str, "%f %f %f", vec[ 0 ], vec[ 1 ], vec[ 2 ] );
|
||||||
SetKeyValue( &entities[ 0 ], "gridsize", str );
|
SetKeyValue( &entities[ 0 ], "gridsize", str );
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user