【3D技术宅公社】XR数字艺术论坛  XR技术讨论 XR互动电影 定格动画

 找回密码
 立即注册

QQ登录

只需一步,快速开始

调查问卷
论坛即将给大家带来全新的技术服务,面向三围图形学、游戏、动画的全新服务论坛升级为UTF8版本后,中文用户名和用户密码中有中文的都无法登陆,请发邮件到324007255(at)QQ.com联系手动修改密码

3D技术论坛将以计算机图形学为核心,面向教育 推出国内的三维教育引擎该项目在持续研发当中,感谢大家的关注。

查看: 3493|回复: 3

[OGRE引擎] 天龙八部资源提取源代码

[复制链接]
发表于 2009-8-6 09:36:47 | 显示全部楼层 |阅读模式

#include <stdio.h>
#include <string>
#include <windows.h>
#include <shlobj.h>

using namespace std;

int do16bit(char t)
{
switch(t)
{
case '0':
   return 0;
case '1':
   return 1;
case '2':
   return 2;
case '3':
   return 3;
case '4':
   return 4;
case '5':
   return 5;
case '6':
   return 6;
case '7':
   return 7;
case '8':
   return 8;
case '9':
   return 9;
case 'A':
   return 10;
case 'B':
   return 11;
case 'C':
   return 12;
case 'D':
   return 13;
case 'E':
   return 14;
case 'F':
   return 15;
default:
   return 0;
}
}

struct fileinfo
{
std::string name;
int      off;
int      size;
};

void mkdir(const char* path)
{
char buff[256];
GetCurrentDirectory(256,buff);
strcat(buff,"\\");
strcat(buff,path);
SHCreateDirectoryEx(NULL,buff,NULL);
}

void domaterial()
{
FILE *fp = fopen( "Material.axp", "rb" );
if( fp == NULL )
{
   return;
}

int nCount = 0;
fseek( fp, 0, SEEK_END );
int nSize = ftell( fp );
fseek( fp, 0x0b7b5d30, 0 );

int msize = nSize - 0x0b7b5d30;
char *pData = new char[msize];
fread( pData, 1, msize, fp );

std::string mfile = pData;
int star = 1;
int off = mfile.find("\n",star);
std::string temp = mfile.substr(star,off-star);

int mfnum = atoi(temp.c_str());

fileinfo *mfulelist = new fileinfo[mfnum];

mkdir("Material");
FILE *fout = fopen("Material\\Material.txt","wb");

for(int i=0; i<mfnum;i++)
{
   star = off+1;
   off = mfile.find("\n",star);
   temp = mfile.substr(star,off-star);

   int off1 = temp.find("|",0);
   int off2 = temp.find("|",off1+1);

   mfulelist.name = temp.substr(0,off1);

   std::string fsize = temp.substr(off1+1,off2-off1-1);

   mfulelist.size = ((((((
     do16bit(fsize[0])*16+
     do16bit(fsize[1]))*16+
     do16bit(fsize[2]))*16+
     do16bit(fsize[3]))*16+
     do16bit(fsize[4]))*16+
     do16bit(fsize[5]))*16+
     do16bit(fsize[6]))*16+
     do16bit(fsize[7]);

   if(mfulelist.name == string("Icons/MenpaiLiveSkill2.jpg"))
   {
     mfulelist.size = 97604;
   }
   if(mfulelist.name == string("Icons/TaskTools4.jpg"))
   {
     mfulelist.size = 77308;
   }

   if(i==0)
   {
     mfulelist.off = 0x00160028;
   }
   else
   {
     mfulelist.off = mfulelist[i-1].off + mfulelist[i-1].size;

     while(1)
     {
       if(mfulelist.off%8 == 0)
       {
         fseek( fp,mfulelist.off , 0 );
         fread( pData, 1, 8, fp );

         if(!(pData[0] == '\0'&&pData[1] == '\0'&&pData[2] == '\0'&&pData[3] == '\0'
           &&pData[4] == '\0'&&pData[5] == '\0'&&pData[6] == '\0'&&pData[7] == '\0'))
         {
           break;
         }
       }
       ++mfulelist.off;
     }
   }

   char *nfilestr = new char[256];
   sprintf(nfilestr,"%d\t%s\t%d\n",i,temp.c_str(),mfulelist.off);
   std::string mfilestr = nfilestr;
   fwrite((void*)mfilestr.c_str(),1,mfilestr.size(),fout);
}

fclose(fout);

for(int i=0; i<mfnum;i++)
{
   fseek( fp, mfulelist.off, 0 );

   char *filedata = new char[mfulelist.size];

   fread( filedata, 1, mfulelist.size, fp );

   if(i == 654)
   {
   }
   int mbdir = 0;
   while(1)
   {
     mbdir = mfulelist.name.find("/",mbdir+1);
     if(mbdir>0)
     {
       std::string mdir = mfulelist.name.substr(0,mbdir);
       mkdir((std::string("Material\\")+mdir).c_str());
     }
     else
     {
       break;
     }
   }

   FILE *fout = fopen((std::string("Material\\")+mfulelist.name).c_str(),"wb");
   fwrite((const void*)filedata,1,mfulelist.size,fout);
   fclose(fout);
}
fclose(fp);
}

