Esempio n. 1
0
        public void CopyMatFrom(TMONode motion)
        {
            Console.WriteLine("copy mat {0} {1}", sname, motion.ShortName);
            int i = 0;

            foreach (TMOMat mat in frame_matrices)
            {
                mat.m = motion.frame_matrices[i % motion.frame_matrices.Count].m;
                i++;
            }
            foreach (TMONode child in children)
            {
                child.CopyMatFrom(motion.FindChildByShortName(child.sname));
            }
        }
Esempio n. 2
0
        public void CopyNodeFrom(TMOFile motion, string sname)
        {
            TMONode node = this.FindNodeByShortName(sname);

            if (node == null)
            {
                return;
            }
            TMONode motion_node = motion.FindNodeByShortName(sname);

            if (motion_node == null)
            {
                return;
            }
            node.CopyMatFrom(motion_node);
        }
Esempio n. 3
0
        public bool IsSameNodeTree(TMOFile motion)
        {
            if (nodes.Length != motion.nodes.Length)
            {
                //Console.WriteLine("nodes length mismatch {0} {1}", nodes.Length, motion.nodes.Length);
                return(false);
            }
            int i = 0;

            foreach (TMONode node in nodes)
            {
                TMONode motion_node = motion.nodes[i];
                //Console.WriteLine("node ShortName {0} {1}", node.ShortName, motion_node.ShortName);
                if (motion_node.ShortName != node.ShortName)
                {
                    return(false);
                }
                i++;
            }
            return(true);
        }
Esempio n. 4
0
 public static void Write(BinaryWriter bw, TMONode item)
 {
     Write(bw, item.Name);
 }
Esempio n. 5
0
        public void Load(Stream source_stream)
        {
            this.reader = new BinaryReader(source_stream, System.Text.Encoding.Default);

            byte[] magic = reader.ReadBytes(4);

            if (magic[0] != (byte)'T' ||
                magic[1] != (byte)'M' ||
                magic[2] != (byte)'O' ||
                magic[3] != (byte)'1')
            {
                throw new Exception("File is not TMO");
            }

            this.header = reader.ReadBytes(8);
            this.opt0   = reader.ReadInt32();
            this.opt1   = reader.ReadInt32();

            int node_count = reader.ReadInt32();

            nodes   = new TMONode[node_count];
            nodemap = new Dictionary <string, TMONode>();

            for (int i = 0; i < node_count; i++)
            {
                nodes[i]       = new TMONode();
                nodes[i].id    = i;
                nodes[i].name  = ReadString();
                nodes[i].sname = nodes[i].name.Substring(nodes[i].name.LastIndexOf('|') + 1);
                nodemap.Add(nodes[i].name, nodes[i]);

                //Console.WriteLine(i + ": " + nodes[i].name);
            }

            for (int i = 0; i < node_count; i++)
            {
                int index = nodes[i].name.LastIndexOf('|');
                if (index <= 0)
                {
                    continue;
                }
                string pname = nodes[i].name.Substring(0, index);
                nodes[i].parent = nodemap[pname];
                nodes[i].parent.children.Add(nodes[i]);
            }

            int frame_count = reader.ReadInt32();

            frames = new TMOFrame[frame_count];

            for (int i = 0; i < frame_count; i++)
            {
                frames[i]    = new TMOFrame();
                frames[i].id = i;

                int matrix_count = reader.ReadInt32();
                frames[i].matrices = new TMOMat[matrix_count];

                for (int j = 0; j < matrix_count; j++)
                {
                    frames[i].matrices[j] = new TMOMat(ReadMatrix());
                    nodes[j].frame_matrices.Add(frames[i].matrices[j]);

                    //Console.WriteLine(frames[i].matrices[j].m);
                }
            }

            this.footer = reader.ReadBytes(4);

            reader.Close();
        }