| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
#include "qdata.h" |
| 24 |
|
| 25 |
char pic_prefix[1024]; |
| 26 |
extern char *g_outputDir; |
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
void Cmd_Pic( void ){ |
| 35 |
int xl,yl,xh,yh,w,h; |
| 36 |
byte *dest, *source; |
| 37 |
int flags, value, contents; |
| 38 |
char lumpname[128]; |
| 39 |
char animname[128]; |
| 40 |
byte buffer[256 * 256]; |
| 41 |
unsigned bufferl[256 * 256]; |
| 42 |
char filename[1024]; |
| 43 |
unsigned *destl, *sourcel; |
| 44 |
int linedelta, x, y; |
| 45 |
int size; |
| 46 |
miptex_t *qtex; |
| 47 |
miptex32_t *qtex32; |
| 48 |
float scale_x, scale_y; |
| 49 |
|
| 50 |
GetScriptToken( false ); |
| 51 |
strcpy( lumpname, token ); |
| 52 |
|
| 53 |
GetScriptToken( false ); |
| 54 |
xl = atoi( token ); |
| 55 |
GetScriptToken( false ); |
| 56 |
yl = atoi( token ); |
| 57 |
GetScriptToken( false ); |
| 58 |
w = atoi( token ); |
| 59 |
GetScriptToken( false ); |
| 60 |
h = atoi( token ); |
| 61 |
|
| 62 |
total_x += w; |
| 63 |
total_y += h; |
| 64 |
total_textures++; |
| 65 |
|
| 66 |
if ( ( w & 7 ) || ( h & 7 ) ) { |
| 67 |
Error( "line %i: miptex sizes must be multiples of 8", scriptline ); |
| 68 |
} |
| 69 |
|
| 70 |
flags = 0; |
| 71 |
contents = 0; |
| 72 |
value = 0; |
| 73 |
|
| 74 |
animname[0] = 0; |
| 75 |
|
| 76 |
scale_x = scale_y = 0.5; |
| 77 |
|
| 78 |
if ( TrueColorImage ) { |
| 79 |
sprintf( filename, "%spics/%s/%s.m32", g_outputDir, pic_prefix, lumpname ); |
| 80 |
if ( g_release ) { |
| 81 |
return; |
| 82 |
|
| 83 |
} |
| 84 |
xh = xl + w; |
| 85 |
yh = yl + h; |
| 86 |
|
| 87 |
if ( xl >= longimagewidth || xh > longimagewidth || |
| 88 |
yl >= longimageheight || yh > longimageheight ) { |
| 89 |
Error( "line %i: bad clip dimmensions (%d,%d) (%d,%d) > image (%d,%d)", scriptline, xl,yl,w,h,longimagewidth,longimageheight ); |
| 90 |
} |
| 91 |
|
| 92 |
sourcel = longimage + ( yl * longimagewidth ) + xl; |
| 93 |
destl = bufferl; |
| 94 |
linedelta = ( longimagewidth - w ); |
| 95 |
|
| 96 |
for ( y = yl ; y < yh ; y++ ) |
| 97 |
{ |
| 98 |
for ( x = xl ; x < xh ; x++ ) |
| 99 |
{ |
| 100 |
*destl++ = *sourcel++; |
| 101 |
} |
| 102 |
sourcel += linedelta; |
| 103 |
} |
| 104 |
|
| 105 |
qtex32 = CreateMip32( bufferl, w, h, &size, false ); |
| 106 |
|
| 107 |
qtex32->flags |= LittleLong( flags ); |
| 108 |
qtex32->contents = contents; |
| 109 |
qtex32->value = value; |
| 110 |
qtex32->scale_x = scale_x; |
| 111 |
qtex32->scale_y = scale_y; |
| 112 |
sprintf( qtex32->name, "%s/%s", pic_prefix, lumpname ); |
| 113 |
if ( animname[0] ) { |
| 114 |
sprintf( qtex32->animname, "%s/%s", pic_prefix, animname ); |
| 115 |
} |
| 116 |
|
| 117 |
|
| 118 |
|
| 119 |
|
| 120 |
printf( "writing %s\n", filename ); |
| 121 |
SaveFile( filename, (byte *)qtex32, size ); |
| 122 |
|
| 123 |
free( qtex32 ); |
| 124 |
} |
| 125 |
else |
| 126 |
{ |
| 127 |
sprintf( filename, "%spics/%s/%s.m8", g_outputDir, pic_prefix, lumpname ); |
| 128 |
if ( g_release ) { |
| 129 |
return; |
| 130 |
|
| 131 |
} |
| 132 |
xh = xl + w; |
| 133 |
yh = yl + h; |
| 134 |
|
| 135 |
if ( xl >= byteimagewidth || xh > byteimagewidth || |
| 136 |
yl >= byteimageheight || yh > byteimageheight ) { |
| 137 |
Error( "line %i: bad clip dimmensions (%d,%d) (%d,%d) > image (%d,%d)", scriptline, xl,yl,w,h,byteimagewidth,byteimageheight ); |
| 138 |
} |
| 139 |
|
| 140 |
source = byteimage + yl * byteimagewidth + xl; |
| 141 |
dest = buffer; |
| 142 |
linedelta = byteimagewidth - w; |
| 143 |
|
| 144 |
for ( y = yl ; y < yh ; y++ ) |
| 145 |
{ |
| 146 |
for ( x = xl ; x < xh ; x++ ) |
| 147 |
{ |
| 148 |
*dest++ = *source++; |
| 149 |
} |
| 150 |
source += linedelta; |
| 151 |
} |
| 152 |
|
| 153 |
qtex = CreateMip( buffer, w, h, lbmpalette, &size, false ); |
| 154 |
|
| 155 |
qtex->flags = flags; |
| 156 |
qtex->contents = contents; |
| 157 |
qtex->value = value; |
| 158 |
sprintf( qtex->name, "%s/%s", pic_prefix, lumpname ); |
| 159 |
if ( animname[0] ) { |
| 160 |
sprintf( qtex->animname, "%s/%s", pic_prefix, animname ); |
| 161 |
} |
| 162 |
|
| 163 |
|
| 164 |
|
| 165 |
|
| 166 |
printf( "writing %s\n", filename ); |
| 167 |
SaveFile( filename, (byte *)qtex, size ); |
| 168 |
|
| 169 |
free( qtex ); |
| 170 |
} |
| 171 |
} |
| 172 |
|
| 173 |
|
| 174 |
|
| 175 |
|
| 176 |
|
| 177 |
|
| 178 |
|
| 179 |
void Cmd_Picdir( void ){ |
| 180 |
char filename[1024]; |
| 181 |
|
| 182 |
GetScriptToken( false ); |
| 183 |
strcpy( pic_prefix, token ); |
| 184 |
|
| 185 |
sprintf( filename, "%sPics", g_outputDir ); |
| 186 |
Q_mkdir( filename ); |
| 187 |
sprintf( filename, "%sPics/%s", g_outputDir, pic_prefix ); |
| 188 |
Q_mkdir( filename ); |
| 189 |
} |