示例#1
0
        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);
                }
            }
        }
示例#2
0
        public static void process(FileData d, int type, int secOff, Animation.KeyNode node, String part, bool debug, Animation a)
        {
            int offset = d.readInt() + secOff;
            int temp   = d.pos();

            d.seek(offset);

            int   max    = 0;
            int   fCount = -1;
            float scale  = 0;

            float[] frame = null, step = null, tan = null;

            if (type == 0x1)
            {
                fCount = d.readShort();
                d.skip(2);
                scale = d.readFloat();
                float stepb = d.readFloat();
                float base2 = d.readFloat();

                frame = new float[fCount];
                step  = new float[fCount];
                tan   = new float[fCount];

                for (int i = 0; i < fCount; i++)
                {
                    frame[i] = d.readByte();
                    int th = d.readThree();
                    step[i] = base2 + ((th >> 12) & 0xfff) * stepb;
                    tan[i]  = (FileData.sign12Bit(th & 0xfff) / 32f);

                    if (frame[i] > max)
                    {
                        max = (int)frame[i];
                    }
                }
            }

            if (type == 0x2)
            {
                fCount = d.readShort();
                d.skip(2);
                scale = d.readFloat();
                float stepb = d.readFloat();
                float base2 = d.readFloat();

                frame = new float[fCount];
                step  = new float[fCount];
                tan   = new float[fCount];

                for (int i = 0; i < fCount; i++)
                {
                    frame[i] = d.readShort() / 32f;
                    step[i]  = base2 + d.readShort() * stepb;
                    tan[i]   = ((short)d.readShort() / 256f);

                    if (frame[i] > max)
                    {
                        max = (int)frame[i];
                    }
                }
            }

            if (type == 0x3)
            {
                //if(debug)
                //System.out.println(part + "\tInterpolated 12 " + Integer.toHexString(offset));

                fCount = d.readShort();
                d.skip(2);
                scale = d.readFloat();

                frame = new float[fCount];
                step  = new float[fCount];
                tan   = new float[fCount];

                for (int i = 0; i < fCount; i++)
                {
                    frame[i] = d.readFloat();
                    step[i]  = d.readFloat();
                    tan[i]   = d.readFloat();

                    if (frame[i] > max)
                    {
                        max = (int)frame[i];
                    }
                }
            }

            //a.FrameCount = max;

            float degrad = (float)(Math.PI / 180f);

            if (frame != null)
            {
                for (int i = 0; i < fCount; i++)
                {
                    Animation.KeyFrame f = new Animation.KeyFrame();
                    f.InterType = Animation.InterpolationType.HERMITE;
                    f.Value     = step[i];
                    f.Frame     = frame[i];
                    f.In        = tan[i];
                    switch (part)
                    {
                    case "RX":
                        f.Value = step[i] * degrad;
                        node.XROT.Keys.Add(f);
                        f.Degrees = true;
                        break;

                    case "RY":
                        f.Value = step[i] * degrad;
                        node.YROT.Keys.Add(f);
                        f.Degrees = true;
                        break;

                    case "RZ":
                        f.Value = step[i] * degrad;
                        node.ZROT.Keys.Add(f);
                        f.Degrees = true;
                        break;

                    case "X":
                        node.XPOS.Keys.Add(f);
                        break;

                    case "Y":
                        node.YPOS.Keys.Add(f);
                        break;

                    case "Z":
                        node.ZPOS.Keys.Add(f);
                        break;

                    case "SX":
                        node.XSCA.Keys.Add(f);
                        break;

                    case "SY":
                        node.YSCA.Keys.Add(f);
                        break;

                    case "SZ":
                        node.ZSCA.Keys.Add(f);
                        break;
                    }
                }
            }

            if (type == 0x4)
            {
                float stepb = d.readFloat();
                float base2 = d.readFloat();
                for (int i = 0; i < a.FrameCount; i++)
                {
                    float v = base2 + stepb * (d.readByte());

                    Animation.KeyFrame f = new Animation.KeyFrame();
                    f.InterType = Animation.InterpolationType.LINEAR;
                    f.Value     = v;
                    f.Frame     = i;

                    switch (part)
                    {
                    case "RX":
                        f.Value = v * degrad;
                        node.XROT.Keys.Add(f);
                        break;

                    case "RY":
                        f.Value = v * degrad;
                        node.YROT.Keys.Add(f);
                        break;

                    case "RZ":
                        f.Value = v * degrad;
                        node.ZROT.Keys.Add(f);
                        break;

                    case "X":
                        node.XPOS.Keys.Add(f);
                        break;

                    case "Y":
                        node.YPOS.Keys.Add(f);
                        break;

                    case "Z":
                        node.ZPOS.Keys.Add(f);
                        break;

                    case "SX":
                        node.XSCA.Keys.Add(f);
                        break;

                    case "SY":
                        node.YSCA.Keys.Add(f);
                        break;

                    case "SZ":
                        node.ZSCA.Keys.Add(f);
                        break;
                    }
                }
            }

            if (type == 0x6)
            {
                for (int i = 0; i < a.FrameCount; i++)
                {
                    float v = d.readFloat();

                    Animation.KeyFrame f = new Animation.KeyFrame();
                    f.InterType = Animation.InterpolationType.LINEAR;
                    f.Value     = v;
                    f.Frame     = i;
                    switch (part)
                    {
                    case "RX":
                        f.Value = v * degrad;
                        node.XROT.Keys.Add(f);
                        break;

                    case "RY":
                        f.Value = v * degrad;
                        node.YROT.Keys.Add(f);
                        break;

                    case "RZ":
                        f.Value = v * degrad;
                        node.ZROT.Keys.Add(f);
                        break;

                    case "X":
                        node.XPOS.Keys.Add(f);
                        break;

                    case "Y":
                        node.YPOS.Keys.Add(f);
                        break;

                    case "Z":
                        node.ZPOS.Keys.Add(f);
                        break;

                    case "SX":
                        node.XSCA.Keys.Add(f);
                        break;

                    case "SY":
                        node.YSCA.Keys.Add(f);
                        break;

                    case "SZ":
                        node.ZSCA.Keys.Add(f);
                        break;
                    }
                }
            }

            d.seek(temp);
        }
