Resource icon

MAKE YOUR OWN UNITS - FLICster Version 1.0.1 (build 18) now available! 2016-10-05

Wow! I love the ettin! It's been years since I played with InsideUO. Does it export the animations to some format? This would be great for someone doing a fantasy mod. Very cool.

One thing I notice... the animation speed is way way too fast (at least in flicster - did you try him in game?). How'd you create this guy. multi-flc? Did you start from an existing unit? If there's an issue with the animation speed, I'd like to fix it.
 
Wow, that's awesome looking. Tell us a little about the animation - did you start from scratch, or start with a anim or 3D model from somewhere? Did you use PCX/FXM format or multi-flc? Any problems with FLICster? (I'm so nosy!)

Also, where's the design/idea come from? I love the look, but I don't associate a bald guy in a red jacket with a ninja. Am I missing some game/movie reference?

Can't wait to see the finished unit. This standalone, or going into a mod?

Now I'm out of questions :D
 
Originally posted by Moeniir
Wow! I love the ettin! It's been years since I played with InsideUO. Does it export the animations to some format? This would be great for someone doing a fantasy mod. Very cool.

One thing I notice... the animation speed is way way too fast (at least in flicster - did you try him in game?). How'd you create this guy. multi-flc? Did you start from an existing unit? If there's an issue with the animation speed, I'd like to fix it.

I know you will love it :lol:

Actually Inside UO can export the animation in avi format. After that its just a matter of converting the avi using AS (told ya its useful ;) ), change the background to the pinkish color, resize the animation so its not too big and resave using one of the existing unit's palette (I used pikeman in this case).

In fact, by using Inside UO I can make almost infinite number of fantasy unit by combing all those different animation and weapons (using the method I discussed in the tutorial). I have tested this out with Dupre swinging a viking on a bucking horse (I purposely choose the bucking horse to proof that the animation is not captured from the game ;) ). Its a combinaton of 3 different flc. I am attaching the gif here to let you have a look. As to the speed, I can always tweak the speed in Flicster's ini file to make it slower. I am pretty comfortable in editing Flicster's ini file for the 8 direction flc by now :king:
 

Attachments

  • dupreattack_w.gif
    dupreattack_w.gif
    11.9 KB · Views: 851
I use poser. One of the default figures was a man in a suit; one of the default poses was a karate kick. The idea sort of stemmed from there...

I used the 1 pcx format. The only problem I had was with the pallete. The red jacket changes colors with each civ, but I am finding it hard to make a smooth transition.
 
Moeniir

There seems to be some problem with the remerging of Storyboard style pcx file with the latest Flicster :(

I created a simple missile for IceBlaZe and when I merge it back to Civ3 flc a few of the directions' flc is damaged. All frame except the first frame has some residue from the previous frame :confused:

However, this problem seems to happen to Default flc only. I created two missiles and both the default flc is damaged. The Run and Attack flc seems ok though :confused: :confused:

Can you take a look at the flc? Its at the unit animation section.
 
Sounds like a bug with the delta-enocder or the delta-decoder. Probably the encoder... Hardest bit of code I had to write. I'll take a look at it - thought I had all the bugs worked out. I may need you to send me a copy of the FXM file and the PCX used to created the unit... if it was encoded incorrectly, I'll need the source material to correct it.
 
Originally posted by Moeniir
Sounds like a bug with the delta-enocder or the delta-decoder. Probably the encoder... Hardest bit of code I had to write. I'll take a look at it - thought I had all the bugs worked out. I may need you to send me a copy of the FXM file and the PCX used to created the unit... if it was encoded incorrectly, I'll need the source material to correct it.

Thanks! I will post a copy of the file when I get home today. (Been reading this in the office again :blush: But I am just dying to know what happen since the 8 direction flc has no problem so far. :cool: ). Now, if only my office's IT people respond half as far as you do I would have a much easier life acting as the System Admin in my regional office. ;)
 
Originally posted by Moeniir
Hey DS... have a look on the thread where the missile is posted. More info as well as a possible work around.

I got that, I will try the work around when I am home tonight :) I do notice that it happens only for those frames that touches the right edge too. Perhaps your method of work around will work since those sequence that do not touch the right edge has no problem when merging. :cool:

While I do have Flicster on my office notebook, I only have PSP & AS at home (I am fulltime CPA, part time Sys Admin/Security Officer/Tech Support but not Artist in my office ;) ). I will try it out tonight and post the result. I believe it should work. :)
 