void domodel()
{
FILE *fp = fopen( "model.axp", "rb" );
if( fp == NULL )
   return;

int nCount = 0;
fseek( fp, 0, SEEK_END );
int nSize = ftell( fp );
fseek( fp, 0x0c628730, 0 );

int msize = nSize - 0x0c628730;
char *pData = new char[msize];
fread( pData, 1, msize, fp );

std::string mfile = pData;
int star = 1;
int off = mfile.find("\n",star);
std::string temp = mfile.substr(star,off-star);

int mfnum = atoi(temp.c_str());

fileinfo *mfulelist = new fileinfo[mfnum];

mkdir("Model");
FILE *fout = fopen("Model\\Model.txt","wb");

for(int i=0; i<mfnum;i++)
{
   star = off+1;
   off = mfile.find("\n",star);
   temp = mfile.substr(star,off-star);

   int off1 = temp.find("|",0);
   int off2 = temp.find("|",off1+1);

   mfulelist.name = temp.substr(0,off1);

   std::string fsize = temp.substr(off1+1,off2-off1-1);

   mfulelist.size = ((((((
     do16bit(fsize[0])*16+
     do16bit(fsize[1]))*16+
     do16bit(fsize[2]))*16+
     do16bit(fsize[3]))*16+
     do16bit(fsize[4]))*16+
     do16bit(fsize[5]))*16+
     do16bit(fsize[6]))*16+
     do16bit(fsize[7]);

   if(i==0)
   {
     mfulelist.off = 0x00160028;
   }
   else
   {
     mfulelist.off = mfulelist[i-1].off + mfulelist[i-1].size;

     while(1)
     {
       if(mfulelist.off%8 == 0)
       {
         fseek( fp,mfulelist.off , 0 );
         fread( pData, 1, 8, fp );

         if(!(pData[0] == '\0'&&pData[1] == '\0'&&pData[2] == '\0'&&pData[3] == '\0'
           &&pData[4] == '\0'&&pData[5] == '\0'&&pData[6] == '\0'&&pData[7] == '\0'))
         {
           break;
         }
       }
       ++mfulelist.off;
     }
   }

   char *nfilestr = new char[256];
   sprintf(nfilestr,"%d\t%s\t%d\n",i,temp.c_str(),mfulelist.off);
   std::string mfilestr = nfilestr;
   fwrite((void*)mfilestr.c_str(),1,mfilestr.size(),fout);
}

fclose(fout);

for(int i=0; i<mfnum;i++)
{
   fseek( fp, mfulelist.off, 0 );

   char *filedata = new char[mfulelist.size];

   fread( filedata, 1, mfulelist.size, fp );

   if(i == 654)
   {
   }
   int mbdir = 0;
   while(1)
   {
     mbdir = mfulelist.name.find("/",mbdir+1);
     if(mbdir>0)
     {
       std::string mdir = mfulelist.name.substr(0,mbdir);
       mkdir((std::string("Model\\")+mdir).c_str());
     }
     else
     {
       break;
     }
   }

   FILE *fout = fopen((std::string("Model\\")+mfulelist.name).c_str(),"wb");
   fwrite((const void*)filedata,1,mfulelist.size,fout);
   fclose(fout);
}
fclose(fp);
}

 楼主| 发表于 2009-8-6 09:37:18 | 显示全部楼层

