public override void Save(HSDWriter Writer) { foreach (KAR_GrUnk2_1Model Unk2_1 in GroupsUnk2_1.Elements) { foreach (KAR_GrUnk2_1DModel Unk2_1D in Unk2_1.GroupsUnk2_1D.Elements) { Writer.AddObject(Unk2_1D.DOBJIndices); foreach (var v in Unk2_1D.DOBJIndices) { Writer.Write(v); } Writer.Align(4); } } foreach (KAR_GrUnk2_1Model Unk2_1 in GroupsUnk2_1.Elements) { Unk2_1.GroupsUnk2_1D.Save(Writer); } GroupsUnk2_1.Save(Writer); Writer.AddObject(this); Writer.WritePointer(GroupsUnk2_1.Size > 0 ? GroupsUnk2_1.Elements[0] : null); Writer.Write((ushort)GroupsUnk2_1.Size); Writer.Write((ushort)0); }
/// <summary> /// writes quantanized value to stream /// </summary> /// <param name="d"></param> /// <param name="Value"></param> public void WriteValue(HSDWriter d, float Value) { if (!Quantanized) { Quantanize(); } switch (ValueType) { case GXAnimDataFormat.Float: d.Write(Value); break; case GXAnimDataFormat.Short: d.Write((short)(Quantanize(Value, ValueType, ValueScale))); break; case GXAnimDataFormat.UShort: d.Write((ushort)(Quantanize(Value, ValueType, ValueScale))); break; case GXAnimDataFormat.SByte: d.Write((sbyte)(Quantanize(Value, ValueType, ValueScale))); break; case GXAnimDataFormat.Byte: d.Write((byte)(Quantanize(Value, ValueType, ValueScale))); break; default: throw new Exception("Unknown GXAnimDataFormat " + ValueType.ToString()); } }
public override void Save(HSDWriter Writer) { Writer.AddObject(this); Writer.WritePointer(DOBJIndices); Writer.Write((ushort)DOBJIndices.Count); Writer.Write((ushort)0); }
public override void Save(HSDWriter Writer) { Writer.AddObject(this); Writer.Write(ID); Writer.Write((ushort)0); Writer.WritePointer(GroupsUnk2_1D.Size > 0 ? GroupsUnk2_1D.Elements[0] : null); Writer.Write((ushort)GroupsUnk2_1D.Size); Writer.Write((ushort)0); }
public void WriteObject(HSDWriter Writer) { Writer.AddObject(this); Writer.Write(Type); Writer.Write((ushort)Points.Count); Writer.Write(Tension); Writer.WritePointer(Points); Writer.Write(TotalLength); Writer.WritePointer(SegmentLengths); Writer.Write(0); }
public override void Save(HSDWriter Writer) { Writer.AddObject(this); for (int i = 0; i < JOBJs.Count; i++) { Writer.WritePointer(JOBJs[i]); Writer.Write(Weights[i]); } Writer.Write(0); Writer.Write(0); }
public override void Save(HSDWriter Writer) { if (Writer.Mode == WriterWriteMode.BUFFER && Data.Length > 0) { Writer.AddBuffer(this); Writer.Write(Data); if (Writer.BaseStream.Position % 4 > 0) { Writer.Write(4 - (Writer.BaseStream.Position % 4)); } } }
public override void Save(HSDWriter Writer) { if (Data != null) { Writer.WriteTexture(Data); } Writer.AddObject(this); Writer.WritePointer(Data); Writer.Write(Width); Writer.Write(Height); Writer.Write((uint)Format); }
public override void Save(HSDWriter Writer) { if (Data != null) { Writer.WriteTexture(Data); } Writer.AddObject(this); Writer.WritePointer(Data); Writer.Write((uint)Format); Writer.Write(GXTlut); Writer.Write(ColorCount); Writer.Write((ushort)0); }
public override void Save(HSDWriter Writer) { Writer.AddObject(FogRegions); foreach (var v in FogRegions) { v.Save(Writer); } Writer.AddObject(this); Writer.WritePointer(FogRegions); Writer.Write(FogRegions.Count); Writer.Write(-1); Writer.Write(-1); }
public override void Save(HSDWriter Writer) { foreach (var v in Nodes) { v.Save(Writer); } Writer.AddObject(this); Writer.Write(0); foreach (var v in Nodes) { Writer.WritePointer(v); } Writer.Write(0); }
public override void Save(HSDWriter Writer) { if (MatAnimJoint == null) { Writer.WriteObject(MatAnimJoint); } foreach (HSD_AnimNode node in Nodes) { foreach (HSD_Track t in node.Tracks) { t.Save(Writer); } } object array = new object(); Writer.AddObject(array); HSD_Track FirstTrack = null; foreach (HSD_AnimNode node in Nodes) { Writer.Write((byte)node.Tracks.Count); foreach (HSD_Track t in node.Tracks) { if (FirstTrack == null) { FirstTrack = t; } } } Writer.Write((byte)0xFF); Writer.Align(4); Writer.AddObject(this); Writer.Write(MatAnimJoint == null ? 1 : -1); if (MatAnimJoint == null) { Writer.Write(0); } else { Writer.WritePointer(MatAnimJoint); } Writer.Write(FrameCount); Writer.WritePointer(array); Writer.WritePointer(FirstTrack); }
public void WriteData(HSDWriter Writer) { Writer.AddObject(Points); foreach (var point in Points) { Writer.Write(point.X); Writer.Write(point.Y); Writer.Write(point.Z); } Writer.AddObject(SegmentLengths); foreach (var length in SegmentLengths) { Writer.Write(length); } }
public void WriteData(HSDWriter Writer) { Writer.AddObject(Indices); foreach (var p in Indices) { Writer.Write(p); } }
public override void Save(HSDWriter Writer) { foreach (var p in Splines) { p.WriteData(Writer); } Writer.AddObject(Splines); foreach (var p in Splines) { p.Save(Writer); } Writer.AddObject(this); Writer.WritePointer(Splines); Writer.Write(Splines.Count == 0 ? 1 : Splines.Count); Writer.Write(0); }
public override void Save(HSDWriter Writer) { Writer.AddObject(this); Writer.WritePointer(DOBJIndices); Writer.Write((ushort)DOBJIndices.Count); Writer.Write((ushort)0); Writer.Write(UnkFloat1); Writer.Write(UnkFloat2); Writer.Write(UnkFloat3); Writer.Write(UnkFloat4); Writer.Write(UnkFloat5); Writer.Write(UnkFloat6); Writer.Write(UnkUInt7); }
private void WriteData(HSDWriter Writer, float Value, GXCompType Type, float Scale) { float Scaled = Value * (float)Math.Pow(2, Scale); switch (Type) { case GXCompType.UInt8: Writer.Write((byte)Scaled); break; case GXCompType.Int8: Writer.Write((sbyte)Scaled); break; case GXCompType.UInt16: Writer.Write((ushort)Scaled); break; case GXCompType.Int16: Writer.Write((short)Scaled); break; case GXCompType.Float: Writer.Write(Scaled); break; default: Writer.Write((byte)Scaled); break; } }
public override void Save(HSDWriter Writer) { if (Next != null) { Next.Save(Writer); } Writer.WriteObject(VertexAttributes); Writer.WriteBuffer(DisplayListBuffer); if (BindGroups != null) { Writer.WriteObject(BindGroups); } Writer.AddObject(this); Writer.Write(0); if (Next != null) { Writer.WritePointer(Next); } else { Writer.Write(0); } Writer.WritePointer(VertexAttributes); Writer.Write((ushort)Flags); if (DisplayListBuffer == null) { Writer.Write((ushort)0); } else { Writer.Write((ushort)(DisplayListBuffer.Length / 32)); } Writer.WritePointer(DisplayListBuffer); Writer.WritePointer(BindGroups); }
public override void Save(HSDWriter Writer) { if (BoneIDs.Count > 0) { Writer.AddObject(BoneIDs); foreach (var b in BoneIDs) { Writer.Write(b); } } if (Matrices.Count > 0) { Writer.AddObject(Matrices); foreach (var m in Matrices) { m.Save(Writer); } } Writer.AddObject(this); if (BoneIDs.Count > 0) { Writer.WritePointer(BoneIDs); } else { Writer.Write(0); } if (Matrices.Count > 0) { Writer.WritePointer(Matrices); } else { Writer.Write(0); } Writer.Write(Math.Max(Matrices.Count, BoneIDs.Count)); }
public override void Save(HSDWriter Writer) { Writer.AddObject(Tables); foreach (var v in Tables) { v.Save(Writer); } Writer.WriteObject(RootNode); Writer.AddObject(this); Writer.WritePointer(RootNode); if (Tables.Count > 0) { Writer.WritePointer(Tables); } else { Writer.Write(0); } Writer.Write(Tables.Count); }
public void Write(HSDWriter Writer, HSD_AttributeGroup Attributes) { Writer.Write((byte)PrimitiveType); Writer.Write((ushort)Indices.Length); foreach (GXIndexGroup ig in Indices) { GXIndexGroup g = ig; int i = 0; foreach (GXVertexBuffer att in Attributes.Attributes) { switch (att.AttributeType) { case GXAttribType.GX_DIRECT: if (att.Name != GXAttribName.GX_VA_CLR0) { Writer.Write((byte)g.Indices[i]); } else if (att.Name == GXAttribName.GX_VA_CLR0) { WriteGXClr(g.Clr0, Writer, att.CompType); } else if (att.Name == GXAttribName.GX_VA_CLR1) { WriteGXClr(g.Clr1, Writer, att.CompType); } break; case GXAttribType.GX_INDEX8: Writer.Write((byte)g.Indices[i]); break; case GXAttribType.GX_INDEX16: Writer.Write(g.Indices[i]); break; } i++; } } }
public override void Save(HSDWriter Writer) { foreach (var p in Paths) { p.Save(Writer); } Writer.AddObject(Paths); foreach (var p in Paths) { Writer.WritePointer(p); } if (Paths.Count == 0) { Writer.Write(0); } Writer.AddObject(this); Writer.WritePointer(Paths); Writer.Write(Paths.Count == 0 ? 1 : Paths.Count); }
public override void Save(HSDWriter Writer) { if (Elements == null) { return; } foreach (IHSDNode node in Elements) { Writer.WriteObject(node); } Writer.AddObject(this); foreach (IHSDNode node in Elements) { Writer.WritePointer(node); } Writer.Write(0); }
public override void Save(HSDWriter Writer) { if (DataBuffer != null) { Writer.WriteBuffer(DataBuffer); } Writer.AddObject(this); Writer.Write((uint)Name); Writer.Write((uint)AttributeType); Writer.Write((uint)CompCount); Writer.Write((uint)CompType); Writer.Write(Scale); Writer.Write((byte)0); Writer.Write(Stride); Writer.WritePointer(DataBuffer); }
public byte[] ToBuffer(HSD_AttributeGroup Group) { MemoryStream o = new MemoryStream(); HSDWriter Writer = new HSDWriter(o); foreach (GXPrimitiveGroup g in Primitives) { g.Write(Writer, Group); } Writer.Write((byte)0); Writer.Align(0x20); Writer.Close(); byte[] bytes = o.ToArray(); o.Close(); return(bytes); }
public void WriteObject(HSDWriter Writer) { Writer.AddObject(this); Writer.WritePointer(Indices); Writer.Write(Indices.Count); }
public override void Save(HSDWriter Writer) { Writer.AddObject(Partitions); foreach (var p in Partitions) { Writer.WritePointer(p); } foreach (var p in Partitions) { p.Save(Writer); } Writer.AddObject(CollidableTriangles); foreach (var v in CollidableTriangles) { Writer.Write(v); } Writer.Align(4); Writer.AddObject(UnknownIndices); foreach (var v in UnknownIndices) { Writer.Write(v); } Writer.Align(4); Writer.AddObject(UnknownIndices2); foreach (var v in UnknownIndices2) { Writer.Write(v); } Writer.Align(4); Writer.AddObject(CollidableTrianglesBits); Writer.Write(new byte[(CollidableTriangles.Count / 8) + 5]); Writer.Align(4); Writer.AddObject(this); Writer.WritePointer(Partitions); Writer.Write((short)Partitions.Count); Writer.Write((short)0); Writer.Write(0x05000000); Writer.WritePointer(CollidableTriangles); Writer.Write((short)CollidableTriangles.Count); Writer.Write((short)0); Writer.Write(0x05000000); Writer.WritePointer(UnknownIndices); Writer.Write((short)UnknownIndices.Count); Writer.Write((short)0); Writer.Write(0x05000000); Writer.WritePointer(UnknownIndices2); Writer.Write((short)UnknownIndices2.Count); Writer.Write((short)0); Writer.Write(0); Writer.Write(0); Writer.Write(0); Writer.Write(0); Writer.Write(0); Writer.Write(0); Writer.Write(0); Writer.Write(0); Writer.Write(0); Writer.Write(0x00000003); Writer.WritePointer(CollidableTrianglesBits); Writer.Write((short)CollidableTriangles.Count); Writer.Write((short)0); }
public override void Save(HSDWriter Writer) { Writer.AddObject(Vertices); foreach (var v in Vertices) { v.Save(Writer); } foreach (var v in Links) { v.Save(Writer); } foreach (var v in AreaTables) { v.Save(Writer); } Writer.AddObject(this); Writer.WritePointer(Vertices.Count == 0 ? null : Vertices); Writer.Write(Vertices.Count); Writer.WritePointer(Links.Count == 0 ? null : Links[0]); Writer.Write(Links.Count); Writer.Write(Unknown1); Writer.Write(Unknown2); Writer.Write(Unknown3); Writer.Write(Unknown4); Writer.Write(Unknown5); Writer.Write(Unknown6); Writer.Write(Unknown7); Writer.WritePointer(AreaTables.Count == 0 ? null : AreaTables[0]); Writer.Write(AreaTables.Count); Writer.Write(Unknown8); }
public override void Save(HSDWriter Writer) { Writer.AddObject(Vertices); foreach (var v in Vertices) { Writer.Write(v.X); Writer.Write(v.Y); Writer.Write(v.Z); } Writer.AddObject(Faces); foreach (var v in Faces) { Writer.WriteObject(v); } Writer.AddObject(Joints); foreach (var v in Joints) { Writer.WriteObject(v); } Writer.AddObject(ZoneVertices); foreach (var v in ZoneVertices) { Writer.Write(v.X); Writer.Write(v.Y); Writer.Write(v.Z); } Writer.AddObject(ZoneFaces); foreach (var v in ZoneFaces) { Writer.WriteObject(v); } Writer.AddObject(ZoneJoints); foreach (var v in ZoneJoints) { Writer.WriteObject(v); } Writer.AddObject(this); Writer.WritePointer(Vertices); Writer.Write(Vertices.Count); Writer.WritePointer(Faces); Writer.Write(Faces.Count); Writer.WritePointer(Joints); Writer.Write(Joints.Count); Writer.WritePointer(ZoneVertices); Writer.Write(ZoneVertices.Count); Writer.WritePointer(ZoneFaces); Writer.Write(ZoneFaces.Count); Writer.WritePointer(ZoneJoints); Writer.Write(ZoneJoints.Count); }
public static void WriteGXClr(byte[] clr, HSDWriter d, GXCompType type) { switch ((int)type) { case 0: // GX_RGB565 d.Write((short)ClrTo565(clr)); break; case 1: // GX_RGB888 d.Write(clr[0]); d.Write(clr[1]); d.Write(clr[2]); break; case 2: // GX_RGBX888 d.Write(clr[0]); d.Write(clr[1]); d.Write(clr[2]); d.Write(0); break; case 3: // GX_RGBA4 short s = (short)((((clr[0] >> 4) & 0xF) << 12) | (((clr[1] >> 4) & 0xF) << 8) | (((clr[2] >> 4) & 0xF) << 4) | (((clr[3] >> 4) & 0xF))); d.Write((ushort)s); break; case 4: // GX_RGBA6 int three = (((clr[0] >> 2) << 18) | ((clr[1] >> 2) << 12) | ((clr[2] >> 2) << 6) | (clr[3] >> 2)); d.Write((byte)((three >> 16) & 0xFF)); d.Write((byte)((three >> 8) & 0xFF)); d.Write((byte)((three) & 0xFF)); break; case 5: // GX_RGBX888 d.Write(clr[0]); d.Write(clr[1]); d.Write(clr[2]); d.Write(clr[3]); break; } }