Guest User

DRS file structure

a guest
Apr 8th, 2017
134
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //Definitions
  2. struct CString
  3. {
  4. int Length;
  5. char Text[Length];
  6. };
  7.  
  8. struct Point
  9. {
  10. float X;
  11. float Y;
  12. float Z;
  13. };
  14.  
  15. struct Point4D
  16. {
  17. float X;
  18. float Y;
  19. float Z;
  20. float W;
  21. };
  22.  
  23. struct Point2D
  24. {
  25. float X;
  26. float Y;
  27. };
  28.  
  29. struct Face
  30. {
  31. short Indices[3];
  32. };
  33.  
  34.  
  35. struct CGeoMesh //seems to rebuild the MeshFile, but with fewer vertices (meshfile seems to have each triangle twice anyway)
  36. {
  37. int magic;
  38. int IndexCount;
  39.  
  40. if (IndexCount > 0)
  41. Face Faces[IndexCount/3];
  42.  
  43. int VertexCount;
  44.  
  45. if (VertexCount > 0)
  46. {
  47. Point4D Vertices[VertexCount];
  48. }
  49. };
  50.  
  51. struct CSkSkinInfo
  52. {
  53. int Version;
  54. int VertexCount;
  55.  
  56. struct _VertexWeight
  57. {
  58. float Weights[4];
  59. int BoneIndices[4];
  60. } VertexWeights[VertexCount];
  61. };
  62.  
  63. struct CDspMeshFile
  64. {
  65. int magic;
  66. local int unknown = -1;
  67. local int MeshCount = 0;
  68. if(magic==1314189598){
  69. int tmp <hidden=true>;
  70. unknown = tmp;
  71. int tmp2 <hidden=true>;
  72. MeshCount = tmp2;
  73.  
  74. } else {
  75. MeshCount = magic;
  76. }
  77.  
  78. Point BoundingBoxLowerLeftCorner1;
  79. Point BoundingBoxUpperRightCorner1;
  80.  
  81. struct sthMesh{
  82.  
  83. int VertexCount;
  84. int FaceCount;
  85.  
  86. Face Faces[FaceCount];
  87.  
  88.  
  89. byte MeshCount;
  90.  
  91.  
  92. struct _Mesh
  93. {
  94. int FVF;
  95. int VertexSize;
  96.  
  97. if(FVF == 133121){
  98. struct _Vertex{
  99. Point vertex;
  100. Point vertexNormal;
  101. Point2D vertexTexture;
  102. } Vertex[VertexCount];
  103. } else if(FVF==12288){
  104. struct FVF30{
  105. float uk[6];
  106. } fvf30[VertexCount];
  107.  
  108.  
  109. } else {
  110. Printf( "unknown FVF: 0x%X \n", FVF); // CDspStaticMesh::LoadVertices for further analysis
  111. float VertexData[VertexCount * VertexSize/4] <fgcolor=cRed>;
  112. }
  113.  
  114. } Meshes[MeshCount] <optimize=false>;
  115.  
  116.  
  117. Point BoundingBoxLowerLeftCorner2; //seems like same BB as before
  118. Point BoundingBoxUpperRightCorner2;
  119.  
  120. short materialID;
  121. int materialParameters;
  122. struct TextureParameter {
  123. int Identifier;
  124. CString Name;
  125. int postString;
  126. };
  127.  
  128. struct TextureParameters
  129. {
  130. int Length;
  131. TextureParameter TextureParameters[Length] <optimize=false>;
  132. };
  133.  
  134. struct ColorParameter {
  135. int Identifier;
  136. int R;
  137. int G;
  138. int B;
  139. };
  140.  
  141. struct ColorParameters {
  142. int Length;
  143. ColorParameter colorParameters[Length];
  144. };
  145.  
  146. struct ScalarParameter {
  147. int Identifier;
  148. float Value;
  149. };
  150.  
  151. struct ScalarParameters {
  152. int Length;
  153. ScalarParameter scalarParameters[Length];
  154. };
  155.  
  156. struct IntegerParameter {
  157. int Value;
  158. };
  159.  
  160. struct IntegerParameters {
  161. int Length;
  162. IntegerParameter integerParameters[Length];
  163. };
  164.  
  165. struct StringParameter {
  166. CString Name;
  167. };
  168.  
  169. struct StringParameters
  170. {
  171. int Length;
  172. StringParameter stringParameters[Length] <optimize=false>;
  173. };
  174.  
  175. struct VectorParameter {
  176. int Identifier;
  177. Point4D Value;
  178. };
  179.  
  180. struct VectorParameters {
  181. int Length;
  182. VectorParameter vectorParameters[Length];
  183. };
  184. if(materialParameters == -86061050){
  185.  
  186. int sthOfMaterialCore;
  187. int boolParamTransfer;
  188.  
  189. TextureParameters textureParameters;
  190. ColorParameters colorParameters;
  191. ScalarParameters scalarParameters;
  192. IntegerParameters integerParameters;
  193. StringParameters stringParameters;
  194. VectorParameters vectorParameters;
  195. } else if (materialParameters == -86061051 || materialParameters == -86061052) {
  196. int sthOfMaterialCore;
  197. int boolParamTransfer; //<- boolParamTransfer = ((unsigned int)boolParamTransfer | 1); for 0xFACED0004
  198.  
  199. TextureParameters textureParameters;
  200. ColorParameters colorParameters;
  201. ScalarParameters scalarParameters;
  202. IntegerParameters integerParameters;
  203. StringParameters stringParameters;
  204. } else if (materialParameters == -86061053) {
  205. int boolParamTransfer;
  206.  
  207. TextureParameters textureParameters;
  208. ColorParameters colorParameters;
  209. ScalarParameters scalarParameters;
  210. IntegerParameters integerParameters;
  211. StringParameters stringParameters;
  212. } else if (materialParameters == -86061054) {
  213. int boolParamTransfer;
  214.  
  215. TextureParameters textureParameters;
  216. ColorParameters colorParameters;
  217. ScalarParameters scalarParameters;
  218. IntegerParameters integerParameters;
  219. } else if (materialParameters == -86061055) {
  220. int boolParamTransfer; ////<- boolParamTransfer = ((unsigned int)boolParamTransfer | 1);
  221.  
  222. TextureParameters textureParameters;
  223. ColorParameters colorParameters;
  224. ScalarParameters scalarParameters;
  225. } else {
  226. Printf( "unknown materialParameter: 0x%X \n", materialParameters); //CDspMaterialCore::ReadParameters for more
  227.  
  228. }
  229. } meshes[MeshCount] <optimize=false>;
  230.  
  231. //Otherwise, Point0=(0,0,0,1) UPoint=(1,1,0,0) VPoint=(0,0,1,1)
  232. if(unknown >= 0){
  233. Point4D Point0;
  234. Point4D UPoint;
  235. Point4D VPoint;
  236. }
  237. };
  238.  
  239.  
  240. struct CSkSkeleton
  241. {
  242. int Version;
  243. int Unknown1;
  244.  
  245. int BoneMatrixCount;
  246. struct BoneMatrix
  247. {
  248. struct BoneVertex
  249. {
  250. float X;
  251. float Y;
  252. float Z;
  253. int ParentReference; //parentRef[0] = parent index, parentRef[1] = index into CSkSkeleton.dBone array, used in SKA
  254. } BoneVertices[4];
  255. } BoneMatrices[BoneMatrixCount];
  256.  
  257. int BoneCount;
  258. struct Bone
  259. {
  260. int Version;
  261.  
  262. int Identifier;
  263. CString Name;
  264.  
  265. int ChildCount;
  266. if (ChildCount > 0)
  267. int Children[ChildCount];
  268. } Bones[BoneCount] <optimize=false>;
  269.  
  270. float Unknown2[16];
  271. };
  272.  
  273. struct CDspJointMap
  274. {
  275. int Version;
  276. int JointGroupCount;
  277.  
  278. if (JointGroupCount > 0)
  279. {
  280. struct _JointGroup
  281. {
  282. int JointCount;
  283. if (JointCount > 0)
  284. short JointIndices[JointCount];
  285. } JointGroups[JointGroupCount] <optimize=false>;
  286. }
  287. };
  288.  
  289. struct AnimationSet
  290. {
  291. CString Magic;
  292. if (Strcmp(Magic.Text, "Battleforge") != 0) Printf("\nerror bad magic AnimSet\n");
  293. int Count; //Should be <= 6
  294. if(Count>6) Printf("\nerror count >6\n");
  295.  
  296. float Unknown1;
  297. float Unknown2;
  298. int Version;
  299.  
  300. if (Count >= 6) //> should not happen -> Count == 6
  301. {
  302. if (Version >= 2)
  303. {
  304. byte Unknown4;
  305. byte Unknown5;
  306. }
  307.  
  308. if (Version >= 5)
  309. {
  310. float Unknown6;
  311. float Unknown7;
  312. float Unknown8;
  313. }
  314.  
  315. if (Version >= 6)
  316. byte Unknown9;
  317. }
  318.  
  319. int ModeAnimationKeyCount;
  320.  
  321. struct _ModeAnimationKey
  322. {
  323. int Type;
  324. CString Magic2;
  325. int Unknown11;
  326.  
  327. if (Type == 1)
  328. {
  329. int Unknown12;
  330. short Unknown13;
  331. int Unknown14;
  332. byte Unknown15;
  333. int Unknown16;
  334. int Unknown17;
  335. int Unknown18;
  336. byte Unknown19;
  337. }
  338. else if (Type == 2 || Type == 3 || Type == 4 || Type == 5)
  339. {
  340. int Unknown20;
  341. short Unknown21;
  342. }
  343. else if (Type == 6)
  344. {
  345. int Unknown22;
  346. short Unknown23;
  347. int Unknown24;
  348. short Unknown24;
  349. } else Printf("\n uk modeAnimType %d\n",Type);
  350.  
  351. int UnknownLength;
  352.  
  353. struct _UnknownStructure
  354. {
  355. int Unknown25;
  356. int Unknown26;
  357. CString Unknown27;
  358.  
  359. if (Unknown25 >= 4)
  360. {
  361. int Unknown28;
  362. int Unknown29;
  363. }
  364.  
  365. if (Unknown25 >= 5)
  366. {
  367. byte Unknown30;
  368. }
  369.  
  370. if (Unknown25 >= 7)
  371. {
  372. byte Unknown31;
  373. }
  374. } Unknowns[UnknownLength] <optimize=false>;
  375. } AnimationKeys[ModeAnimationKeyCount] <optimize=false>;
  376.  
  377.  
  378. if (Count >= 3)
  379. {
  380. short Unknown32;
  381.  
  382. if (Unknown32 >= 1)
  383. {
  384. int len;
  385.  
  386. struct UnknownStruct123{
  387. int uk123;
  388.  
  389. short uk124;
  390. if(uk124>=1){
  391.  
  392. int uk125;
  393. int uk126;
  394.  
  395. struct UKStruct1234{
  396. short uk1234;
  397. if(uk1234==1){
  398. int uk1236[5];
  399. }
  400. } uk1234[3] <optimize=false>;
  401. }
  402. if(uk124>=2){
  403. short uk127;
  404. }
  405.  
  406. } unknown123[len] <optimize=false>;
  407.  
  408.  
  409.  
  410.  
  411. }
  412.  
  413. if (Unknown32 >= 2)
  414. {
  415. int len1;
  416. struct _UnknownStruct2
  417. {
  418. int Unknown36;
  419. int Unknown37;
  420. int Unknown38;
  421. } Unknowns2[len1];
  422. }
  423. }
  424.  
  425.  
  426. if (Count >= 4)
  427. {
  428. short Unknown39;
  429. if (Unknown39 == 2)
  430. {
  431. int Unknown40;
  432.  
  433. struct _UnknownStruct3
  434. {
  435. int Unknown41;
  436. CString Unknown42;
  437. int Unknown43;
  438. int Unknown44;
  439.  
  440. struct _UnknownStruct4
  441. {
  442. int Unknown45;
  443. int Unknown46;
  444. int Unknown47;
  445. int Unknown48;
  446.  
  447. int Unknown49;
  448. int Unknown50;
  449. int Unknown51;
  450. int Unknown52;
  451. } Unknowns4[Unknown44];
  452. } Unknowns3[Unknown40] <optimize=false>;
  453. }
  454. else if (Unknown39 == 1)
  455. {
  456. int Unknown53;
  457.  
  458. struct _UnknownStruct5
  459. {
  460. int Unknown54;
  461. CString Unknown55;
  462. int Unknown56;
  463. int Unknown57;
  464.  
  465. struct _UnknownStruct6
  466. {
  467. int Unknown58;
  468. int Unknown59;
  469. int Unknown60;
  470. int Unknown61;
  471. int Unknown62;
  472. } Unknowns6[Unknown57];
  473. } Unknowns5[Unknown53] <optimize=false>;
  474. }
  475. }
  476. };
  477.  
  478.  
  479.  
  480. struct AnimationTimings{
  481. int magic;
  482.  
  483. if(magic==1650881127){
  484. short version;
  485.  
  486.  
  487. struct Time{
  488. short len;
  489. struct Sth8{
  490. int uk;
  491. if(version==4 || version == 2 || version == 3){
  492. int uk2;
  493. short uk;
  494. }
  495. short len2;
  496.  
  497. struct Sth9{
  498. byte uk;
  499. if(version==4) byte uk2;
  500. short len3;
  501. struct Sth10{
  502. int uk[6];
  503. } sth10[len3] <optimize=false>;
  504. } sth9[len2] <optimize=false>;
  505. } sth8[len] <optimize=false>;
  506. } time <optimize=false>;
  507.  
  508.  
  509. if(version==3 || version==4) {
  510. struct TimeV3{
  511. int len;
  512. struct Sth7{
  513. int uk[2];
  514. } sth7[len];
  515. } time3 <optimize=false>;
  516. }
  517. } else Printf("\nbad animTimings magic\n");
  518.  
  519. };
  520.  
  521.  
  522. struct DrwResourceMeta {
  523. int uk[2];
  524. CString uk;
  525. };
  526.  
  527.  
  528. struct SthSound{
  529. byte sthSoundFile;
  530. short uk;
  531. int uk1[5];
  532. CString uk2;
  533. };
  534.  
  535. struct EffectSet{
  536. short type;
  537. CString checksum;
  538.  
  539. if(type == 10 || type == 11 || type == 12){
  540. if(type==10) byte uk[20];
  541. int len;
  542.  
  543. struct skelEff{
  544. CString skelFileName;
  545. int len1;
  546. struct WavHolder{
  547. int uk2[2];
  548. float one;
  549. int uk3[7];
  550. if(type>=12) byte uk4;
  551. byte FF;
  552. int len2;
  553. struct Wav{
  554. byte id;
  555. CString wavFileName;
  556. } wav[len2] <optimize=false>;
  557. } wavHolder[len1] <optimize=false>;
  558. } skelEffekts[len] <optimize=false>;
  559.  
  560. short len4;
  561. struct Uks3{
  562. short uk1;
  563. int uk2[5];
  564. short uk3;
  565. short len6;
  566. SthSound sthSound2[len6] <optimize=false>;
  567. } uks3[len4] <optimize=false>;
  568.  
  569.  
  570.  
  571.  
  572. short len3;
  573. struct Uks1{
  574. short uk;
  575. int uk1[5];
  576. short uk2;
  577. short len4;
  578. struct Uks2{
  579. short uk;
  580. int uk1[5];
  581. short uk2;
  582. short len5;
  583. SthSound sthSound[len5];
  584. } uks2[len4] <optimize=false>;
  585. } uks1[len3] <optimize=false>;
  586.  
  587.  
  588.  
  589. } else if(type == 7 || type == 8 || type == 9){//needs testing, no file with this type found
  590. Printf("\nwarning, untested code");
  591. short len6;
  592. struct Uks4{
  593. short uk;
  594. short len7;
  595. SthSound sthSound3[len7];
  596. } uks4[len6] <optimize=false>;
  597.  
  598. short len8;
  599. struct Uks5{
  600. short uk1;
  601. short len9;
  602. SthSound sthSound4[len9];
  603. } uks5[len8] <optimize=false>;
  604.  
  605.  
  606.  
  607. }
  608.  
  609. };
  610.  
  611. struct CDrwLocatorList{
  612. int uk;
  613. int version;
  614. if(version==4){
  615. int len;
  616. struct UK2{
  617. int uk1[12];
  618. int uk3[2];
  619. CString str2;
  620. } uk2[len] <optimize=false>;
  621. } else if(version==5){
  622. int len;
  623. struct Uk1{
  624. int uk1[12];
  625. int uk2[2];
  626. CString str;
  627. int uk3;
  628. } uk1[len] <optimize=false>;
  629.  
  630. } else Printf("\nnot implemented locator list version %d\n",version);
  631. };
  632.  
  633. struct CGeoOBBTree{
  634. int magic;
  635. if(magic==1845540702){
  636. int id;
  637. if(id==1){
  638. byte uk[4096];
  639. } else if(id==2){
  640. byte uk[4096];
  641. int len1;
  642. struct Uks123{
  643. int64 uk1;
  644. short uk2[3];
  645. short uk3;
  646. } uks123[len1];
  647. } else if(id==3){
  648. int len2;
  649. float asd[len2*64/4];
  650. int len3;
  651. short uk6[len3*3];
  652.  
  653.  
  654. }
  655.  
  656. } else Printf("\n invalid obb tree file\n");
  657.  
  658.  
  659. };
  660.  
  661.  
  662. local string filter = "*";
  663.  
  664. //Structure
  665. int Magic <fgcolor=cBlue>; //0xC57CF11E
  666. if(Magic==-981667554){
  667. int NumberOfModels <fgcolor=cBlue>; //Must be 1; confirmed everywhere 1
  668.  
  669. int NodeInformationOffset <fgcolor=cBlue>;
  670. int NodeHierarchyOffset <fgcolor=cBlue>;
  671. uint NodeCount <fgcolor=cBlue>; //Node count
  672.  
  673. if (NodeCount != 0)
  674. {
  675. FSeek(NodeInformationOffset);
  676.  
  677. struct _RootNodeInfo{
  678. byte zeros[16]; //confirmed zero
  679. int negOne <format=hex>; //confirmed
  680. int one;//confirmed
  681. int uk2;
  682. int zero;//confirmed zero
  683. } RootNodeInfo <fgcolor=cBlue>;
  684.  
  685. struct _NodeInformation
  686. {
  687. int magic;
  688. int Identifier;
  689. int Offset;
  690. int Size;
  691. byte uk[16]; // set to 0 didnt break anything
  692. } NodeInformation[NodeCount-1] <fgcolor=cBlue>;
  693.  
  694.  
  695. FSeek(NodeHierarchyOffset);
  696.  
  697. struct _RootNode
  698. {
  699. int RootIdentifier;
  700. int Unknown;
  701. CString rootName;
  702. } RootNode <fgcolor=cBlue>;
  703.  
  704. local int i = 1;
  705. struct _Node
  706. {
  707. local int NodeIndex = i;
  708. int InfoIndex;
  709. CString Name;
  710. int Unknown; //ChildCount?
  711.  
  712. local int j;
  713. local int64 oldPosition;
  714. for (j = NodeCount-2; j >= 0; j--)
  715. {
  716. if (NodeInformation[j].Identifier != NodeIndex)
  717. continue;
  718.  
  719. oldPosition = FTell();
  720. FSeek(NodeInformation[j].Offset);
  721. if (NodeInformation[j].Size > 0) //CGeoPrimitiveContainer always has size 0
  722. {
  723. if(Strcmp(Name.Text,filter)==0 || Strcmp("*",filter)==0){
  724. if (Strcmp(Name.Text, "CGeoMesh") == 0)
  725. CGeoMesh Mesh;
  726. else if (Strcmp(Name.Text, "CDspJointMap") == 0)
  727. CDspJointMap JointMap;
  728. else if (Strcmp(Name.Text, "CSkSkinInfo") == 0)
  729. CSkSkinInfo SkinInfo;
  730. else if (Strcmp(Name.Text, "CSkSkeleton") == 0)
  731. CSkSkeleton Skeleton;
  732. else if (Strcmp(Name.Text, "CDspMeshFile") == 0)
  733. CDspMeshFile MeshFile;
  734. else if (Strcmp(Name.Text, "AnimationSet") == 0)
  735. AnimationSet AnimationsSet;
  736. else if (Strcmp(Name.Text, "AnimationTimings") == 0)
  737. AnimationTimings animationTimings;
  738. else if (Strcmp(Name.Text, "DrwResourceMeta") == 0)
  739. DrwResourceMeta drwResourceMeta;
  740. else if (Strcmp(Name.Text, "EffectSet") == 0)
  741. EffectSet effectSet;
  742. else if (Strcmp(Name.Text, "CDrwLocatorList") == 0)
  743. CDrwLocatorList locList;
  744. else if (Strcmp(Name.Text, "CGeoOBBTree") == 0)
  745. CGeoOBBTree obbTree;
  746. else {
  747. Printf("\nunknown Node Name %s \n",Name.Text);
  748. byte Data[NodeInformation[j].Size];
  749. }
  750. }
  751. }
  752. FSeek(oldPosition);
  753. break;
  754. }
  755.  
  756. i = i + 1;
  757. } Nodes[NodeCount-1] <optimize=false, fgcolor=cBlue>;
  758. }
  759. //Printf("\n");
  760. } else Printf("\n unknown drs magic");
RAW Paste Data