void doBrushes()
{
FILE *fp = fopen( "brushes.axp", "rb" );
if( fp == NULL )
   return;

int nCount = 0;
fseek( fp, 0, SEEK_END );
int nSize = ftell( fp );
fseek( fp, 0x01e97e30, 0 );

int msize = nSize - 0x01e97e30;
char *pData = new char[msize];
fread( pData, 1, msize, fp );

std::string mfile = pData;
int star = 1;
int off = mfile.find("\n",star);
std::string temp = mfile.substr(star,off-star);

int mfnum = atoi(temp.c_str());

fileinfo *mfulelist = new fileinfo[mfnum];

mkdir("Brushes");
FILE *fout = fopen("Brushes\\Brushes.txt","wb");

for(int i=0; i<mfnum;i++)
{
   star = off+1;
   off = mfile.find("\n",star);
   temp = mfile.substr(star,off-star);

   int off1 = temp.find("|",0);
   int off2 = temp.find("|",off1+1);

   mfulelist.name = temp.substr(0,off1);

   std::string fsize = temp.substr(off1+1,off2-off1-1);

   mfulelist.size = ((((((
     do16bit(fsize[0])*16+
     do16bit(fsize[1]))*16+
     do16bit(fsize[2]))*16+
     do16bit(fsize[3]))*16+
     do16bit(fsize[4]))*16+
     do16bit(fsize[5]))*16+
     do16bit(fsize[6]))*16+
     do16bit(fsize[7]);

   if(i==0)
   {
     mfulelist.off = 0x00160028;
   }
   else
   {
     mfulelist.off = mfulelist[i-1].off + mfulelist[i-1].size;

     while(1)
     {
       if(mfulelist.off%8 == 0)
       {
         fseek( fp,mfulelist.off , 0 );
         fread( pData, 1, 8, fp );

         if(!(pData[0] == '\0'&&pData[1] == '\0'&&pData[2] == '\0'&&pData[3] == '\0'
           &&pData[4] == '\0'&&pData[5] == '\0'&&pData[6] == '\0'&&pData[7] == '\0'))
         {
           break;
         }
       }
       ++mfulelist.off;
     }
   }

   char *nfilestr = new char[256];
   sprintf(nfilestr,"%d\t%s\t%d\n",i,temp.c_str(),mfulelist.off);
   std::string mfilestr = nfilestr;
   fwrite((void*)mfilestr.c_str(),1,mfilestr.size(),fout);
}

fclose(fout);

for(int i=0; i<mfnum;i++)
{
   fseek( fp, mfulelist.off, 0 );

   char *filedata = new char[mfulelist.size];

   fread( filedata, 1, mfulelist.size, fp );

   if(i == 654)
   {
   }
   int mbdir = 0;
   while(1)
   {
     mbdir = mfulelist.name.find("/",mbdir+1);
     if(mbdir>0)
     {
       std::string mdir = mfulelist.name.substr(0,mbdir);
       mkdir((std::string("Brushes\\")+mdir).c_str());
     }
     else
     {
       break;
     }
   }

   FILE *fout = fopen((std::string("Brushes\\")+mfulelist.name).c_str(),"wb");
   fwrite((const void*)filedata,1,mfulelist.size,fout);
   fclose(fout);
}
fclose(fp);
}

