Initial full mirror of c:\VWE (source + assets + toolchain + outputs) via Git LFS

Complete disaster-recovery snapshot: engine/game source, game data assets,
VC6 toolchain + DX SDKs, build outputs, deployed game, and _UNUSED archive.
Large binaries in Git LFS; text preserved byte-for-byte (core.autocrlf=false,
no eol attributes). See RECOVERY.md for the one-clone rebuild procedure.
This commit is contained in:
Cyd
2026-06-24 21:28:16 -05:00
commit 2b8ca921cb
66341 changed files with 7923174 additions and 0 deletions
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,92 @@
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
void
FeatureGrid::BLENDFUNCTION (
FeatureInstance *featureInstance,
unsigned char *pix_buf,
int start_span,
int end_span,
int downScale
)
{
unsigned char *data_ptr = featureInstance->currentTexturePtr;
int texture_width = (featureInstance->feature->featureTexture->width) >> downScale;
int count_down = featureInstance->countDownToBorder;
#ifdef SHOW_MATERIAL
DWORD mat_color = downScale & 0xffffff;
downScale >>= 24;
#endif
#ifdef TEXTURE_HORIZONTAL_FLIP
#else
#endif
WORD *data_ptr_word = (WORD *)data_ptr;
#ifdef TEXTURE_HORIZONTAL_FLIP
int i, j;
for(i=0,j=0;i<end_span-start_span;i++,j--)
#else
for(int i=0;i<end_span-start_span;i++)
#endif
{
#ifdef TEXTURE_HORIZONTAL_FLIP
int alpha = (data_ptr_word[j] & 0xf) << 4;
#ifdef SHOW_MATERIAL
if(alpha>0x80)
{
*(DWORD *)pix_buf = mat_color;
}
#else // SHOW_MATERIAL
if(alpha>0)
{
int col = *pix_buf*(0xf0-alpha) + (data_ptr_word[j] & 0xf0)*alpha;
*pix_buf = static_cast<unsigned char>(col>>8);
col = *(pix_buf+1)*(0xf0-alpha) + ((data_ptr_word[j] & 0xf00)>>4)*alpha;
*(pix_buf+1) = static_cast<unsigned char>(col>>8);
col = *(pix_buf+2)*(0xf0-alpha) + ((data_ptr_word[j] & 0xf000)>>8)*alpha;
*(pix_buf+2) = static_cast<unsigned char>(col>>8);
}
#endif // SHOW_MATERIAL
if(--count_down <= 0)
{
data_ptr_word += texture_width;
count_down = texture_width;
}
#else
int alpha = (data_ptr_word[i] & 0xf) << 4;
#ifdef SHOW_MATERIAL
if(alpha>0x80)
{
*(DWORD *)pix_buf = mat_color;
}
#else // SHOW_MATERIAL
if(alpha>0)
{
int col = *pix_buf*(0xf0-alpha) + (data_ptr_word[i] & 0xf0)*alpha;
*pix_buf = static_cast<unsigned char>(col>>8);
col = *(pix_buf+1)*(0xf0-alpha) + ((data_ptr_word[i] & 0xf00)>>4)*alpha;
*(pix_buf+1) = static_cast<unsigned char>(col>>8);
col = *(pix_buf+2)*(0xf0-alpha) + ((data_ptr_word[i] & 0xf000)>>8)*alpha;
*(pix_buf+2) = static_cast<unsigned char>(col>>8);
}
#endif // SHOW_MATERIAL
if(--count_down <= 0)
{
data_ptr_word -= texture_width;
count_down = texture_width;
}
#endif
pix_buf += colorDepth;
}
}
@@ -0,0 +1,150 @@
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
void
FeatureGrid::BLENDFUNCTION (
FeatureInstance *featureInstance,
unsigned char *pix_buf,
int start_span,
int end_span,
int downScale
)
{
Feature *feature = featureInstance->feature;
Verify(feature->featureMask0!=NULL);
unsigned char *mask0data = featureInstance->currentMask0Ptr;
#ifdef SHOW_MATERIAL
DWORD mat_color = downScale & 0xffffff;
downScale >>= 24;
#else
int texture_width = (featureInstance->feature->featureTexture->width) >> downScale;
int count_down = featureInstance->countDownToBorder;
WORD *data_ptr_word = (WORD *)featureInstance->currentTexturePtr;
#endif
int mask0_x_off = featureInstance->mask0_x_off >> downScale;
int mask0_z_off = featureInstance->mask0_z_off >> downScale;
int shifter = feature->GetZMask0Scale() + feature->GetXMask0Scale() - 2*downScale;
int x_stretch = 1<<(feature->GetXMask0Scale()-downScale);
int z_stretch = 1<<(feature->GetZMask0Scale()-downScale);
#ifdef MASK0_HORIZONTAL_FLIP
int advancer = x_stretch-1;
#else
int advancer = ~(x_stretch-1);
#endif
int adv, mixH, mix0, mix1, mix00, mix01, mix10, mix11;
int pitch = feature->featureMask0->width + 2;
mix00 = *mask0data;
mix01 = *(mask0data + 1);
mix10 = *(mask0data + pitch);
mix11 = *(mask0data + pitch + 1);
mix0 = (mix00*(z_stretch - mask0_z_off) + mix10*mask0_z_off);
mix1 = (mix01*(z_stretch - mask0_z_off) + mix11*mask0_z_off);
mixH = (mix0*(x_stretch - mask0_x_off) + mix1*mask0_x_off);
adv = mix1 - mix0;
int *pix_buf_int = (int *)pix_buf;
// for(int i=0;i<end_span-start_span;i++)
for(int i=0;;)
{
int mix = mixH>>shifter;
#ifdef MASK0_HORIZONTAL_FLIP
mixH -= adv;
#else
mixH += adv;
#endif
#ifdef SHOW_MATERIAL
if(mix > 0x80)
{
pix_buf_int[i] = mat_color;
}
#else
if(mix!=0)
{
DWORD dst = pix_buf_int[i];
#ifdef TEXTURE_HORIZONTAL_FLIP
DWORD src = data_ptr_word[-i];
#else
DWORD src = data_ptr_word[i];
#endif
DWORD buf;
DWORD srcmix = mix<<3;
mix = 0xff-mix;
buf = ((dst & 0xff)*mix + (src & 0x1f)*srcmix)>>8;
buf |= (((dst>>8)&0xff)*mix + ((src & 0x3e0) >> 5)*srcmix)&0xff00;
buf |= ((((dst>>16)&0xff)*mix + (src >> 10)*srcmix)&0xff00)<<8;
pix_buf_int[i] = buf;
}
#endif
if(++i>=end_span-start_span)
{
break;
}
#ifdef MASK0_HORIZONTAL_FLIP
#ifndef SHOW_MATERIAL
if(--count_down <= 0)
{
data_ptr_word += texture_width;
count_down = texture_width;
}
#endif
if(--mask0_x_off < 0)
{
mask0_x_off = advancer;
mask0data -= feature->featureMask0->depth;
mix01 = mix00;
mix00 = *mask0data;
mix11 = mix10;
mix10 = *(mask0data + pitch);
mix1 = mix0;
mix0 = (mix00*(z_stretch - mask0_z_off) + mix10*mask0_z_off);
#else
#ifndef SHOW_MATERIAL
if(--count_down <= 0)
{
data_ptr_word -= texture_width;
count_down = texture_width;
}
#endif
if(++mask0_x_off & advancer)
{
mask0_x_off = 0;
mask0data += feature->featureMask0->depth;
mix00 = mix01;
mix01 = *(mask0data + 1);
mix10 = mix11;
mix11 = *(mask0data + pitch + 1);
mix0 = mix1;
mix1 = (mix01*(z_stretch - mask0_z_off) + mix11*mask0_z_off);
#endif
mixH = (mix0*(x_stretch - mask0_x_off) + mix1*mask0_x_off);
adv = mix1 - mix0;
}
}
}
@@ -0,0 +1,240 @@
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
void
FeatureGrid::BLENDFUNCTION (
FeatureInstance *featureInstance,
unsigned char *pix_buf,
int x, int z,
int start_span,
int end_span,
int downScale
)
{
Feature *feature = featureInstance->feature;
Verify(feature->featureMask0!=NULL);
#ifdef SHOW_MATERIAL
DWORD mat_color = downScale & 0xffffff;
downScale >>= 24;
#else
int texture_width = (featureInstance->feature->featureTexture->width) >> downScale;
int count_down = featureInstance->countDownToBorder;
WORD *data_ptr_word = (WORD *)featureInstance->currentTexturePtr;
#endif
//===============================================================
int mask0_x_off, mask0_z_off;
int mask0_x = (x-featureInstance->feature_x_pos) >> feature->GetXMask0Scale();
int mask0_z = (z-featureInstance->feature_z_pos) >> feature->GetZMask0Scale();
mask0_x_off = (x-featureInstance->feature_x_pos) & ((1<<feature->GetXMask0Scale())-1);
mask0_z_off = (z-featureInstance->feature_z_pos) & ((1<<feature->GetZMask0Scale())-1);
// Verify(mask0_x<feature->featureMask0->width+1);
// Verify(mask0_z<feature->featureMask0->height+1);
if(! (mask0_x<feature->featureMask0->width+1) )
{
SPEW(("micgaert", "Whats going on in here ?"));
}
if(! (mask0_z<feature->featureMask0->height+1) )
{
SPEW(("micgaert", "Whats going on in here ?"));
}
if(feature->GetFlipMode() & Feature::Flip_Mode::Mask0_Vertical_Flip)
{
mask0_z = feature->featureMask0->height - mask0_z;
mask0_z -= 2;
mask0_z_off = (1<<feature->GetZMask0Scale()) - 1 - mask0_z_off;
}
if(feature->GetFlipMode() & Feature::Flip_Mode::Mask0_Horizontal_Flip)
{
mask0_x = feature->featureMask0->width - mask0_x;
mask0_x -= 2;
mask0_x_off = (1<<feature->GetXMask0Scale()) - 1 - mask0_x_off;
}
int mask0_x_bit = mask0_x & 7;
#ifdef MASK0_HORIZONTAL_FLIP
int bit_mask = 0x80>>mask0_x_bit;
#else
int bit_mask = 1<<mask0_x_bit;
#endif
mask0_x >>= 3;
int pitch = (feature->featureMask0->width>>3) + 2;
unsigned char *mask0data = feature->featureMask0->data
+ (mask0_z+1)*pitch + mask0_x + 1;
//===============================================================
mask0_x_off >>= downScale;
mask0_z_off >>= downScale;
int shifter = feature->GetZMask0Scale() + feature->GetXMask0Scale() - 2*downScale;
int x_stretch = 1<<(feature->GetXMask0Scale()-downScale);
int z_stretch = 1<<(feature->GetZMask0Scale()-downScale);
#ifdef MASK0_HORIZONTAL_FLIP
int advancer = x_stretch-1;
#else
int advancer = ~(x_stretch-1);
#endif
int adv, mixH, mix0, mix1, mix00, mix01, mix10, mix11;
mix00 = (*mask0data & bit_mask) ? 0xff : 0;
mix10 = (*(mask0data + pitch) & bit_mask) ? 0xff : 0;
int off = 0;
#ifdef MASK0_HORIZONTAL_FLIP
bit_mask >>= 1;
if(bit_mask == 0)
{
off = 1;
bit_mask = 0x80;
}
#else
bit_mask <<= 1;
if(bit_mask > 0x80)
{
off = 1;
bit_mask = 1;
}
#endif
mix01 = (*(mask0data + off) & bit_mask) ? 0xff : 0;
mix11 = (*(mask0data + pitch + off) & bit_mask) ? 0xff : 0;
mix0 = (mix00*(z_stretch - mask0_z_off) + mix10*mask0_z_off);
mix1 = (mix01*(z_stretch - mask0_z_off) + mix11*mask0_z_off);
mixH = (mix0*(x_stretch - mask0_x_off) + mix1*mask0_x_off);
adv = mix1 - mix0;
int *pix_buf_int = (int *)pix_buf;
for(int i=0;;)
{
int mix = mixH>>shifter;
#ifdef MASK0_HORIZONTAL_FLIP
mixH -= adv;
#else
mixH += adv;
#endif
#ifdef SHOW_MATERIAL
if(mix > 0x80)
{
pix_buf_int[i] = mat_color;
}
#else // SHOW_MATERIAL
if(mix!=0)
{
DWORD dst = pix_buf_int[i];
#ifdef TEXTURE_HORIZONTAL_FLIP
DWORD src = data_ptr_word[-i];
#else // TEXTURE_HORIZONTAL_FLIP
DWORD src = data_ptr_word[i];
#endif // TEXTURE_HORIZONTAL_FLIP
DWORD buf;
DWORD srcmix = mix<<3;
mix = 0xff-mix;
buf = ((dst & 0xff)*mix + (src & 0x1f)*srcmix)>>8;
buf |= (((dst>>8)&0xff)*mix + ((src & 0x3e0) >> 5)*srcmix)&0xff00;
buf |= ((((dst>>16)&0xff)*mix + (src >> 10)*srcmix)&0xff00)<<8;
pix_buf_int[i] = buf;
}
#endif // SHOW_MATERIAL
if(++i>=end_span-start_span)
{
break;
}
#ifdef MASK0_HORIZONTAL_FLIP
#ifndef SHOW_MATERIAL
if(--count_down <= 0)
{
data_ptr_word += texture_width;
count_down = texture_width;
}
#endif
if(--mask0_x_off < 0)
{
mask0_x_off = advancer;
if(off)
{
mask0data--;
}
bit_mask >>= 1;
off = 0;
if(bit_mask == 0)
{
off = 1;
bit_mask = 0x80;
}
mix01 = mix00;
mix00 = (*(mask0data - off) & bit_mask) ? 0xff : 0;
mix11 = mix10;
mix10 = (*(mask0data + pitch - off) & bit_mask) ? 0xff : 0;
mix1 = mix0;
mix0 = (mix00*(z_stretch - mask0_z_off) + mix10*mask0_z_off);
#else
#ifndef SHOW_MATERIAL
if(--count_down <= 0)
{
data_ptr_word -= texture_width;
count_down = texture_width;
}
#endif
if(++mask0_x_off & advancer)
{
mask0_x_off = 0;
if(off)
{
mask0data++;
}
bit_mask <<= 1;
off = 0;
if(bit_mask > 0x80)
{
off = 1;
bit_mask = 1;
}
mix00 = mix01;
mix01 = (*(mask0data + off) & bit_mask) ? 0xff : 0;
mix10 = mix11;
mix11 = (*(mask0data + pitch + off) & bit_mask) ? 0xff : 0;
mix0 = mix1;
mix1 = (mix01*(z_stretch - mask0_z_off) + mix11*mask0_z_off);
#endif
mixH = (mix0*(x_stretch - mask0_x_off) + mix1*mask0_x_off);
adv = mix1 - mix0;
}
}
}
@@ -0,0 +1,92 @@
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
void
FeatureGrid::BLENDFUNCTION (
FeatureInstance *featureInstance,
unsigned char *pix_buf,
int start_span,
int end_span,
int downScale
)
{
#ifdef TEXTURE_HORIZONTAL_FLIP
#else
#endif
unsigned char *mask0data = featureInstance->currentMask0Ptr;
#ifdef SHOW_MATERIAL
DWORD mat_color = downScale & 0xffffff;
downScale >>= 24;
#else
int texture_width = (featureInstance->feature->featureTexture->width) >> downScale;
int count_down = featureInstance->countDownToBorder;
WORD *data_ptr_word = (WORD *)featureInstance->currentTexturePtr;
#endif
#ifdef MASK0_HORIZONTAL_FLIP
int i, j;
for(i=0,j=0;i<end_span-start_span;i++,j--)
#else
for(int i=0;i<end_span-start_span;i++)
#endif
{
#ifdef MASK0_HORIZONTAL_FLIP
int alpha = mask0data[j];
#ifdef SHOW_MATERIAL
if(alpha>0x80)
{
*(DWORD *)pix_buf = mat_color;
}
#else // SHOW_MATERIAL
if(alpha>0)
{
int col = *pix_buf*(0xff-alpha) + ((data_ptr_word[j] & 0x1f)<<3)*alpha;
*pix_buf = static_cast<unsigned char>(col>>8);
col = *(pix_buf+1)*(0xff-alpha) + ((data_ptr_word[j] & 0x3e0)>>2)*alpha;
*(pix_buf+1) = static_cast<unsigned char>(col>>8);
col = *(pix_buf+2)*(0xff-alpha) + ((data_ptr_word[j] & 0x7c00)>>7)*alpha;
*(pix_buf+2) = static_cast<unsigned char>(col>>8);
}
if(--count_down <= 0)
{
data_ptr_word += texture_width;
count_down = texture_width;
}
#endif // SHOW_MATERIAL
#else
int alpha = mask0data[i];
#ifdef SHOW_MATERIAL
if(alpha>0x80)
{
*(DWORD *)pix_buf = mat_color;
}
#else // SHOW_MATERIAL
if(alpha>0)
{
int col = *pix_buf*(0xff-alpha) + ((data_ptr_word[i] & 0x1f)<<3)*alpha;
*pix_buf = static_cast<unsigned char>(col>>8);
col = *(pix_buf+1)*(0xff-alpha) + ((data_ptr_word[i] & 0x3e0)>>2)*alpha;
*(pix_buf+1) = static_cast<unsigned char>(col>>8);
col = *(pix_buf+2)*(0xff-alpha) + ((data_ptr_word[i] & 0x7c00)>>7)*alpha;
*(pix_buf+2) = static_cast<unsigned char>(col>>8);
}
if(--count_down <= 0)
{
data_ptr_word -= texture_width;
count_down = texture_width;
}
#endif // SHOW_MATERIAL
#endif
pix_buf += colorDepth;
}
}
@@ -0,0 +1,212 @@
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
void
FeatureGrid::BLENDFUNCTION (
FeatureInstance *featureInstance,
unsigned char *pix_buf,
int start_span,
int end_span,
int downScale
)
{
Feature *feature = featureInstance->feature;
Verify(feature->featureMask0!=NULL);
Verify(feature->featureMask1!=NULL);
#ifdef SHOW_MATERIAL
DWORD mat_color = downScale & 0xffffff;
downScale >>= 24;
#else
int texture_width = (featureInstance->feature->featureTexture->width) >> downScale;
int count_down = featureInstance->countDownToBorder;
WORD *data_ptr_word = (WORD *)featureInstance->currentTexturePtr;
#endif
unsigned char *mask0data = featureInstance->currentMask0Ptr;
unsigned char *mask1data = featureInstance->currentMask1Ptr;
int mask0_x_off = featureInstance->mask0_x_off >> downScale;
int mask0_z_off = featureInstance->mask0_z_off >> downScale;
int mask1_x_off = featureInstance->mask1_x_off >> downScale;
int mask1_z_off = featureInstance->mask1_z_off >> downScale;
int shifter0 = feature->GetZMask0Scale() + feature->GetXMask0Scale() - 2*downScale;
int shifter1 = feature->GetZMask1Scale() + feature->GetXMask1Scale() - 2*downScale;
int x0_stretch = 1<<(feature->GetXMask0Scale()-downScale);
int z0_stretch = 1<<(feature->GetZMask0Scale()-downScale);
int x1_stretch = 1<<(feature->GetXMask1Scale()-downScale);
int z1_stretch = 1<<(feature->GetZMask1Scale()-downScale);
#ifdef MASK0_HORIZONTAL_FLIP
int advancer0 = x0_stretch-1;
#else
int advancer0 = ~(x0_stretch-1);
#endif
#ifdef MASK1_HORIZONTAL_FLIP
int advancer1 = x1_stretch-1;
#else
int advancer1 = ~(x1_stretch-1);
#endif
int adv0, adv1, mixH0, mixH1;
int pitch0 = feature->featureMask0->width + 2; // 2 - padding
int pitch1 = feature->featureMask1->width + 2; // 2 - padding
{
int mix0, mix1, mix00, mix01, mix10, mix11;
mix00 = *mask0data;
mix01 = *(mask0data + 1);
mix10 = *(mask0data + pitch0);
mix11 = *(mask0data + pitch0 + 1);
mix0 = (mix00*(z0_stretch - mask0_z_off) + mix10*mask0_z_off);
mix1 = (mix01*(z0_stretch - mask0_z_off) + mix11*mask0_z_off);
mixH0 = (mix0*(x0_stretch - mask0_x_off) + mix1*mask0_x_off);
adv0 = mix1 - mix0;
//=================================================
mix00 = *mask1data;
mix01 = *(mask1data + 1);
mix10 = *(mask1data + pitch1);
mix11 = *(mask1data + pitch1 + 1);
mix0 = (mix00*(z1_stretch - mask1_z_off) + mix10*mask1_z_off);
mix1 = (mix01*(z1_stretch - mask1_z_off) + mix11*mask1_z_off);
mixH1 = (mix0*(x1_stretch - mask1_x_off) + mix1*mask1_x_off);
adv1 = mix1 - mix0;
}
int *pix_buf_int = (int *)pix_buf;
for(int i=0;;)
{
int mix = (mixH0>>shifter0) + (mixH1>>shifter1);
#ifdef MASK0_HORIZONTAL_FLIP
mixH0 -= adv0;
#else
mixH0 += adv0;
#endif
#ifdef MASK1_HORIZONTAL_FLIP
mixH1 -= adv1;
#else
mixH1 += adv1;
#endif
#ifdef SHOW_MATERIAL
if(mix > 0x80)
{
pix_buf_int[i] = mat_color;
}
#else // SHOW_MATERIAL
if(mix!=0)
{
mix = mix&0xffffff00 ? 0xff : mix;
DWORD dst = pix_buf_int[i];
#ifdef TEXTURE_HORIZONTAL_FLIP
DWORD src = data_ptr_word[-i];
#else
DWORD src = data_ptr_word[i];
#endif
DWORD buf;
DWORD srcmix = mix<<3;
mix = 0xff-mix;
buf = ((dst & 0xff)*mix + (src & 0x1f)*srcmix)>>8;
buf |= (((dst>>8)&0xff)*mix + ((src & 0x3e0) >> 5)*srcmix)&0xff00;
buf |= ((((dst>>16)&0xff)*mix + (src >> 10)*srcmix)&0xff00)<<8;
pix_buf_int[i] = buf;
}
#endif // SHOW_MATERIAL
if(++i>=end_span-start_span)
{
break;
}
#ifdef MASK0_HORIZONTAL_FLIP
#ifndef SHOW_MATERIAL
if(--count_down <= 0)
{
data_ptr_word += texture_width;
count_down = texture_width;
}
#endif // SHOW_MATERIAL
if(--mask0_x_off < 0)
{
mask0_x_off = advancer0;
mask0data -= feature->featureMask0->depth;
#else
#ifndef SHOW_MATERIAL
if(--count_down <= 0)
{
data_ptr_word -= texture_width;
count_down = texture_width;
}
#endif // SHOW_MATERIAL
if(++mask0_x_off & advancer0)
{
mask0_x_off = 0;
mask0data += feature->featureMask0->depth;
#endif
int mix0, mix1, mix00, mix01, mix10, mix11;
mix00 = *mask0data;
mix01 = *(mask0data + 1);
mix10 = *(mask0data + pitch0);
mix11 = *(mask0data + pitch0 + 1);
mix0 = (mix00*(z0_stretch - mask0_z_off) + mix10*mask0_z_off);
mix1 = (mix01*(z0_stretch - mask0_z_off) + mix11*mask0_z_off);
mixH0 = (mix0*(x0_stretch - mask0_x_off) + mix1*mask0_x_off);
adv0 = mix1 - mix0;
}
#ifdef MASK1_HORIZONTAL_FLIP
if(--mask1_x_off < 0)
{
mask1_x_off = advancer1;
mask1data -= feature->featureMask1->depth;
#else
if(++mask1_x_off & advancer1)
{
mask1_x_off = 0;
mask1data += feature->featureMask1->depth;
#endif
int mix0, mix1, mix00, mix01, mix10, mix11;
mix00 = *mask1data;
mix01 = *(mask1data + 1);
mix10 = *(mask1data + pitch1);
mix11 = *(mask1data + pitch1 + 1);
mix0 = (mix00*(z1_stretch - mask1_z_off) + mix10*mask1_z_off);
mix1 = (mix01*(z1_stretch - mask1_z_off) + mix11*mask1_z_off);
mixH1 = (mix0*(x1_stretch - mask1_x_off) + mix1*mask1_x_off);
adv1 = mix1 - mix0;
}
}
}
@@ -0,0 +1,192 @@
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
void
FeatureGrid::BLENDFUNCTION (
FeatureInstance *featureInstance,
unsigned char *pix_buf,
int start_span,
int end_span,
int downScale
)
{
Feature *feature = featureInstance->feature;
Verify(feature->featureMask0!=NULL);
unsigned char *mask0data0 = featureInstance->currentMask0Ptr;
int mask0_x_off = featureInstance->mask0_x_off >> downScale;
int mask0_z_off = featureInstance->mask0_z_off >> downScale;
int shifter = feature->GetZMask0Scale() + feature->GetXMask0Scale() - 2*downScale;
int x_stretch = 1<<(feature->GetXMask0Scale()-downScale);
int z_stretch = 1<<(feature->GetZMask0Scale()-downScale);
#ifdef MASK0_HORIZONTAL_FLIP
int advancer = x_stretch-1;
#else
int advancer = ~(x_stretch-1);
#endif
int advr, mixHr, mixr, mix0r, mix1r, mix00r, mix01r, mix10r, mix11r;
int advg, mixHg, mixg, mix0g, mix1g, mix00g, mix01g, mix10g, mix11g;
int advb, mixHb, mixb, mix0b, mix1b, mix00b, mix01b, mix10b, mix11b;
int pitch = feature->featureMask0->depth * (feature->featureMask0->width + 2); // 2 - padding
int src;
src = *(int *)mask0data0;
mix00r = (src & 0x1f) << 3;
mix00g = (src & 0x3e0) >> 2;
mix00b = (src & 0x7c00) >> 7;
src = *(int *)(mask0data0 + feature->featureMask0->depth);
mix01r = (src & 0x1f) << 3;
mix01g = (src & 0x3e0) >> 2;
mix01b = (src & 0x7c00) >> 7;
src = *(int *)(mask0data0 + pitch);
mix10r = (src & 0x1f) << 3;
mix10g = (src & 0x3e0) >> 2;
mix10b = (src & 0x7c00) >> 7;
src = *(int *)(mask0data0 + pitch + feature->featureMask0->depth);
mix11r = (src & 0x1f) << 3;
mix11g = (src & 0x3e0) >> 2;
mix11b = (src & 0x7c00) >> 7;
mix0r = (mix00r*(z_stretch - mask0_z_off) + mix10r*mask0_z_off);
mix0g = (mix00g*(z_stretch - mask0_z_off) + mix10g*mask0_z_off);
mix0b = (mix00b*(z_stretch - mask0_z_off) + mix10b*mask0_z_off);
mix1r = (mix01r*(z_stretch - mask0_z_off) + mix11r*mask0_z_off);
mix1g = (mix01g*(z_stretch - mask0_z_off) + mix11g*mask0_z_off);
mix1b = (mix01b*(z_stretch - mask0_z_off) + mix11b*mask0_z_off);
mixHr = (mix0r*(x_stretch - mask0_x_off) + mix1r*mask0_x_off);
mixHg = (mix0g*(x_stretch - mask0_x_off) + mix1g*mask0_x_off);
mixHb = (mix0b*(x_stretch - mask0_x_off) + mix1b*mask0_x_off);
advr = mix1r - mix0r;
advg = mix1g - mix0g;
advb = mix1b - mix0b;
int *pix_buf_int = (int *)pix_buf;
for(int i=0;;)
{
mixr = mixHr>>shifter;
mixg = mixHg>>shifter;
mixb = mixHb>>shifter;
#ifdef MASK0_HORIZONTAL_FLIP
mixHr -= advr;
mixHg -= advg;
mixHb -= advb;
#else
mixHr += advr;
mixHg += advg;
mixHb += advb;
#endif
#ifdef SHOW_MATERIAL
if(mixr+mixg+mixb < 3*DarkFactor)
{
pix_buf_int[i] = DarkMachine(pix_buf_int[i]);
}
#else // SHOW_MATERIAL
DWORD dst = pix_buf_int[i];
DWORD buf;
buf = ((dst & 0xff)*mixr) >> 8;
buf |= (((dst>>8)&0xff)*mixg) & 0xff00;
buf |= ((((dst>>16)&0xff)*mixb) << 8) & 0xff00000;
pix_buf_int[i] = buf;
#endif // SHOW_MATERIAL
if(++i>=end_span-start_span)
{
break;
}
#ifdef MASK0_HORIZONTAL_FLIP
if(--mask0_x_off < 0)
{
mask0_x_off = advancer;
mask0data0 -= feature->featureMask0->depth;
mix01r = mix00r;
mix01g = mix00g;
mix01b = mix00b;
src = *(int *)mask0data0;
mix00r = (src & 0x1f) << 3;
mix00g = (src & 0x3e0) >> 2;
mix00b = (src & 0x7c00) >> 7;
mix11r = mix10r;
mix11g = mix10g;
mix11b = mix10b;
src = *(int *)(mask0data0 + pitch);
mix10r = (src & 0x1f) << 3;
mix10g = (src & 0x3e0) >> 2;
mix10b = (src & 0x7c00) >> 7;
mix1r = mix0r;
mix1g = mix0g;
mix1b = mix0b;
mix0r = (mix00r*(z_stretch - mask0_z_off) + mix10r*mask0_z_off);
mix0g = (mix00g*(z_stretch - mask0_z_off) + mix10g*mask0_z_off);
mix0b = (mix00b*(z_stretch - mask0_z_off) + mix10b*mask0_z_off);
#else // MASK0_HORIZONTAL_FLIP
if(++mask0_x_off & advancer)
{
mask0_x_off = 0;
mask0data0 += feature->featureMask0->depth;
mix00r = mix01r;
mix00g = mix01g;
mix00b = mix01b;
src = *(int *)(mask0data0 + feature->featureMask0->depth);
mix01r = (src & 0x1f) << 3;
mix01g = (src & 0x3e0) >> 2;
mix01b = (src & 0x7c00) >> 7;
mix10r = mix11r;
mix10g = mix11g;
mix10b = mix11b;
src = *(int *)(mask0data0 + pitch + feature->featureMask0->depth);
mix11r = (src & 0x1f) << 3;
mix11g = (src & 0x3e0) >> 2;
mix11b = (src & 0x7c00) >> 7;
mix0r = mix1r;
mix0g = mix1g;
mix0b = mix1b;
mix1r = (mix01r*(z_stretch - mask0_z_off) + mix11r*mask0_z_off);
mix1g = (mix01g*(z_stretch - mask0_z_off) + mix11g*mask0_z_off);
mix1b = (mix01b*(z_stretch - mask0_z_off) + mix11b*mask0_z_off);
#endif // MASK0_HORIZONTAL_FLIP
mixHr = (mix0r*(x_stretch - mask0_x_off) + mix1r*mask0_x_off);
advr = mix1r - mix0r;
mixHg = (mix0g*(x_stretch - mask0_x_off) + mix1g*mask0_x_off);
advg = mix1g - mix0g;
mixHb = (mix0b*(x_stretch - mask0_x_off) + mix1b*mask0_x_off);
advb = mix1b - mix0b;
}
}
}
@@ -0,0 +1,192 @@
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
void
FeatureGrid::BLENDFUNCTION (
FeatureInstance *featureInstance,
unsigned char *pix_buf,
int start_span,
int end_span,
int downScale
)
{
Feature *feature = featureInstance->feature;
Verify(feature->featureMask0!=NULL);
unsigned char *mask0data0 = featureInstance->currentMask0Ptr;
#ifdef SHOW_MATERIAL
DWORD mat_color = downScale & 0xffffff;
downScale >>= 24;
#endif
int mask0_x_off = featureInstance->mask0_x_off >> downScale;
int mask0_z_off = featureInstance->mask0_z_off >> downScale;
int shifter = feature->GetZMask0Scale() + feature->GetXMask0Scale() - 2*downScale;
int x_stretch = 1<<(feature->GetXMask0Scale()-downScale);
int z_stretch = 1<<(feature->GetZMask0Scale()-downScale);
#ifdef MASK0_HORIZONTAL_FLIP
int advancer = x_stretch-1;
#else
int advancer = ~(x_stretch-1);
#endif
int advr, mixHr, mixr, mix0r, mix1r, mix00r, mix01r, mix10r, mix11r;
int advg, mixHg, mixg, mix0g, mix1g, mix00g, mix01g, mix10g, mix11g;
int advb, mixHb, mixb, mix0b, mix1b, mix00b, mix01b, mix10b, mix11b;
int pitch = feature->featureMask0->depth * (feature->featureMask0->width + 2); // 2 - padding
int src;
src = *(int *)mask0data0;
mix00r = (src & 0x1f) << 3;
mix00g = (src & 0x3e0) >> 2;
mix00b = (src & 0x7c00) >> 7;
src = *(int *)(mask0data0 + feature->featureMask0->depth);
mix01r = (src & 0x1f) << 3;
mix01g = (src & 0x3e0) >> 2;
mix01b = (src & 0x7c00) >> 7;
src = *(int *)(mask0data0 + pitch);
mix10r = (src & 0x1f) << 3;
mix10g = (src & 0x3e0) >> 2;
mix10b = (src & 0x7c00) >> 7;
src = *(int *)(mask0data0 + pitch + feature->featureMask0->depth);
mix11r = (src & 0x1f) << 3;
mix11g = (src & 0x3e0) >> 2;
mix11b = (src & 0x7c00) >> 7;
mix0r = (mix00r*(z_stretch - mask0_z_off) + mix10r*mask0_z_off);
mix0g = (mix00g*(z_stretch - mask0_z_off) + mix10g*mask0_z_off);
mix0b = (mix00b*(z_stretch - mask0_z_off) + mix10b*mask0_z_off);
mix1r = (mix01r*(z_stretch - mask0_z_off) + mix11r*mask0_z_off);
mix1g = (mix01g*(z_stretch - mask0_z_off) + mix11g*mask0_z_off);
mix1b = (mix01b*(z_stretch - mask0_z_off) + mix11b*mask0_z_off);
mixHr = (mix0r*(x_stretch - mask0_x_off) + mix1r*mask0_x_off);
mixHg = (mix0g*(x_stretch - mask0_x_off) + mix1g*mask0_x_off);
mixHb = (mix0b*(x_stretch - mask0_x_off) + mix1b*mask0_x_off);
advr = mix1r - mix0r;
advg = mix1g - mix0g;
advb = mix1b - mix0b;
int *pix_buf_int = (int *)pix_buf;
for(int i=0;;)
{
mixr = mixHr>>shifter;
mixg = mixHg>>shifter;
mixb = mixHb>>shifter;
#ifdef MASK0_HORIZONTAL_FLIP
mixHr -= advr;
mixHg -= advg;
mixHb -= advb;
#else
mixHr += advr;
mixHg += advg;
mixHb += advb;
#endif
#ifdef SHOW_MATERIAL
pix_buf_int[i] = mat_color;
#else
DWORD buf;
buf = mixr;
buf |= mixg << 8;
buf |= mixb << 16;
pix_buf_int[i] = buf;
#endif
if(++i>=end_span-start_span)
{
break;
}
#ifdef MASK0_HORIZONTAL_FLIP
if(--mask0_x_off < 0)
{
mask0_x_off = advancer;
mask0data0 -= feature->featureMask0->depth;
mix01r = mix00r;
mix01g = mix00g;
mix01b = mix00b;
src = *(int *)mask0data0;
mix00r = (src & 0x1f) << 3;
mix00g = (src & 0x3e0) >> 2;
mix00b = (src & 0x7c00) >> 7;
mix11r = mix10r;
mix11g = mix10g;
mix11b = mix10b;
src = *(int *)(mask0data0 + pitch);
mix10r = (src & 0x1f) << 3;
mix10g = (src & 0x3e0) >> 2;
mix10b = (src & 0x7c00) >> 7;
mix1r = mix0r;
mix1g = mix0g;
mix1b = mix0b;
mix0r = (mix00r*(z_stretch - mask0_z_off) + mix10r*mask0_z_off);
mix0g = (mix00g*(z_stretch - mask0_z_off) + mix10g*mask0_z_off);
mix0b = (mix00b*(z_stretch - mask0_z_off) + mix10b*mask0_z_off);
#else
if(++mask0_x_off & advancer)
{
mask0_x_off = 0;
mask0data0 += feature->featureMask0->depth;
mix00r = mix01r;
mix00g = mix01g;
mix00b = mix01b;
src = *(int *)(mask0data0 + feature->featureMask0->depth);
mix01r = (src & 0x1f) << 3;
mix01g = (src & 0x3e0) >> 2;
mix01b = (src & 0x7c00) >> 7;
mix10r = mix11r;
mix10g = mix11g;
mix10b = mix11b;
src = *(int *)(mask0data0 + pitch + feature->featureMask0->depth);
mix11r = (src & 0x1f) << 3;
mix11g = (src & 0x3e0) >> 2;
mix11b = (src & 0x7c00) >> 7;
mix0r = mix1r;
mix0g = mix1g;
mix0b = mix1b;
mix1r = (mix01r*(z_stretch - mask0_z_off) + mix11r*mask0_z_off);
mix1g = (mix01g*(z_stretch - mask0_z_off) + mix11g*mask0_z_off);
mix1b = (mix01b*(z_stretch - mask0_z_off) + mix11b*mask0_z_off);
#endif
mixHr = (mix0r*(x_stretch - mask0_x_off) + mix1r*mask0_x_off);
advr = mix1r - mix0r;
mixHg = (mix0g*(x_stretch - mask0_x_off) + mix1g*mask0_x_off);
advg = mix1g - mix0g;
mixHb = (mix0b*(x_stretch - mask0_x_off) + mix1b*mask0_x_off);
advb = mix1b - mix0b;
}
}
}
@@ -0,0 +1,186 @@
#include "CompostHeaders.hpp"
DWORD Compost::Number_Of_Worked_On_Textures;
DEFINE_TIMER(Compost, Composting_Time);
DWORD Compost::Number_Of_Used_128_Textures = 0;
DWORD Compost::Number_Of_Used_256_Textures = 0;
HGOSHEAP
Compost::Heap = NULL;
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
static bool __stdcall Check_0() {return TerrainTextureLogistic::GetResolution() == 0;}
static bool __stdcall Check_1() {return TerrainTextureLogistic::GetResolution() == 1;}
static bool __stdcall Check_2() {return TerrainTextureLogistic::GetResolution() == 2;}
static bool __stdcall Check_3() {return TerrainTextureLogistic::GetResolution() == 3;}
static void __stdcall Activate_0() {TerrainTextureLogistic::SetResolution(0);}
static void __stdcall Activate_1() {TerrainTextureLogistic::SetResolution(1);}
static void __stdcall Activate_2() {TerrainTextureLogistic::SetResolution(2);}
static void __stdcall Activate_3() {TerrainTextureLogistic::SetResolution(3);}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
MaterialEntry Compost::MaterialEntries[128];
int Compost::MaterialEntriesCount = 0;
int Compost::DarkFactor = 128;
int
Feature_Texture::RecalculateSize()
{
int dsize = 0;
switch(flags & Compost::Feature_Texture::TextureTypeMask)
{
case Compost::Feature_Texture::TextureMode::FTT_555:
case Compost::Feature_Texture::TextureMode::FTT_4444:
case Compost::Feature_Texture::TextureMode::FTT_1_M:
{
dsize = depth*(width+2)*(height+2);
dsize += depth*((width>>1)+2)*((height>>1)+2);
dsize += depth*((width>>2)+2)*((height>>2)+2);
dataSize = dsize;
}
break;
case Compost::Feature_Texture::TextureMode::FTT_1:
{
dsize = depth*(width+2)*(height+2);
dataSize = dsize;
}
break;
case Compost::Feature_Texture::TextureMode::FTT_1_1:
{
dsize = depth*(2+ (width>>3))*(2+height);
dataSize = dsize;
}
break;
default:
STOP(("Unknown Compost Texture Format !!"));
break;
}
return dsize;
}
const char*
Feature::GetBlendModeName(Blend_Mode bm)
{
static char name[1024];
switch(bm)
{
case Blend_Mode::Paste:
strcpy(name, "Paste");
break;
case Blend_Mode::Added:
strcpy(name, "Added");
break;
case Blend_Mode::Multiply:
strcpy(name, "Multiply");
break;
case Blend_Mode::Blend555_1:
strcpy(name, "Blend555_1");
break;
case Blend_Mode::Blend555_2:
strcpy(name, "Blend555_2");
break;
case Blend_Mode::Blend4444:
strcpy(name, "Blend4444");
break;
case Blend_Mode::StretchMultiply:
strcpy(name, "StretchMultiply");
break;
case Blend_Mode::Blend555_1_1:
strcpy(name, "Blend555_1_1");
break;
case Blend_Mode::StretchPaste:
strcpy(name, "StretchPaste");
break;
case Blend_Mode::Blend555_1_S:
strcpy(name, "Blend555_1_S");
break;
default:
strcpy(name, "Unknown");
};
return name;
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
void
Compost::InitializeClasses(NotationFile *startup_ini)
{
AddDebuggerMenuItem("Libraries\\Graphics Options\\Terrain Texture Level 0", Check_0, Activate_0, NULL );
AddDebuggerMenuItem("Libraries\\Graphics Options\\Terrain Texture Level 1", Check_1, Activate_1, NULL );
AddDebuggerMenuItem("Libraries\\Graphics Options\\Terrain Texture Level 2", Check_2, Activate_2, NULL );
AddDebuggerMenuItem("Libraries\\Graphics Options\\Terrain Texture Level 3", Check_3, Activate_3, NULL );
Verify(!Heap);
Heap = gos_CreateMemoryHeap("Compositing");
Check_Pointer(Heap);
gos_PushCurrentHeap(Heap);
//
//---------------------
// Setup the statistics
//---------------------
//
#if !(defined(NO_STATS) && defined(NO_TIMERS))
StatisticFormat( "" );
StatisticFormat( "Compositing" );
StatisticFormat( "===========" );
StatisticFormat( "" );
#endif
#ifdef LAB_ONLY
Number_Of_Used_128_Textures = Number_Of_Reserved_Textures;
Number_Of_Used_256_Textures = Number_Of_Reserved_Textures/2;
#endif
#if !defined(NO_STATS)
AddStatistic( "Textures in work", "#", gos_DWORD, &Number_Of_Worked_On_Textures, Stat_AutoReset );
AddStatistic( "128 Textures used", "#", gos_DWORD, &Number_Of_Used_128_Textures, Stat_AutoReset + Stat_GraphMax);
AddStatistic( "256 Textures used", "#", gos_DWORD, &Number_Of_Used_256_Textures, Stat_AutoReset + Stat_GraphMax);
#endif
Initialize_Timer(Composting_Time, "Compost time");
if (startup_ini)
{
Check_Object(startup_ini);
Page *page = startup_ini->FindPage("Graphics Options");
if (page)
{
Check_Object(page);
int compositing;
if (page->GetEntry("Compositing", &compositing))
TerrainTextureLogistic::SetResolution(compositing);
}
}
gos_PopCurrentHeap();
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
void
Compost::TerminateClasses(NotationFile *startup_ini)
{
if (startup_ini)
{
Check_Object(startup_ini);
Page *page = startup_ini->SetPage("Graphics Options");
Check_Object(page);
int compositing = TerrainTextureLogistic::GetResolution();
page->SetEntry("Compositing", compositing);
}
Check_Pointer(Heap);
gos_DestroyMemoryHeap(Heap);
Heap = NULL;
}
@@ -0,0 +1,889 @@
# Microsoft Developer Studio Project File - Name="Compost" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Static Library" 0x0104
CFG=Compost - Win32 Release
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "Compost.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "Compost.mak" CFG="Compost - Win32 Release"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "Compost - Win32 Release" (based on "Win32 (x86) Static Library")
!MESSAGE "Compost - Win32 Profile" (based on "Win32 (x86) Static Library")
!MESSAGE "Compost - Win32 Armor" (based on "Win32 (x86) Static Library")
!MESSAGE "Compost - Win32 Debug" (based on "Win32 (x86) Static Library")
!MESSAGE "Compost - Win32 icecap" (based on "Win32 (x86) Static Library")
!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName ""$/GameLeapCode/mw4/Libraries/Compost", LCHAAAAA"
# PROP Scc_LocalPath "."
CPP=cl.exe
RSC=rc.exe
!IF "$(CFG)" == "Compost - Win32 Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "../../../rel.bin"
# PROP Intermediate_Dir "Release"
# PROP Target_Dir ""
MTL=midl.exe
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
# ADD CPP /nologo /G6 /Zp4 /MD /W4 /GR /Oa /Og /Oi /Oy /Gy /I "..\..\Libraries" /I "..\..\..\CoreTech\Libraries" /I "..\..\Libraries\stlport" /D "RELEASE" /D "USE_PROTOTYPES" /D "STRICT" /D "_WINDOWS" /D "NDEBUG" /D "WIN32" /YX /FD /GF /c
# SUBTRACT CPP /WX /Fr
# ADD BASE RSC /l 0x409
# ADD RSC /l 0x409
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LIB32=link.exe -lib
# ADD BASE LIB32 /nologo
# ADD LIB32 /nologo
!ELSEIF "$(CFG)" == "Compost - Win32 Profile"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Profile"
# PROP BASE Intermediate_Dir "Profile"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "../../../pro.bin"
# PROP Intermediate_Dir "Profile"
# PROP Target_Dir ""
MTL=midl.exe
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
# ADD CPP /nologo /G6 /Zp4 /MD /W4 /Zi /O2 /I "..\..\Libraries" /I "..\..\..\CoreTech\Libraries" /I "..\..\Libraries\stlport" /D "LAB_ONLY" /D "USE_PROTOTYPES" /D "STRICT" /D "_WINDOWS" /D "NDEBUG" /D "WIN32" /FD /GF /c
# SUBTRACT CPP /WX /Fr /YX /Yc /Yu
# ADD BASE RSC /l 0x409
# ADD RSC /l 0x409
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LIB32=link.exe -lib
# ADD BASE LIB32 /nologo
# ADD LIB32 /nologo
!ELSEIF "$(CFG)" == "Compost - Win32 Armor"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Armor"
# PROP BASE Intermediate_Dir "Armor"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "../../../arm.bin"
# PROP Intermediate_Dir "Armor"
# PROP Target_Dir ""
MTL=midl.exe
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
# ADD CPP /nologo /G6 /Zp4 /MD /W4 /GR /Zi /Ox /Ot /Oa /Og /Oi /Gy /I "..\..\Libraries" /I "..\..\..\CoreTech\Libraries" /I "..\..\Libraries\stlport" /D "LAB_ONLY" /D "NDEBUG" /D "_ARMOR" /D "USE_PROTOTYPES" /D "STRICT" /D "_WINDOWS" /D "WIN32" /YX /FD /GF /c
# SUBTRACT CPP /WX /Fr
# ADD BASE RSC /l 0x409
# ADD RSC /l 0x409
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LIB32=link.exe -lib
# ADD BASE LIB32 /nologo
# ADD LIB32 /nologo
!ELSEIF "$(CFG)" == "Compost - Win32 Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Debug"
# PROP BASE Intermediate_Dir "Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "../../../dbg.bin"
# PROP Intermediate_Dir "Debug"
# PROP Target_Dir ""
MTL=midl.exe
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
# ADD CPP /nologo /G6 /Zp4 /MDd /W4 /GR /Zi /Od /I "..\..\Libraries" /I "..\..\..\CoreTech\Libraries" /I "..\..\Libraries\stlport" /D "TRACE_ENABLE" /D "LAB_ONLY" /D "USE_PROTOTYPES" /D "STRICT" /D "_ARMOR" /D "_WINDOWS" /D "WIN32" /D "_DEBUG" /FR /Yu"CompostHeaders.hpp" /FD /c
# SUBTRACT CPP /WX
# ADD BASE RSC /l 0x409
# ADD RSC /l 0x409
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LIB32=link.exe -lib
# ADD BASE LIB32 /nologo
# ADD LIB32 /nologo
!ELSEIF "$(CFG)" == "Compost - Win32 icecap"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "icecap"
# PROP BASE Intermediate_Dir "icecap"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "../../../ice.bin"
# PROP Intermediate_Dir "icecap"
# PROP Target_Dir ""
MTL=midl.exe
# ADD BASE CPP /nologo /G6 /Zp4 /MD /W4 /WX /Zi /Ox /Ot /Oa /Og /Oi /Gy /I "..\..\Libraries" /I "..\..\..\CoreTech\Libraries" /D "LAB_ONLY" /D "USE_PROTOTYPES" /D "STRICT" /D "_WINDOWS" /D "NDEBUG" /D "WIN32" /FD /GF /c
# SUBTRACT BASE CPP /Gf /Fr /YX /Yc /Yu
# ADD CPP /nologo /G6 /Zp4 /MD /W4 /Zi /Ot /Oa /Oi /Gy /I "..\..\Libraries" /I "..\..\..\CoreTech\Libraries" /I "..\..\Libraries\stlport" /D "LAB_ONLY" /D "USE_PROTOTYPES" /D "STRICT" /D "_WINDOWS" /D "NDEBUG" /D "WIN32" /D "_ICECAP" /FD /GF /c
# SUBTRACT CPP /WX /Og /Fr
# ADD BASE RSC /l 0x409
# ADD RSC /l 0x409
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LIB32=link.exe -lib
# ADD BASE LIB32 /nologo
# ADD LIB32 /nologo
!ENDIF
# Begin Target
# Name "Compost - Win32 Release"
# Name "Compost - Win32 Profile"
# Name "Compost - Win32 Armor"
# Name "Compost - Win32 Debug"
# Name "Compost - Win32 icecap"
# Begin Group "TextureLibrary"
# PROP Default_Filter ""
# Begin Source File
SOURCE=.\TexturePool.cpp
# End Source File
# Begin Source File
SOURCE=.\TexturePool.hpp
# End Source File
# End Group
# Begin Group "FeaturePool"
# PROP Default_Filter ""
# Begin Source File
SOURCE=.\BlendMode4444.hpp
# End Source File
# Begin Source File
SOURCE=.\BlendMode555_1.hpp
# End Source File
# Begin Source File
SOURCE=.\BlendMode555_1_1.hpp
# End Source File
# Begin Source File
SOURCE=.\BlendMode555_1_S.hpp
# End Source File
# Begin Source File
SOURCE=.\BlendMode555_2.hpp
# End Source File
# Begin Source File
SOURCE=.\BlendModeSM.hpp
# End Source File
# Begin Source File
SOURCE=.\BlendModeSS.hpp
# End Source File
# Begin Source File
SOURCE=.\FeatureGrid.cpp
# End Source File
# Begin Source File
SOURCE=.\FeatureGrid.hpp
# End Source File
# Begin Source File
SOURCE=.\FeaturePool.cpp
# End Source File
# Begin Source File
SOURCE=.\FeaturePool.hpp
# End Source File
# End Group
# Begin Group "Terrain Texture Logistic"
# PROP Default_Filter ""
# Begin Source File
SOURCE=.\TerrainTextureLogistic.cpp
# End Source File
# Begin Source File
SOURCE=.\TerrainTextureLogistic.hpp
# End Source File
# End Group
# Begin Group "Missed Dependencies"
# PROP Default_Filter ""
# Begin Source File
SOURCE=..\Adept\Adept.hpp
# End Source File
# Begin Source File
SOURCE=..\stuff\AffineMatrix.hpp
# End Source File
# Begin Source File
SOURCE=..\stuff\Angle.hpp
# End Source File
# Begin Source File
SOURCE=..\stuff\ArmorOn.hpp
# End Source File
# Begin Source File
SOURCE=..\stuff\Auto_Container.hpp
# End Source File
# Begin Source File
SOURCE=..\stuff\Auto_Ptr.hpp
# End Source File
# Begin Source File
SOURCE=..\stuff\Average.hpp
# End Source File
# Begin Source File
SOURCE=..\elementrenderer\CameraElement.hpp
# End Source File
# Begin Source File
SOURCE=..\stuff\Chain.hpp
# End Source File
# Begin Source File
SOURCE=..\stuff\Color.hpp
# End Source File
# Begin Source File
SOURCE=..\Adept\Connection.hpp
# End Source File
# Begin Source File
SOURCE=..\stuff\Database.hpp
# End Source File
# Begin Source File
SOURCE=..\gosfx\Effect.hpp
# End Source File
# Begin Source File
SOURCE=..\elementrenderer\Element.hpp
# End Source File
# Begin Source File
SOURCE=..\elementrenderer\ElementRenderer.hpp
# End Source File
# Begin Source File
SOURCE=..\elementrenderer\ElementRendererHeaders.hpp
# End Source File
# Begin Source File
SOURCE=..\Adept\Entity.hpp
# End Source File
# Begin Source File
SOURCE=..\Adept\Event.hpp
# End Source File
# Begin Source File
SOURCE=..\Adept\ExecutionState.hpp
# End Source File
# Begin Source File
SOURCE=..\stuff\ExtentBox.hpp
# End Source File
# Begin Source File
SOURCE=..\gosfx\Fcurve.hpp
# End Source File
# Begin Source File
SOURCE=..\stuff\FileStream.hpp
# End Source File
# Begin Source File
SOURCE=..\stuff\FileStreamManager.hpp
# End Source File
# Begin Source File
SOURCE=..\Adept\GameOS.HPP
# End Source File
# Begin Source File
SOURCE=..\gosfx\gosFX.hpp
# End Source File
# Begin Source File
SOURCE=..\elementrenderer\gosFXElement.hpp
# End Source File
# Begin Source File
SOURCE=..\mlr\GOSImage.hpp
# End Source File
# Begin Source File
SOURCE=..\mlr\GOSImagePool.hpp
# End Source File
# Begin Source File
SOURCE=..\mlr\GOSVertex.hpp
# End Source File
# Begin Source File
SOURCE=..\mlr\GOSVertex2UV.hpp
# End Source File
# Begin Source File
SOURCE=..\mlr\GOSVertexManipulation.hpp
# End Source File
# Begin Source File
SOURCE=..\mlr\GOSVertexPool.hpp
# End Source File
# Begin Source File
SOURCE=..\elementrenderer\GridElement.hpp
# End Source File
# Begin Source File
SOURCE=..\elementrenderer\GroupElement.hpp
# End Source File
# Begin Source File
SOURCE=..\stuff\Hash.hpp
# End Source File
# Begin Source File
SOURCE=..\stuff\Initialized_Ptr.hpp
# End Source File
# Begin Source File
SOURCE=..\stuff\Iterator.hpp
# End Source File
# Begin Source File
SOURCE=..\elementrenderer\LightElement.hpp
# End Source File
# Begin Source File
SOURCE=..\stuff\Line.hpp
# End Source File
# Begin Source File
SOURCE=..\stuff\LinearMatrix.hpp
# End Source File
# Begin Source File
SOURCE=..\elementrenderer\LineCloudElement.hpp
# End Source File
# Begin Source File
SOURCE=..\stuff\Link.hpp
# End Source File
# Begin Source File
SOURCE=..\elementrenderer\ListElement.hpp
# End Source File
# Begin Source File
SOURCE=..\elementrenderer\LODElement.hpp
# End Source File
# Begin Source File
SOURCE=..\stuff\MArray.hpp
# End Source File
# Begin Source File
SOURCE=..\stuff\Matrix.hpp
# End Source File
# Begin Source File
SOURCE=..\stuff\MatrixStack.hpp
# End Source File
# Begin Source File
SOURCE=..\stuff\MemoryBlock.hpp
# End Source File
# Begin Source File
SOURCE=..\stuff\MemoryStream.hpp
# End Source File
# Begin Source File
SOURCE=..\mlr\MLR.hpp
# End Source File
# Begin Source File
SOURCE=..\mlr\MLR_I_C_DeT_PMesh.hpp
# End Source File
# Begin Source File
SOURCE=..\mlr\MLR_I_C_DeT_TMesh.hpp
# End Source File
# Begin Source File
SOURCE=..\mlr\MLR_I_C_DT_PMesh.hpp
# End Source File
# Begin Source File
SOURCE=..\mlr\MLR_I_C_DT_TMesh.hpp
# End Source File
# Begin Source File
SOURCE=..\mlr\MLR_I_C_PMesh.hpp
# End Source File
# Begin Source File
SOURCE=..\mlr\MLR_I_C_TMesh.hpp
# End Source File
# Begin Source File
SOURCE=..\mlr\MLR_I_DeT_PMesh.hpp
# End Source File
# Begin Source File
SOURCE=..\mlr\MLR_I_DeT_TMesh.hpp
# End Source File
# Begin Source File
SOURCE=..\mlr\MLR_I_DT_PMesh.hpp
# End Source File
# Begin Source File
SOURCE=..\mlr\MLR_I_DT_TMesh.hpp
# End Source File
# Begin Source File
SOURCE=..\mlr\MLR_I_L_DeT_PMesh.hpp
# End Source File
# Begin Source File
SOURCE=..\mlr\MLR_I_L_DeT_TMesh.hpp
# End Source File
# Begin Source File
SOURCE=..\mlr\MLR_I_L_DT_PMesh.hpp
# End Source File
# Begin Source File
SOURCE=..\mlr\MLR_I_L_DT_TMesh.hpp
# End Source File
# Begin Source File
SOURCE=..\mlr\MLR_I_L_PMesh.hpp
# End Source File
# Begin Source File
SOURCE=..\mlr\MLR_I_L_TMesh.hpp
# End Source File
# Begin Source File
SOURCE=..\mlr\MLR_I_PMesh.hpp
# End Source File
# Begin Source File
SOURCE=..\mlr\MLR_I_TMesh.hpp
# End Source File
# Begin Source File
SOURCE=..\mlr\MLR_Terrain2.hpp
# End Source File
# Begin Source File
SOURCE=..\mlr\MLR_Water.hpp
# End Source File
# Begin Source File
SOURCE=..\mlr\MLRAmbientLight.hpp
# End Source File
# Begin Source File
SOURCE=..\mlr\MLRCardCloud.hpp
# End Source File
# Begin Source File
SOURCE=..\mlr\MLRCenterPointLight.hpp
# End Source File
# Begin Source File
SOURCE=..\mlr\MLRClipper.hpp
# End Source File
# Begin Source File
SOURCE=..\mlr\MLRClippingState.hpp
# End Source File
# Begin Source File
SOURCE=..\mlr\MLRCulturShape.hpp
# End Source File
# Begin Source File
SOURCE=..\mlr\MLREffect.hpp
# End Source File
# Begin Source File
SOURCE=..\mlr\MLRHeaders.hpp
# End Source File
# Begin Source File
SOURCE=..\mlr\MLRIndexedPrimitiveBase.hpp
# End Source File
# Begin Source File
SOURCE=..\mlr\MLRIndexedTriangleCloud.hpp
# End Source File
# Begin Source File
SOURCE=..\mlr\MLRInfiniteLight.hpp
# End Source File
# Begin Source File
SOURCE=..\mlr\MLRInfiniteLightWithFallOff.hpp
# End Source File
# Begin Source File
SOURCE=..\mlr\MLRLight.hpp
# End Source File
# Begin Source File
SOURCE=..\mlr\MLRLightMap.hpp
# End Source File
# Begin Source File
SOURCE=..\mlr\MLRLineCloud.hpp
# End Source File
# Begin Source File
SOURCE=..\mlr\MLRLookUpLight.hpp
# End Source File
# Begin Source File
SOURCE=..\mlr\MLRNGonCloud.hpp
# End Source File
# Begin Source File
SOURCE=..\mlr\MLRPointCloud.hpp
# End Source File
# Begin Source File
SOURCE=..\mlr\MLRPointLight.hpp
# End Source File
# Begin Source File
SOURCE=..\mlr\MLRPrimitiveBase.hpp
# End Source File
# Begin Source File
SOURCE=..\mlr\MLRProjectLight.hpp
# End Source File
# Begin Source File
SOURCE=..\mlr\MLRShadowLight.hpp
# End Source File
# Begin Source File
SOURCE=..\mlr\MLRShape.hpp
# End Source File
# Begin Source File
SOURCE=..\mlr\MLRSortByOrder.hpp
# End Source File
# Begin Source File
SOURCE=..\mlr\MLRSorter.hpp
# End Source File
# Begin Source File
SOURCE=..\mlr\MLRSpotLight.hpp
# End Source File
# Begin Source File
SOURCE=..\mlr\MLRSpriteCloud.hpp
# End Source File
# Begin Source File
SOURCE=..\mlr\MLRState.hpp
# End Source File
# Begin Source File
SOURCE=..\mlr\MLRTexture.hpp
# End Source File
# Begin Source File
SOURCE=..\mlr\MLRTexturePool.hpp
# End Source File
# Begin Source File
SOURCE=..\mlr\MLRTriangleCloud.hpp
# End Source File
# Begin Source File
SOURCE=..\stuff\Motion.hpp
# End Source File
# Begin Source File
SOURCE=..\stuff\MString.hpp
# End Source File
# Begin Source File
SOURCE=..\elementrenderer\MultiLODElement.hpp
# End Source File
# Begin Source File
SOURCE=..\Adept\NameTable.hpp
# End Source File
# Begin Source File
SOURCE=..\Adept\Network.hpp
# End Source File
# Begin Source File
SOURCE=..\stuff\Node.hpp
# End Source File
# Begin Source File
SOURCE=..\stuff\Noncopyable.hpp
# End Source File
# Begin Source File
SOURCE=..\stuff\Normal.hpp
# End Source File
# Begin Source File
SOURCE=..\stuff\NotationFile.hpp
# End Source File
# Begin Source File
SOURCE=..\stuff\Note.hpp
# End Source File
# Begin Source File
SOURCE=..\stuff\OBB.hpp
# End Source File
# Begin Source File
SOURCE=..\stuff\Origin.hpp
# End Source File
# Begin Source File
SOURCE=..\stuff\Page.hpp
# End Source File
# Begin Source File
SOURCE=..\stuff\Plane.hpp
# End Source File
# Begin Source File
SOURCE=..\stuff\Plug.hpp
# End Source File
# Begin Source File
SOURCE=..\stuff\Point3D.hpp
# End Source File
# Begin Source File
SOURCE=..\elementrenderer\PointCloudElement.hpp
# End Source File
# Begin Source File
SOURCE=..\gosfx\PointLight.hpp
# End Source File
# Begin Source File
SOURCE=..\stuff\Polar.hpp
# End Source File
# Begin Source File
SOURCE=..\stuff\Random.hpp
# End Source File
# Begin Source File
SOURCE=..\Adept\Receiver.hpp
# End Source File
# Begin Source File
SOURCE=..\stuff\RegisteredClass.hpp
# End Source File
# Begin Source File
SOURCE=..\Adept\Replicator.hpp
# End Source File
# Begin Source File
SOURCE=..\Adept\ReplicatorID.hpp
# End Source File
# Begin Source File
SOURCE=..\Adept\Resource.hpp
# End Source File
# Begin Source File
SOURCE=..\stuff\Rotation.hpp
# End Source File
# Begin Source File
SOURCE=..\stuff\SafeChain.hpp
# End Source File
# Begin Source File
SOURCE=..\stuff\SafeSocket.hpp
# End Source File
# Begin Source File
SOURCE=..\elementrenderer\ScalableShapeElement.hpp
# End Source File
# Begin Source File
SOURCE=..\stuff\Scalar.hpp
# End Source File
# Begin Source File
SOURCE=..\elementrenderer\ScreenQuadsElement.hpp
# End Source File
# Begin Source File
SOURCE=..\elementrenderer\ShapeElement.hpp
# End Source File
# Begin Source File
SOURCE=..\elementrenderer\ShapeLODElement.hpp
# End Source File
# Begin Source File
SOURCE=..\stuff\Slot.hpp
# End Source File
# Begin Source File
SOURCE=..\stuff\Socket.hpp
# End Source File
# Begin Source File
SOURCE=..\stuff\SortedChain.hpp
# End Source File
# Begin Source File
SOURCE=..\stuff\SortedSocket.hpp
# End Source File
# Begin Source File
SOURCE=..\stuff\Sphere.hpp
# End Source File
# Begin Source File
SOURCE=..\Adept\State.hpp
# End Source File
# Begin Source File
SOURCE=..\elementrenderer\StateChange.hpp
# End Source File
# Begin Source File
SOURCE=..\stuff\Stuff.hpp
# End Source File
# Begin Source File
SOURCE=..\stuff\Style.hpp
# End Source File
# Begin Source File
SOURCE=..\elementrenderer\SwitchElement.hpp
# End Source File
# Begin Source File
SOURCE=..\stuff\Table.hpp
# End Source File
# Begin Source File
SOURCE=..\Adept\Tile.hpp
# End Source File
# Begin Source File
SOURCE=..\..\..\CoreTech\Libraries\GameOS\ToolOS.hpp
# End Source File
# Begin Source File
SOURCE=..\stuff\Tree.hpp
# End Source File
# Begin Source File
SOURCE=..\elementrenderer\TriangleCloudElement.hpp
# End Source File
# Begin Source File
SOURCE=..\stuff\UnitVector.hpp
# End Source File
# Begin Source File
SOURCE=..\stuff\Vector2D.hpp
# End Source File
# Begin Source File
SOURCE=..\stuff\Vector3D.hpp
# End Source File
# Begin Source File
SOURCE=..\stuff\Vector4D.hpp
# End Source File
# End Group
# Begin Source File
SOURCE=.\Compost.cpp
# End Source File
# Begin Source File
SOURCE=.\Compost.hpp
# End Source File
# Begin Source File
SOURCE=.\CompostHeaders.cpp
!IF "$(CFG)" == "Compost - Win32 Release"
!ELSEIF "$(CFG)" == "Compost - Win32 Profile"
!ELSEIF "$(CFG)" == "Compost - Win32 Armor"
!ELSEIF "$(CFG)" == "Compost - Win32 Debug"
# ADD CPP /Yc"CompostHeaders.hpp"
!ELSEIF "$(CFG)" == "Compost - Win32 icecap"
!ENDIF
# End Source File
# Begin Source File
SOURCE=.\CompostHeaders.hpp
# End Source File
# End Target
# End Project
@@ -0,0 +1,363 @@
#pragma once
#define COMPOSITE_HPP
#if !defined(STUFF_STUFF_HPP)
#include <Stuff\Stuff.hpp>
#endif
namespace Compost
{
enum {
Current_Compost_Version = 6,
Number_Of_Reserved_Textures = 50,
MAX_NUMBER_LAYERS=64,
Length_Of_Compost_Queue = 128,
Length_Of_Compost_Queue_Tracker = 4 // this value is (int)ln(Length_Of_Compost_Queue) + (fmod(ln(Length_Of_Compost_Queue))>0.0) ? 1 : 0
};
struct MaterialEntry
{
Stuff::MString MatName;
int darkEntryIndex;
DWORD color;
};
extern MaterialEntry MaterialEntries[128];
extern int MaterialEntriesCount;
extern int DarkFactor;
inline DWORD
DarkMachine(DWORD color)
{
for(int i=0;i<MaterialEntriesCount;i++)
{
if(MaterialEntries[i].color == color)
{
return MaterialEntries[MaterialEntries[i].darkEntryIndex].color;
}
}
return color;
}
inline int
GetPow(int value)
{
if(value<=0)
{
return -1;
}
int count = (sizeof(value)-1)<<3;
int mask = 1<<count;
while(!(value&mask))
{
count--;
mask>>=1;
}
return count;
}
inline bool
IsPowerOf2(int X)
{
return !( X & ( X - 1 ) );
}
struct Feature_Texture :
public Stuff::Plug
{
Feature_Texture() : Plug (DefaultData) { data = NULL; flags = 0; dataSize = 0; }
enum {
TextureTypeBit = 0,
TextureTypeBits = 3,
TextureTypeMask =
(0xFFFFFFFF >> (Stuff::INT_BITS - TextureTypeBits)) << TextureTypeBit,
StatusBit = TextureTypeBit + TextureTypeBits,
StatusBits = 1,
StatusMask = (0xFFFFFFFF >> (Stuff::INT_BITS - StatusBits)) << StatusBit,
UsedBits = StatusBit + StatusBits,
UsedMask = 0xFFFFFFFF >> (Stuff::INT_BITS - UsedBits)
};
enum TextureMode {
NoMode = 0,
FTT_555 = 1 << TextureTypeBit,
FTT_4444 = 2 << TextureTypeBit,
FTT_1 = 3 << TextureTypeBit,
FTT_1_1 = 4 << TextureTypeBit,
FTT_1_M = 5 << TextureTypeBit
};
enum StatusMode {
NoStatus = 0,
Loaded = 1 << StatusBit
};
void
SetTextureMode(TextureMode mode)
{ flags &= ~TextureTypeMask; flags |= mode; }
TextureMode
GetTextureMode() const
{ return static_cast<TextureMode>(flags & TextureTypeMask); }
void
SetLoadedOn()
{ flags |= Loaded; }
void
SetLoadedOff()
{ flags &= ~Loaded; }
bool
GetLoadedMode() const
{ return (flags & Loaded)!=0;}
void
SetTextureDepth(int d)
{ Verify(d>0&&d<5); depth = d; }
int
RecalculateSize();
int width, height;
int width_mask, height_mask;
int depth;
int flags;
void *handle;
int dataSize;
unsigned char *data;
virtual Stuff::MString* GetName() { return NULL; }
};
struct Tool_Feature_Texture :
public Feature_Texture
{
Stuff::MString name;
virtual Stuff::MString* GetName() { return &name; }
};
extern void FetchTextureData(Feature_Texture*, int index, int);
extern void FetchTextureData(Feature_Texture*, const char *name, int);
extern void DestroyTextureData(Feature_Texture*);
class FeatureGrid;
class FeaturePool;
struct FeatureInstance;
class Feature {
friend class FeatureGrid;
friend class FeaturePool;
friend struct FeatureInstance;
public:
Feature()
{
flags = Paste;
featureTexture = featureMask0 = featureMask1 = NULL;
feature_width = feature_height = 256;
scaleXTexture=scaleXMask0=scaleXMask1=0;
scaleZTexture=scaleZMask0=scaleZMask1=0;
}
virtual ~Feature() {}
enum {
FlipBit = 0,
FlipBits = 6,
FlipMask =
(0xFFFFFFFF >> (Stuff::INT_BITS - FlipBits)) << FlipBit,
BlendBit = FlipBit + FlipBits,
BlendBits = 8,
BlendMask = (0xFFFFFFFF >> (Stuff::INT_BITS - BlendBits)) << BlendBit,
StretchBit = BlendBit + BlendBits,
StretchBits = 1,
StretchMask = (0xFFFFFFFF >> (Stuff::INT_BITS - StretchBits)) << StretchBit,
UsedBits = StretchBit + StretchBits,
UsedMask = 0xFFFFFFFF >> (Stuff::INT_BITS - UsedBits)
};
enum Flip_Mode {
Texture_Horizontal_Flip=1<<FlipBit,
Texture_Vertical_Flip=2<<FlipBit,
Mask0_Horizontal_Flip=4<<FlipBit,
Mask0_Vertical_Flip=8<<FlipBit,
Mask1_Horizontal_Flip=16<<FlipBit,
Mask1_Vertical_Flip=32<<FlipBit
};
enum Blend_Mode {
Paste=1<<BlendBit,
Added=2<<BlendBit,
Multiply=3<<BlendBit,
Blend555_1=4<<BlendBit, // 555 texture blended with one 8-bit mask
Blend555_2=5<<BlendBit, // 555 texture blended with two 8-bit masks
Blend4444=6<<BlendBit, // 4444 texture - alpha channel is mask
StretchMultiply=7<<BlendBit, // texture is stretched across feature and multiplied to destination
Blend555_1_1=8<<BlendBit, // 555 texture blended with one 1-bit mask
StretchPaste=9<<BlendBit, // 555 texture streched across feature and pasted
Blend555_1_S=10<<BlendBit // 555 texture blended with one 8-bit mask of the size of the feature
};
enum Stretch_Mode {
StretchOn=1<<StretchBit // this is tricky :) you can use odd-sized masks in this mode,
}; // scale[XZ]Mask[01] will be calculated in a way that following equation is true
// mask_width * (1<<scale_mask) > feature_width, scale_mask is the smallest
// possible value to make the equation true
virtual Stuff::MString* GetName() { return NULL; }
virtual int GetIndex() { return index; }
void SetFlipMode (Flip_Mode mode) { flags |= mode; }
void ClearFlipMode (Flip_Mode mode) { flags &= ~mode; }
int GetFlipMode ()
{ return (flags & FlipMask); }
void SetBlendMode (Blend_Mode mode) { flags &= ~BlendMask; flags |= mode; }
Blend_Mode GetBlendMode ()
{ return static_cast<Blend_Mode>(flags & BlendMask); }
static const char*
GetBlendModeName(Blend_Mode);
void SetStretchMode(bool b=true) { if(b) flags |= StretchOn; else flags &= ~StretchOn; }
bool
IsStretched() { return (flags & StretchOn)!=0; }
int IsValidFeature();
void SetFeatureTexture(Feature_Texture *texture) { featureTexture=texture; }
void SetFeatureMask0(Feature_Texture *texture)
{
featureMask0 = texture;
if(featureMask0)
{
SetXMask0Scale(GetPow(feature_width/featureMask0->width) + (IsPowerOf2(feature_width/featureMask0->width) ? 0 : 1));
SetZMask0Scale(GetPow(feature_height/featureMask0->height) + (IsPowerOf2(feature_height/featureMask0->height) ? 0 : 1));
}
}
void SetFeatureMask1(Feature_Texture *texture)
{
featureMask1 = texture;
if(featureMask1)
{
SetXMask1Scale(GetPow(feature_width/featureMask1->width) + (IsPowerOf2(feature_width/featureMask1->width) ? 0 : 1));
SetZMask1Scale(GetPow(feature_height/featureMask1->height) + (IsPowerOf2(feature_height/featureMask1->height) ? 0 : 1));
}
}
Feature_Texture *GetFeatureTexture() { return featureTexture;}
Feature_Texture *GetFeatureMask0() { return featureMask0;}
Feature_Texture *GetFeatureMask1() { return featureMask1;}
int GetFeatureWidth() { return feature_width; }
int GetFeatureHeight() { return feature_height; }
void SetFeatureWidth( unsigned short x) {feature_width=x;}
void SetFeatureHeight( unsigned short z) {feature_height=z;}
int GetXTextureScale () { return scaleXTexture; }
int GetZTextureScale () { return scaleZTexture; }
void SetXTextureScale(int s) { scaleXTexture = s; }
void SetZTextureScale(int s) { scaleZTexture = s; }
void SetXMask0Scale(int s) { scaleXMask0 = s; }
void SetZMask0Scale(int s) { scaleZMask0 = s; }
int GetXMask0Scale () { return scaleXMask0; }
int GetZMask0Scale () { return scaleZMask0; }
void SetXMask1Scale(int s) { scaleXMask1 = s; }
void SetZMask1Scale(int s) { scaleZMask1 = s; }
int GetXMask1Scale () { return scaleXMask1; }
int GetZMask1Scale () { return scaleZMask1; }
void ReCalculateScale()
{
if(featureMask0)
{
SetXMask0Scale(GetPow(feature_width/featureMask0->width) + (IsPowerOf2(feature_width/featureMask0->width) ? 0 : 1));
SetZMask0Scale(GetPow(feature_height/featureMask0->height) + (IsPowerOf2(feature_height/featureMask0->height) ? 0 : 1));
}
if(featureMask1)
{
SetXMask1Scale(GetPow(feature_width/featureMask1->width) + (IsPowerOf2(feature_width/featureMask1->width) ? 0 : 1));
SetZMask1Scale(GetPow(feature_height/featureMask1->height) + (IsPowerOf2(feature_height/featureMask1->height) ? 0 : 1));
}
}
protected:
// position of texture with feature in pixel
int feature_width, feature_height;
// scale of texture in x and z, we just store the power of 2
int scaleXTexture, scaleZTexture;
// scale of mask0 in x and z, we just store the power of 2
int scaleXMask0, scaleZMask0;
// scale of mask1 in x and z, we just store the power of 2
int scaleXMask1, scaleZMask1;
Feature_Texture *featureTexture;
Feature_Texture *featureMask0;
Feature_Texture *featureMask1;
int flags;
int index;
};
class Tool_Feature :
public Feature
{
friend class FeatureGrid;
friend class FeaturePool;
friend struct FeatureInstance;
protected:
Stuff::MString name;
Feature_Texture *HFTexture;
DWORD material;
public:
int HFBLendMode,BlendVal;
unsigned char StatFlags;
Tool_Feature() : Feature () {HFTexture=NULL; StatFlags=0; HFBLendMode=0; BlendVal=128; material=0;}
virtual ~Tool_Feature() {}
void SetHFTexture(Feature_Texture *texture) { HFTexture=texture; }
Feature_Texture *GetHFTexture() { return HFTexture;}
virtual Stuff::MString* GetName() { return &name; }
void SetName(const char* _name) { name = _name; index = name.GetHashValue(); }
void SetMaterial(int mat) { material = mat; }
int GetMaterial () { return material; }
virtual int GetIndex() { return name.GetHashValue(); }
};
void InitializeClasses(Stuff::NotationFile *startup_ini = NULL);
void TerminateClasses(Stuff::NotationFile *startup_ini=NULL);
extern HGOSHEAP Heap;
extern DWORD Number_Of_Worked_On_Textures;
DECLARE_TIMER(extern, Composting_Time);
extern DWORD Number_Of_Used_128_Textures;
extern DWORD Number_Of_Used_256_Textures;
#define BOUNDARY_TEST
}
@@ -0,0 +1,3 @@
#include "CompostHeaders.hpp"
// This file does nothing but make the pch file
@@ -0,0 +1,13 @@
#define COMPOST_COMPOSTHEADERS_HPP
#if !defined(COMPOST_COMPOST_HPP)
#include <Compost\Compost.hpp>
#endif
using namespace Stuff;
using namespace Compost;
#include "TexturePool.hpp"
#include "FeaturePool.hpp"
#include "FeatureGrid.hpp"
#include "TerrainTextureLogistic.hpp"
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,353 @@
#pragma once
#include "Compost.hpp"
#include "FeaturePool.hpp"
namespace Compost
{
struct FeatureInstance {
unsigned char StatFlags,Tag;
FeatureInstance() {
feature = NULL; feature_x_pos = feature_z_pos = 0;
texture_x_pos = texture_z_pos = 0;
currentTexturePtr = NULL; currentMask0Ptr = NULL; currentMask1Ptr = NULL;
StatFlags=0;
Tag=0;
}
void
LoadInstance(
Stuff::MemoryStream *stream,
FeaturePool*,
int version
);
void
SaveInstance(
Stuff::MemoryStream *stream, int xoffset=0, int zoffset=0
);
void
LoadInstance(
Stuff::Page *inst_page,
FeaturePool*,
int version
);
void
SaveInstance(
Stuff::Page *inst_page,int xoffset=0,int zoffset=0
);
bool
CalculateCurrentPtr(int, int, int=0);
int GetTextureXPos() {return texture_x_pos;}
int GetTextureZPos() {return texture_z_pos;}
void SetTextureXPos( unsigned short x) {texture_x_pos=x;}
void SetTextureZPos( unsigned short z) {texture_z_pos=z;}
// void
// AdvanceCurrentPtr();
Feature *feature;
FeatureInstance&
operator=(FeatureInstance&);
// position in pixel %256(&0xff) = position in tile, /256(>>8) tile
int feature_x_pos, feature_z_pos;
int texture_x_pos, texture_z_pos;
int position;
unsigned char *currentTexturePtr;
int countDownToBorder;
unsigned char *currentMask0Ptr;
int mask0_x_off, mask0_z_off;
unsigned char *currentMask1Ptr;
int mask1_x_off, mask1_z_off;
};
struct EdgeListPlug {
EdgeListPlug();
~EdgeListPlug();
bool
AddUp(FeatureInstance*, int row, int column, int gridSize=256);
int x_pos_start;
int x_pos_end;
int z_pos;
int count;
FeatureInstance *featureInstance;
bool key;
EdgeListPlug *next;
EdgeListPlug *prev;
};
struct ActiveEdgeListPlug {
ActiveEdgeListPlug () { elp = NULL; counter = 0; next = NULL; prev = NULL; }
EdgeListPlug *elp;
int counter;
ActiveEdgeListPlug *next;
ActiveEdgeListPlug *prev;
};
struct TextureHolder
{
TextureHolder() {
handle = -1; textureHandle = -1; priority = NULL; flags = Free; lastLine = -1;
elp = NULL; nextLineElp = NULL;
aelp = NULL; aelp_ptr = NULL; taelp = NULL;
pix_dest = NULL;
#ifdef LAB_ONLY
borderKey = false; borderColor = 0;
#endif
#ifdef _ARMOR
queuePosition = -1;
#endif
#ifdef _DEBUG
row = -1;
column = -1;
#endif
}
bool
ShutDown();
int handle;
int textureHandle;
BYTE *priority;
enum TextureHolderState {
Free = 0,
InWork = 1,
Done = 2
};
int flags;
int lastLine;
int linesToProcess;
EdgeListPlug *elp;
EdgeListPlug *nextLineElp;
ActiveEdgeListPlug *aelp;
ActiveEdgeListPlug *aelp_ptr;
ActiveEdgeListPlug *taelp;
unsigned char *pix_dest;
int pitch;
#ifdef _ARMOR
int queuePosition;
#endif
#ifdef LAB_ONLY
DWORD borderColor;
bool borderKey;
#endif
#ifdef _DEBUG
int row, column;
#endif
};
class TerrainTextureLogistic;
class FeatureGrid
{
friend class TerrainTextureLogistic;
public:
FeatureGrid(int, int, FeaturePool*, bool=false);
FeatureGrid(Stuff::MemoryStream *stream, FeaturePool*);
FeatureGrid(Stuff::NotationFile *note_file, FeaturePool*);
~FeatureGrid();
void
LoadGrid(
Stuff::MemoryStream *stream
);
void
SaveGrid(
Stuff::MemoryStream *stream,int xoffset=0,int zoffset=0
);
void
LoadGrid(
Stuff::NotationFile *stream
);
void
SaveGrid(
Stuff::NotationFile *stream,int xoffset=0,int zoffset=0
);
FeatureInstance *
Add(Feature*, unsigned short x_pos, unsigned short z_pos);
void
Remove(FeatureInstance*);
void
RedoFeaturePosition();
bool
ComposeGrid(int row, int column, unsigned char *dest, int downSample=0, int type=0);
bool
ComposeGrid(int row, int column, TextureHolder*, int downSample=0, int type=0);
int
GetRows()
{ return rows; }
int
GetColumns()
{ return columns; }
Stuff::DynamicArrayOf<FeatureInstance*>*
GetGridElement(int row, int column)
{ return &featureInstance[row*columns+column]; }
int
ShootRay(unsigned short x, unsigned short z);
int
ShootRectangle(
Stuff::DynamicArrayOf<FeatureInstance*>& list,
unsigned short x,
unsigned short z,
unsigned short width,
unsigned short height
);
static unsigned char depthColors[16][3];
void
LoadGridFromUnique();
void
LoadGridFromUnique(int row, int column);
void
LoadEdgeListFromGrid();
FeatureInstance*
GetCollectedNr(int nr)
{ return rayCollect[nr]; }
int
CountFeature(FeatureInstance *fI) { return CountFeature(fI->feature); }
int
CountFeature(Feature*);
const Stuff::DynamicArrayOf<FeatureInstance*> *
GetUniqueFeatureInstances(int& count)
{ count = used; return &uniqueFeatureInstance; }
int
GetGridSize() {return gridSize;}
int
GetGridShift() {return gridSizeShift;}
protected:
int
gridSize, gridSizeShift;
inline void
AddToRayCollect(FeatureInstance*, unsigned short&);
inline void
DeleteFromRayCollect(FeatureInstance*, unsigned short&);
inline void
AddToActiveEdgeList(ActiveEdgeListPlug**, EdgeListPlug*);
static void Blend555_1(FeatureInstance*, unsigned char*, int, int, int=0);
static void Blend555_1_TH(FeatureInstance*, unsigned char*, int, int, int=0);
static void Blend555_1_M0H(FeatureInstance*, unsigned char*, int, int, int=0);
static void Blend555_1_TH_M0H(FeatureInstance*, unsigned char*, int, int, int=0);
static void Blend555_2(FeatureInstance*, unsigned char*, int, int, int=0);
static void Blend555_2_TH(FeatureInstance*, unsigned char*, int, int, int=0);
static void Blend555_2_M0H(FeatureInstance*, unsigned char*, int, int, int=0);
static void Blend555_2_TH_M0H(FeatureInstance*, unsigned char*, int, int, int=0);
static void Blend555_2_M1H(FeatureInstance*, unsigned char*, int, int, int=0);
static void Blend555_2_TH_M1H(FeatureInstance*, unsigned char*, int, int, int=0);
static void Blend555_2_M0H_M1H(FeatureInstance*, unsigned char*, int, int, int=0);
static void Blend555_2_TH_M0H_M1H(FeatureInstance*, unsigned char*, int, int, int=0);
static void BlendSM(FeatureInstance*, unsigned char*, int, int, int=0);
static void BlendSM_M0H(FeatureInstance*, unsigned char*, int, int, int=0);
static void Blend4444(FeatureInstance*, unsigned char*, int, int, int=0);
static void Blend4444_TH(FeatureInstance*, unsigned char*, int, int, int=0);
static void Blend555_1_1(FeatureInstance*, unsigned char*, int, int, int, int, int=0);
static void Blend555_1_1_TH(FeatureInstance*, unsigned char*, int, int, int, int, int=0);
static void Blend555_1_1_M0H(FeatureInstance*, unsigned char*, int, int, int, int, int=0);
static void Blend555_1_1_TH_M0H(FeatureInstance*, unsigned char*, int, int, int, int, int=0);
static void Blend555_1_S(FeatureInstance*, unsigned char*, int, int, int=0);
static void Blend555_1_S_TH(FeatureInstance*, unsigned char*, int, int, int=0);
static void Blend555_1_S_M0H(FeatureInstance*, unsigned char*, int, int, int=0);
static void Blend555_1_S_TH_M0H(FeatureInstance*, unsigned char*, int, int, int=0);
static void BlendSS(FeatureInstance*, unsigned char*, int, int, int=0);
//============================================================================================================
static void Blend555_1_MAT(FeatureInstance*, unsigned char*, int, int, int=0);
static void Blend555_1_TH_MAT(FeatureInstance*, unsigned char*, int, int, int=0);
static void Blend555_1_M0H_MAT(FeatureInstance*, unsigned char*, int, int, int=0);
static void Blend555_1_TH_M0H_MAT(FeatureInstance*, unsigned char*, int, int, int=0);
static void Blend555_2_MAT(FeatureInstance*, unsigned char*, int, int, int=0);
static void Blend555_2_TH_MAT(FeatureInstance*, unsigned char*, int, int, int=0);
static void Blend555_2_M0H_MAT(FeatureInstance*, unsigned char*, int, int, int=0);
static void Blend555_2_TH_M0H_MAT(FeatureInstance*, unsigned char*, int, int, int=0);
static void Blend555_2_M1H_MAT(FeatureInstance*, unsigned char*, int, int, int=0);
static void Blend555_2_TH_M1H_MAT(FeatureInstance*, unsigned char*, int, int, int=0);
static void Blend555_2_M0H_M1H_MAT(FeatureInstance*, unsigned char*, int, int, int=0);
static void Blend555_2_TH_M0H_M1H_MAT(FeatureInstance*, unsigned char*, int, int, int=0);
static void BlendSM_MAT(FeatureInstance*, unsigned char*, int, int, int=0);
static void BlendSM_M0H_MAT(FeatureInstance*, unsigned char*, int, int, int=0);
static void Blend4444_MAT(FeatureInstance*, unsigned char*, int, int, int=0);
static void Blend4444_TH_MAT(FeatureInstance*, unsigned char*, int, int, int=0);
static void Blend555_1_1_MAT(FeatureInstance*, unsigned char*, int, int, int, int, int=0);
static void Blend555_1_1_TH_MAT(FeatureInstance*, unsigned char*, int, int, int, int, int=0);
static void Blend555_1_1_M0H_MAT(FeatureInstance*, unsigned char*, int, int, int, int, int=0);
static void Blend555_1_1_TH_M0H_MAT(FeatureInstance*, unsigned char*, int, int, int, int, int=0);
static void Blend555_1_S_MAT(FeatureInstance*, unsigned char*, int, int, int=0);
static void Blend555_1_S_TH_MAT(FeatureInstance*, unsigned char*, int, int, int=0);
static void Blend555_1_S_M0H_MAT(FeatureInstance*, unsigned char*, int, int, int=0);
static void Blend555_1_S_TH_M0H_MAT(FeatureInstance*, unsigned char*, int, int, int=0);
static void BlendSS_MAT(FeatureInstance*, unsigned char*, int, int, int=0);
//============================================================================================================
int rows, columns;
FeaturePool* featurePool;
FeatureInstance* rayCollect[MAX_NUMBER_LAYERS];
int max, used;
Stuff::DynamicArrayOf<FeatureInstance*> uniqueFeatureInstance;
Stuff::DynamicArrayOf<FeatureInstance*> *featureInstance;
Stuff::DynamicArrayOf<EdgeListPlug*> edgeList;
};
}
@@ -0,0 +1,990 @@
#include "CompostHeaders.hpp"
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
int
Feature::IsValidFeature()
{
switch(GetBlendMode())
{
case Paste:
if(featureTexture==NULL)
{
return 1;
}
if(featureTexture->GetTextureMode()!=Feature_Texture::TextureMode::FTT_555)
{
return 4;
}
break;
case Added:
if(featureTexture==NULL)
{
return 1;
}
if(featureTexture->GetTextureMode()!=Feature_Texture::TextureMode::FTT_555)
{
return 4;
}
break;
case Multiply:
if(featureTexture==NULL)
{
return 1;
}
if(featureTexture->GetTextureMode()!=Feature_Texture::TextureMode::FTT_555)
{
return 4;
}
break;
case Blend555_1:
if(featureTexture==NULL)
{
return 1;
}
if(featureTexture->GetTextureMode()!=Feature_Texture::TextureMode::FTT_555)
{
return 4;
}
if(featureMask0==NULL)
{
return 2;
}
if(featureMask0->GetTextureMode()!=Feature_Texture::TextureMode::FTT_1)
{
return 6;
}
if(featureMask0->width == feature_width || featureMask0->height == feature_height)
{
return 11;
}
if(!IsPowerOf2(featureTexture->width) || !IsPowerOf2(featureTexture->height) )
{
return 14;
}
if( !IsStretched() && (!IsPowerOf2(featureMask0->width) || !IsPowerOf2(featureMask0->height)) )
{
return 15;
}
break;
case Blend555_2:
if(featureTexture==NULL)
{
return 1;
}
if(featureTexture->GetTextureMode()!=Feature_Texture::TextureMode::FTT_555)
{
return 4;
}
if(featureMask0==NULL)
{
return 2;
}
if(featureMask0->GetTextureMode()!=Feature_Texture::TextureMode::FTT_1)
{
return 6;
}
if(featureMask0->width == feature_width || featureMask0->height == feature_height)
{
return 11;
}
if(featureMask1==NULL)
{
return 3;
}
if(featureMask1->GetTextureMode()!=Feature_Texture::TextureMode::FTT_1)
{
return 7;
}
if(featureMask1->width == feature_width || featureMask1->height == feature_height)
{
return 12;
}
if(!IsPowerOf2(featureTexture->width) || !IsPowerOf2(featureTexture->height) )
{
return 14;
}
if( !IsStretched() && (!IsPowerOf2(featureMask0->width) || !IsPowerOf2(featureMask0->height)) )
{
return 15;
}
if( !IsStretched() && (!IsPowerOf2(featureMask1->width) || !IsPowerOf2(featureMask1->height)) )
{
return 16;
}
break;
case Blend4444:
if(featureTexture==NULL)
{
return 1;
}
if(featureTexture->GetTextureMode()!=Feature_Texture::TextureMode::FTT_4444)
{
return 5;
}
if(!IsPowerOf2(featureTexture->width) || !IsPowerOf2(featureTexture->height) )
{
return 14;
}
break;
case StretchMultiply:
if(featureMask0==NULL)
{
return 2;
}
if(featureMask0->GetTextureMode()!=Feature_Texture::TextureMode::FTT_555)
{
return 8;
}
if( !IsStretched() && (!IsPowerOf2(featureMask0->width) || !IsPowerOf2(featureMask0->height)) )
{
return 15;
}
break;
case Blend555_1_1:
if(featureTexture==NULL)
{
return 1;
}
if(featureTexture->GetTextureMode()!=Feature_Texture::TextureMode::FTT_555)
{
return 4;
}
if(featureMask0==NULL)
{
return 2;
}
if(featureMask0->GetTextureMode()!=Feature_Texture::TextureMode::FTT_1_1)
{
return 9;
}
if(!IsPowerOf2(featureTexture->width) || !IsPowerOf2(featureTexture->height) )
{
return 14;
}
if( !IsStretched() && (!IsPowerOf2(featureMask0->width) || !IsPowerOf2(featureMask0->height)) )
{
return 15;
}
break;
case Blend555_1_S:
if(featureTexture==NULL)
{
return 1;
}
if(featureTexture->GetTextureMode()!=Feature_Texture::TextureMode::FTT_555)
{
return 4;
}
if(featureMask0==NULL)
{
return 2;
}
if(featureMask0->GetTextureMode()!=Feature_Texture::TextureMode::FTT_1_M)
{
return 10;
}
if(!IsPowerOf2(featureTexture->width) || !IsPowerOf2(featureTexture->height) )
{
return 14;
}
if( !IsStretched() && (!IsPowerOf2(featureMask0->width) || !IsPowerOf2(featureMask0->height)) )
{
return 15;
}
break;
}
return 0;
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
FeaturePool::FeaturePool()
{
Verify(gos_GetCurrentHeap() == Heap);
used = 0;
max = 100;
features.SetLength(max);
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
FeaturePool::FeaturePool(
Stuff::MemoryStream *stream
)
{
LoadIndex(stream);
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
FeaturePool::~FeaturePool()
{
for(int i=0;i<used;i++)
{
Unregister_Pointer(features[i]);
delete features[i];
}
features.SetLength(0);
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
void
FeaturePool::LoadIndex(
Stuff::MemoryStream *stream
)
{
Verify(gos_GetCurrentHeap() == Heap);
int version;
*stream >> version;
if(version<6)
{
STOP(("The current fgd-file is a version lower than 6. Not supported anymore ! Content error !"));
}
*stream >> used;
max = 100*(1 + (used/100));
features.SetLength(max);
for(int i=0;i<used;i++)
{
features[i] = LoadFeature(stream, version);
}
}
void
FeaturePool::LoadIndex(
Stuff::NotationFile *note_file
)
{
Check_Object(note_file);
Page *page=note_file->GetPage("FeaturePool");
int version;
page->GetEntry("Version",&version);
NotationFile fet_note;
page->GetEntry("Features",&fet_note);
used=0;
NotationFile::PageIterator *page_list=fet_note.MakePageIterator();
Check_Object(page_list);
Page *fet_page;
while((fet_page = page_list->ReadAndNext()) != NULL)
{
Check_Object(fet_page);
used++;
}
max = 100*(1 + (used/100));
features.SetLength(max);
page_list->First();
int i=0;
while((fet_page = page_list->ReadAndNext()) != NULL)
{
Check_Object(fet_page);
features[i++] = LoadFeature(fet_page, version);
}
Verify(i==used);
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
void
FeaturePool::SaveIndex(
Stuff::MemoryStream *stream
)
{
*stream << static_cast<int>(Current_Compost_Version);
*stream << used;
MString *name = NULL;
for(int i=0;i<used;i++)
{
name = features[i]->GetName();
if(name==NULL)
{
*stream << 0;
SaveFeature(stream, features[i]);
}
else
{
*stream << 1;
*stream << *name;
SaveFeature(stream, features[i]);
}
}
}
void
FeaturePool::SaveIndex(
Stuff::NotationFile *note_file
)
{
Check_Object(note_file);
Page *page=note_file->SetPage("FeaturePool");
page->SetEntry("Version",Current_Compost_Version);
page->SetEntry("FeatureCount",used);
NotationFile fet_note;
for(int i=0;i<used;i++)
{
Verify(features[i]->GetName()!=NULL);
SaveFeature(&fet_note, features[i]);
}
page->SetEntry("Features",&fet_note);
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
void
FeaturePool::Add(Feature *f)
{
Verify(gos_GetCurrentHeap() == Heap);
if(GetFeature(f->index))
{
return;
}
if(used<max)
{
features[used++] = f;
}
else
{
max += 100;
features.SetLength(max);
features[used++] = f;
}
Verify(f->featureTexture);
TexturePool::Instance->Load(f->featureTexture);
TexturePool::Instance->Load(f->featureMask0);
TexturePool::Instance->Load(f->featureMask1);
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
void
FeaturePool::Insert(Feature *f, int at)
{
Verify(gos_GetCurrentHeap() == Heap);
Verify(at<=used);
if(at==used)
{
Add(f);
}
else
{
used++;
if(used>=max)
{
max += 100;
features.SetLength(max);
}
int i;
for(i=used;i>at;i--)
{
features[i] = features[i-1];
}
features[at] = f;
}
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
void
FeaturePool::Move(int from, int to)
{
Feature *f = features[from];
Remove(from);
if(to<used-1)
{
Insert(f, to);
}
else
{
Add(f);
}
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
void
FeaturePool::Remove(int from)
{
Verify(from>=0);
Verify(from<used);
int i;
for(i=from;i<used-1;i++)
{
features[i] = features[i+1];
}
used--;
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
void
FeaturePool::Remove(Feature *f)
{
Remove(Find(f));
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
int
FeaturePool::Find(Feature *f)
{
int i;
for(i=0;i<features.GetLength();i++)
{
if( features[i]==f) return i;
}
return -1;
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
Feature*
FeaturePool::GetFeature(int idx)
{
Feature *feature=NULL;
for(int i=0;i<used;i++)
{
if(idx==features[i]->GetIndex())
{
feature = features[i];
return feature;
}
}
return NULL;
}
Feature*
FeaturePool::GetFeature(const char *feature_name)
{
MString *name;
for(int i=0;i<used;i++)
{
name=features[i]->GetName();
Verify(name!=NULL);
if(*name==feature_name)
return features[i];
}
return NULL;
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
int
FeaturePool::GetFeaturePosition(Feature* feature)
{
for(int i=0;i<used;i++)
{
if(feature==features[i])
{
return i;
}
}
return -1;
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
Feature*
FeaturePool::IsUsed(Feature_Texture *ft)
{
Feature *feature=NULL;
for(int i=0;i<used;i++)
{
if(
ft==features[i]->GetFeatureTexture() ||
ft==features[i]->GetFeatureMask0() ||
ft==features[i]->GetFeatureMask1()
)
{
feature = features[i];
return feature;
}
}
return NULL;
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/*
int
FeaturePool::ShootRay(unsigned short x, unsigned short z)
{
int i;
int hit=0;
for(i=0;i<used;i++)
{
if( features[i]->feature_x_pos<=x && features[i]->feature_x_pos+features[i]->feature_width>=x &&
features[i]->feature_z_pos<=z && features[i]->feature_z_pos+features[i]->feature_height>=z
)
{
Verify(hit<MAX_NUMBER_LAYERS);
rayCollect[hit++] = features[i];
}
}
return hit;
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
int
FeaturePool::ShootRectangle(
unsigned short x,
unsigned short z,
unsigned short width,
unsigned short height
)
{
int i;
int hit=0;
rectangleCollect.SetLength(MAX_NUMBER_LAYERS);
for(i=0;i<used;i++)
{
if( features[i]->feature_x_pos > x+width)
{
continue;
}
if( features[i]->feature_z_pos > z+height)
{
continue;
}
if( features[i]->feature_x_pos+features[i]->feature_width < x)
{
continue;
}
if( features[i]->feature_z_pos+features[i]->feature_height < z)
{
continue;
}
if(hit>=rectangleCollect.GetLength())
{
rectangleCollect.SetLength(MAX_NUMBER_LAYERS+rectangleCollect.GetLength());
}
rectangleCollect[hit++] = features[i];
}
rectangleCollect.SetLength(hit);
return hit;
}
*/
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
void
FeaturePool::SaveFeature(
Stuff::MemoryStream *stream,
Feature* feature
)
{
*stream << feature->feature_width << feature->feature_height;
*stream << feature->scaleXTexture << feature->scaleZTexture;
*stream << feature->scaleXMask0 << feature->scaleZMask0;
*stream << feature->scaleXMask1 << feature->scaleZMask1;
if(feature->GetName()==NULL)
{
*stream << TexturePool::Instance->GetIndex(feature->featureTexture);
*stream << TexturePool::Instance->GetIndex(feature->featureMask0);
*stream << TexturePool::Instance->GetIndex(feature->featureMask1);
}
else
{
MString noName("");
MString *name = feature->featureTexture->GetName();
Verify(name!=NULL);
*stream << *name;
if(feature->featureMask0 && (name=feature->featureMask0->GetName())!=NULL)
{
*stream << *name;
}
else
{
*stream << noName;
}
if(feature->featureMask1 && (name=feature->featureMask1->GetName())!=NULL)
{
*stream << *name;
}
else
{
*stream << noName;
}
Tool_Feature *tool_fet = (Tool_Feature *)feature;
if(tool_fet->HFTexture && (name=tool_fet->HFTexture->GetName())!=NULL)
{
*stream << *name;
}
else
{
*stream << noName;
}
*stream << tool_fet->material;
}
*stream << feature->flags << feature->index;
}
void
FeaturePool::SaveFeature(
Stuff::NotationFile *note_file,
Feature* feature
)
{
Verify(feature->GetName()!=NULL);
Tool_Feature *tool_fet=(Tool_Feature *)feature;
Stuff::Page *page=note_file->SetPage(*(feature->GetName()));
Check_Object(page);
page->SetEntry("FeatureWidth",feature->feature_width);
page->SetEntry("FeatureHeight",feature->feature_height);
page->SetEntry("ScaleXTexture",feature->scaleXTexture);
page->SetEntry("ScaleZTexture",feature->scaleZTexture);
page->SetEntry("ScaleXMask0",feature->scaleXMask0);
page->SetEntry("ScaleZMask0",feature->scaleZMask0);
page->SetEntry("ScaleXMask1",feature->scaleXMask1);
page->SetEntry("ScaleZMask1",feature->scaleZMask1);
page->SetEntry("Material",MaterialEntries[tool_fet->material].MatName);
page->SetEntry("Flags",feature->flags);
if(tool_fet->HFTexture) page->SetEntry("HFTexture",*(tool_fet->HFTexture->GetName()));
if(tool_fet->featureTexture) page->SetEntry("FeatureTexture",*(feature->featureTexture->GetName()));
if(tool_fet->featureMask0) page->SetEntry("FeatureMask0",*(feature->featureMask0->GetName()));
if(tool_fet->featureMask1) page->SetEntry("FeatureMask1",*(feature->featureMask1->GetName()));
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
Feature*
FeaturePool::LoadFeature(
Stuff::MemoryStream *stream,
int version
)
{
Verify(gos_GetCurrentHeap() == Heap);
int type;
Feature *feature = NULL;
*stream >> type;
switch(type)
{
case 0:
{
feature = new Feature();
}
break;
case 1:
{
feature = new Tool_Feature();
MString name;
*stream >> name;
name.ToLower();
(static_cast<Tool_Feature*>(feature))->SetName(name);
}
break;
}
if(feature==NULL)
{
return feature;
}
*stream >> feature->feature_width >> feature->feature_height;
if(version<3)
{
int temp;
*stream >> temp;
*stream >> temp;
}
/*
// HACK
feature->texture_x_pos &= ~1;
feature->texture_z_pos &= ~1;
// HACK
*/
*stream >> feature->scaleXTexture >> feature->scaleZTexture;
*stream >> feature->scaleXMask0 >> feature->scaleZMask0;
*stream >> feature->scaleXMask1 >> feature->scaleZMask1;
feature->ReCalculateScale();
if(version < 5)
{
int index;
*stream >> index;
feature->featureTexture = TexturePool::Instance->Get(index);
if(type==1)
{
if(feature->featureTexture==NULL)
{
Tool_Feature *tool_fet=Cast_Pointer(Tool_Feature *, feature);
STOP(("Featuretexture from feature \"%s\" is missing in Compost Texture Pool.", (const char *)(*tool_fet->GetName()) ));
}
}
*stream >> index;
feature->featureMask0 = TexturePool::Instance->Get(index);
*stream >> index;
feature->featureMask1 = TexturePool::Instance->Get(index);
if(version>1 && type==1)
{
Tool_Feature *tool_fet=(Tool_Feature *)feature;
*stream >> index;
tool_fet->HFTexture = TexturePool::Instance->Get(index);
if(version>3)
{
*stream >> tool_fet->material;
}
else
{
tool_fet->material = 0;
}
}
}
else
{
if(type==0)
{
int index;
*stream >> index;
feature->featureTexture = TexturePool::Instance->Get(index);
*stream >> index;
feature->featureMask0 = TexturePool::Instance->Get(index);
*stream >> index;
feature->featureMask1 = TexturePool::Instance->Get(index);
}
else
{
MString name, name0, name1, tool_name;
*stream >> name;
Verify(!name==false);
name.ToLower();
feature->featureTexture = TexturePool::Instance->Get(name.GetHashValue());
*stream >> name0;
if(!name0==false)
{
name0.ToLower();
feature->featureMask0 = TexturePool::Instance->Get(name0.GetHashValue());
}
else
{
feature->featureMask0 = NULL;
}
*stream >> name1;
if(!name1==false)
{
name1.ToLower();
feature->featureMask1 = TexturePool::Instance->Get(name1.GetHashValue());
}
else
{
feature->featureMask1 = NULL;
}
if(version>1)
{
Tool_Feature *tool_fet=(Tool_Feature *)feature;
*stream >> tool_name;
if(!tool_name==false)
{
tool_name.ToLower();
tool_fet->HFTexture = TexturePool::Instance->Get(tool_name.GetHashValue());
}
else
{
tool_fet->HFTexture = NULL;
}
if(version>3)
{
*stream >> tool_fet->material;
}
else
{
tool_fet->material = 0;
}
}
}
}
*stream >> feature->flags >> feature->index;
if(feature->GetBlendMode()==Feature::Blend555_1)
{
Verify(feature->featureMask0!=NULL);
if(!(feature->feature_width>feature->featureMask0->width) || !(feature->feature_height>feature->featureMask0->height) )
{
if(feature->featureMask0->GetTextureMode() == Feature_Texture::FTT_1)
{
SPEW(("micgaert", "Houston we have a problem in %s.", (type==1) ? (const char *)(*(static_cast<Tool_Feature*>(feature))->GetName()):"Unnamed feature"));
DestroyTextureData(feature->featureMask0);
feature->featureMask0->SetTextureMode(Feature_Texture::FTT_1_M);
feature->featureMask0->SetLoadedOff();
TexturePool::Instance->Load(feature->featureMask0);
TexturePool::Instance->IsChanged(true);
}
feature->SetBlendMode(Feature::Blend555_1_S);
}
}
if(feature->GetBlendMode()==Feature::Blend555_1_S && feature->featureMask0->GetTextureMode() != Feature_Texture::FTT_1_M)
{
DestroyTextureData(feature->featureMask0);
feature->featureMask0->SetTextureMode(Feature_Texture::FTT_1_M);
feature->featureMask0->SetLoadedOff();
TexturePool::Instance->Load(feature->featureMask0);
TexturePool::Instance->IsChanged(true);
SPEW(("micgaert", "Houston we have another problem in %s.", (type==1) ? (const char *)(*(static_cast<Tool_Feature*>(feature))->GetName()):"Unnamed feature"));
}
Register_Pointer(feature);
return feature;
}
Feature*
FeaturePool::LoadFeature(
Stuff::Page *fet_page,
int version
)
{
Verify(gos_GetCurrentHeap() == Heap);
Tool_Feature *feature = new Tool_Feature();
feature->SetName(fet_page->GetName());
fet_page->GetEntry("FeatureWidth",&(feature->feature_width));
fet_page->GetEntry("FeatureHeight",&(feature->feature_height));
fet_page->GetEntry("ScaleXTexture",&(feature->scaleXTexture));
fet_page->GetEntry("ScaleZTexture",&(feature->scaleZTexture));
fet_page->GetEntry("ScaleXMask0",&(feature->scaleXMask0));
fet_page->GetEntry("ScaleZMask0",&(feature->scaleZMask0));
fet_page->GetEntry("ScaleXMask1",&(feature->scaleXMask1));
fet_page->GetEntry("ScaleZMask1",&(feature->scaleZMask1));
fet_page->GetEntry("Flags",&(feature->flags));
const char *mat_name,*texture_name;
fet_page->GetEntry("Material",&mat_name);
for(int i=0;i<MaterialEntriesCount;i++)
if(MaterialEntries[i].MatName==mat_name) feature->material=i;
feature->ReCalculateScale();
if(fet_page->GetEntry("HFTexture",&texture_name))
feature->HFTexture=TexturePool::Instance->Get(texture_name);
if(fet_page->GetEntry("FeatureTexture",&texture_name))
feature->featureTexture=TexturePool::Instance->Get(texture_name);
if(fet_page->GetEntry("FeatureMask0",&texture_name))
feature->featureMask0=TexturePool::Instance->Get(texture_name);
if(fet_page->GetEntry("FeatureMask1",&texture_name))
feature->featureMask1=TexturePool::Instance->Get(texture_name);
if(feature->featureTexture==NULL)
{
STOP(("Texture: %s is missing in Compost Texture Pool.", (const char *)(*feature->GetName()) ));
}
if(feature->GetBlendMode()==Feature::Blend555_1)
{
Verify(feature->featureMask0!=NULL);
if(!(feature->feature_width>feature->featureMask0->width) || !(feature->feature_height>feature->featureMask0->height) )
{
if(feature->featureMask0->GetTextureMode() == Feature_Texture::FTT_1)
{
SPEW(("micgaert", "Houston we have a problem in %s.", (const char *)(*(static_cast<Tool_Feature*>(feature))->GetName())));
DestroyTextureData(feature->featureMask0);
feature->featureMask0->SetTextureMode(Feature_Texture::FTT_1_M);
feature->featureMask0->SetLoadedOff();
TexturePool::Instance->Load(feature->featureMask0);
TexturePool::Instance->IsChanged(true);
}
feature->SetBlendMode(Feature::Blend555_1_S);
}
}
if(feature->GetBlendMode()==Feature::Blend555_1_S && feature->featureMask0->GetTextureMode() != Feature_Texture::FTT_1_M)
{
DestroyTextureData(feature->featureMask0);
feature->featureMask0->SetTextureMode(Feature_Texture::FTT_1_M);
feature->featureMask0->SetLoadedOff();
TexturePool::Instance->Load(feature->featureMask0);
TexturePool::Instance->IsChanged(true);
SPEW(("micgaert", "Houston we have another problem in %s.", (const char *)(*(static_cast<Tool_Feature*>(feature))->GetName())));
}
Register_Pointer(feature);
return feature;
}
@@ -0,0 +1,111 @@
#pragma once
#define FEATUREPOOL_HPP
#include "Compost.hpp"
namespace Compost
{
class FeatureGrid;
class FeaturePool
{
friend class FeatureGrid;
public:
FeaturePool();
FeaturePool(
Stuff::MemoryStream *stream
);
~FeaturePool();
void
LoadIndex(
Stuff::MemoryStream *stream
);
void
SaveIndex(
Stuff::MemoryStream *stream
);
void
LoadIndex(
Stuff::NotationFile *note_file
);
void
SaveIndex(
Stuff::NotationFile *note_file
);
void
Add(Feature *f);
void
Insert(Feature *f, int at);
void
Move(int from, int to);
void
Remove(int from);
void
Remove(Feature *f);
int
Find(Feature *f);
int
GetNumberOfFeatures() { return used; }
Feature*
GetFeatureNumber(int idx) { return features[idx]; }
Feature*
GetFeature(int idx);
Feature*
GetFeature(const char *feture_name);
int
GetFeaturePosition(Feature*);
Feature*
IsUsed(Feature_Texture*);
/*
int
ShootRay(unsigned short x, unsigned short z);
int
ShootRectangle(
unsigned short x,
unsigned short z,
unsigned short width,
unsigned short height
);
*/
void
SaveFeature(
Stuff::MemoryStream *stream,
Feature*
);
Feature*
LoadFeature(
Stuff::MemoryStream *stream,
int version
);
void
SaveFeature(
Stuff::NotationFile *note_file,
Feature*
);
Feature*
LoadFeature(
Stuff::Page *fet_page,
int version
);
protected:
int max, used;
Feature* rayCollect[MAX_NUMBER_LAYERS];
Stuff::DynamicArrayOf<Feature*> rectangleCollect;
Stuff::DynamicArrayOf<Feature*> features;
};
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,183 @@
#pragma once
#include "FeatureGrid.hpp"
#include <MLR\MLR.hpp>
#include <MLR\GOSVertex.hpp>
namespace MidLevelRenderer {
class MLR_Terrain2;
class MLRTexture;
}
namespace ElementRenderer {class GridElement;}
// #define THE03HACK
namespace Compost
{
struct CompostQueueStruct {
CompostQueueStruct() { featureGrid=NULL; row=0; column=0; textureHolder=NULL; downSample=0; type=0; done = -1; }
FeatureGrid *featureGrid;
int row, column;
TextureHolder *textureHolder;
int downSample;
int type;
int done;
bool
Compose() {
Check_Pointer(this);
Check_Pointer(featureGrid);
Check_Pointer(textureHolder);
return featureGrid->ComposeGrid(row, column, textureHolder, downSample, type);
}
};
class CompostQueue {
public:
CompostQueue();
bool SetCompostQueue(
FeatureGrid *featureGrid,
int row,
int column,
TextureHolder *textureHolder,
int downSample,
int type
);
void
EraseCompostQueueFlag(int index)
{
if(index<0)
{
return;
}
Verify(index<Length_Of_Compost_Queue);
compostQueueTracker[index>>5] &= ~(1<<(index & (32-1)));
compostQueue[index].done = -1;
}
void
Restart();
void
DoWork();
CompostQueueStruct*
IsInQueue(int row, int column, int downSample);
protected:
int GetFirstFreeSpot();
int firstInQueue;
int lastInQueue;
int flipAround;
CompostQueueStruct compostQueue[Length_Of_Compost_Queue];
CompostQueueStruct *compostQueuePointer[Length_Of_Compost_Queue];
DWORD compostQueueTracker[Length_Of_Compost_Queue_Tracker];
};
class TerrainTextureLogistic
{
public:
TerrainTextureLogistic(int, int, Scalar, Scalar, Stuff::MemoryStream*);
TerrainTextureLogistic(int, int, Scalar, Scalar, Stuff::NotationFile*);
TerrainTextureLogistic(int, int, Scalar, Scalar, const char*);
~TerrainTextureLogistic();
void
Restart();
void
AttachZone(ElementRenderer::GridElement*, BYTE, BYTE);
void
DetachMeshes(int, int, int, int);
void
SetNewPosition(
const Stuff::LinearMatrix4D *now,
const Stuff::LinearMatrix4D *soon,
const Stuff::LinearMatrix4D *later
);
static void
SetResolution(int res) { MidLevelRenderer::terrainTextureResolution = res; }
static int
GetResolution() {return MidLevelRenderer::terrainTextureResolution;}
#ifdef LAB_ONLY
static void
TurnOnBorder(RGBAColor color) { borderColor = MidLevelRenderer::GOSCopyColor(&color); borderKey = true; }
static void
TurnOffBorder() { borderKey = false; }
#endif
void
NextUnusedTexture(int res, int lastUnused);
void
FreeUsedTexture(int res, int lastUsed);
static TerrainTextureLogistic *Instance;
//==================================================================================
// these 2 functions are for adding features during run-time
// the feature will be centered at x, z (x and z rounded to the next power of 4 !!!)
// index = MString.GetHashValue(), please use this function
// scale is the factor by what the feature gets stretched
//==================================================================================
bool
AddFeature(const char *name, Scalar x, Scalar z, int scale=1)
{ return AddFeature(MString(name).GetHashValue(), x, z, scale); };
bool
AddFeature(int index, Scalar x, Scalar z, int scale=1);
void
SetOffset(Stuff::Scalar xo, Stuff::Scalar zo)
{ x_offset = xo; z_offset = zo; }
void
TestInstance()
{}
protected:
enum {
DesiredResolution=0,
CurrentResolution=1,
Priority=2,
DirtyFlag=3
};
#ifdef LAB_ONLY
static DWORD borderColor;
static bool borderKey;
#endif
int x_grid, z_grid;
Stuff::Scalar x_grid_length, z_grid_length;
Stuff::Scalar x_offset, z_offset;
unsigned char nrOfAllocatedTexture[5], nrOfUsedTextures[5];
unsigned char firstUnusedTexture[5];
bool textureAvailable[5];
Stuff::DynamicArrayOf<MidLevelRenderer::MLRTexture*> textures[5];
Stuff::DynamicArrayOf<int> textureFlags[5];
Stuff::DynamicArrayOf< Stuff::DynamicArrayOf<MidLevelRenderer::MLR_Terrain2*> > terrainMeshes;
Stuff::DynamicArrayOf<BYTE> resolutionTracker[4];
Stuff::DynamicArrayOf<TextureHolder> textureHolder[3];
FeatureGrid *featureGrid;
FeaturePool *featurePool;
CompostQueue compostQueue;
};
}
@@ -0,0 +1,672 @@
#include "CompostHeaders.hpp"
#include <GameOS\ToolOS.hpp>
TexturePool *TexturePool::Instance=NULL;
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
TexturePool::TexturePool()
: imageTable(
NULL,
true
)
{
texturePath = NULL;
changed = false;
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
TexturePool::~TexturePool()
{
Stuff::TableIteratorOf<Feature_Texture*, int> images(&imageTable);
Feature_Texture *fettext=NULL;
while(NULL!=(fettext=images.ReadAndNext()))
{
if(fettext->GetLoadedMode())
{
Compost::DestroyTextureData(fettext);
}
}
images.DeletePlugs();
if(texturePath)
{
Unregister_Pointer(texturePath);
delete texturePath;
}
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
void
TexturePool::SetTexturePath(const char *pName)
{
Verify(gos_GetCurrentHeap() == Heap);
Check_Pointer(this);
if(pName==NULL)
{
return;
}
if(texturePath)
{
Unregister_Pointer(texturePath);
delete texturePath;
}
texturePath = new char [strlen(pName)+1];
Register_Pointer(texturePath);
strcpy(texturePath, pName);
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
void
TexturePool::SetTexturePath(const char *pName, const char *tcf_filename)
{
Verify(gos_GetCurrentHeap() == Heap);
Check_Pointer(this);
if(pName==NULL)
{
return;
}
if(texturePath)
{
Unregister_Pointer(texturePath);
delete texturePath;
}
texturePath = new char [strlen(pName)+1];
Register_Pointer(texturePath);
strcpy(texturePath, pName);
LoadIndex(tcf_filename);
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
int
TexturePool::GetMask(int value)
{
int i, first=-1;
int mask=1;
for(i=0;i<8*sizeof(int);i++)
{
if(value & mask)
{
if(first<0)
{
first = i;
}
else
{
return 0xffffffff;
}
}
mask <<= 1;
}
if(first<0)
{
return 0;
}
mask = 1;
for(i=1;i<first;i++)
{
mask <<= 1;
mask |= 1;
}
return mask;
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
int
TexturePool::Add(
Stuff::MString name,
int width,
int height,
Feature_Texture::TextureMode type
)
{
Verify(gos_GetCurrentHeap() == Heap);
Check_Object(this);
Verify(name.GetLength() > 0);
name.ToLower();
int index = name.GetHashValue();
Feature_Texture *image;
if ((image = imageTable.Find(index)) == NULL)
{
image = new Tool_Feature_Texture();
Check_Object(image);
((Tool_Feature_Texture *)image)->name = name;
image->SetTextureMode(type);
switch(type)
{
case Feature_Texture::TextureMode::FTT_555:
image->SetTextureDepth(2);
break;
case Feature_Texture::TextureMode::FTT_4444:
image->SetTextureDepth(2);
break;
case Feature_Texture::TextureMode::FTT_1:
image->SetTextureDepth(1);
break;
case Feature_Texture::TextureMode::FTT_1_1:
image->SetTextureDepth(1);
break;
case Feature_Texture::TextureMode::FTT_1_M:
image->SetTextureDepth(1);
break;
}
image->width = width;
image->height = height;
image->width_mask = GetMask(width);
image->height_mask = GetMask(height);
imageTable.AddValue(image, index);
changed = true;
return name.GetHashValue();
}
return 0;
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
int
TexturePool::Add(
int index,
int width,
int height,
Feature_Texture::TextureMode type
)
{
Verify(gos_GetCurrentHeap() == Heap);
Check_Object(this);
Feature_Texture *image;
if ((image = imageTable.Find(index)) == NULL)
{
image = new Feature_Texture();
Check_Object(image);
image->SetTextureMode(type);
switch(type)
{
case Feature_Texture::TextureMode::FTT_555:
image->SetTextureDepth(2);
break;
case Feature_Texture::TextureMode::FTT_4444:
image->SetTextureDepth(2);
break;
case Feature_Texture::TextureMode::FTT_1:
image->SetTextureDepth(1);
break;
case Feature_Texture::TextureMode::FTT_1_1:
image->SetTextureDepth(1);
break;
case Feature_Texture::TextureMode::FTT_1_M:
image->SetTextureDepth(1);
break;
}
image->width = width;
image->height = height;
image->width_mask = GetMask(width);
image->height_mask = GetMask(height);
imageTable.AddValue(image, index);
changed = true;
return index;
}
else
{
return 0;
}
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
Feature_Texture*
TexturePool::Get(const char* image_name)
{
Check_Object(this);
Stuff::MString imageName = image_name;
Verify(imageName.GetLength() > 0);
//
//---------------------------
// Get the image for the name
//---------------------------
//
MString name(image_name);
name.ToLower();
return Get(name.GetHashValue());
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
Feature_Texture*
TexturePool::Get(int index)
{
Check_Pointer(this);
Feature_Texture *image;
if ((image = imageTable.Find(index)) == NULL)
{
return NULL;
}
Check_Pointer(image);
return image;
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
int
TexturePool::GetIndex(Feature_Texture *ft)
{
if(imageTable.IsEmpty() || ft==NULL)
{
return 0;
}
TableIteratorOf<Feature_Texture*, int> imageTableIterator(&imageTable);
Feature_Texture *featureTexture;
do
{
featureTexture = imageTableIterator.GetCurrent();
if(featureTexture==NULL)
{
break;
}
if(ft==featureTexture)
{
return imageTableIterator.GetValue();
}
} while(NULL!=imageTableIterator.ReadAndNext());
return 0;
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
void
TexturePool::Remove(Feature_Texture *image)
{
Check_Pointer(this);
Unregister_Pointer(image);
delete image;
changed = true;
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
void
TexturePool::Remove(const char* name)
{
Check_Pointer(this);
Remove(Get(name));
changed = true;
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
bool
TexturePool::Load(const char* , int)
{
return false;
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
bool
TexturePool::Load(int index , int type)
{
if(index==0)
{
return false;
}
Feature_Texture *tex = Get(index);
if(tex->GetLoadedMode())
{
return true;
}
MString *name = tex->GetName();
if(name)
{
MString fileName(texturePath);
fileName += "\\";
fileName += *name;
FetchTextureData(tex, fileName, type);
}
else
{
FetchTextureData(tex, index, type);
}
if(tex->data)
{
tex->SetLoadedOn();
return true;
}
return false;
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
bool
TexturePool::Load(Feature_Texture *tex)
{
if(tex==NULL)
{
return false;
}
if(tex->GetLoadedMode())
{
return true;
}
MString *name = tex->GetName();
if(name)
{
MString fileName(texturePath);
fileName += "\\";
fileName += *name;
FetchTextureData(tex, fileName, tex->flags);
}
else
{
// FetchTexture(tex, index, tex->type);
}
if(tex->data)
{
tex->SetLoadedOn();
return true;
}
return false;
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
void
TexturePool::LoadIndex()
{
TableIteratorOf<Feature_Texture*, int> imageTableIterator(&imageTable);
imageTableIterator.DeletePlugs();
MString files(texturePath);
files += "\\*.tcf";
char *tmpfile_name=gos_FindFiles(files);
while(tmpfile_name)
{
MString fileName(texturePath);
fileName +="\\";
fileName +=tmpfile_name;
if(!gos_DoesFileExist(fileName))
{
return;
}
NotationFile index(fileName);
const char *textureName;
int width, height, type;
NotationFile::PageIterator *page_list = index.MakePageIterator();
Page *tex_page;
while((tex_page = page_list->ReadAndNext()) != NULL)
{
Check_Object(tex_page);
if( tex_page->GetEntry("Type", &type) &&
tex_page->GetEntry("Width", &width) &&
tex_page->GetEntry("Height", &height)
)
{
if(!tex_page->GetEntry("Name", &textureName))
{
int number;
tex_page->GetEntry("Index", &number, true);
Add(
number,
static_cast<unsigned short>(width),
static_cast<unsigned short>(height),
static_cast<Feature_Texture::TextureMode>(type)
);
}
else
{
Add(
textureName,
static_cast<unsigned short>(width),
static_cast<unsigned short>(height),
static_cast<Feature_Texture::TextureMode>(type)
);
}
}
}
delete page_list;
tmpfile_name=gos_FindFilesNext();
}
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
void
TexturePool::LoadIndex(const char *tcf_filename)
{
TableIteratorOf<Feature_Texture*, int> imageTableIterator(&imageTable);
imageTableIterator.DeletePlugs();
if(!gos_DoesFileExist(tcf_filename))
{
return;
}
NotationFile index(tcf_filename);
const char *textureName;
int width, height, type;
NotationFile::PageIterator *page_list = index.MakePageIterator();
Page *tex_page;
while((tex_page = page_list->ReadAndNext()) != NULL)
{
Check_Object(tex_page);
if( tex_page->GetEntry("Type", &type) &&
tex_page->GetEntry("Width", &width) &&
tex_page->GetEntry("Height", &height)
)
{
if(!tex_page->GetEntry("Name", &textureName))
{
int number;
tex_page->GetEntry("Index", &number, true);
Add(
number,
static_cast<unsigned short>(width),
static_cast<unsigned short>(height),
static_cast<Feature_Texture::TextureMode>(type)
);
}
else
{
Add(
textureName,
static_cast<unsigned short>(width),
static_cast<unsigned short>(height),
static_cast<Feature_Texture::TextureMode>(type)
);
}
}
}
delete page_list;
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
void
TexturePool::LoadIndex(NotationFile *index)
{
TableIteratorOf<Feature_Texture*, int> imageTableIterator(&imageTable);
imageTableIterator.DeletePlugs();
const char *textureName;
int width, height, type;
NotationFile::PageIterator *page_list = index->MakePageIterator();
Page *tex_page;
while((tex_page = page_list->ReadAndNext()) != NULL)
{
Check_Object(tex_page);
if( tex_page->GetEntry("Type", &type) &&
tex_page->GetEntry("Width", &width) &&
tex_page->GetEntry("Height", &height)
)
{
if(!tex_page->GetEntry("Name", &textureName))
{
int number;
tex_page->GetEntry("Index", &number, true);
Add(
number,
static_cast<unsigned short>(width),
static_cast<unsigned short>(height),
static_cast<Feature_Texture::TextureMode>(type)
);
}
else
{
Add(
textureName,
static_cast<unsigned short>(width),
static_cast<unsigned short>(height),
static_cast<Feature_Texture::TextureMode>(type)
);
}
}
}
delete page_list;
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
bool
TexturePool::SaveIndex(const char*)
{
if(imageTable.IsEmpty())
{
changed = false;
return true;
}
TableIteratorOf<Feature_Texture*, int> imageTableIterator(&imageTable);
MString fileName(texturePath);
fileName += "\\index.tcf";
if(gos_FileReadOnly(fileName)) return false;
NotationFile index;
char numberString[8];
const char *str;
int number = 0;
MString *name;
Feature_Texture *featureTexture;
str = numberString;
do
{
featureTexture = imageTableIterator.GetCurrent();
if(featureTexture==NULL)
{
break;
}
sprintf(numberString, "%d", number);
Page *page = index.AddPage(str);
Check_Object(page);
name = featureTexture->GetName();
if(name)
{
page->SetEntry("Name", *name);
}
else
{
int value = imageTableIterator.GetValue();
page->SetEntry("Index", value);
}
page->SetEntry("Type", featureTexture->GetTextureMode());
page->SetEntry("Width", featureTexture->width);
page->SetEntry("Height", featureTexture->height);
number++;
} while(NULL!=imageTableIterator.ReadAndNext());
index.SaveAs(fileName);
changed = false;
return true;
}
@@ -0,0 +1,116 @@
#pragma once
#define TEXTUREPOOL_HPP
#include "Compost.hpp"
namespace Compost
{
class TexturePool
{
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Constructors/Destructors
//
public:
TexturePool();
~TexturePool();
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Image handling
//
public:
int
Add(
Stuff::MString name,
int width,
int height,
Feature_Texture::TextureMode type
);
int
Add(
int index,
int width,
int height,
Feature_Texture::TextureMode type
);
Feature_Texture*
Get(const char* imageName);
Feature_Texture*
Get(int index);
int
GetIndex(Feature_Texture*);
bool
Load(const char* , int=0);
bool
Load(int index , int=0);
bool
Load(Feature_Texture *);
void
Remove(Feature_Texture *image);
void
Remove(const char* name);
void
Remove(int index);
void
LoadIndex();
void
LoadIndex(const char*);
void
LoadIndex(Stuff::NotationFile*);
bool
SaveIndex(const char*);
const char*
GetTexturePath()
{ Check_Pointer(this); return texturePath; }
void
SetTexturePath(const char *pName);
void
SetTexturePath(const char *pName, const char *tcf_filename);
Stuff::TableOf<Feature_Texture*, int>*
GetImageTable()
{ return &imageTable; }
static TexturePool *Instance;
bool
IsChanged()
{ Check_Pointer(this); return changed; }
void
IsChanged(bool b)
{ Check_Pointer(this); changed = b; }
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Testing
//
public:
void
TestInstance() const
{}
protected:
int
GetMask(int);
char*
texturePath;
Stuff::TableOf<Feature_Texture*, int>
imageTable;
int fill[16];
bool
changed;
};
}