Browse Source

utils: mdldec: small update.

pull/2/head
Andrey Akhmichin 4 years ago committed by Alibek Omarov
parent
commit
299e3fe957
  1. 2
      utils/mdldec/Makefile
  2. 46
      utils/mdldec/qc.c
  3. 25
      utils/mdldec/smd.c
  4. 6
      utils/mdldec/texture.c

2
utils/mdldec/Makefile

@ -4,7 +4,7 @@ @@ -4,7 +4,7 @@
MODULE = mdldec
CC ?= gcc
CFLAGS ?= -O3 -pipe -DHAVE_TGMATH_H
CFLAGS ?= -O3 -pipe -DHAVE_TGMATH_H -DSTDINT_H=\<stdint.h\>
LDFLAGS ?= -Wl,--no-undefined
SYS = $(shell $(CC) -dumpmachine)

46
utils/mdldec/qc.c

@ -145,23 +145,20 @@ static void GetMotionTypeString( int type, char *str, qboolean is_composite ) @@ -145,23 +145,20 @@ static void GetMotionTypeString( int type, char *str, qboolean is_composite )
if( type & STUDIO_LZ )
Q_strcat( str, " LZ" );
if( type & STUDIO_AX )
Q_strcat( str, " AX" );
if( type & STUDIO_LXR )
Q_strcat( str, " LXR" );
if( type & STUDIO_AY )
Q_strcat( str, " AY" );
if( type & STUDIO_LYR )
Q_strcat( str, " LYR" );
if( type & STUDIO_AZ )
Q_strcat( str, " AZ" );
if( type & STUDIO_LZR )
Q_strcat( str, " LZR" );
if( type & STUDIO_AXR )
Q_strcat( str, " AXR" );
if( type & STUDIO_LINEAR )
Q_strcat( str, " LM" );
if( type & STUDIO_AYR )
Q_strcat( str, " AYR" );
if( type & STUDIO_AZR )
Q_strcat( str, " AZR" );
if( type & STUDIO_QUADRATIC_MOTION )
Q_strcat( str, " LQ" );
return;
}
@ -179,12 +176,11 @@ static void GetMotionTypeString( int type, char *str, qboolean is_composite ) @@ -179,12 +176,11 @@ static void GetMotionTypeString( int type, char *str, qboolean is_composite )
case STUDIO_LX: p = "LX"; break;
case STUDIO_LY: p = "LY"; break;
case STUDIO_LZ: p = "LZ"; break;
case STUDIO_AX: p = "AX"; break;
case STUDIO_AY: p = "AY"; break;
case STUDIO_AZ: p = "AZ"; break;
case STUDIO_AXR: p = "AXR"; break;
case STUDIO_AYR: p = "AYR"; break;
case STUDIO_AZR: p = "AZR"; break;
case STUDIO_LXR: p = "LXR"; break;
case STUDIO_LYR: p = "LYR"; break;
case STUDIO_LZR: p = "LZR"; break;
case STUDIO_LINEAR: p = "LM"; break;
case STUDIO_QUADRATIC_MOTION: p = "LQ"; break;
default: break;
}
@ -218,7 +214,7 @@ static void WriteTextureRenderMode( FILE *fp ) @@ -218,7 +214,7 @@ static void WriteTextureRenderMode( FILE *fp )
if( texture->flags & STUDIO_NF_NOMIPS )
fprintf( fp, "$texrendermode \"%s\" \"nomips\" \n", texture->name ); // sven-coop extension
if( texture->flags & STUDIO_NF_NOSMOOTH )
if( texture->flags & STUDIO_NF_SMOOTH )
{
fprintf( fp, "$texrendermode \"%s\" \"alpha\" \n", texture->name ); // sven-coop extension
fprintf( fp, "$texrendermode \"%s\" \"nosmooth\" \n", texture->name ); // xash3d extension
@ -230,7 +226,7 @@ static void WriteTextureRenderMode( FILE *fp ) @@ -230,7 +226,7 @@ static void WriteTextureRenderMode( FILE *fp )
if( texture->flags & STUDIO_NF_MASKED )
fprintf( fp, "$texrendermode \"%s\" \"masked\" \n", texture->name );
if( texture->flags & ( STUDIO_NF_MASKED | STUDIO_NF_SOLID ) )
if( texture->flags & ( STUDIO_NF_MASKED | STUDIO_NF_ALPHASOLID ) )
fprintf( fp, "$texrendermode \"%s\" \"masked_solid\" \n", texture->name ); // xash3d extension
if( texture->flags & STUDIO_NF_TWOSIDE )
@ -557,10 +553,6 @@ static void WriteSequenceInfo( FILE *fp ) @@ -557,10 +553,6 @@ static void WriteSequenceInfo( FILE *fp )
if( seqdesc->numblends > 2 )
fputs( "}\n", fp );
if( seqdesc->numpivots )
printf( "WARNING: Sequence %s uses %i foot pivots, feature not supported.\n",
seqdesc->label, seqdesc->numpivots );
}
}
@ -573,11 +565,11 @@ void WriteQCScript( void ) @@ -573,11 +565,11 @@ void WriteQCScript( void )
{
FILE *fp;
char filename[MAX_SYSPATH];
size_t len;
int len;
len = Q_snprintf( filename, MAX_SYSPATH, "%s%s.qc", destdir, modelfile );
if( len >= MAX_SYSPATH )
if( len == -1 )
{
fprintf( stderr, "ERROR: Destination path is too long. Can't write %s.qc\n", modelfile );
return;

25
utils/mdldec/smd.c

@ -107,15 +107,11 @@ static void ClipRotations( vec3_t angle ) @@ -107,15 +107,11 @@ static void ClipRotations( vec3_t angle )
ProperBoneRotationZ
============
*/
static void ProperBoneRotationZ( mstudioseqdesc_t *seqdesc, vec_t *motion, int frame, float angle )
static void ProperBoneRotationZ( vec_t *motion, float angle )
{
int i;
float c, s, x, y;
float rot;
for( i = 0; i < 3; i++ )
motion[i] += frame * 1.0f / seqdesc->numframes * seqdesc->linearmovement[i];
rot = DEG2RAD( angle );
s = sin( rot );
@ -302,7 +298,7 @@ static void WriteTriangles( FILE *fp, mstudiomodel_t *model ) @@ -302,7 +298,7 @@ static void WriteTriangles( FILE *fp, mstudiomodel_t *model )
{
if( j >= 0 )
{
// triangle fan
// triangle strip
for( k = 0; j > 0; j--, k++, tricmds += 4 )
{
if( k == 0 )
@ -337,7 +333,7 @@ static void WriteTriangles( FILE *fp, mstudiomodel_t *model ) @@ -337,7 +333,7 @@ static void WriteTriangles( FILE *fp, mstudiomodel_t *model )
}
else
{
// triangle strip
// triangle fan
j = abs( j );
for( k = 0; j > 0; j--, k++, tricmds += 4 )
@ -391,7 +387,12 @@ static void WriteFrameInfo( FILE *fp, mstudioanim_t *anim, mstudioseqdesc_t *seq @@ -391,7 +387,12 @@ static void WriteFrameInfo( FILE *fp, mstudioanim_t *anim, mstudioseqdesc_t *seq
CalcBonePosition( anim, bone, motion, frame );
if( bone->parent == -1 )
ProperBoneRotationZ( seqdesc, motion, frame, 270.0f );
{
for( j = 0; j < 3; j++ )
motion[j] += frame * 1.0f / seqdesc->numframes * seqdesc->linearmovement[j];
ProperBoneRotationZ( motion, 270.0f );
}
ClipRotations( &motion[3] );
@ -433,7 +434,7 @@ WriteReferences @@ -433,7 +434,7 @@ WriteReferences
static void WriteReferences( void )
{
int i, j;
size_t len;
int len;
FILE *fp;
mstudiomodel_t *model;
mstudiobodyparts_t *bodypart;
@ -460,7 +461,7 @@ static void WriteReferences( void ) @@ -460,7 +461,7 @@ static void WriteReferences( void )
len = Q_snprintf( filename, MAX_SYSPATH, "%s%s.smd", destdir, name );
if( len >= MAX_SYSPATH )
if( len == -1 )
{
fprintf( stderr, "ERROR: Destination path is too long. Can't write %s.smd\n", name );
RemoveBoneTransformMatrices();
@ -499,7 +500,7 @@ WriteSequences @@ -499,7 +500,7 @@ WriteSequences
static void WriteSequences( void )
{
int i, j;
size_t len;
int len;
FILE *fp;
char filename[MAX_SYSPATH];
mstudioseqdesc_t *seqdesc;
@ -515,7 +516,7 @@ static void WriteSequences( void ) @@ -515,7 +516,7 @@ static void WriteSequences( void )
else
len = Q_snprintf( filename, MAX_SYSPATH, "%s%s_blend%i.smd", destdir, seqdesc->label, j + 1 );
if( len >= MAX_SYSPATH )
if( len == -1 )
{
fprintf( stderr, "ERROR: Destination path is too long. Can't write %s.smd\n", seqdesc->label );
return;

6
utils/mdldec/texture.c

@ -30,19 +30,19 @@ WriteBMP @@ -30,19 +30,19 @@ WriteBMP
*/
static void WriteBMP( mstudiotexture_t *texture )
{
int i;
int i, len;
FILE *fp;
const byte *p;
byte *palette, *pic, *buf;
char filename[MAX_SYSPATH], texturename[64];
rgba_t rgba_palette[256];
bmp_t bmp_hdr = {0,};
size_t texture_size, len;
size_t texture_size;
COM_FileBase( texture->name, texturename );
len = Q_snprintf( filename, MAX_SYSPATH, "%s%s.bmp", destdir, texturename );
if( len >= MAX_SYSPATH )
if( len == -1 )
{
fprintf( stderr, "ERROR: Destination path is too long. Can't write %s.bmp\n", texturename );
return;

Loading…
Cancel
Save