void doEffect()
{
FILE *fp = fopen( "effect.axp", "rb" );
if( fp == NULL )
   return;

int nCount = 0;
fseek( fp, 0, SEEK_END );
int nSize = ftell( fp );
fseek( fp, 0x00746730, 0 );

int msize = nSize - 0x00746730;
char *pData = new char[msize];
fread( pData, 1, msize, fp );

std::string mfile = pData;
int star = 1;
int off = mfile.find("\n",star);
std::string temp = mfile.substr(star,off-star);

int mfnum = atoi(temp.c_str());

fileinfo *mfulelist = new fileinfo[mfnum];

mkdir("Effect");
FILE *fout = fopen("Effect\\Effect.txt","wb");

for(int i=0; i<mfnum;i++)
{
   star = off+1;
   off = mfile.find("\n",star);
   temp = mfile.substr(star,off-star);

   int off1 = temp.find("|",0);
   int off2 = temp.find("|",off1+1);

   mfulelist.name = temp.substr(0,off1);

   std::string fsize = temp.substr(off1+1,off2-off1-1);

   mfulelist.size = ((((((
     do16bit(fsize[0])*16+
     do16bit(fsize[1]))*16+
     do16bit(fsize[2]))*16+
     do16bit(fsize[3]))*16+
     do16bit(fsize[4]))*16+
     do16bit(fsize[5]))*16+
     do16bit(fsize[6]))*16+
     do16bit(fsize[7]);

   if(i==0)
   {
     mfulelist.off = 0x00160028;
   }
   else
   {
     mfulelist.off = mfulelist[i-1].off + mfulelist[i-1].size;

     while(1)
     {
       if(mfulelist.off%8 == 0)
       {
         fseek( fp,mfulelist.off , 0 );
         fread( pData, 1, 8, fp );

         if(!(pData[0] == '\0'&&pData[1] == '\0'&&pData[2] == '\0'&&pData[3] == '\0'
           &&pData[4] == '\0'&&pData[5] == '\0'&&pData[6] == '\0'&&pData[7] == '\0'))
         {
           break;
         }
       }
       ++mfulelist.off;
     }
   }

   char *nfilestr = new char[256];
   sprintf(nfilestr,"%d\t%s\t%d\n",i,temp.c_str(),mfulelist.off);
   std::string mfilestr = nfilestr;
   fwrite((void*)mfilestr.c_str(),1,mfilestr.size(),fout);
}

fclose(fout);

for(int i=0; i<mfnum;i++)
{
   fseek( fp, mfulelist.off, 0 );

   char *filedata = new char[mfulelist.size];

   fread( filedata, 1, mfulelist.size, fp );

   if(i == 654)
   {
   }
   int mbdir = 0;
   while(1)
   {
     mbdir = mfulelist.name.find("/",mbdir+1);
     if(mbdir>0)
     {
       std::string mdir = mfulelist.name.substr(0,mbdir);
       mkdir((std::string("Effect\\")+mdir).c_str());
     }
     else
     {
       break;
     }
   }

   FILE *fout = fopen((std::string("Effect\\")+mfulelist.name).c_str(),"wb");
   fwrite((const void*)filedata,1,mfulelist.size,fout);
   fclose(fout);
}
fclose(fp);
}

 楼主| 发表于 2009-8-6 09:37:42 | 显示全部楼层


void doInterface()
{
FILE *fp = fopen( "interface.axp", "rb" );
if( fp == NULL )
   return;

int nCount = 0;
fseek( fp, 0, SEEK_END );
int nSize = ftell( fp );
fseek( fp, 0x012ee230, 0 );

int msize = nSize - 0x012ee230;
char *pData = new char[msize];
fread( pData, 1, msize, fp );

std::string mfile = pData;
int star = 1;
int off = mfile.find("\n",star);
std::string temp = mfile.substr(star,off-star);

int mfnum = atoi(temp.c_str());

fileinfo *mfulelist = new fileinfo[mfnum];

mkdir("Interface");
FILE *fout = fopen("Interface\\Interface.txt","wb");

for(int i=0; i<mfnum;i++)
{
   star = off+1;
   off = mfile.find("\n",star);
   temp = mfile.substr(star,off-star);

   int off1 = temp.find("|",0);
   int off2 = temp.find("|",off1+1);

   mfulelist.name = temp.substr(0,off1);

   std::string fsize = temp.substr(off1+1,off2-off1-1);

   mfulelist.size = ((((((
     do16bit(fsize[0])*16+
     do16bit(fsize[1]))*16+
     do16bit(fsize[2]))*16+
     do16bit(fsize[3]))*16+
     do16bit(fsize[4]))*16+
     do16bit(fsize[5]))*16+
     do16bit(fsize[6]))*16+
     do16bit(fsize[7]);

   if(i==0)
   {
     mfulelist.off = 0x00160028;
   }
   else
   {
     mfulelist.off = mfulelist[i-1].off + mfulelist[i-1].size;

     while(1)
     {
       if(mfulelist.off%8 == 0)
       {
         fseek( fp,mfulelist.off , 0 );
         fread( pData, 1, 8, fp );

         if(!(pData[0] == '\0'&&pData[1] == '\0'&&pData[2] == '\0'&&pData[3] == '\0'
           &&pData[4] == '\0'&&pData[5] == '\0'&&pData[6] == '\0'&&pData[7] == '\0'))
         {
           break;
         }
       }
       ++mfulelist.off;
     }
   }

   char *nfilestr = new char[256];
   sprintf(nfilestr,"%d\t%s\t%d\n",i,temp.c_str(),mfulelist.off);
   std::string mfilestr = nfilestr;
   fwrite((void*)mfilestr.c_str(),1,mfilestr.size(),fout);
}

fclose(fout);

for(int i=0; i<mfnum;i++)
{
   fseek( fp, mfulelist.off, 0 );

   char *filedata = new char[mfulelist.size];

   fread( filedata, 1, mfulelist.size, fp );

   if(i == 654)
   {
   }
   int mbdir = 0;
   while(1)
   {
     mbdir = mfulelist.name.find("/",mbdir+1);
     if(mbdir>0)
     {
       std::string mdir = mfulelist.name.substr(0,mbdir);
       mkdir((std::string("Interface\\")+mdir).c_str());
     }
     else
     {
       break;
     }
   }

   FILE *fout = fopen((std::string("Interface\\")+mfulelist.name).c_str(),"wb");
   fwrite((const void*)filedata,1,mfulelist.size,fout);
   fclose(fout);
}
fclose(fp);
}