示例#3
0
文件: CHR0.cs 项目: struz/Smash-Forge
        public static void process(FileData d, int type, int secOff, SkelAnimation anim, String part, int nid, bool debug, VBN vbn)
        {
            int offset = d.readInt() + secOff;
            int temp   = d.pos();

            d.seek(offset);
            //		System.out.println(d.pos());

            int   max    = 0;
            int   fCount = -1;
            float scale  = 0;

            float[] frame = null, step = null, tan = null;

            if (type == 0x1)
            {
                fCount = d.readShort();
                d.skip(2);
                scale = d.readFloat();
                float stepb = d.readFloat();
                float base2 = d.readFloat();

                frame = new float[fCount];
                step  = new float[fCount];
                tan   = new float[fCount];

                for (int i = 0; i < fCount; i++)
                {
                    frame[i] = d.readByte();
                    int th = d.readThree();
                    step[i] = base2 + ((th >> 12) & 0xfff) * stepb;
                    tan[i]  = (FileData.sign12Bit(th & 0xfff) / 32f);

                    if (frame[i] > max)
                    {
                        max = (int)frame[i];
                    }
                }
            }

            if (type == 0x2)
            {
                //if(debug)
                //System.out.println(part + "\tInterpolated 6\t" + Integer.toHexString(offset));

                fCount = d.readShort();
                d.skip(2);
                scale = d.readFloat();
                float stepb = d.readFloat();
                float base2 = d.readFloat();

                frame = new float[fCount];
                step  = new float[fCount];
                tan   = new float[fCount];

                for (int i = 0; i < fCount; i++)
                {
                    frame[i] = d.readShort() / 32f;
                    step[i]  = base2 + d.readShort() * stepb;
                    tan[i]   = ((short)d.readShort() / 256f);

                    if (frame[i] > max)
                    {
                        max = (int)frame[i];
                    }
                }
            }

            if (type == 0x3)
            {
                //if(debug)
                //System.out.println(part + "\tInterpolated 12 " + Integer.toHexString(offset));

                fCount = d.readShort();
                d.skip(2);
                scale = d.readFloat();

                frame = new float[fCount];
                step  = new float[fCount];
                tan   = new float[fCount];

                for (int i = 0; i < fCount; i++)
                {
                    frame[i] = d.readFloat();
                    step[i]  = d.readFloat();
                    tan[i]   = d.readFloat();

                    if (frame[i] > max)
                    {
                        max = (int)frame[i];
                    }
                }
            }

            if (frame != null)
            {
                generateInter(anim, max, nid, part, frame, tan, step, vbn);
            }

            if (type == 0x4)
            {
                //if(debug)
                //System.out.println(part + "\tLkin 1 " + Integer.toHexString(offset) + " " + anim.size());
                float stepb = d.readFloat();
                float base2 = d.readFloat();
                for (int i = 0; i < anim.size(); i++)
                {
                    KeyNode n = anim.getNode(i, nid);

                    if (part.Contains("R"))
                    {
                        n.r_type = 1;
                    }
                    else
                    if (part.Contains("S"))
                    {
                        n.s_type = 1;
                    }
                    else
                    {
                        n.t_type = 1;
                    }

                    float v = base2 + stepb * (d.readByte());
                    //				float f = d.readFloat();
                    //				System.out.println(stepb + " " + base + " " + (byte)d.readByte());

                    switch (part)
                    {
                    case "RX":
                        n.r.X = (float)(Math.PI / 180f) * (v);
                        break;

                    case "RY":
                        n.r.Y = (float)(Math.PI / 180f) * (v);
                        break;

                    case "RZ":
                        n.r.Z = (float)(Math.PI / 180f) * (v);
                        break;

                    case "X":
                        n.t.X = v;
                        break;

                    case "Y":
                        n.t.Y = v;
                        break;

                    case "Z":
                        n.t.Z = v;
                        break;

                    case "SX":
                        n.s.X = v;
                        break;

                    case "SY":
                        n.s.Y = v;
                        break;

                    case "SZ":
                        n.s.Z = v;
                        break;
                    }
                }

                //			System.out.println(d.pos());
            }

            if (type == 0x6)
            {
                //if(debug)
                //System.out.println(part + "\tLin 4");
                for (int i = 0; i < anim.size(); i++)
                {
                    KeyNode n = anim.getNode(i, nid);

                    if (part.Contains("R"))
                    {
                        n.r_type = 1;
                    }
                    else
                    if (part.Contains("S"))
                    {
                        n.s_type = 1;
                    }
                    else
                    {
                        n.t_type = 1;
                    }

                    float v = d.readFloat();

                    switch (part)
                    {
                    case "RX":
                        n.r.X = (float)(Math.PI / 180) * (v);
                        break;

                    case "RY":
                        n.r.Y = (float)(Math.PI / 180) * (v);
                        break;

                    case "RZ":
                        n.r.Z = (float)(Math.PI / 180) * (v);
                        break;

                    case "X":
                        n.t.X = v;
                        break;

                    case "Y":
                        n.t.Y = v;
                        break;

                    case "Z":
                        n.t.Z = v;
                        break;

                    case "SX":
                        n.s.X = v;
                        break;

                    case "SY":
                        n.s.Y = v;
                        break;

                    case "SZ":
                        n.s.Z = v;
                        break;
                    }
                }
            }

            d.seek(temp);
        }