Esempio n. 1
0
        public override void Save(HSDWriter Writer)
        {
            if (Track != null && Track.Data != null)
            {
                DataSize = (ushort)Track.Data.Length;
            }

            base.Save(Writer);

            //int start = (int)Writer.BaseStream.Position;
            //Writer.WriteAt(start, (uint)Track.Data.Length << 16);
        }
Esempio n. 2
0
        public override void Save(HSDWriter Writer)
        {
            foreach (var table in Tables)
            {
                table.WriteData(Writer);
            }

            Writer.AddObject(this);
            foreach (var table in Tables)
            {
                table.WriteObject(Writer);
            }
        }
Esempio n. 3
0
        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);
        }
Esempio n. 4
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);
        }
Esempio n. 5
0
        public override void Save(HSDWriter Writer)
        {
            foreach (var v in Lights)
            {
                v.Save(Writer);
            }

            Writer.AddObject(this);
            foreach (var v in Lights)
            {
                Writer.WritePointer(v);
            }
            Writer.Write(0);
        }
Esempio n. 6
0
        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);
        }
Esempio n. 7
0
        public override void Save(HSDWriter Writer)
        {
            Writer.AddObject(Tables);
            foreach (var v in Tables)
            {
                v.Save(Writer);
            }
            TableCount = Tables.Count;

            base.Save(Writer);
            if (Writer.Mode == WriterWriteMode.NORMAL)
            {
                Writer.WritePointerAt((int)(Writer.BaseStream.Position - 0x2C), Tables.Count == 0 ? null : Tables[0]);
            }
        }
Esempio n. 8
0
        public override void Save(HSDWriter Writer)
        {
            Writer.AddObject(this);

            Writer.WritePointer(DOBJIndices);
            Writer.Write((ushort)DOBJIndices.Count);
            Writer.Write((ushort)0);

            Writer.Write(MinX);
            Writer.Write(MinY);
            Writer.Write(MinZ);
            Writer.Write(MaxX);
            Writer.Write(MaxY);
            Writer.Write(MaxZ);
        }
Esempio n. 9
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);
        }
Esempio n. 10
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);
        }
Esempio n. 11
0
        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);
            }
        }
Esempio n. 12
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);
        }
Esempio n. 13
0
        public override void Save(HSDWriter Writer)
        {
            foreach (var sa in FightSubActions)
            {
                sa.Save(Writer);
            }

            foreach (var sa in WinSubActions)
            {
                sa.Save(Writer);
            }

            base.Save(Writer);

            Writer.WritePointerAt((int)(Writer.BaseStream.Position - 0x58), FightSubActions[0]);

            Writer.WritePointerAt((int)(Writer.BaseStream.Position - 0x50), WinSubActions[0]);
        }
Esempio n. 14
0
        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);
        }
Esempio n. 15
0
        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);
        }
Esempio n. 16
0
        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);
        }
Esempio n. 17
0
        public override void Save(HSDWriter Writer)
        {
            foreach (KAR_GrUnk3DModel Unk3D in GroupsUnk3D.Elements)
            {
                Writer.AddObject(Unk3D.DOBJIndices);
                foreach (var v in Unk3D.DOBJIndices)
                {
                    Writer.Write(v);
                }
                Writer.Align(4);
            }

            GroupsUnk3D.Save(Writer);

            Writer.AddObject(this);

            Writer.WritePointer(GroupsUnk3D.Size > 0 ? GroupsUnk3D.Elements[0] : null);
            Writer.Write((ushort)GroupsUnk3D.Size);
            Writer.Write((ushort)0);
        }
Esempio n. 18
0
        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;
            }
        }
Esempio n. 19
0
        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));
        }
Esempio n. 20
0
        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++;
                }
            }
        }
Esempio n. 21
0
        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);
        }
Esempio n. 22
0
        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);
        }
Esempio n. 23
0
        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);
        }
