 |
|  |
 |
|  |
 |
|
Martin the Dane
|
 |
Aarhus, Denmark
Feb 2000 time: 06:30
|
|
As far as I hav been able to figure it out the fields are as follows:
Sprite Num Frames = the number of actual images available for the selected animation.
Sprite First Frame = this is the number of the first image imported when using makespr.exe (the Apolyton sprite generator) What it does in the game, or the sprite-file I don't know. Just keep it at 0 or 1 to be safe 
Anim Type = the way the animation is played in ctp. sequential plays through from the first frame to the last defined frame, looped starts over at the first frame when it's gone through all of the frames, back-n-forth reverses direction of playback when it reaches the last frame, and playes back to the first before reversing direction again.
Anim Num Frames = the number of frames in the animation, these frames are realy just a list of numbers, refering to Sprite Frames.
Anim Playback Time = the time to play the animation sequence, not used in Civ:CTP, not sure about CTP2
Anim Delay = Amount of time to display the last frame before repeating, don't know how it is messured.
If you have not done this yet, it is a good idea to read the first part of documentation that came with makespr.exe (I have attached it to this post)
I have not had the time to look into why SpriteEdit allows import of wrong-sized images. I won't be home much over the next week or so, so I can't promise anything.
Attachment: docs.zip
This has been downloaded 2 time(s).
|
|
|  |
 |
|
E
|
 |
