218 lines
6.1 KiB
C++
218 lines
6.1 KiB
C++
#include "stdafx.h"
|
|
|
|
#include "_TextureMode.h"
|
|
K3DTexture * _spSpecular[8]={NULL,};
|
|
STRUCT_TEXTURE_MODE g_pTextureMode[MAX_TEXTURE_MODE] =
|
|
{
|
|
#include "TextureMode.txt"
|
|
};
|
|
|
|
|
|
#ifdef _DEV
|
|
STRUCT_TEXTURE_MODE_FILE g_pTextureModeFile[MAX_TEXTURE_MODE] =
|
|
{
|
|
#include "TextureModeFile.txt"
|
|
};
|
|
|
|
void _TextureModeReload(void)
|
|
{
|
|
FILE * fp = fopen("TextureModeFile.txt","rt");
|
|
if (fp==NULL) return;
|
|
|
|
memset(g_pTextureModeFile,0,sizeof(g_pTextureModeFile));
|
|
for (int i=0;i<MAX_TEXTURE_MODE;i++)
|
|
{
|
|
while(TRUE)
|
|
{ char buf[256];
|
|
char * ret = fgets(buf,255,fp);
|
|
if (ret<=0) break;
|
|
int len = strlen(buf);
|
|
for (int j=0;j<len;j++)
|
|
{ if (buf[j]=='\"' || buf[j]==',' || buf[j]<' ') buf[j]=' ';
|
|
}
|
|
char token[2][256];
|
|
sscanf(buf,"%s %s",token[0],token[1]);
|
|
if (token[0][0] =='/') continue;
|
|
|
|
int mode = atoi(token[1]);
|
|
if (mode<=0) continue;
|
|
|
|
strcpy(g_pTextureModeFile[i].pFile,token[0]);
|
|
g_pTextureModeFile[i].nMode = mode;
|
|
break;
|
|
};
|
|
}
|
|
|
|
fclose(fp);
|
|
}
|
|
|
|
|
|
void _TextureModeBuild(void)
|
|
{
|
|
// if (g_pTextureMode[0].nHash1) return;
|
|
memset(g_pTextureMode,0,sizeof(g_pTextureMode));
|
|
FILE * fp = fopen("TextureMode.txt","wt");
|
|
for (int i=0;i<MAX_TEXTURE_MODE;i++)
|
|
{
|
|
char *pfile =g_pTextureModeFile[i].pFile;
|
|
if (pfile[0]==0) break;
|
|
|
|
int nhash1 = 0;
|
|
int nhash2 = 0;
|
|
_TextureModeEncode(pfile,&nhash1,&nhash2);
|
|
|
|
// 기존 테이블에 중복된 값이 있는지 검사
|
|
for (int j=0;j<i;j++)
|
|
{
|
|
if (g_pTextureMode[i].nHash1 == nhash1 && g_pTextureMode[i].nHash2 == nhash2 )
|
|
{ MessageBox(NULL,pfile,"error: same hash key",MB_OK);
|
|
}
|
|
}
|
|
int mode =g_pTextureModeFile[i].nMode;
|
|
g_pTextureMode[i].nHash1 = nhash1;
|
|
g_pTextureMode[i].nHash2 = nhash2;
|
|
g_pTextureMode[i].nMode = mode;
|
|
|
|
fprintf(fp,"%d,%d,%d,\n", nhash1,nhash2,mode);
|
|
}
|
|
|
|
fclose(fp);
|
|
|
|
};
|
|
#endif
|
|
|
|
|
|
|
|
void _TextureModeEncode(char * name,int * nhash1,int * nhash2)
|
|
{
|
|
*nhash1=0;
|
|
*nhash2=0;
|
|
int len = strlen (name);
|
|
for (int i=0;i<len;i++)
|
|
{
|
|
if (name[i]=='.') break; // 확장자는 포함하지 않는다.
|
|
if (i&0x1)
|
|
{ *nhash1 += ((name[i]-'0') << (i>>1));
|
|
} else
|
|
{ *nhash2 += ((name[i]-'0') << (i>>1));
|
|
}
|
|
}
|
|
}
|
|
|
|
int _TextureModeGet(char *name)
|
|
{
|
|
int mode = 1;
|
|
int nhash1 = 0;
|
|
int nhash2 = 0;
|
|
_TextureModeEncode(name,&nhash1,&nhash2);
|
|
for (int i=0;i<MAX_TEXTURE_MODE;i++)
|
|
{ if (g_pTextureMode[i].nHash1 == nhash1 && g_pTextureMode[i].nHash2 == nhash2 )
|
|
{ return g_pTextureMode[i].nMode;
|
|
}
|
|
}
|
|
|
|
int len = strlen(name);
|
|
for (int i=0;i<len-3;i++)
|
|
{
|
|
|
|
if (name[i+1]=='f' && name[i+2]=='x' && name[i+3]=='_') return 21;
|
|
|
|
if (name[i]=='_')
|
|
{
|
|
if (name[i+1]=='n' && name[i+2]=='p' && name[i+3]=='c') {mode= 23; break;}
|
|
if (name[i+1]=='f' && name[i+2]=='a' && name[i+3]=='c') {mode= 23; break;}
|
|
if (name[i+1]=='h' && name[i+2]=='a' && name[i+3]=='n') {mode= 23; break;}
|
|
|
|
}
|
|
}
|
|
|
|
FILE * fp = fopen("tex.txt","at+");
|
|
fprintf(fp,"%s %d : %d %d\n", name, mode, nhash1,nhash2);
|
|
fclose(fp);
|
|
|
|
|
|
return mode;
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
EnhanceFX g_pEnhanceFX[MAX_ENHANCEFX];
|
|
EnhanceFX * GetEnhanceFX( int code, int level)
|
|
{
|
|
//g_pEnhanceFX[0].weapon_id = 0;
|
|
if (g_pEnhanceFX[0].enhance_level==0)
|
|
{
|
|
g_pEnhanceFX[0].enhance_level = level+1;
|
|
g_pEnhanceFX[0].enhance_color = (255<24) | (255<<16) | (0 <<8) | (0 << 0);
|
|
g_pEnhanceFX[0].wt_length = 250;
|
|
g_pEnhanceFX[0].wt_width = 22;
|
|
g_pEnhanceFX[0].wt00 = (128<<24) | (255<<16) | (0<<8) + 0;
|
|
g_pEnhanceFX[0].wt01 = (128<<24) | (0<<16) | (255<<8) + 0;
|
|
g_pEnhanceFX[0].wt10 = (128<<24) | (0<<16) | (0<<8) + 255;
|
|
g_pEnhanceFX[0].wt11 = (128<<24) | (255<<16) | (255<<8) + 255;
|
|
}
|
|
if (g_pEnhanceFX[1].enhance_level==1)
|
|
{
|
|
g_pEnhanceFX[1].enhance_level = level+1;
|
|
g_pEnhanceFX[1].enhance_color = (255<24) | (0<<16) | (255 <<8) | (0 << 0);
|
|
g_pEnhanceFX[1].wt_length = 250;
|
|
g_pEnhanceFX[1].wt_width = 22;
|
|
g_pEnhanceFX[1].wt00 = (128<<24) | (255<<16) | (0<<8) + 0;
|
|
g_pEnhanceFX[1].wt01 = (128<<24) | (0<<16) | (255<<8) + 0;
|
|
g_pEnhanceFX[1].wt10 = (128<<24) | (0<<16) | (0<<8) + 255;
|
|
g_pEnhanceFX[1].wt11 = (128<<24) | (255<<16) | (255<<8) + 255;
|
|
}
|
|
if (g_pEnhanceFX[2].enhance_level==0)
|
|
{
|
|
|
|
g_pEnhanceFX[2].enhance_level = level+1;
|
|
g_pEnhanceFX[2].enhance_color = (255<24) | (0<<16) | (0 <<8) | (255 << 0);
|
|
g_pEnhanceFX[2].wt_length = 250;
|
|
g_pEnhanceFX[2].wt_width = 22;
|
|
g_pEnhanceFX[2].wt00 = (192<<24) | (255<<16) | (0<<8) + 0;
|
|
g_pEnhanceFX[2].wt01 = (192<<24) | (0<<16) | (255<<8) + 0;
|
|
g_pEnhanceFX[2].wt10 = (192<<24) | (0<<16) | (0<<8) + 255;
|
|
g_pEnhanceFX[2].wt11 = (192<<24) | (255<<16) | (255<<8) + 255;
|
|
}
|
|
if (g_pEnhanceFX[3].enhance_level==0)
|
|
{
|
|
g_pEnhanceFX[3].enhance_level = level+1;
|
|
g_pEnhanceFX[3].enhance_color = (255<24) | (255<<16) | (255 <<8) | (0 << 0);
|
|
g_pEnhanceFX[3].wt_length = 250;
|
|
g_pEnhanceFX[3].wt_width = 22;
|
|
g_pEnhanceFX[3].wt00 = (255<<24) | (255<<16) | (0<<8) + 0;
|
|
g_pEnhanceFX[3].wt01 = (255<<24) | (0<<16) | (255<<8) + 0;
|
|
g_pEnhanceFX[3].wt10 = (255<<24) | (0<<16) | (0<<8) + 255;
|
|
g_pEnhanceFX[3].wt11 = (255<<24) | (255<<16) | (255<<8) + 255;
|
|
}
|
|
if (g_pEnhanceFX[4].enhance_level==0)
|
|
{
|
|
g_pEnhanceFX[4].enhance_level = level+1;
|
|
g_pEnhanceFX[4].enhance_color = (255<24) | (0<<16) | (255 <<8) | (255 << 0);
|
|
g_pEnhanceFX[4].wt_length = 250;
|
|
g_pEnhanceFX[4].wt_width = 22;
|
|
g_pEnhanceFX[4].wt00 = (255<<24) | (255<<16) | (0<<8) + 0;
|
|
g_pEnhanceFX[4].wt01 = (255<<24) | (0<<16) | (255<<8) + 0;
|
|
g_pEnhanceFX[4].wt10 = (128<<24) | (0<<16) | (0<<8) + 255;
|
|
g_pEnhanceFX[4].wt11 = (128<<24) | (255<<16) | (255<<8) + 255;
|
|
}
|
|
if (g_pEnhanceFX[5].enhance_level==0)
|
|
{
|
|
g_pEnhanceFX[5].enhance_level = level+1;
|
|
g_pEnhanceFX[5].enhance_color = (255<24) | (255<<16) | (0 <<8) | (255 << 0);
|
|
g_pEnhanceFX[5].wt_length = 250;
|
|
g_pEnhanceFX[5].wt_width = 22;
|
|
g_pEnhanceFX[5].wt00 = (128<<24) | (255<<16) | (0<<8) + 0;
|
|
g_pEnhanceFX[5].wt01 = (128<<24) | (0<<16) | (255<<8) + 0;
|
|
g_pEnhanceFX[5].wt10 = (2558<<24) | (0<<16) | (0<<8) + 255;
|
|
g_pEnhanceFX[5].wt11 = (255<<24) | (255<<16) | (255<<8) + 255;
|
|
}
|
|
|
|
//NX3LoadPack loadpack;
|
|
//loadpack.Init();
|
|
//g_pEnhanceFX[0].wt_texture_ID= 1;// GetTexture( "wfxsforce_lv03.dds",&loadpack,TRUE,0);
|
|
return &g_pEnhanceFX[level];
|
|
|
|
} |