public void Read(string fname) { FileData d = new FileData(fname); d.Endian = System.IO.Endianness.Little; d.skip(4); // RIFF int riffsize = d.readInt(); d.skip(4); //WAVE d.skip(4); //fmt int formatsize = d.readInt(); int audio_format = d.readShort(); int channelCount = d.readShort(); int sampleRate = d.readInt(); int byte_rate = d.readInt(); int blockalign = d.readShort(); int bps = d.readShort(); d.skip(4); // data int datasize = d.readInt(); byte[] data = d.getSection(d.pos(), datasize); Play(data, channelCount, bps, sampleRate); }
public void read(FileData f) { f.skip(0xD); name = f.readString(f.pos(), 0x38); f.skip(0x38); f.skip(1);//Seperation char subname = f.readString(f.pos(), 0x40); f.skip(0xAC); int sectionCount = f.readInt(); for (int i = 0; i < sectionCount; i++) { f.skip(0x18);// unknown data Section temp = new Section(); temp.points = new List <Vector2D>(); int vertCount = f.readInt(); for (int j = 0; j < vertCount; j++) { f.skip(1);//Seperation char Vector2D point = new Vector2D(); point.x = f.readFloat(); point.y = f.readFloat(); temp.points.Add(point); } sections.Add(temp); } }
public void read(FileData f) { base.read(f); f.readByte(); type = f.readInt(); //3 = rect, 4 = path if ((type != 3) && (type != 4)) { throw new NotImplementedException($"Unknown general shape type {type} at offset {f.pos()-4}"); } x1 = f.readFloat(); y1 = f.readFloat(); x2 = f.readFloat(); y2 = f.readFloat(); f.skip(1); f.skip(1); int pointCount = f.readInt(); for (int i = 0; i < pointCount; i++) { f.skip(1); points.Add(new Vector2D() { x = f.readFloat(), y = f.readFloat() }); } }
public void read(FileData f) { int nameOff = f.readInt(); unknown = f.readInt(); valueCount = f.readInt(); int frameCount = f.readInt(); unknown2 = f.readShort(); unknown3 = f.readShort(); int dataOff = f.readInt(); f.seek(nameOff); name = f.readString(); f.seek(dataOff); for (int i = 0; i < frameCount; i++) { frame temp = new frame(); //temp.size = valueCount; temp.values = new float[valueCount]; for (int j = 0; j < valueCount; j++) { temp.values[j] = f.readFloat(); } frames.Add(temp); } }
public void read(FileData f) { int nameOff = f.readInt(); unk1 = (f.readInt() != 0); int dataOff = f.readInt(); f.seek(nameOff); name = f.readString(); f.seek(dataOff); frameCount = f.readInt(); unk2 = (f.readShort() != 0); short keyframeCount = (short)f.readShort(); int keyframeOffset = f.readInt(); f.seek(keyframeOffset); frame tempFrame; for (int i = 0; i < keyframeCount; i++) { tempFrame.frameNum = (short)f.readShort(); tempFrame.state = (byte)f.readByte(); tempFrame.unknown = (byte)f.readByte(); frames.Add(tempFrame); tempFrame = new frame(); } }
public void Read(FileData f) { AtlasId = f.readInt(); FillType = (FillType)f.readShort(); int numVerts = f.readShort(); int numIndices = f.readInt(); Verts = new Vertex[numVerts]; Indices = new ushort[numIndices]; for (int i = 0; i < numVerts; i++) { Verts[i] = new Vertex(); Verts[i].X = f.readFloat(); Verts[i].Y = f.readFloat(); Verts[i].U = f.readFloat(); Verts[i].V = f.readFloat(); } for (int i = 0; i < numIndices; i++) { Indices[i] = (ushort)f.readShort(); } // indices are padded to word boundaries if ((numIndices % 2) != 0) { f.skip(0x02); } }
public void ReadParameters(FileData f, int count) { for (int i = 0; i < count; i++) { BCH_TextureParameter p = new BCH_TextureParameter() { Value = f.readInt() }; p.ParseParameter(f.readInt()); Nodes.Add(p); if (p.Id == BCH_TextureParameter.Parameter.texUnit0Size) { Width = p.GetHalf1(); Height = p.GetHalf2(); } if (p.Id == BCH_TextureParameter.Parameter.texUnit0Type) { type = p.Value; } if (p.Id == BCH_TextureParameter.Parameter.texUnit0Address) { data = f.getSection(p.Value, f.size() - p.Value); } } if (Width > 0 && Height > 0) { texture = _3DS.DecodeImage(data, Width, Height, (_3DS.Tex_Formats)type); //Texture glTex = new Texture2D(texture); //display = glTex.Id; } }
// Loading Mat private void button2_Click(object sender, EventArgs e) { MaterialSelector m = new MaterialSelector(); m.ShowDialog(); if (m.exitStatus == MaterialSelector.Opened) { FileData f = new FileData(m.path); int soff = f.readInt(); NUD._s_Poly pol = new NUD._s_Poly() { texprop1 = f.readInt(), texprop2 = f.readInt(), texprop3 = f.readInt(), texprop4 = f.readInt() }; int texid = poly.materials[0].textures[0].hash; poly.materials = NUD.readMaterial(f, pol, soff); poly.materials[0].textures[0].hash = texid; material = poly.materials; Console.WriteLine(material.Count); current = 0; Init(); FillForm(); } /*using (var ofd = new OpenFileDialog()) * { * ofd.Filter = "Namco Material (NMT)|*.nmt|" + * "All files(*.*)|*.*"; * * if (ofd.ShowDialog() == DialogResult.OK) * { * if (ofd.FileName.EndsWith(".nmt")) * { * FileData f = new FileData(ofd.FileName); * * int soff = f.readInt(); * * NUD._s_Poly pol = new NUD._s_Poly() * { * texprop1 = f.readInt(), * texprop2 = f.readInt(), * texprop3 = f.readInt(), * texprop4 = f.readInt() * }; * * poly.materials = NUD.readMaterial(f, pol, soff); * material = poly.materials; * Console.WriteLine(material.Count); * current = 0; * Init(); * FillForm(); * } * } * }*/ }
// Loading Mat private void loadPresetButton_Click(object sender, EventArgs e) { MaterialSelector matSelector = new MaterialSelector(); matSelector.ShowDialog(); if (matSelector.exitStatus == MaterialSelector.Opened) { FileData matFile = new FileData(matSelector.path); int soff = matFile.readInt(); NUD.PolyData pol = new NUD.PolyData() { texprop1 = matFile.readInt(), texprop2 = matFile.readInt(), texprop3 = matFile.readInt(), texprop4 = matFile.readInt() }; // Store the original material to preserve Tex IDs. NUD.Material original = currentPolygon.materials[0].Clone(); currentPolygon.materials = NUD.ReadMaterials(matFile, pol, soff); // Copy the old Tex IDs. currentPolygon.materials[0].CopyTextureIds(original); currentMaterialList = currentPolygon.materials; currentMatIndex = 0; Init(); FillForm(); } }
public void Read(FileData f) { type = f.readInt(); format = f.readInt(); scale = f.readFloat(); Text = ((_3DSGPU.VertexAttribute)type).ToString() + "_" + format; }
public void Read(FileData file) { file.Endian = Endianness.Little; file.skip(0x4); unk1 = file.readShort(); unk2 = file.readShort(); int sequenceCount = file.readInt(); int sequenceDataOffset = file.readInt(); List <int> sequenceOffsets = new List <int>(); for (int i = 0; i < sequenceCount; ++i) { sequenceOffsets.Add(file.readInt()); } sequences = new List <SoundSequence>(); for (int i = 0; i < sequenceCount; ++i) { if (sequenceOffsets[i] == -1) { sequences.Add(new SoundSequence() { empty = true }); continue; } file.seek(0x10 + sequenceDataOffset + sequenceOffsets[i]); sequences.Add(new SoundSequence(file)); } }
public void Read(FileData d) { names.Clear(); d.skip(8);// magic and section size int c1 = d.readInt(); int start = d.pos(); for (int i = 0; i < c1; i++) { int offset = d.readInt(); int size = d.readInt(); int temp = d.pos(); d.seek(start + offset); d.readInt(); int s = (sbyte)d.readByte(); names.Add(d.readString(d.pos(), -1)); d.skip(s); d.align(4); d.seek(temp); } }
public override void Read(string filename) { FileData d = new FileData(filename); d.Endian = Endianness.Little; if (d.Magic().Equals("3SUN")) { throw new Exception("Not a valid nus3bank"); } d.seek(4); int filesize = d.readInt(); d.skip(8); // BANKTOC int headerSize = 0x14 + d.readInt(); int secCount = d.readInt(); for (int i = 0; i < secCount; i++) { string magic = d.readString(d.pos(), 4); d.skip(4); int size = d.readInt(); int temp = d.pos(); d.seek(headerSize); Console.WriteLine(magic + " " + d.pos().ToString("x")); if (magic.Equals("PROP")) { prop.Read(d); } if (magic.Equals("BINF")) { binf.Read(d); } if (magic.Equals("GRP ")) { grp.Read(d); } if (magic.Equals("DTON")) { dton.Read(d); } if (magic.Equals("TONE")) { tone.Read(d); } if (magic.Equals("PACK")) { tone.ReadPACK(d); } headerSize += size + 8; d.seek(temp); } }
public void Read(FileData d) { hash = d.readInt(); unk1 = d.readInt(); int s = d.readByte(); name = d.readString(d.pos(), -1); d.skip(s); d.align(4); d.skip(8); offset = d.readInt(); size = d.readInt(); for (int i = 0; i < param.Length; i++) { param[i] = d.readFloat(); } offsets = new int[d.readInt()]; for (int i = 0; i < offsets.Length; i++) { offsets[i] = d.readInt(); } unkvalues = new float[d.readInt()]; for (int i = 0; i < unkvalues.Length; i++) { unkvalues[d.readInt()] = d.readFloat(); } List <int> une = new List <int>(); while (true) { int i = d.readInt(); une.Add(i); if (i == -1) { break; } } unkending = une.ToArray(); end = new int[3 + (int)Math.Ceiling((double)((unk1 >> 8) & 0xFF) / 4)]; for (int i = 0; i < end.Length; i++) { end[i] = d.readInt(); } //Console.WriteLine(id + " " + name + " " + offset.ToString("x")); }
public void read(FileData f) { base.read(f); flag1 = Convert.ToBoolean(f.readByte()); flag2 = Convert.ToBoolean(f.readByte()); flag3 = Convert.ToBoolean(f.readByte()); flag4 = Convert.ToBoolean(f.readByte()); f.skip(1); int vertCount = f.readInt(); for (int i = 0; i < vertCount; i++) { f.skip(1); Vector2D temp = new Vector2D(); temp.x = f.readFloat(); temp.y = f.readFloat(); verts.Add(temp); } f.skip(1); int normalCount = f.readInt(); for (int i = 0; i < normalCount; i++) { f.skip(1); Vector2D temp = new Vector2D(); temp.x = f.readFloat(); temp.y = f.readFloat(); normals.Add(temp); } f.skip(1); int cliffCount = f.readInt(); for (int i = 0; i < cliffCount; i++) { CollisionCliff temp = new CollisionCliff(); temp.read(f); cliffs.Add(temp); } f.skip(1); int materialCount = f.readInt(); for (int i = 0; i < materialCount; i++) { f.skip(1); CollisionMat temp = new CollisionMat(); temp.material = f.read(0xC);//Temporary, will work on fleshing out material more later materials.Add(temp); } }
public void Read(FileData d) { d.Endian = Endianness.Big; d.seek(0x16); int count = d.readShort(); d.seek(0x60); for (int i = 0; i < count; i++) { string name = d.readString(d.pos(), -1); d.skip(0x40); int unk = d.readInt(); int nextFile = d.readInt(); int c2 = d.readShort(); int c1 = d.readShort(); d.skip(4); // padding? int[] partsizes = new int[4]; for (int j = 0; j < 4; j++) { partsizes[j] = d.readInt(); } TreeNode part = new TreeNode(); part.Text = name; Nodes.Add(part); int off = 0; for (int j = 0; j < c1; j++) { TreeNode t = new TreeNode(); part.Nodes.Add(t); int decompressedSize = d.readInt(); byte[] dat = FileData.InflateZLIB(d.getSection(d.pos(), partsizes[j] - 4 - off)); d.skip(partsizes[j] - 4); off += partsizes[j]; string mag = new FileData(dat).Magic(); t.Text = name + "." + mag; if (mag.Equals("NTWD")) { Runtime.TextureContainers.Add(new NUT(new FileData(dat))); } if (mag.Equals("OMO ")) { Runtime.Animations.Add(t.Text, OMOOld.read(new FileData(dat))); MainForm.Instance.animList.treeView1.Nodes.Add(t.Text); } } } }
public void Read(FileData d) { d.skip(12); unk1 = d.readInt(); int s = d.readByte(); name = d.readString(d.pos(), s - 1); d.skip(s); d.align(4); flag = d.readInt(); }
public SARC(String FileName) { FileData f = new FileData(FileName); f.skip(4); // magic check f.skip(2); // headerlength if (f.readShort() == 0xFEFF) { f.Endian = Endianness.Big; } else { f.Endian = Endianness.Little; } f.skip(4); // filesize int dataOffset = f.readInt(); f.skip(4); // always 0x01000000 // SFAT Header f.skip(4); // SFAT f.skip(2); // header size int nodeCount = f.readShort(); f.skip(4); // hash multiplyer always 0x65 // before nodes get strings int stringoff = f.pos() + 16 * nodeCount + 8; // nodes for (int i = 0; i < nodeCount; i++) { uint hash = (uint)f.readInt(); byte flag = (byte)f.readByte(); string name = f.readString(stringoff + f.readThree() * 4, -1); int nodeStart = f.readInt(); int size = f.readInt() - nodeStart; byte[] data = f.getSection(nodeStart + dataOffset, size); // Nodes.Add(name); FileData d = new FileData(data); int Magic = d.readInt(); if (Magic == 0x46524563) { Console.WriteLine(name); } } }
public ATKD Read(FileData f) { f.skip(4); int entryCount = f.readInt(); commonSubactions = (uint)f.readInt(); uniqueSubactions = (uint)f.readInt(); for (int i = 0; i < entryCount; i++) { entries.Add(new Entry().Read(f)); } return(this); }
public ATKD Read(FileData f) { f.skip(4); int entryCount = f.readInt(); unknown1 = (uint)f.readInt(); unknown2 = (uint)f.readInt(); for (int i = 0; i < entryCount; i++) { entries.Add((new Entry()).Read(f)); } return(this); }
public void read(FileData f) { f.skip(0x2); //x01 03 type = f.readInt(); //First set of sections = type 1, second set = type 3. No difference in structure but type 3 seems to have non-zero for z and unk x = f.readFloat(); y = f.readFloat(); z = f.readFloat(); //0 unless type 3 unk = f.readFloat(); //0 unless type 3 f.skip(0x2); //x01 01 f.readInt(); //Only seen this as 0, probably a count }
public void ReadBNTX(FileData f) { textures.Clear(); BFRES b = new BFRES(); temp = f.pos(); f.skip(8); //Magic int Version = f.readInt(); int ByteOrderMark = f.readShort(); int FormatRevision = f.readShort(); Text = f.readString(f.readInt() + temp, -1); f.skip(2); int strOffset = f.readShort(); int relocOffset = f.readInt(); int FileSize = f.readInt(); f.skip(4); //NX Magic int TexturesCount = f.readInt(); int InfoPtrsOffset = f.readInt(); int DataBlockOffset = f.readInt(); int DictOffset = f.readInt(); int strDictSize = f.readInt(); Text = Text + ".bntx"; BNTXFile = f.getSection(temp, FileSize); for (int i = 0; i < TexturesCount; i++) { f.seek(InfoPtrsOffset + temp + i * 8); BRTIOffset = f.readInt(); f.seek(BRTIOffset + temp); // textures.Add(new BRTI(f)); BRTI texture = new BRTI(f); if (!textured.ContainsKey(texture.Text)) { textured.Add(texture.Text, texture); } textures.Add(texture); } Nodes.AddRange(textures.ToArray()); }
public void Read(FileData f) { CharacterId = f.readInt(); PlacementId = f.readInt(); Unk1 = f.readInt(); NameId = f.readInt(); Flags = (PlaceFlag)f.readShort(); BlendMode = (BlendMode)f.readShort(); Depth = f.readShort(); Unk4 = f.readShort(); Unk5 = f.readShort(); Unk6 = f.readShort(); PositionFlags = (ushort)f.readShort(); PositionId = f.readShort(); ColorMultId = f.readInt(); ColorAddId = f.readInt(); bool hasColorMatrix = (f.readInt() == 1); bool hasUnkF014 = (f.readInt() == 1); if (hasColorMatrix) { ColorMatrix = new UnhandledTag(f); } if (hasUnkF014) { UnkF014 = new UnhandledTag(f); } }
public void Read(FileData f) { f.Endian = endianess; if (f.size() < 4) { return; } int entryCount = f.readInt(); int otherCount = f.readInt(); int startOffset = f.readInt(); int unk = f.readInt(); //0x20 - Entry size? int unk2 = f.readInt(); //0x8? - values per entry? int unk3 = f.readInt(); //0x30? - start offset again? int otherStartOffset = f.readInt(); if (unk != 0x20 || unk2 != 0x8 || unk3 != 0x30) { throw new Exception("Unexpected Unkowns Please Report to Jam"); } f.seek(startOffset); for (int i = 0; i < entryCount; i++) { Entry temp = new Entry(); temp.values = new int[8]; for (int j = 0; j < 8; j++) { temp.values[j] = f.readInt(); } int returnOffset = f.pos(); f.seek(temp.values[0]); temp.name = f.readString(); f.seek(returnOffset); entries.Add(temp); } f.seek(otherStartOffset); for (int i = 0; i < otherCount; i++) { Entry temp = new Entry(); temp.values = new int[2]; for (int j = 0; j < 2; j++) { temp.values[j] = f.readInt(); } int returnOffset = f.pos(); f.seek(temp.values[0]); temp.name = f.readString(); f.seek(returnOffset); otherEntries.Add(temp); } }
public override void Read(string filename) { FileData buf = new FileData(filename); buf.Endian = Endianness.Little; buf.seek(0x06); short numAtlases = buf.readShort(); short numTextures = buf.readShort(); short flagsOffset = buf.readShort(); short entriesOffset = buf.readShort(); short stringsOffset = buf.readShort(); buf.seek(flagsOffset); for (int i = 0; i < numAtlases; i++) { atlases.Add((AtlasFlag)buf.readInt()); } buf.seek(entriesOffset); for (int i = 0; i < numTextures; i++) { Texture entry = new Texture(); int nameOffset = buf.readInt(); int nameOffset2 = buf.readInt(); // I have yet to see this. if (nameOffset != nameOffset2) { throw new NotImplementedException("texlist name offsets don't match?"); } buf.seek(stringsOffset + nameOffset); entry.name = buf.readString(); entry.topLeft = new Vector2(buf.readFloat(), buf.readFloat()); entry.botRight = new Vector2(buf.readFloat(), buf.readFloat()); entry.width = buf.readShort(); entry.height = buf.readShort(); entry.atlasId = buf.readShort(); textures.Add(entry); buf.skip(0x02); // Padding. } }
public override void Read(string filename) { FileData file = new FileData(filename); if (file != null) { file.Endian = Endianness.Little; Endian = Endianness.Little; string magic = file.readString(0, 4); if (magic == "VBN ") { file.Endian = Endianness.Big; Endian = Endianness.Big; } file.seek(4); unk_1 = (short)file.readShort(); unk_2 = (short)file.readShort(); totalBoneCount = (UInt32)file.readInt(); boneCountPerType[0] = (UInt32)file.readInt(); boneCountPerType[1] = (UInt32)file.readInt(); boneCountPerType[2] = (UInt32)file.readInt(); boneCountPerType[3] = (UInt32)file.readInt(); for (int i = 0; i < totalBoneCount; i++) { Bone temp = new Bone(this); temp.boneName = file.readString(file.pos(), -1).ToCharArray(); file.skip(64); temp.boneType = (UInt32)file.readInt(); temp.parentIndex = file.readInt(); temp.boneId = (UInt32)file.readInt(); temp.position = new float[3]; temp.rotation = new float[3]; temp.scale = new float[3]; bones.Add(temp); } for (int i = 0; i < bones.Count; i++) { bones[i].position[0] = file.readFloat(); bones[i].position[1] = file.readFloat(); bones[i].position[2] = file.readFloat(); bones[i].rotation[0] = file.readFloat(); bones[i].rotation[1] = file.readFloat(); bones[i].rotation[2] = file.readFloat(); bones[i].scale[0] = file.readFloat(); bones[i].scale[1] = file.readFloat(); bones[i].scale[2] = file.readFloat(); Bone temp = bones[i]; //Debug.Write(temp.parentIndex); //if (temp.parentIndex != 0x0FFFFFFF && temp.parentIndex > -1) // bones[temp.parentIndex].children.Add(i); bones[i] = temp; } reset(); } }
public void Read(FileData f) { CharacterId = f.readInt(); Unk1 = f.readInt(); BoundsId = f.readInt(); Unk3 = f.readInt(); numGraphics = f.readInt(); Graphics = new Graphic[numGraphics]; for (int i = 0; i < numGraphics; i++) { f.skip(0x08); // graphic tag header Graphics[i] = new Graphic(f); } }
public void read(FileData f) { base.read(f); f.skip(1); f.readInt(); //unknown }
public void read(FileData f) { base.read(f); f.skip(1); type = f.readInt(); //2 = sphere, 3 = capsule if ((type != 2) && (type != 3)) { throw new NotImplementedException($"Unknown damage shape type {type} at offset {f.pos()-4}"); } x = f.readFloat(); y = f.readFloat(); z = f.readFloat(); if (type == 2) { radius = f.readFloat(); dx = f.readFloat(); dy = f.readFloat(); dz = f.readFloat(); } else if (type == 3) { dx = f.readFloat(); dy = f.readFloat(); dz = f.readFloat(); radius = f.readFloat(); } unk = f.readFloat(); f.skip(0x1); }
public void Read(FileData d) { hash = d.readInt(); unk1 = d.readInt(); int s = d.readByte(); name = d.readString(d.pos(), s - 1); d.skip(s); d.align(4); data = new float[0x2c]; for (int i = 0; i < 0x2c; i++) { data[i] = d.readFloat(); } }