July 24,2005 Ctp2 Tiles in sig!
May 1999 time: 21:30
|
|
Martin,
I glanced through the source code would any of this help:
code:
#include "c3.h"
#include "pixelutils.h"
#include "spriteutils.h"
extern sint32 g_is565Format;
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)) {
(*inBuf)++;
(*pos)++;
runLen++;
RGB32Info(**inBuf, &pix16, &alpha);
}
footer = (Pixel16)(k_SHADOW_RUN_ID << 8 | runLen);
if (*pos >= width) footer |= k_EOLN_ID << 8;
**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)) {
if (pix16 == 0x0000) pix16 = 0x0001;
**outBufPtr = pix16;
(*outBufPtr)++;
(*inBuf)++;
(*pos)++;
runLen++;
RGB32Info(**inBuf, &pix16, &alpha);
}
footer = (Pixel16) (k_COPY_RUN_ID << 8 | runLen);
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)) {
(*inBuf)++;
(*pos)++;
runLen++;
RGB32Info(**inBuf, &pix16, &alpha);
}
if (runLen < width) {
footer = (Pixel16)(k_CHROMAKEY_RUN_ID << 8 | runLen);
if (*pos >= width) footer |= k_EOLN_ID << 8;
**outBufPtr = footer;
(*outBufPtr)++;
} else {
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) ) {
(*inBuf)++;
(*pos)++;
runLen++;
RGB32Info(**inBuf, &pix16, &alpha);
}
if (runLen < width) {
footer = (Pixel16)(k_CHROMAKEY_RUN_ID << 8 | runLen);
if (*pos >= width) footer |= k_EOLN_ID << 8;
**outBufPtr = footer;
(*outBufPtr)++;
} else {
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);
if (pix16 == 0x0000) pix16 = 0x0001;
(*inBuf)++;
(*pos)++;
footer = (k_FEATHERED_RUN_ID << 8) | alpha;
if (*pos >= width)
footer |= k_EOLN_ID << 8;
**outBufPtr = footer;
(*outBufPtr)++;
**outBufPtr = pix16;
(*outBufPtr)++;
}
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;
startPtr = *outBufPtr;
while (scanPtr < (scanline + width))
{
pix32 = *scanPtr;
empty = FALSE;
RGB32Info(pix32, &pix16, &alpha);
if ((pix16 == k_CHROMAKEY_PIXEL)&&(alpha == k_NO_ALPHA))
{
empty = spriteutils_EncodeChromakeyRun(&scanPtr, &pos, width, outBufPtr);
}
else
if (pix16 == shadowPixel)
{
spriteutils_EncodeShadowRun(&scanPtr, &pos, width, outBufPtr);
}
else
if ((alpha!=k_NO_ALPHA) && (alpha!=k_ALL_ALPHA))
{
spriteutils_EncodeFeatheredRun(&scanPtr, &pos, width, outBufPtr);
}
else {
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;
}
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;
startPtr = *outBufPtr;
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) )
{
empty = spriteutils_EncodeChromakeyWshadowRun(&scanPtr, &pos, width, outBufPtr);
}
else
if (pix16 == shadowPixel) {
spriteutils_EncodeShadowRun(&scanPtr, &pos, width, outBufPtr);
}
else
if (alpha != k_NO_ALPHA && alpha != k_ALL_ALPHA) {
spriteutils_EncodeFeatheredRun(&scanPtr, &pos, width, outBufPtr);
}
else {
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;
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> 8) {
case k_CHROMAKEY_RUN_ID :
destPixel += (tag & 0x00FF);
break;
case k_COPY_RUN_ID : {
short len = (tag & 0x00FF);
for (short i=0; i>4);
destPixel++;
rowData--;
} else {
*destPixel++ = *rowData--;
}
tag = *rowData--;
break;
default:
Assert(FALSE);
}
tag = *rowData--;
}
}
}
}
Pixel32 spriteutils_AveragePixel32(Pixel32 pixel1, Pixel32 pixel2, Pixel32 pixel3, Pixel32 pixel4)
{
Pixel16 r1, r2, r3, r4;
Pixel16 g1, g2, g3, g4;
Pixel16 b1, b2, b3, b4;
Pixel16 a1, a2, a3, a4;
Pixel32 r, g, b, a;
Pixel32 result;
RGB32Components(pixel1, &r1, &g1, &b1, &a1);
RGB32Components(pixel2, &r2, &g2, &b2, &a2);
RGB32Components(pixel3, &r3, &g3, &b3, &a3);
RGB32Components(pixel4, &r4, &g4, &b4, &a4);
r = (Pixel32)ceil((r1 + r2 + r3 + r4) / 4.0);
g = (Pixel32)ceil((g1 + g2 + g3 + g4) / 4.0);
b = (Pixel32)ceil((b1 + b2 + b3 + b4) / 4.0);
a = (Pixel32)ceil((a1 + a2 + a3 + a4) / 4.0);
result = ( r | (g << 8) | (b << 16) | (a << 24));
return result;
}
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> 8) {
case k_CHROMAKEY_RUN_ID :
break;
case k_COPY_RUN_ID : {
short len = (tag & 0x00FF);
for (short i=0; i> 8) {
case k_CHROMAKEY_RUN_ID :
break;
case k_COPY_RUN_ID : {
short len = (tag & 0x00FF);
for (short i=0; i 0) return 5;
else return 6;
} else {
if (x > 0) {
if (y < 0) return 1;
else if (y > 0) return 3;
else return 2;
} else {
if (y < 0) return 0;
else if (y > 0) return 4;
else return 4;
}
}
}
I can dig more if there smething specific you need....
|
|
|  |
 |
|
E
|
 |
July 24,2005 Ctp2 Tiles in sig!
May 1999 time: 21:30
|
|
And this in Sprite.cpp
code:
void Sprite::ImportTGA(uint16 index, char **imageFiles,Pixel32 **imageData)
{
int bpp;
int w,h;
if (!Get_TGA_Dimension(imageFiles[index], w, h, bpp))
{
printf("Bad TGA Sprite File(%s)\n",imageFiles[index]);
*imageData = NULL;
fcloseall();
exit(0);
return;
}
if (bpp!=4)
{
printf("TGA Sprite File not 32-bits\n",imageFiles[index]);
*imageData=NULL;
fcloseall();
exit(0);
return;
}
*imageData = new Pixel32[w*h];
Load_TGA_File_Simple(imageFiles[index],(unsigned char *)*imageData,w*sizeof(Pixel32),w,h);
m_width = (uint16)w;
m_height = (uint16)h;
TGA2RGB32((Pixel32 *)*imageData,w*h);
}
void Sprite::Import(uint16 nframes, char **imageFiles, char **shadowFiles)
{
m_numFrames = nframes;
if (m_frames != NULL)
{
free(m_frames);
m_frames = NULL;
}
m_frames = new Pixel16*[m_numFrames];
if (m_frames == NULL)
return;
if (m_miniframes != NULL)
{
free(m_miniframes);
m_miniframes = NULL;
}
m_miniframes = new Pixel16*[m_numFrames];
if (m_miniframes == NULL)
return;
Pixel32 *image,*miniimage;
Pixel32 *shadow,*minishadow;
for (uint16 i=0; i> 1, m_height >> 1);
}
if (image) delete []image;
if (shadow) delete []shadow;
if (miniimage) delete []miniimage;
if (minishadow) delete []minishadow;
printf(".");
}
}
|
|
|  |
 |
|
endless_dark
|
|
Where can I find a good sprite packer/extractor that works with any sprites? All of them I have found only work for a certain game/program. I am trying to make graphics for my buddy's game, and I cant find anything that will work.
|
|
|  |
All times are GMT. The time now is 05:30. Apolyton Time is 00:30. |
top of page
|
|
|
Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is ON
vB code is ON
Smilies are ON
[IMG] code is ON
|
|
|
|
|
|