Ok, ok, so I can't ressist the urge to try it out. I use paintbrush to cut and paste during my lunch break ;)

Adding one pixel to each side of the frame doesn't work. HOWEVER, adding 2 pixels to each side works!! It seems that the graphic must be at least 3 pixels from the right edge (ie leaving 3 blank line on the right side) to make sure that there is no residual effect when merging. :cool: The residual effect will be there if there is only 1 or 2 pixel between the graphic and the frame. The left side has no effect as my graphic has no space from the left side and its fine.

So, Moeniir, does this test result worth a piece of real estate in UO (say a small tower) ? :cooool: J/K ;)
 
Thanks for the info DS. I'll try to get time to build a patch. Been extra busy at work lately... not in the mood for more coding at nite. I hope you were kidding about cut & pasting.... just exporting to Storyboard (you can start from a storyboard) & enlarging the frame width (using the FLICster export screen) does all the grunt work for you. Either increase the frame width by 3 or 6 (don't remember if it centers the old work, I think it does).

As to why this happens, and why its the right edge (if you care... if not take a short nap :) ) the Delta encoding used in a FLC to record the frame transitions has a scanline break... meaning that the encoding algorith starts over at the start of each row of pixels. So, when you hit the end of the row (the right edge), you have to end the current encoding run and output it to the file. This is basically special case code, and I must have overlooked a particular case. Sorry about that.

And as to the small tower... I've got one one LS - Trammel. How's 10 million gold sound? :D Shoot, for that price, I'll even throw in a free copy of FLICster! :lol:

Thanks again for the info.
 
Originally posted by Moeniir
Thanks for the info DS. I'll try to get time to build a patch. Been extra busy at work lately... not in the mood for more coding at nite. I hope you were kidding about cut & pasting.... just exporting to Storyboard (you can start from a storyboard) & enlarging the frame width (using the FLICster export screen) does all the grunt work for you. Either increase the frame width by 3 or 6 (don't remember if it centers the old work, I think it does).

As to why this happens, and why its the right edge (if you care... if not take a short nap :) ) the Delta encoding used in a FLC to record the frame transitions has a scanline break... meaning that the encoding algorith starts over at the start of each row of pixels. So, when you hit the end of the row (the right edge), you have to end the current encoding run and output it to the file. This is basically special case code, and I must have overlooked a particular case. Sorry about that.

And as to the small tower... I've got one one LS - Trammel. How's 10 million gold sound? :D Shoot, for that price, I'll even throw in a free copy of FLICster! :lol:

Thanks again for the info.

Well, the reason why I do the cut and paste is of course I downloaded the flc at the office and re-export to Storyboard using Flicster. Luckily for me those have problem is only 3 of the direction and Default for missile is just moving up and down :D

And I love to know why a program doesn't work. In fact, whenever I play a game of use a program, I always think of how the code work and why certain things can or cannot be done (I used to do lots of programming in the old days with Assembly Language on Apple II machines ;) ).

As to the tower, I have 2 small tower in Trammel on Pac and 1 large tower and small house in Fel on Cats :D Never have much gold though as I always give them away. In total I must have given away more than 5 million in gold plus countless GM armor and stuff :coool:
 