Esempio n. 24
0
 public override void Save(HSDWriter Writer)
 {
     throw new Exception("Saving TexMapG not supported");
 }
Esempio n. 25
0
 public override void Save(HSDWriter Writer)
 {
     WriteData(Writer);
     WriteObject(Writer);
 }
Esempio n. 26
0
        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);
        }
Esempio n. 27
0
 public void WriteObject(HSDWriter Writer)
 {
     Writer.AddObject(this);
     Writer.WritePointer(Indices);
     Writer.Write(Indices.Count);
 }
Esempio n. 28
0
        public static HSD_FOBJ EncodeFrames(List <FOBJKey> Keys, byte TrackType)
        {
            HSD_FOBJ fobj = new HSD_FOBJ();

            fobj.AnimationType = TrackType;

            // perform quantization
            FOBJQuantanizer valueQ   = new FOBJQuantanizer();
            FOBJQuantanizer tangentQ = new FOBJQuantanizer();

            foreach (FOBJKey key in Keys)
            {
                valueQ.AddValue(key.Value);
                tangentQ.AddValue(key.Tan);
            }

            fobj.ValueScale  = valueQ.GetValueScale();
            fobj.ValueFormat = valueQ.GetDataFormat();

            fobj.TanScale  = tangentQ.GetValueScale();
            fobj.TanFormat = tangentQ.GetDataFormat();

            MemoryStream o = new MemoryStream();

            using (HSDWriter Writer = new HSDWriter(o))
            {
                Writer.BigEndian = false;

                int time = 0;
                for (int i = 0; i < Keys.Count;)
                {
                    InterpolationType ip = Keys[i].InterpolationType;
                    int j;
                    for (j = 0; j < Keys.Count - i; j++)
                    {
                        if (Keys[i + j].InterpolationType != ip)
                        {
                            break;
                        }
                    }

                    int flag = ((j - 1) << 4) | (int)ip;
                    Writer.ExtendedByte(flag);

                    for (int k = i; k < i + j; k++)
                    {
                        int DeltaTime = 0;

                        if (k + 1 < Keys.Count)
                        {
                            DeltaTime = (int)(Keys[k + 1].Frame - Keys[k].Frame);
                        }

                        if (k == Keys.Count)
                        {
                            DeltaTime = 1;
                        }

                        switch (ip)
                        {
                        case InterpolationType.Step:
                            valueQ.WriteValue(Writer, Keys[k].Value);
                            Writer.ExtendedByte(DeltaTime);
                            break;

                        case InterpolationType.Linear:
                            valueQ.WriteValue(Writer, Keys[k].Value);
                            Writer.ExtendedByte(DeltaTime);
                            break;

                        case InterpolationType.HermiteValue:
                            valueQ.WriteValue(Writer, Keys[k].Value);
                            Writer.ExtendedByte(DeltaTime);
                            break;

                        case InterpolationType.Hermite:
                            valueQ.WriteValue(Writer, Keys[k].Value);
                            tangentQ.WriteValue(Writer, Keys[k].Tan);
                            Writer.ExtendedByte(DeltaTime);
                            break;

                        case InterpolationType.HermiteCurve:
                            tangentQ.WriteValue(Writer, Keys[k].Tan);
                            break;

                        case InterpolationType.Constant:
                            valueQ.WriteValue(Writer, Keys[k].Value);
                            break;

                        default:
                            throw new Exception("end");
                        }

                        if (ip != InterpolationType.HermiteCurve)
                        {
                            time = (int)Keys[k].Frame;
                        }
                    }

                    i += j;
                }
            }
            fobj.Data = o.ToArray();
            o.Close();
            o.Dispose();
            return(fobj);
        }
Esempio n. 29
0
        public override void Save(HSDWriter Writer)
        {
            base.Save(Writer);

            Writer.WriteAt((int)(Writer.BaseStream.Position - 16), (uint)Track.Data.Length);
        }
Esempio n. 30
0
 public override void Save(HSDWriter Writer)
 {
 }