void doSound()
{
FILE *fp = fopen( "sound.axp", "rb" );
if( fp == NULL )
   return;

int nCount = 0;
fseek( fp, 0, SEEK_END );
int nSize = ftell( fp );
fseek( fp, 0x07ce2930, 0 );

int msize = nSize - 0x07ce2930;
char *pData = new char[msize];
fread( pData, 1, msize, fp );

std::string mfile = pData;
int star = 1;
int off = mfile.find("\n",star);
std::string temp = mfile.substr(star,off-star);

int mfnum = atoi(temp.c_str());

fileinfo *mfulelist = new fileinfo[mfnum];

mkdir("Sound");
FILE *fout = fopen("Sound\\Sound.txt","wb");

for(int i=0; i<mfnum;i++)
{
   star = off+1;
   off = mfile.find("\n",star);
   temp = mfile.substr(star,off-star);

   int off1 = temp.find("|",0);
   int off2 = temp.find("|",off1+1);

   mfulelist.name = temp.substr(0,off1);

   std::string fsize = temp.substr(off1+1,off2-off1-1);

   mfulelist.size = ((((((
     do16bit(fsize[0])*16+
     do16bit(fsize[1]))*16+
     do16bit(fsize[2]))*16+
     do16bit(fsize[3]))*16+
     do16bit(fsize[4]))*16+
     do16bit(fsize[5]))*16+
     do16bit(fsize[6]))*16+
     do16bit(fsize[7]);

   if(i==0)
   {
     mfulelist.off = 0x00160028;
   }
   else
   {
     mfulelist.off = mfulelist[i-1].off + mfulelist[i-1].size;

     while(1)
     {
       if(mfulelist.off%8 == 0)
       {
         fseek( fp,mfulelist.off , 0 );
         fread( pData, 1, 8, fp );

         if(!(pData[0] == '\0'&&pData[1] == '\0'&&pData[2] == '\0'&&pData[3] == '\0'
           &&pData[4] == '\0'&&pData[5] == '\0'&&pData[6] == '\0'&&pData[7] == '\0'))
         {
           break;
         }
       }
       ++mfulelist.off;
     }
   }

   char *nfilestr = new char[256];
   sprintf(nfilestr,"%d\t%s\t%d\n",i,temp.c_str(),mfulelist.off);
   std::string mfilestr = nfilestr;
   fwrite((void*)mfilestr.c_str(),1,mfilestr.size(),fout);
}

fclose(fout);

for(int i=0; i<mfnum;i++)
{
   fseek( fp, mfulelist.off, 0 );

   char *filedata = new char[mfulelist.size];

   fread( filedata, 1, mfulelist.size, fp );

   if(i == 654)
   {
   }
   int mbdir = 0;
   while(1)
   {
     mbdir = mfulelist.name.find("/",mbdir+1);
     if(mbdir>0)
     {
       std::string mdir = mfulelist.name.substr(0,mbdir);
       mkdir((std::string("Sound\\")+mdir).c_str());
     }
     else
     {
       break;
     }
   }

   FILE *fout = fopen((std::string("Sound\\")+mfulelist.name).c_str(),"wb");
   fwrite((const void*)filedata,1,mfulelist.size,fout);
   fclose(fout);
}
fclose(fp);
}

