G2A Many GEOs
SHARE
TWEET

Script FileImport ADT> TXT

Wolfyruz Mar 25th, 2020 75 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  4. FILE *Input;
  5.  
  6. struct MCIN{
  7.     unsigned int Offset;
  8.     unsigned int Size;
  9.     unsigned int Temp1;
  10.     unsigned int Temp2;
  11. };
  12.  
  13. /*
  14. MCNK
  15. 0x14 MCVT Offset
  16. 0x18 MCNR Offset
  17. 0x1C MCLY Offset
  18. 0x20 MCRF Offset
  19. 0x24 MCAL Offset
  20. 0x2C MCSH Offset
  21. 0x52 MCSE Offset
  22. 0x60 MCLQ Offset
  23. 0x68 Z' Base Coordinate
  24. 0x6C X' Base Coordinate
  25. 0x70 Y Base Coordinate
  26. */
  27. struct MCNK{
  28.     float Z;
  29.     float X;
  30.     float Y;
  31. };
  32.  
  33. struct Pos
  34. {
  35.     float x;
  36.     float y;
  37.     float z;
  38. };
  39.  
  40. struct MCLQ
  41. {
  42.     int   Enabled;
  43.     float First;
  44.     float Vertex[81];
  45.     int   Flags[81];
  46.     float   Last;
  47. };
  48.  
  49. MCIN Positions[256];
  50. MCNK ADTOffsets[256];
  51. MCLQ WaterLevels[256];
  52. unsigned int MCNK_Positions[256];
  53.  
  54. unsigned int MTEX_Offset;
  55. unsigned int MMDX_Offset;
  56. unsigned int MMID_Offset;
  57. unsigned int MWMO_Offset;
  58. unsigned int MWID_Offset;
  59. unsigned int MDDF_Offset;
  60. unsigned int MODF_Offset;
  61.  
  62. int NumDoodads;
  63. Pos *Doodads;
  64.  
  65.  
  66. unsigned char *File;
  67. unsigned int FileSize;
  68.  
  69. struct DDF
  70. {
  71.     unsigned int    ID;
  72.     unsigned int    UniqueID;
  73.     float           Pos[3];
  74.     float           Rot[3];
  75.     unsigned int    Scale;
  76. };
  77.  
  78. struct WMO
  79. {
  80.     unsigned int    ID;
  81.     unsigned int    UniqueID;
  82.     float           Pos[3];
  83.     float           Rot[3];
  84.     float           Pos2[3];
  85.     float           Pos3[3];
  86.     short           Unknown1;
  87.     short           DoodadIndex;
  88.     unsigned int    Unknown2;
  89. };
  90.  
  91. int NumWMOs;
  92.  
  93. WMO *WMOs;
  94.  
  95. char *Textures;
  96.  
  97. char *MDXFiles;
  98. int diffMDXs;
  99. int *MDXOffsets;
  100.  
  101. char *WMOFiles;
  102. int diffWMOs;
  103. int *WMOOffsets;
  104.  
  105. int NumDDFs;
  106. DDF *DDFs;
  107.  
  108. void FindMDDFandMODF()
  109. {
  110.     fseek(Input,0x1c,SEEK_SET);
  111.     fread(&MTEX_Offset,sizeof(unsigned int),1,Input);
  112.     fread(&MMDX_Offset,sizeof(unsigned int),1,Input);
  113.     fread(&MMID_Offset,sizeof(unsigned int),1,Input);
  114.     fread(&MWMO_Offset,sizeof(unsigned int),1,Input);
  115.     fread(&MWID_Offset,sizeof(unsigned int),1,Input);
  116.     fread(&MDDF_Offset,sizeof(unsigned int),1,Input);
  117.     fread(&MODF_Offset,sizeof(unsigned int),1,Input);
  118. }
  119.  
  120. short Map[256];
  121.  
  122. void LoadMTEX()
  123. {
  124.     unsigned int TexSize;
  125.     fseek(Input,0x14+0x04+MTEX_Offset,SEEK_SET);
  126.     fread(&TexSize,sizeof(int),1,Input);
  127.     Textures=new char[TexSize];
  128.     fread(Textures,sizeof(char),TexSize,Input);
  129.  
  130.     for(int i=0;i<TexSize-1;i++)
  131.         if (Textures[i]==0)
  132.             Textures[i]='\n';
  133. }
  134.  
  135. void LoadMDXs()
  136. {
  137.     unsigned int temp;
  138.     fseek(Input,0x14+0x04+MMDX_Offset,SEEK_SET);
  139.     fread(&temp,sizeof(int),1,Input);
  140.     MDXFiles=new char[temp];
  141.  
  142.     fread(MDXFiles,sizeof(char),temp,Input);
  143.  
  144.     fseek(Input,0x14+0x04+MMID_Offset,SEEK_SET);
  145.     fread(&temp,sizeof(int),1,Input);
  146.     diffMDXs=temp/4;
  147.     MDXOffsets=new int[diffMDXs];
  148.     fread(MDXOffsets,sizeof(int),diffMDXs,Input);
  149.  
  150.  
  151.     fseek(Input,0x14+0x04+MDDF_Offset,SEEK_SET);
  152.     fread(&NumDDFs,sizeof(unsigned int),1,Input);
  153.  
  154.     NumDDFs=NumDDFs/sizeof(DDF);
  155.     DDFs=new DDF[NumDDFs];
  156.     fread(DDFs,sizeof(DDF),NumDDFs,Input); 
  157. }
  158.  
  159.  
  160. void LoadWMOs()
  161. {
  162.     unsigned int temp;
  163.     fseek(Input,0x14+0x04+MWMO_Offset,SEEK_SET);
  164.     fread(&temp,sizeof(int),1,Input);
  165.     WMOFiles=new char[temp];
  166.  
  167.     fread(WMOFiles,sizeof(char),temp,Input);
  168.  
  169.     fseek(Input,0x14+0x04+MWID_Offset,SEEK_SET);
  170.     fread(&temp,sizeof(int),1,Input);
  171.     diffWMOs=temp/4;
  172.     WMOOffsets=new int[diffWMOs];
  173.     fread(WMOOffsets,sizeof(int),diffWMOs,Input);
  174.  
  175.  
  176.     fseek(Input,0x14+0x04+MODF_Offset,SEEK_SET);
  177.     fread(&NumWMOs,sizeof(unsigned int),1,Input);
  178.  
  179.     NumWMOs=NumWMOs/64;
  180.     WMOs=new WMO[NumWMOs];
  181.     fread(WMOs,sizeof(WMO),NumWMOs,Input); 
  182. }
  183.  
  184. int main(int argc, char **argv)
  185. {
  186.     int i;
  187.     char *replace;
  188.     if(argc<2)
  189.     {
  190.         printf("fileinfo <adt file>\n");
  191.         return 0;
  192.     }
  193.     printf("Extracting Info From File %s\n",argv[1]);
  194.     Input=fopen(argv[1],"rb");
  195.     if(Input==0)
  196.     {
  197.         printf("ERROR: Could not open %s\n",argv[1]);
  198.         return 0;
  199.     }
  200.     printf("Finding MDDF's & MODF's\n");
  201.     FindMDDFandMODF();
  202.     printf("Loading MTEX\n");
  203.     LoadMTEX();
  204.     printf("Loading MDX\n");
  205.     LoadMDXs();
  206.     printf("Loading WMOs\n");
  207.     LoadWMOs();
  208.     fclose(Input);
  209.     printf("Closing File\n");
  210.  
  211.     replace=strstr(argv[1],"adt");
  212.     replace[0]='t';
  213.     replace[1]='x';
  214.     replace[2]='t';
  215.  
  216.     FILE *Output;
  217.     Output=fopen(argv[1],"wt");
  218.     if(Output==0)
  219.     {
  220.         printf("ERROR: Couldn't open %s for saving\n",argv[1]);
  221.         return 0;
  222.     }
  223.     printf("Writing Info To File %s\n",argv[1]);
  224.     fprintf(Output,"MMDX\t%d\n",diffMDXs); 
  225.     for(i=0;i<diffMDXs;i++)
  226.         fprintf(Output,"%d\t%s\n",i,MDXFiles+MDXOffsets[i]);
  227.  
  228.     fprintf(Output,"\nMWMO\t%d\n",diffWMOs);   
  229.     for(i=0;i<diffWMOs;i++)
  230.         fprintf(Output,"%d\t%s\n",i,WMOFiles+WMOOffsets[i]);
  231.  
  232.     fprintf(Output,"\nMDDF\t%d\n",NumDDFs);
  233.     for(i=0;i<NumDDFs;i++)
  234.         fprintf(Output,"%d\t%d\t%f\t%f\t%f\t%f\t%f\t%f\t%d\n",DDFs[i].ID,DDFs[i].UniqueID,DDFs[i].Pos[0],DDFs[i].Pos[1],DDFs[i].Pos[2],DDFs[i].Rot[0],DDFs[i].Rot[1],DDFs[i].Rot[2],DDFs[i].Scale);
  235.  
  236.     fprintf(Output,"\nMODF\t%d\n",NumWMOs);
  237.     for(i=0;i<NumWMOs;i++)
  238.         fprintf(Output,"%d\t%d\t%f\t%f\t%f\t%f\t%f\t%f\t%f\t%f\t%f\t%f\t%f\t%f\t%d\n",WMOs[i].ID,WMOs[i].UniqueID,WMOs[i].Pos[0],WMOs[i].Pos[1],WMOs[i].Pos[2],WMOs[i].Rot[0],WMOs[i].Rot[1],WMOs[i].Rot[2],WMOs[i].Pos2[0],WMOs[i].Pos2[1],WMOs[i].Pos2[2],WMOs[i].Pos3[0],WMOs[i].Pos3[1],WMOs[i].Pos3[2],WMOs[i].DoodadIndex);
  239.     fclose(Output);
  240. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top