private static float[] Read(HSDReader d, GXCompType type, int size) { switch (type) { case GXCompType.UInt16: size /= 2; break; case GXCompType.Int16: size /= 2; break; case GXCompType.Float: size /= 4; break; } float[] a = new float[size]; switch (type) { case GXCompType.UInt8: for (int i = 0; i < size; i++) { a[i] = d.ReadByte(); } break; case GXCompType.Int8: for (int i = 0; i < size; i++) { a[i] = d.ReadSByte(); } break; case GXCompType.UInt16: for (int i = 0; i < size; i++) { a[i] = d.ReadUInt16(); } break; case GXCompType.Int16: for (int i = 0; i < size; i++) { a[i] = d.ReadInt16(); } break; case GXCompType.Float: for (int i = 0; i < size; i++) { a[i] = d.ReadSingle(); } break; default: for (int i = 0; i < size; i++) { a[i] = d.ReadByte(); } break; } return(a); }
// public override void Open(HSDReader Reader) { var modelGroupOffset = Reader.ReadUInt32(); var modelGroupCount = Reader.ReadInt32(); var unk1GroupOffset = Reader.ReadUInt32(); var unk1GroupCount = Reader.ReadInt32(); var unk2GroupOffset = Reader.ReadUInt32(); var unk2GroupCount = Reader.ReadInt32(); var lightGroupOffset = Reader.ReadUInt32(); var lightGroupCount = Reader.ReadInt32(); var unk4GroupOffset = Reader.ReadUInt32(); var unk4GroupCount = Reader.ReadInt32(); var unk5GroupOffset = Reader.ReadUInt32(); var unk5GroupCount = Reader.ReadInt32(); for (int i = 0; i < modelGroupCount; i++) { Reader.Seek(modelGroupOffset + (uint)(12 * i)); SBM_GrMapModelGroup mg = new SBM_GrMapModelGroup(); mg.Open(Reader); ModelGroups.Add(mg); } for (int i = 0; i < modelGroupCount; i++) { Reader.Seek(lightGroupOffset + (uint)(i * 8)); SBM_GrMapLight mg = new SBM_GrMapLight(); mg.Open(Reader); Lights.Add(mg); } }
public override void Open(HSDReader Reader) { uint DataOffset = Reader.ReadUInt32(); base.Open(Reader); Data = Reader.ReadBuffer(DataOffset, TPL.TextureByteSize((TPL_TextureFormat)Format, Width, Height)); }
public override void Open(HSDReader Reader) { for (int i = 0; i < Size; i++) { Elements[i] = Reader.ReadObject <T>(Reader.Position()); } }
public override void Open(HSDReader Reader) { var boneTableOffset = Reader.ReadUInt32(); var matrixTableOffset = Reader.ReadUInt32(); var count = Reader.ReadUInt32(); if (boneTableOffset != 0) { Reader.Seek(boneTableOffset); for (int i = 0; i < count; i++) { BoneIDs.Add(Reader.ReadInt32()); } } if (matrixTableOffset != 0) { Reader.Seek(matrixTableOffset); for (int i = 0; i < count; i++) { HSD_Matrix3x3 mat = new HSD_Matrix3x3(); mat.Open(Reader); Matrices.Add(mat); } } }
public override void Open(HSDReader Reader) { Type = Reader.ReadInt16(); int PathPointCount = Reader.ReadInt16(); Tension = Reader.ReadSingle(); uint PointTableOffset = Reader.ReadUInt32(); TotalLength = Reader.ReadSingle(); uint segmentLengthOffset = Reader.ReadUInt32(); if (Reader.ReadInt32() != 0) // this is a pointer to a float array of length 5? { Console.WriteLine("Resave not supported"); //throw new NotSupportedException("Dat not supported"); } Reader.Seek(PointTableOffset); for (int i = 0; i < PathPointCount; i++) { Points.Add(new GXVector3(Reader.ReadSingle(), Reader.ReadSingle(), Reader.ReadSingle())); } Reader.Seek(segmentLengthOffset); for (int i = 0; i < PathPointCount; i++) { SegmentLengths.Add(Reader.ReadSingle()); } }
public override void Open(HSDReader Reader) { var vertexOffset = Reader.ReadUInt32(); var vertexCount = Reader.ReadInt32(); var faceOffset = Reader.ReadUInt32(); var faceCount = Reader.ReadInt32(); var jointOffset = Reader.ReadUInt32(); var jointCount = Reader.ReadInt32(); var zonevertexOffset = Reader.ReadUInt32(); var zonevertexCount = Reader.ReadInt32(); var zonefaceOffset = Reader.ReadUInt32(); var zonefaceCount = Reader.ReadInt32(); var zonejointOffset = Reader.ReadUInt32(); var zonejointCount = Reader.ReadInt32(); Reader.Seek(vertexOffset); for (int i = 0; i < vertexCount; i++) { Vertices.Add(new GXVector3(Reader.ReadSingle(), Reader.ReadSingle(), Reader.ReadSingle())); } Reader.Seek(faceOffset); for (int i = 0; i < faceCount; i++) { KAR_CollisionTriangle tri = new KAR_CollisionTriangle(); tri.Open(Reader); Faces.Add(tri); } Reader.Seek(jointOffset); for (int i = 0; i < jointCount; i++) { KAR_CollisionJoint joint = new KAR_CollisionJoint(); joint.Open(Reader); Joints.Add(joint); } Reader.Seek(zonevertexOffset); for (int i = 0; i < zonevertexCount; i++) { ZoneVertices.Add(new GXVector3(Reader.ReadSingle(), Reader.ReadSingle(), Reader.ReadSingle())); } Reader.Seek(zonefaceOffset); for (int i = 0; i < zonefaceCount; i++) { KAR_ZoneCollisionTriangle tri = new KAR_ZoneCollisionTriangle(); tri.Open(Reader); ZoneFaces.Add(tri); } Reader.Seek(zonejointOffset); for (int i = 0; i < zonejointCount; i++) { KAR_ZoneCollisionJoint joint = new KAR_ZoneCollisionJoint(); joint.Open(Reader); ZoneJoints.Add(joint); } }
public override void Open(HSDReader Reader) { base.Open(Reader); if (PathAnimJoint != 0) { throw new Exception("Error Reading AOBJ Path Detected"); } }
public override void Open(HSDReader Reader) { base.Open(Reader); if (Renderanim != 0) { throw new Exception("Error reading MatAnim"); } }
public override void Open(HSDReader Reader) { base.Open(Reader); GroupsUnk2_1 = new HSD_Array <KAR_GrUnk2_1Model>(Size); Reader.Seek(Offset); GroupsUnk2_1.Open(Reader); }
public override void Open(HSDReader Reader) { base.Open(Reader); if (ROBJOffset != 0) { throw new Exception("Path in joint detected"); } }
public override void Open(HSDReader Reader) { base.Open(Reader); if (ROBJPointer != 0) { Console.WriteLine("TODO: ROBJ in AnimJoint 0x" + ROBJPointer.ToString("X")); } }
public override void Open(HSDReader Reader) { base.Open(Reader); if (Unk1 != 0) { Console.WriteLine("Collision bubble unknown " + Unk1.ToString("X")); } }
private static byte[] ReadGXClr(HSDReader Reader, int CompType) { byte[] clr = new byte[] { 1, 1, 1, 1 }; int b; switch (CompType) { case 0: // GX_RGB565 b = Reader.ReadUInt16(); clr[0] = (byte)((((b >> 11) & 0x1F) << 3) | (((b >> 11) & 0x1F) >> 2)); clr[1] = (byte)((((b >> 5) & 0x3F) << 2) | (((b >> 5) & 0x3F) >> 4)); clr[2] = (byte)((((b) & 0x1F) << 3) | (((b) & 0x1F) >> 2)); break; case 1: // GX_RGB888 clr[0] = Reader.ReadByte(); clr[1] = Reader.ReadByte(); clr[2] = Reader.ReadByte(); break; case 2: // GX_RGBX888 clr[0] = Reader.ReadByte(); clr[1] = Reader.ReadByte(); clr[2] = Reader.ReadByte(); Reader.ReadByte(); break; case 3: // GX_RGBA4 b = Reader.ReadUInt16(); clr[0] = (byte)((((b >> 12) & 0xF) << 4) | ((b >> 12) & 0xF)); clr[1] = (byte)((((b >> 8) & 0xF) << 4) | ((b >> 8) & 0xF)); clr[2] = (byte)((((b >> 4) & 0xF) << 4) | ((b >> 4) & 0xF)); clr[3] = (byte)((((b) & 0xF) << 4) | ((b) & 0xF)); break; case 4: // GX_RGBA6 b = (Reader.ReadByte() << 16) | (Reader.ReadByte() << 8) | (Reader.ReadByte()); clr[0] = (byte)((((b >> 18) & 0x3F) << 2) | (((b >> 18) & 0x3F) >> 4)); clr[1] = (byte)((((b >> 12) & 0x3F) << 2) | (((b >> 12) & 0x3F) >> 4)); clr[2] = (byte)((((b >> 6) & 0x3F) << 2) | (((b >> 6) & 0x3F) >> 4)); clr[3] = (byte)((((b) & 0x3F) << 2) | (((b) & 0x3F) >> 4)); break; case 5: // GX_RGBX888 clr[0] = Reader.ReadByte(); clr[1] = Reader.ReadByte(); clr[2] = Reader.ReadByte(); clr[3] = Reader.ReadByte(); break; default: throw new Exception("Unknown Color Type"); } return(clr); }
public override void Open(HSDReader Reader) { base.Open(Reader); uint BaseOffset = Reader.Position(); GroupsUnk2_1D = new HSD_Array <KAR_GrUnk2_1DModel>(Size); Reader.Seek(Offset); GroupsUnk2_1D.Open(Reader); Reader.Seek(BaseOffset); }
public override void Open(HSDReader Reader) { uint DataOffset = Reader.ReadUInt32(); Format = (GXTlutFmt)Reader.ReadUInt32(); GXTlut = Reader.ReadUInt32(); ColorCount = Reader.ReadUInt16(); Reader.ReadUInt16(); Data = Reader.ReadBuffer(DataOffset, TPL.PaletteByteSize((TPL_PaletteFormat)Format, ColorCount)); }
public override void Open(HSDReader Reader) { GXVertexBuffer a = new GXVertexBuffer(); a.Open(Reader); while (a.Name != GXAttribName.GX_VA_NULL) { Attributes.Add(a); a = new GXVertexBuffer(); a.Open(Reader); } }
public override void Open(HSDReader Reader) { base.Open(Reader); Reader.Seek(TableOffset); for (int i = 0; i < TableCount; i++) { var table = new SBM_GrGroundParamTable(); table.Open(Reader); Tables.Add(table); } }
public override void Open(HSDReader Reader) { Name = (GXAttribName)Reader.ReadUInt32(); AttributeType = (GXAttribType)Reader.ReadUInt32(); CompCount = (GXCompCnt)Reader.ReadInt32(); CompType = (GXCompType)Reader.ReadUInt32(); Scale = Reader.ReadByte(); Reader.ReadByte();//Padding Stride = Reader.ReadUInt16(); Offset = Reader.ReadUInt32(); }
public override void Open(HSDReader Reader) { uint DataOffset = Reader.ReadUInt32(); Width = Reader.ReadUInt16(); Height = Reader.ReadUInt16(); Format = (GXTexFmt)Reader.ReadUInt32(); Mipmap = Reader.ReadUInt32(); MinLOD = Reader.ReadSingle(); MaxLOD = Reader.ReadSingle(); Data = Reader.ReadBuffer(DataOffset, TPL.TextureByteSize((TPL_TextureFormat)Format, Width, Height)); }
public override void Open(HSDReader Reader) { var offset = Reader.ReadUInt32(); var count = Reader.ReadInt32(); for (int i = 0; i < count; i++) { Reader.Seek(offset + (uint)(i * 0x18)); var spline = new KAR_GrSpline(); spline.Open(Reader); Splines.Add(spline); } }
public override void Open(HSDReader Reader) { List <byte> data = new List <byte>(); byte cmd = Reader.ReadByte(); while (cmd != 0) { int size = MeleeScript.GetCommandSize(cmd); data.Add(cmd); data.AddRange(Reader.ReadBytes(size - 1)); cmd = Reader.ReadByte(); } Data = data.ToArray(); }
public override void Open(HSDReader Reader) { base.Open(Reader); uint BaseOffset = Reader.Position(); DOBJIndices.Clear(); Reader.Seek(Offset); for (int i = 0; i < Size; i++) { DOBJIndices.Add(Reader.ReadUInt16()); } Reader.Seek(BaseOffset); }
public override void Open(HSDReader Reader) { uint Offset = Reader.ReadUInt32(); float Weight = Reader.ReadSingle(); JOBJs = new List <HSD_JOBJ>(); Weights = new List <float>(); while (Offset != 0) { JOBJs.Add(Reader.ReadObject <HSD_JOBJ>(Offset)); Weights.Add(Weight); Offset = Reader.ReadUInt32(); Weight = Reader.ReadSingle(); } }
public override void Open(HSDReader Reader) { var off = Reader.ReadUInt32(); while (off != 0) { var temp = Reader.Position(); Reader.Seek(off); HSD_Light light = new HSD_Light(); light.Open(Reader); Lights.Add(light); Reader.Seek(temp); off = Reader.ReadUInt32(); } }
public override void Open(HSDReader Reader) { uint NameOffset = Reader.ReadUInt32(); uint NextOff = Reader.ReadUInt32(); uint VertexAttributeArray = Reader.ReadUInt32(); Flags = (POBJ_FLAG)Reader.ReadUInt16(); int DisplayListSize = Reader.ReadUInt16() * 32; uint DisplayListOffset = Reader.ReadUInt32(); uint WeightListOffset = Reader.ReadUInt32(); if (NextOff > 0) { Next = Reader.ReadObject <HSD_POBJ>(NextOff); } // Display List if (DisplayListOffset > 0) { DisplayListBuffer = Reader.ReadBuffer(DisplayListOffset, DisplayListSize); } if (VertexAttributeArray > 0) { VertexAttributes = Reader.ReadObject <HSD_AttributeGroup>(VertexAttributeArray); } //Skinning if (WeightListOffset > 0) { if (Flags.HasFlag(POBJ_FLAG.ENVELOPE)) { // offsets to array of bone-weight combinations BindGroups = Reader.ReadObject <HSD_PointerArray <HSD_JOBJWeight> >(WeightListOffset); } else if (Flags.HasFlag(POBJ_FLAG.SHAPEANIM)) { throw new Exception("Shape Anim not supported");//?? } else if (Flags.HasFlag(POBJ_FLAG.SKIN)) { // Single bind to given bone SingleBind = Reader.ReadObject <HSD_JOBJ>(WeightListOffset); } } }
public override void Open(HSDReader Reader) { var rootNodeOffset = Reader.ReadUInt32(); var offset = Reader.ReadUInt32(); var count = Reader.ReadInt32(); RootNode = Reader.ReadObject <HSD_JOBJ>(rootNodeOffset); Reader.Seek(offset); for (int i = 0; i < count; i++) { SBM_GrMapModelTable table = new SBM_GrMapModelTable(); table.Open(Reader); Tables.Add(table); } }
public override void Open(HSDReader Reader) { var offset = Reader.ReadUInt32(); var count = Reader.ReadInt32(); if (offset == 0) { return; } Reader.Seek(offset); for (int i = 0; i < count; i++) { Indices.Add(Reader.ReadInt32()); } }
public override void Open(HSDReader Reader) { var start = Reader.Position(); for (int i = 0; i < 4; i++) { Reader.Seek(start + (uint)(8 * i)); KAR_GrCourseSplineTable table = new KAR_GrCourseSplineTable(); if (table.Indices.Count == 0) { break; } table.Open(Reader); Tables.Add(table); } }
public void Open(HSDReader Reader, uint offset) { var mipCount = Reader.ReadInt32(); Format = Reader.ReadInt32(); Flag = Reader.ReadInt32(); Width = Reader.ReadInt32(); Height = Reader.ReadInt32(); Depth = Reader.ReadInt32(); uint[] mipOffsets = new uint[mipCount]; for (int i = 0; i < mipCount; i++) { mipOffsets[i] = Reader.ReadUInt32(); } }