コード例 #1
0
        public void Apply(VBN vbn, int frame)
        {
            if (frame == 0)
            {
                vbn.reset();
            }

            OMOFrame keys = Frames[frame];

            foreach (OMONode node in Nodes)
            {
                foreach (Bone b in vbn.bones)
                {
                    if (b.boneId == node.hash)
                    {
                        // apply interpolation frames
                        Console.WriteLine(b.Text);
                        node.Apply(b, keys);
                        break;
                    }
                }
            }

            vbn.update();
        }
コード例 #2
0
            public void Apply(Bone b, OMOFrame f)
            {
                if (posType == OMOFlags.PosConst)
                {
                    b.pos = pos_min;
                }
                if (rotType == OMOFlags.RotConst || rotType == OMOFlags.RotFConst)
                {
                    b.rot = new Quaternion(rot_min.Xyz, rot_min.W);
                }
                if (scaType == OMOFlags.ScaConst || scaType == OMOFlags.ScaConst2)
                {
                    b.sca = sca_min;
                }

                int i = keyOffset / 2;

                if (posType == OMOFlags.PosInter)
                {
                    b.pos = new Vector3(
                        pos_min.X + (pos_max.X * ((float)f.keys[i++] / 0xFFFF)),
                        pos_min.Y + (pos_max.Y * ((float)f.keys[i++] / 0xFFFF)),
                        pos_min.Z + (pos_max.Z * ((float)f.keys[i++] / 0xFFFF))
                        );
                }

                if (rotType == OMOFlags.RotInter)
                {
                    Vector4 v = calcW(new Vector4(
                                          rot_min.X + (rot_max.X * ((float)f.keys[i++] / 0xFFFF)),
                                          rot_min.Y + (rot_max.Y * ((float)f.keys[i++] / 0xFFFF)),
                                          rot_min.Z + (rot_max.Z * ((float)f.keys[i++] / 0xFFFF))
                                          , 0));
                    //Console.WriteLine(rot_min.ToString() + " " + rot_max.ToString());
                    b.rot = new Quaternion(v.Xyz, v.W);
                }

                if (rotType == OMOFlags.RotFrame)
                {
                    Vector4 v = new Vector4(
                        ((ushort)f.keys[i++] / (float)0xFFFF),
                        ((ushort)f.keys[i++] / (float)0xFFFF),
                        ((ushort)f.keys[i++] / (float)0xFFFF),
                        ((ushort)f.keys[i++] / (float)0xFFFF));
                    Console.WriteLine("WHAT DO I DO HERE?");
                    Console.WriteLine(b.rot.ToString() + " " + v.ToString() + " " + Math.Sqrt(v.X * v.X + v.Y * v.Y + v.Z * v.Z + v.W * v.W) + "\n" + Matrix4.CreateFromQuaternion(b.rot).Inverted().ToString());
                    //4adbb195
                }

                if (scaType == OMOFlags.ScaInter)
                {
                    b.sca = new Vector3(
                        sca_min.X + (sca_max.X * ((float)f.keys[i++] / 0xFFFF)),
                        sca_min.Y + (sca_max.Y * ((float)f.keys[i++] / 0xFFFF)),
                        sca_min.Z + (sca_max.Z * ((float)f.keys[i++] / 0xFFFF))
                        );
                }
            }
コード例 #3
0
        public void Read(FileData d)
        {
            d.Endian = Endianness.Big;

            d.skip(4);

            header = new OMOHeader()
            {
                verHi       = d.readUShort(),
                verLow      = d.readUShort(),
                flags       = d.readInt(),
                unk1        = d.readUShort(),
                boneCount   = d.readUShort(),
                frameCount  = d.readUShort(),
                frameSize   = d.readUShort(),
                nodeOffset  = d.readInt(),
                interOffset = d.readInt(),
                keyOffset   = d.readInt()
            };

            d.seek(header.nodeOffset);
            for (int i = 0; i < header.boneCount; i++)
            {
                OMONode node = new OMONode()
                {
                    flags       = d.readInt(),
                    hash        = (uint)d.readInt(),
                    interOffset = d.readInt(),
                    keyOffset   = d.readInt()
                };
                int temp = d.pos();
                d.seek(header.interOffset + node.interOffset);
                Console.WriteLine(node.hash.ToString("x") + " " + (header.interOffset + node.interOffset).ToString("x"));
                node.Read(d);
                d.seek(temp);
                Nodes.Add(node);
            }

            d.seek(header.keyOffset);
            for (int i = 0; i < header.frameCount; i++)
            {
                OMOFrame frame = new OMOFrame();
                // /2 because size of short
                for (int j = 0; j < header.frameSize / 2; j++)
                {
                    frame.keys.Add(d.readUShort());
                }
                Frames.Add(frame);
            }
        }