Sheer I knew I liked you, anybody who goes back to assembly langauge for the Apple II is okay in my book. You two talkin' about UO has got me all titilated, I used to write muds but never made the switch to the hardcore stuff, it sounds cool. Mebbe I'll hafta dust off my crash chair (specially suited to muddin' and losing a character you spent 100 hours on :)
 
Originally posted by micmc_atl_ga
Sheer I knew I liked you, anybody who goes back to assembly langauge for the Apple II is okay in my book. You two talkin' about UO has got me all titilated, I used to write muds but never made the switch to the hardcore stuff, it sounds cool. Mebbe I'll hafta dust off my crash chair (specially suited to muddin' and losing a character you spent 100 hours on :)

Hehe, this just go to show that we are not only interested in TBS. We also have the spirit of adventuring in some untamed land :lol:

I still remember the good old days of programming. Its kinda hard to forget when there are 200+ people in the lecture hall and only 5 of us really understand what the lecturer says ;) We were treated like king back then (what do you expect, a year's assignment finished within a day :coool: ). Of course our dear lecturer is now the Managing Director of one of the two biggest ISP in Malaysia. :)
 
Is it possible to make/edit leader heads with this program. And is this program just for editing units, or can you make units with it.

I read something about Jascs Animation shop, do I need this program to make units/leader heads, if so, where can I find it?
 
Homie -

FLICster only handles unit animations. I *think* Mega-Dan Megha, Firaxian Extrondinaire, once posted some info here on this site about leader heads. I believe they do use the Custom flic format, but only have a single direction defined; I seem to recall Dan thoerizing that a standard Animation Shop anim. might work. Of course, this was pre-patch.

Anyone else remember this stuff? I suppose I could search the forums, but then I also suppose someone else could :)D Sorry, I'm just so busy right now...) If anyone finds that info, post a link up here. If a custom tool is required to get a leader head working, let me know - I'd bet that most of the required code already exists in FLICster.
 
Heres an idea, albeit a crazy one. How about the option to export CTP sprites into there individual pics? FYI, ctp *.spr's are a collection of TGA's. Here is the C/C++ code of the *.spr format
Code:
#pragma once 
#ifndef __SPRITEUTILS_H__ 
#define __SPRITEUTILS_H__ 
// 16 bit pixels of interest 
#define k_CHROMAKEY_PIXEL  0x0000 
#define k_SHADOW_PIXEL_565  0xF81F 
#define k_SHADOW_PIXEL_555  0x7C1F 
#define k_SHADOWBACKGD_PIXEL 0xFFFF 
// IDs in the RLE sprite stream 
#define k_CHROMAKEY_RUN_ID  0x0A 
#define k_COPY_RUN_ID   0x0C 
#define k_SHADOW_RUN_ID   0x0E 
#define k_FEATHERED_RUN_ID  0x0F 

// EOLN mask for tag 
#define k_EOLN_ID    0xF0 

// Alpha values 
#define k_NO_ALPHA   0x00 
#define k_ALL_ALPHA   0xFF 

// Flag for empty row in sprite table 
#define k_EMPTY_TABLE_ENTRY 0xFFFF 

void spriteutils_MergeShadowMap(Pixel32 *buf, Pixel32 *shadowBuf, uint16 width, uint16 height); 

// Sprite Encoding 
void spriteutils_EncodeShadowRun(Pixel32 **inBuf, sint32 *pos, sint32 width, Pixel16 **outBufPtr); 
void spriteutils_EncodeCopyRun(Pixel32 **inBuf, sint32 *pos, sint32 width, Pixel16 **outBufPtr); 
char spriteutils_EncodeChromakeyRun(Pixel32 **inBuf, sint32 *pos, sint32 width, Pixel16 **outBufPtr); 
void spriteutils_EncodeFeatheredRun(Pixel32 **inBuf, sint32 *pos, sint32 width, Pixel16 **outBufPtr); 
char spriteutils_EncodeScanline(Pixel32 *scanline, sint32 width, Pixel16 **outBufPtr); 
Pixel16 *spriteutils_RGB32ToEncoded(Pixel32 *buf, Pixel32 *shadowBuf, uint16 width, uint16 height); 
Pixel16 *spriteutils_RGB32ToEncoded(Pixel32 *buf, uint16 width, uint16 height); 

#endif//__SPRITEUTILS_H__ 



--------------------------------------------------------------------------------
//////////////////////////////////////////////////////////////////////////////
void spriteutils_EncodeShadowRun(Pixel32 **inBuf, sint32 *pos, sint32 width, Pixel16 **outBufPtr) 
{ 
 Pixel16   pix16; 
 uint8   alpha; 
 sint32   runLen = 0; 
 Pixel16   footer=0; 
 Pixel16   shadowPixel; 
 if (g_is565Format) shadowPixel = k_SHADOW_PIXEL_565; 
 else shadowPixel = k_SHADOW_PIXEL_555; 

 RGB32Info(**inBuf, &pix16, &alpha); 
 while (pix16 == shadowPixel && (*pos < width)) { 
  // Increment input buffer 
  (*inBuf)++; 

  // Increment position counter 
  (*pos)++; 

  // Increment run length 
  runLen++; 

  RGB32Info(**inBuf, &pix16, &alpha); 
 } 

 // Build header/footer ID 
 footer = (Pixel16)(k_SHADOW_RUN_ID << 8 | runLen); 

 // Set the high nybble of the tag if it's an EOLN condition 
 if (*pos >= width) footer |= k_EOLN_ID << 8; 
  
 // Append header/footer ID to output buffer 
 **outBufPtr = footer; 
 (*outBufPtr)++; 
} 

////////////////////////////////////////////////////////////////////////////// 
void spriteutils_EncodeCopyRun(Pixel32 **inBuf, sint32 *pos, sint32 width, Pixel16 **outBufPtr) 
{ 
 Pixel16   pix16; 
 uint8   alpha; 
 sint32   runLen = 0; 
 Pixel16   footer=0; 
 Pixel16   *headerPtr; 
 Pixel16   shadowPixel; 

 if (g_is565Format) { 
  shadowPixel = k_SHADOW_PIXEL_565; 
 } else { 
  shadowPixel = k_SHADOW_PIXEL_555; 
 } 

 headerPtr = *outBufPtr; 
 (*outBufPtr)++; 

 RGB32Info(**inBuf, &pix16, &alpha); 
 while (pix16 != shadowPixel && alpha == k_ALL_ALPHA && (*pos < width)) { 

  // Filter pure-black 
  if (pix16 == 0x0000) pix16 = 0x0001; 

  // Write pixel to output buffer 
  **outBufPtr = pix16; 

  // Increment output buffer 
  (*outBufPtr)++; 
  
  // Increment input buffer 
  (*inBuf)++; 

  // Increment position counter 
  (*pos)++; 

  // Increment run length 
  runLen++; 

  RGB32Info(**inBuf, &pix16, &alpha); 
 } 
  
 // Build the tag with the ID and length 
 footer = (Pixel16) (k_COPY_RUN_ID << 8 | runLen); 

 // Set the high nybble of the tag if it's an EOLN condition 
 if (*pos >= width) footer |= k_EOLN_ID << 8; 

 *headerPtr = footer; 
} 

////////////////////////////////////////////////////////////////////////////// 
char spriteutils_EncodeChromakeyRun(Pixel32 **inBuf, sint32 *pos, sint32 width, Pixel16 **outBufPtr) 
{ 
 Pixel16   pix16; 
 uint8   alpha; 
 sint32   runLen = 0; 
 Pixel16   footer=0; 

 RGB32Info(**inBuf, &pix16, &alpha); 
 while (pix16 == k_CHROMAKEY_PIXEL && alpha == k_NO_ALPHA && (*pos < width)) { 
  // Increment input buffer 
  (*inBuf)++; 

  // Increment position counter 
  (*pos)++; 

  // Increment run length 
  runLen++; 

  RGB32Info(**inBuf, &pix16, &alpha); 
 } 

 // If it's a full-row transparent run, it's a skipped row 
 if (runLen < width) { 
  // Build header/footer ID 
  footer = (Pixel16)(k_CHROMAKEY_RUN_ID << 8 | runLen); 

  // Set the high nybble of the tag if it's an EOLN condition 
  if (*pos >= width) footer |= k_EOLN_ID << 8; 
  
  // Append header/footer ID to output buffer 
  **outBufPtr = footer; 
  (*outBufPtr)++; 
 } else { 
  // return TRUE that it's an empty row 
  return TRUE; 
 } 

 return FALSE; 
} 

////////////////////////////////////////////////////////////////////////////// 
char spriteutils_EncodeChromakeyWshadowRun(Pixel32 **inBuf, sint32 *pos, sint32 width, Pixel16 **outBufPtr) 
{ 
 Pixel16   pix16; 
 uint8   alpha; 
 sint32   runLen = 0; 
 Pixel16   footer=0; 

 RGB32Info(**inBuf, &pix16, &alpha); 
 while ( ((pix16 == k_CHROMAKEY_PIXEL && alpha == k_NO_ALPHA) ||  (pix16 == k_SHADOWBACKGD_PIXEL))  && (*pos < width) ) { 
  // Increment input buffer 
  (*inBuf)++; 

  // Increment position counter 
  (*pos)++; 

  // Increment run length 
  runLen++; 

  RGB32Info(**inBuf, &pix16, &alpha); 
 } 

 // If it's a full-row transparent run, it's a skipped row 
 if (runLen < width) { 
  // Build header/footer ID 
  footer = (Pixel16)(k_CHROMAKEY_RUN_ID << 8 | runLen); 

  // Set the high nybble of the tag if it's an EOLN condition 
  if (*pos >= width) footer |= k_EOLN_ID << 8; 
  
  // Append header/footer ID to output buffer 
  **outBufPtr = footer; 
  (*outBufPtr)++; 
 } else { 
  // return TRUE that it's an empty row 
  return TRUE; 
 } 

 return FALSE; 
} 

////////////////////////////////////////////////////////////////////////////// 
void spriteutils_EncodeFeatheredRun(Pixel32 **inBuf, sint32 *pos, sint32 width, Pixel16 **outBufPtr) 
{ 
 Pixel16   pix16; 
 Pixel16   footer=0; 
 uint8   alpha; 

 RGB32Info(**inBuf, &pix16, &alpha); 

 (*inBuf)++; 
 (*pos)++; 

 footer = (k_FEATHERED_RUN_ID << 8) | alpha; 

 // Set the high nybble of the tag if it's an EOLN condition 
 if (*pos >= width) 
  footer |= k_EOLN_ID << 8; 

 // Write leading footer tag 
 **outBufPtr = footer; 
 (*outBufPtr)++; 

 // Write pixel value 
 **outBufPtr = pix16; 
 (*outBufPtr)++; 

} 

////////////////////////////////////////////////////////////////////////////// 
// this will encode a normal image with shadow merged into it. 
char spriteutils_EncodeScanline(Pixel32 *scanline, sint32 width, Pixel16 **outBufPtr) 
{ 
 Pixel16   pix16; 
 Pixel32   pix32; 
 Pixel32   *scanPtr = scanline; 
 uint8   alpha; 
 sint32   pos; 
 Pixel16   *startPtr; 
 BOOL   empty; 
 Pixel16   shadowPixel; 

 if (g_is565Format) { 
  shadowPixel = k_SHADOW_PIXEL_565; 
 } else { 
  shadowPixel = k_SHADOW_PIXEL_555; 
 } 
  

 pos = 0; 

 // Save starting position of the scanline's data stream 
 startPtr = *outBufPtr; 

 // EOLN needs to be at both ends 

 while (scanPtr < (scanline + width)) { 
  pix32 = *scanPtr; 
  
  empty = FALSE; 

  RGB32Info(pix32, &pix16, &alpha); 

  if (pix16 == k_CHROMAKEY_PIXEL   && alpha == k_NO_ALPHA) 
  { 
   // Whitespace Run 
   empty = spriteutils_EncodeChromakeyRun(&scanPtr, &pos, width, outBufPtr); 
  } 
  else 
  if (pix16 == shadowPixel) { 
   // Shadow Run 
   spriteutils_EncodeShadowRun(&scanPtr, &pos, width, outBufPtr); 
  } 
  else 
  if (alpha != k_NO_ALPHA && alpha != k_ALL_ALPHA) { 
   // Feathered pixel 
   spriteutils_EncodeFeatheredRun(&scanPtr, &pos, width, outBufPtr); 
  } 
  else { 
   // Jus' a plain ol' pixel.  This is a copy run. 
   if (alpha == k_ALL_ALPHA) 
    spriteutils_EncodeCopyRun(&scanPtr, &pos, width, outBufPtr); 
   else { 
    printf("\nError in bitmap data.  Pixel with no associated alpha.\n"); 
    exit(-1); 
   } 
  } 
 } 

 return empty; 
} 

////////////////////////////////////////////////////////////////////////////// 
// this will encode a shadow just like a regular image, taking into account shadow's with white backgrounds 
char spriteutils_EncodeScanlineWshadow(Pixel32 *scanline, sint32 width, Pixel16 **outBufPtr) 
{ 
 Pixel16   pix16; 
 Pixel32   pix32; 
 Pixel32   *scanPtr = scanline; 
 uint8   alpha; 
 sint32   pos; 
 Pixel16   *startPtr; 
 BOOL   empty; 
 Pixel16   shadowPixel; 

 if (g_is565Format) { 
  shadowPixel = k_SHADOW_PIXEL_565; 
 } else { 
  shadowPixel = k_SHADOW_PIXEL_555; 
 } 
  

 pos = 0; 

 // Save starting position of the scanline's data stream 
 startPtr = *outBufPtr; 

 // EOLN needs to be at both ends 

 while (scanPtr < (scanline + width)) { 
  pix32 = *scanPtr; 
  
  empty = FALSE; 

  RGB32Info(pix32, &pix16, &alpha); 

  if ( (pix16 == k_CHROMAKEY_PIXEL  && alpha == k_NO_ALPHA) ||  (pix16 == k_SHADOWBACKGD_PIXEL) ) 
  { 
   // Whitespace Run 
   empty = spriteutils_EncodeChromakeyWshadowRun(&scanPtr, &pos, width, outBufPtr); 
  } 
  else 
  if (pix16 == shadowPixel) { 
   // Shadow Run 
   spriteutils_EncodeShadowRun(&scanPtr, &pos, width, outBufPtr); 
  } 
  else 
  if (alpha != k_NO_ALPHA && alpha != k_ALL_ALPHA) { 
   // Feathered pixel 
   spriteutils_EncodeFeatheredRun(&scanPtr, &pos, width, outBufPtr); 
  } 
  else { 
   // Jus' a plain ol' pixel.  This is a copy run. 
   if (alpha == k_ALL_ALPHA) 
    spriteutils_EncodeCopyRun(&scanPtr, &pos, width, outBufPtr); 
   else { 
    printf("\nError in bitmap data.  Pixel with no associated alpha.\n"); 
    exit(-1); 
   } 
  } 
 } 

 return empty; 
} 

////////////////////////////////////////////////////////////////////////////// 
void spriteutils_MergeShadowMap(Pixel32 *buf, Pixel32 *shadowBuf, uint16 width, uint16 height) 
{ 
 Pixel32  *pixPtr, pix; 
 Pixel32  *shadowPixPtr, shadowPix; 

 // if the upper-left pixel is pure white, assume this is a white background with a black shadow on it 
 // otherwise, it's a black background with a pure-magenta shadow on it 
 BOOL  whiteBackground = FALSE; 
 if ((*shadowBuf & 0x00FFFFFF) == 0x00FFFFFF) { 
  whiteBackground = TRUE; 
 } else { 
  if ((*shadowBuf & 0x00FFFFFF) != 0x00000000) { 
   printf("\nShadow file is in invalid format.\n"); 
   exit(-1); 
  } 
 } 

 for (sint32 j=0; j<height; j++) { 
  for (sint32 i=0; i<width; i++) { 
   pixPtr = buf + j*width + i; 
   shadowPixPtr = shadowBuf + j*width + i; 

   pix = *pixPtr; 
   shadowPix = *shadowPixPtr; 
   shadowPix = shadowPix & 0x00FFFFFF; 

   if (whiteBackground) { 
    // See if there's shadow information there 
    if (shadowPix != 0x00FFFFFF) { 
     // There's a shadow pixel, copy it over to the source image's bitmap 
     // only if there's null alpha 
     Pixel16  r, g, b, a; 

     RGB32Components(pix, &r, &g, &b, &a); 

     // check against empty and full alpha 
     if (a != 0xFF) { 
      *pixPtr = 0x00FF00FF; 
     } 
    } 
   } else { 
    // See if there's shadow information there 
    if (shadowPix) { 
     // There's a shadow pixel, copy it over to the source image's bitmap 
     // only if there's null alpha 
     Pixel16  r, g, b, a; 

     RGB32Components(pix, &r, &g, &b, &a); 

     // check against empty and full alpha 
     if (a != 0xFF) { 
      *pixPtr = shadowPix; 
     } 
    } 
   } 
  } 
 } 
} 

////////////////////////////////////////////////////////////////////////////// 
// this takes an image and a shadow and makes one image with them 
Pixel16 *spriteutils_RGB32ToEncoded(Pixel32 *buf, Pixel32 *shadowBuf, uint16 width, uint16 height) 
{ 
 Pixel32    *srcPixel = buf; 
 Pixel16    *outBuf = new Pixel16[(1+height+width*height)*8]; 
 Pixel16    *returnBuf = NULL; 
 uint16    *table = (uint16 *)outBuf; 
 Pixel16    *startOfData; 
 Pixel16    *dataPtr, *startDataPtr; 
 BOOL    empty; 
  

 // One solution to the shadow encoding problem is to merge the shadow information sint32o the source bitmap 
 if (shadowBuf != NULL) 
  spriteutils_MergeShadowMap(buf, shadowBuf, width, height); 

 // Write the height of the sprite as the first 16 bits of the table data 
 *table++ = (uint16)height; 

 startOfData = outBuf + 1 + height; 
 dataPtr = startOfData; 

 for(sint32 y=0; y<height; y++) { 
  // Start at the beginning of the scanline 
  srcPixel = buf + width * y; 

  startDataPtr = dataPtr; 

  // Encode runs for this line 
  empty = spriteutils_EncodeScanline(srcPixel, width, &dataPtr); 
  if (empty) { 
   *table++ = k_EMPTY_TABLE_ENTRY; 
  } else { 
   // Write the line start sint32o the table 
   *table++ = startDataPtr - startOfData; 
  } 
 } 

 sint32 resultSize = (dataPtr - outBuf); 

 returnBuf = new Pixel16[resultSize]; 

 memcpy(returnBuf, outBuf, resultSize * sizeof(Pixel16)); 

 return (Pixel16 *)returnBuf; 
} 

////////////////////////////////////////////////////////////////////////////// 
// this takes any buffer and encodes it as it's own image; Including shadows treated as seperate images 
Pixel16 *spriteutils_RGB32ToEncoded(Pixel32 *buf, uint16 width, uint16 height) 
{ 
 Pixel32    *srcPixel = buf; 
 Pixel16    *outBuf = new Pixel16[(1+height+width*height)*8]; 
 Pixel16    *returnBuf = NULL; 
 uint16    *table = (uint16 *)outBuf; 
 Pixel16    *startOfData; 
 Pixel16    *dataPtr, *startDataPtr; 
 BOOL    empty; 
  

 // Write the height of the sprite as the first 16 bits of the table data 
 *table++ = (uint16)height; 

 startOfData = outBuf + 1 + height; 
 dataPtr = startOfData; 

 for(sint32 y=0; y<height; y++) { 
  // Start at the beginning of the scanline 
  srcPixel = buf + width * y; 

  startDataPtr = dataPtr; 

  // Encode runs for this line 
  empty = spriteutils_EncodeScanlineWshadow(srcPixel, width, &dataPtr); 
  if (empty) { 
   *table++ = k_EMPTY_TABLE_ENTRY; 
  } else { 
   // Write the line start sint32o the table 
   *table++ = startDataPtr - startOfData; 
  } 
 } 

 sint32 resultSize = (dataPtr - outBuf); 

 returnBuf = new Pixel16[resultSize]; 

 memcpy(returnBuf, outBuf, resultSize * sizeof(Pixel16)); 

 return (Pixel16 *)returnBuf; 
}
 
and the rest...
Code:
////////////////////////////////////////////////////////////////////////////// 
void spriteutils_CreateQuarterSize(Pixel32 *srcBuf, sint32 srcWidth, sint32 srcHeight, Pixel32 **destBuf, BOOL aa) 
{ 
 sint32  destWidth = srcWidth / 2; 
 sint32  destHeight = srcHeight / 2; 
 sint32  i,j; 
 Pixel32  pixel, pixel1, pixel2, pixel3, pixel4; 
 Pixel32  *outBuf; 

 outBuf = (Pixel32 *)malloc(destWidth * destHeight * sizeof(Pixel32) ); 
  
 for (i=0; i<destHeight; i++) { 
  for (j=0; j<destWidth; j++) { 
   pixel1 = srcBuf[(i * 2) * srcWidth + (j * 2)]; 

   if (aa) { 
    pixel2 = srcBuf[(i * 2) * srcWidth + (j * 2) + 1]; 
    pixel3 = srcBuf[((i * 2) + 1) * srcWidth + (j * 2)]; 
    pixel4 = srcBuf[((i * 2) + 1) * srcWidth + (j * 2) + 1]; 

    pixel = spriteutils_AveragePixel32(pixel1, pixel2, pixel3, pixel4); 
   } else { 
    pixel = pixel1; 
   } 

   outBuf[i*destWidth + j] = pixel; 
  } 
 } 
  
 *destBuf = outBuf; 
}
 
OMG Heardie :eek:, are you trying to make my eyes bleed? I'm primarily a VB programmer - and everyone knows we're too dumb to read C! :D

Seriously, thats an interesting idea. Is the goal to translate CTP units for Civ3 use? If so, i'd be tempted to make the export create FXM files in all three PCX variations. Hmm, you've certainly got me thinking. I'll try give your source code a read this weekend, see if I can still grok C source. :)
 
hehe, brings back unpleasant memories for me to.

The goal would be to use them for Civ3 Graphics, yes.


BTW: I have attached a sprite from CTP2. It is just a guess of whether it is a unit, but you made need it if you eventually try to do this.

As for flicster being done all in VB, thats a damn good effort.
 

Attachments

  • gu35.zip
    58.6 KB · Views: 296
Top Bottom