void doScene()
{
FILE *fp = fopen( "scene.axp", "rb" );
if( fp == NULL )
{
   return;
}

int nCount = 0;
fseek( fp, 0, SEEK_END );
int nSize = ftell( fp );
fseek( fp, 0x159b8b30, 0 );

int msize = nSize - 0x159b8b30;
char *pData = new char[msize];
fread( pData, 1, msize, fp );

std::string mfile = pData;
int star = 1;
int off = mfile.find("\n",star);
std::string temp = mfile.substr(star,off-star);

int mfnum = atoi(temp.c_str());

fileinfo *mfulelist = new fileinfo[mfnum];

mkdir("Scene");
FILE *fout = fopen("Scene\\Scene.txt","wb");

for(int i=0; i<mfnum;i++)
{
   star = off+1;
   off = mfile.find("\n",star);
   temp = mfile.substr(star,off-star);

   int off1 = temp.find("|",0);
   int off2 = temp.find("|",off1+1);

   mfulelist.name = temp.substr(0,off1);

   std::string fsize = temp.substr(off1+1,off2-off1-1);

   mfulelist.size = ((((((
     do16bit(fsize[0])*16+
     do16bit(fsize[1]))*16+
     do16bit(fsize[2]))*16+
     do16bit(fsize[3]))*16+
     do16bit(fsize[4]))*16+
     do16bit(fsize[5]))*16+
     do16bit(fsize[6]))*16+
     do16bit(fsize[7]);

   if(i==0)
   {
     mfulelist.off = 0x00160028;
   }
   else
   {
     mfulelist.off = mfulelist[i-1].off + mfulelist[i-1].size;

     while(1)
     {
       if(mfulelist.off%8 == 0)
       {
         fseek( fp,mfulelist.off , 0 );
         fread( pData, 1, 8, fp );

         if(!(pData[0] == '\0'&&pData[1] == '\0'&&pData[2] == '\0'&&pData[3] == '\0'
           &&pData[4] == '\0'&&pData[5] == '\0'&&pData[6] == '\0'&&pData[7] == '\0'))
         {
           break;
         }
       }
       ++mfulelist.off;
     }
   }

   char *nfilestr = new char[256];
   sprintf(nfilestr,"%d\t%s\t%d\n",i,temp.c_str(),mfulelist.off);
   std::string mfilestr = nfilestr;
   fwrite((void*)mfilestr.c_str(),1,mfilestr.size(),fout);
}

fclose(fout);

for(int i=0; i<mfnum;i++)
{
   fseek( fp, mfulelist.off, 0 );

   char *filedata = new char[mfulelist.size];

   fread( filedata, 1, mfulelist.size, fp );

   if(i == 654)
   {
   }
   int mbdir = 0;
   while(1)
   {
     mbdir = mfulelist.name.find("/",mbdir+1);
     if(mbdir>0)
     {
       std::string mdir = mfulelist.name.substr(0,mbdir);
       mkdir((std::string("Scene\\")+mdir).c_str());
     }
     else
     {
       break;
     }
   }

   FILE *fout = fopen((std::string("Scene\\")+mfulelist.name).c_str(),"wb");
   fwrite((const void*)filedata,1,mfulelist.size,fout);
   fclose(fout);
}
fclose(fp);
}

int main()
{
domaterial();
domodel();
doBrushes();
doEffect();
doInterface();
doSound();
doScene();
}

发表于 2009-8-7 13:14:43 | 显示全部楼层
好牛X
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|3D数字艺术论坛 ( 沪ICP备14023054号 )

GMT+8, 2025-2-6 09:47

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表