Ejemplo n.º 1
0
 public TSOFigure()
 {
     tmo              = new TMOFile();
     nodemap          = new Dictionary <TSONode, TMONode>();
     tmo_frame_one    = new TMOFrame();
     combinedMatrices = new Dictionary <TMOFrame, Dictionary <TSONode, Matrix> >();
     combinedMatrices[tmo_frame_one] = new Dictionary <TSONode, Matrix>();
     matrixStack = new MatrixStack();
 }
Ejemplo 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);
        }
Ejemplo n.º 3
0
        public List <TSOFigure> LoadPNGFile(string source_file)
        {
            List <TSOFigure> fig_list = new List <TSOFigure>();

            if (File.Exists(source_file))
            {
                try
                {
                    PNGFile   png = new PNGFile();
                    TSOFigure fig = null;
                    TMOFile   tmo = null;

                    png.Hsav += delegate(string type)
                    {
                        fig = new TSOFigure();
                        fig_list.Add(fig);
                    };
                    png.Lgta += delegate(Stream dest, int extract_length)
                    {
                        fig = new TSOFigure();
                        fig_list.Add(fig);
                    };
                    png.Ftmo += delegate(Stream dest, int extract_length)
                    {
                        tmo = new TMOFile();
                        tmo.Load(dest);
                        fig.Tmo = tmo;
                    };
                    png.Figu += delegate(Stream dest, int extract_length)
                    {
                    };
                    png.Ftso += delegate(Stream dest, int extract_length, byte[] opt1)
                    {
                        TSOFile tso = new TSOFile();
                        tso.Load(dest);
                        fig.TSOList.Add(tso);
                    };
                    png.Load(source_file);
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Error: " + ex);
                }
            }
            return(fig_list);
        }
Ejemplo n.º 4
0
        public void SlerpFrameEndTo(TMOFile motion, int append_length)
        {
            int i0 = (frames.Length > 1) ? frames.Length - 1 - 1 : 0;
            int i1 = frames.Length - 1;
            int i2 = 0;
            int i3 = (motion.frames.Length > 1) ? 1 : 0;

            TMOFrame frame0 = frames[i0];
            TMOFrame frame1 = frames[i1];
            TMOFrame frame2 = motion.frames[i2];
            TMOFrame frame3 = motion.frames[i3];

            TMOFrame[] interp_frames = TMOFrame.Slerp(frame0, frame1, frame2, frame3, append_length);
            int        old_length    = frames.Length;

            Array.Resize(ref frames, frames.Length + append_length);
            Array.Copy(interp_frames, 0, frames, old_length, append_length);
            this.opt0 = frames.Length - 1;
        }
Ejemplo n.º 5
0
        public void AppendFrameFrom(TMOFile motion)
        {
            int[] index_pair = CreateFrameIndexPair(motion);

            TMOFrame source_frame  = frames[0];
            int      append_length = motion.frames.Length;

            TMOFrame[] append_frames = new TMOFrame[append_length];
            for (int i = 0; i < motion.frames.Length; i++)
            {
                append_frames[i] = TMOFrame.Select(source_frame, motion.frames[i], index_pair);
            }

            int old_length = frames.Length;

            Array.Resize(ref frames, frames.Length + append_length);
            Array.Copy(append_frames, 0, frames, old_length, append_length);
            this.opt0 = frames.Length - 1;
        }
Ejemplo n.º 6
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);
        }
Ejemplo n.º 7
0
        public int[] CreateFrameIndexPair(TMOFile motion)
        {
            Dictionary <string, TMONode> source_nodes = new Dictionary <string, TMONode>();

            Dictionary <string, TMONode> motion_nodes = new Dictionary <string, TMONode>();

            foreach (TMONode node in motion.nodes)
            {
                try {
                    motion_nodes.Add(node.ShortName, node);
                } catch (ArgumentException) {
                    Console.WriteLine("node {0} already exists.", node.ShortName);
                }
            }
            foreach (TMONode node in nodes)
            {
                if (!motion_nodes.ContainsKey(node.ShortName))
                {
                    throw new ArgumentException("error: node not found in motion: " + node.ShortName);
                }
                try {
                    source_nodes.Add(node.ShortName, node);
                } catch (ArgumentException) {
                    Console.WriteLine("node {0} already exists.", node.ShortName);
                }
            }

            int[] index_pair = new int[nodes.Length];

            for (int i = 0; i < nodes.Length; i++)
            {
                index_pair[i] = motion_nodes[nodes[i].ShortName].ID;
            }

            return(index_pair);
        }
Ejemplo n.º 8
0
        public void AddFigureFromPNGFile(string source_file)
        {
            List <TSOFigure> fig_list = LoadPNGFile(source_file);

            if (fig_list.Count != 0)                //taOb png
            {
                if (fig_list[0].TSOList.Count == 0) //POSE png
                {
                    TMOFile   tmo = fig_list[0].Tmo;
                    TSOFigure fig;
                    if (tmo != null && TryGetFigure(out fig))
                    {
                        fig.Tmo = tmo;
                        fig.UpdateNodeMapAndBoneMatrices();
                    }
                }
                else
                {
                    figureIndex = TSOFigureList.Count;
                    foreach (TSOFigure fig in fig_list)
                    {
                        fig.OpenTSOFile(device, effect);
                        fig.UpdateNodeMapAndBoneMatrices();
                        TSOFigureList.Add(fig);
                    }
                }
            }
            {
                TSOFigure fig;
                if (TryGetFigure(out fig))
                {
                    fig.UpdateCenterPosition();
                    camera.SetCenter(fig.position);
                }
            }
        }
Ejemplo n.º 9
0
        public static int UpdateTmo(string source_file)
        {
            string dest_file = source_file + ".tmp";

            TMOFile tmo = new TMOFile();

            try
            {
                tmo.Load(source_file);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                return(-1);
            }

            if (tmo.nodes[0].ShortName != "W_Hips")
            {
                Console.WriteLine("Passed: root node is not W_Hips");
                return(1);
            }

            Dictionary <string, TMONode> nodes = new Dictionary <string, TMONode>();

            foreach (TMONode node in tmo.nodes)
            {
                try {
                    nodes.Add(node.ShortName, node);
                } catch (ArgumentException) {
                    Console.WriteLine("node {0} already exists.", node.ShortName);
                }
            }

            try {
                TMONode node;
                node = nodes["W_Hips"];
                node.Scale1(0.93F, 0.75F, 0.85F);
                node = nodes["W_LeftUpLeg"];
                node.Scale1(0.78F, 0.66F, 0.78F);
                node.Move(-0.100F, 0.000F, 0.000F);
                node = nodes["W_LeftUpLegRoll"];
                node.Scale1(0.85F, 0.68F, 0.86F);
                node = nodes["W_LeftLeg"];
                node.Scale1(0.81F, 0.63F, 0.71F);
                node = nodes["W_LeftLegRoll"];
                node.Scale1(0.83F, 0.84F, 0.81F);
                node = nodes["W_LeftFoot"];
                node.Scale1(0.91F, 0.81F, 0.71F);
                node = nodes["W_LeftToeBase"];
                node.Scale1(0.80F, 0.80F, 0.80F);
                node = nodes["W_RightUpLeg"];
                node.Scale1(0.78F, 0.66F, 0.78F);
                node.Move(0.100F, 0.000F, 0.000F);
                node = nodes["W_RightUpLegRoll"];
                node.Scale1(0.85F, 0.68F, 0.86F);
                node = nodes["W_RightLeg"];
                node.Scale1(0.81F, 0.63F, 0.71F);
                node = nodes["W_RightLegRoll"];
                node.Scale1(0.83F, 0.84F, 0.81F);
                node = nodes["W_RightFoot"];
                node.Scale1(0.91F, 0.81F, 0.71F);
                node = nodes["W_RightToeBase"];
                node.Scale1(0.80F, 0.80F, 0.80F);
                node = nodes["W_Spine_Dummy"];
                node.Scale1(0.95F, 0.70F, 0.90F);
                node = nodes["W_Spine1"];
                node.Scale1(0.95F, 0.70F, 1.00F);
                node.Move(0.000F, -0.090F, 0.000F);
                node = nodes["W_Spine2"];
                node.Scale1(0.95F, 0.60F, 1.00F);
                node.Move(0.000F, -0.100F, 0.000F);
                node = nodes["W_Spine3"];
                node.Scale1(0.90F, 1.00F, 0.95F);
                node.Move(0.000F, -0.065F, 0.000F);
                node = nodes["W_RightShoulder_Dummy"];
                node.Scale1(0.73F, 0.96F, 0.84F);
                node = nodes["W_RightShoulder"];
                node.Scale1(1.00F, 0.75F, 1.00F);
                node = nodes["W_RightArm_Dummy"];
                node.Scale1(0.71F, 1.00F, 1.00F);
                node = nodes["W_RightArm"];
                node.Scale1(0.76F, 1.00F, 1.00F);
                node = nodes["W_RightArmRoll"];
                node.Scale1(0.76F, 1.00F, 1.00F);
                node = nodes["W_RightForeArm"];
                node.Scale1(0.70F, 0.90F, 0.90F);
                node = nodes["W_RightForeArmRoll"];
                node.Scale1(0.72F, 1.00F, 1.00F);
                node = nodes["W_RightHand"];
                node.Scale1(0.70F, 0.87F, 0.87F);
                node = nodes["W_RightHandPinky1"];
                node.Scale1(0.70F, 1.00F, 1.00F);
                node = nodes["W_RightHandPinky2"];
                node.Scale1(0.70F, 1.00F, 1.00F);
                node = nodes["W_RightHandPinky3"];
                node.Scale1(0.70F, 1.00F, 1.00F);
                node = nodes["W_RightHandPinky4"];
                node.Scale1(0.70F, 1.00F, 1.00F);
                node = nodes["W_RightHandRing1"];
                node.Scale1(0.70F, 1.00F, 1.00F);
                node = nodes["W_RightHandRing2"];
                node.Scale1(0.70F, 1.00F, 1.00F);
                node = nodes["W_RightHandRing3"];
                node.Scale1(0.70F, 1.00F, 1.00F);
                node = nodes["W_RightHandRing4"];
                node.Scale1(0.70F, 1.00F, 1.00F);
                node = nodes["W_RightHandMiddle1"];
                node.Scale1(0.70F, 1.00F, 1.00F);
                node = nodes["W_RightHandMiddle2"];
                node.Scale1(0.70F, 1.00F, 1.00F);
                node = nodes["W_RightHandMiddle3"];
                node.Scale1(0.70F, 1.00F, 1.00F);
                node = nodes["W_RightHandMiddle4"];
                node.Scale1(0.70F, 1.00F, 1.00F);
                node = nodes["W_RightHandIndex1"];
                node.Scale1(0.70F, 1.00F, 1.00F);
                node = nodes["W_RightHandIndex2"];
                node.Scale1(0.70F, 1.00F, 1.00F);
                node = nodes["W_RightHandIndex3"];
                node.Scale1(0.70F, 1.00F, 1.00F);
                node = nodes["W_RightHandIndex4"];
                node.Scale1(0.70F, 1.00F, 1.00F);
                node = nodes["W_RightHandThumb1"];
                node.Scale1(0.70F, 1.00F, 1.00F);
                node = nodes["W_RightHandThumb2"];
                node.Scale1(0.70F, 1.00F, 1.00F);
                node = nodes["W_RightHandThumb3"];
                node.Scale1(0.70F, 1.00F, 1.00F);
                node = nodes["W_RightHandThumb4"];
                node.Scale1(0.70F, 1.00F, 1.00F);
                node = nodes["W_LeftShoulder_Dummy"];
                node.Scale1(0.73F, 0.96F, 0.84F);
                node = nodes["W_LeftShoulder"];
                node.Scale1(1.00F, 0.75F, 1.00F);
                node = nodes["W_LeftArm_Dummy"];
                node.Scale1(0.71F, 1.00F, 1.00F);
                node = nodes["W_LeftArm"];
                node.Scale1(0.76F, 1.00F, 1.00F);
                node = nodes["W_LeftArmRoll"];
                node.Scale1(0.76F, 1.00F, 1.00F);
                node = nodes["W_LeftForeArm"];
                node.Scale1(0.70F, 0.90F, 0.90F);
                node = nodes["W_LeftForeArmRoll"];
                node.Scale1(0.72F, 1.00F, 1.00F);
                node = nodes["W_LeftHand"];
                node.Scale1(0.70F, 0.87F, 0.87F);
                node = nodes["W_LeftHandPinky1"];
                node.Scale1(0.70F, 1.00F, 1.00F);
                node = nodes["W_LeftHandPinky2"];
                node.Scale1(0.70F, 1.00F, 1.00F);
                node = nodes["W_LeftHandPinky3"];
                node.Scale1(0.70F, 1.00F, 1.00F);
                node = nodes["W_LeftHandPinky4"];
                node.Scale1(0.70F, 1.00F, 1.00F);
                node = nodes["W_LeftHandRing1"];
                node.Scale1(0.70F, 1.00F, 1.00F);
                node = nodes["W_LeftHandRing2"];
                node.Scale1(0.70F, 1.00F, 1.00F);
                node = nodes["W_LeftHandRing3"];
                node.Scale1(0.70F, 1.00F, 1.00F);
                node = nodes["W_LeftHandRing4"];
                node.Scale1(0.70F, 1.00F, 1.00F);
                node = nodes["W_LeftHandMiddle1"];
                node.Scale1(0.70F, 1.00F, 1.00F);
                node = nodes["W_LeftHandMiddle2"];
                node.Scale1(0.70F, 1.00F, 1.00F);
                node = nodes["W_LeftHandMiddle3"];
                node.Scale1(0.70F, 1.00F, 1.00F);
                node = nodes["W_LeftHandMiddle4"];
                node.Scale1(0.70F, 1.00F, 1.00F);
                node = nodes["W_LeftHandIndex1"];
                node.Scale1(0.70F, 1.00F, 1.00F);
                node = nodes["W_LeftHandIndex2"];
                node.Scale1(0.70F, 1.00F, 1.00F);
                node = nodes["W_LeftHandIndex3"];
                node.Scale1(0.70F, 1.00F, 1.00F);
                node = nodes["W_LeftHandIndex4"];
                node.Scale1(0.70F, 1.00F, 1.00F);
                node = nodes["W_LeftHandThumb1"];
                node.Scale1(0.70F, 1.00F, 1.00F);
                node = nodes["W_LeftHandThumb2"];
                node.Scale1(0.70F, 1.00F, 1.00F);
                node = nodes["W_LeftHandThumb3"];
                node.Scale1(0.70F, 1.00F, 1.00F);
                node = nodes["W_LeftHandThumb4"];
                node.Scale1(0.70F, 1.00F, 1.00F);
                node = nodes["W_Neck"];
                node.Scale1(1.00F, 0.72F, 1.00F);
                node = nodes["face_oya"];
                node.Scale1(1.00F, 0.94F, 1.00F);
                node = nodes["sitakuti_oya"];
                node.Scale1(1.00F, 0.94F, 1.00F);
                node = nodes["Ha_Down"];
                node.Scale1(1.00F, 0.94F, 1.00F);
                node = nodes["sitakuti_l_1"];
                node.Scale1(1.00F, 0.94F, 1.00F);
                node = nodes["sitakuti_r_1"];
                node.Scale1(1.00F, 0.94F, 1.00F);
                node = nodes["sita_01"];
                node.Scale1(1.00F, 0.94F, 1.00F);
                node = nodes["sita_02"];
                node.Scale1(1.00F, 0.94F, 1.00F);
                node = nodes["sita_03"];
                node.Scale1(1.00F, 0.94F, 1.00F);
                node = nodes["kutiyoko_r"];
                node.Scale1(1.00F, 0.94F, 1.00F);
                node = nodes["kutiyoko_l"];
                node.Scale1(1.00F, 0.94F, 1.00F);
                node = nodes["uekuti_oya"];
                node.Scale1(1.00F, 0.94F, 1.00F);
                node = nodes["Ha_UP"];
                node.Scale1(1.00F, 0.94F, 1.00F);
                node = nodes["uekuti_l_1"];
                node.Scale1(1.00F, 0.94F, 1.00F);
                node = nodes["uekuti_r_1"];
                node.Scale1(1.00F, 0.94F, 1.00F);
                node = nodes["Kami_Oya"];
                node.Scale1(1.00F, 0.94F, 1.00F);
                node = nodes["kami_Front_Mid1_L"];
                node.Scale1(1.00F, 0.94F, 1.00F);
                node = nodes["kami_Front_Mid2_L"];
                node.Scale1(1.00F, 0.94F, 1.00F);
                node = nodes["kami_Front_Mid3_L"];
                node.Scale1(1.00F, 0.94F, 1.00F);
                node = nodes["kami_Front_Mid1_R"];
                node.Scale1(1.00F, 0.94F, 1.00F);
                node = nodes["kami_Front_Mid2_R"];
                node.Scale1(1.00F, 0.94F, 1.00F);
                node = nodes["kami_Front_Mid3_R"];
                node.Scale1(1.00F, 0.94F, 1.00F);
                node = nodes["Chichi_Right1"];
                node.Scale1(0.90F, 1.00F, 0.91F);
                node = nodes["Chichi_Left1"];
                node.Scale1(0.90F, 1.00F, 0.91F);
            } catch (KeyNotFoundException) {
                Console.WriteLine("node not found.");
            }

            tmo.Save(dest_file);

            System.IO.File.Delete(source_file);
            System.IO.File.Move(dest_file, source_file);
            Console.WriteLine("Pedoed: " + source_file);

            return(0);
        }
Ejemplo n.º 10
0
 public void SlerpFrameEndTo(TMOFile motion)
 {
     SlerpFrameEndTo(motion, 200);
 }
Ejemplo n.º 11
0
        public bool InitializeApplication(TSOForm form)
        {
            this.form = form;

            for (int i = 0; i < keysEnabled.Length; i++)
            {
                keysEnabled[i] = true;
            }
            form.KeyDown += new KeyEventHandler(form_OnKeyDown);
            form.KeyUp   += new KeyEventHandler(form_OnKeyUp);

            form.MouseDown += new MouseEventHandler(form_OnMouseDown);
            form.MouseMove += new MouseEventHandler(form_OnMouseMove);

            form.DragDrop  += new DragEventHandler(form_OnDragDrop);
            form.DragEnter += new DragEventHandler(form_OnDragEnter);

            PresentParameters pp = new PresentParameters();

            try
            {
                pp.Windowed               = true;
                pp.SwapEffect             = SwapEffect.Discard;
                pp.BackBufferFormat       = Format.X8R8G8B8;
                pp.BackBufferCount        = 1;
                pp.EnableAutoDepthStencil = true;
                pp.AutoDepthStencilFormat = DepthFormat.D16;

                int adapter_ordinal = Manager.Adapters.Default.Adapter;

                int ret, quality;
                if (Manager.CheckDeviceMultiSampleType(adapter_ordinal, DeviceType.Hardware, pp.BackBufferFormat, pp.Windowed, MultiSampleType.FourSamples, out ret, out quality))
                {
                    pp.MultiSample        = MultiSampleType.FourSamples;
                    pp.MultiSampleQuality = quality - 1;
                }

                CreateFlags flags = CreateFlags.SoftwareVertexProcessing;
                Caps        caps  = Manager.GetDeviceCaps(adapter_ordinal, DeviceType.Hardware);
                if (caps.DeviceCaps.SupportsHardwareTransformAndLight)
                {
                    flags = CreateFlags.HardwareVertexProcessing;
                }
                if (caps.DeviceCaps.SupportsPureDevice)
                {
                    flags |= CreateFlags.PureDevice;
                }
                device = new Device(adapter_ordinal, DeviceType.Hardware, form.Handle, flags, pp);

                FontDescription fd = new FontDescription();
                fd.Height   = 24;
                fd.FaceName = "MS Gothic";
                font        = new Direct3D.Font(device, fd);
            }
            catch (DirectXException ex)
            {
                Console.WriteLine("Error: " + ex);
                return(false);
            }

            Directory.SetCurrentDirectory(Application.StartupPath);

            boneMatrices = new Matrix[maxBones];

            string effect_file = @"toonshader.cgfx";

            if (!File.Exists(effect_file))
            {
                Console.WriteLine("File not found: " + effect_file);
                return(false);
            }
            string compile_error;

            effect = Effect.FromFile(device, effect_file, null, ShaderFlags.None, null, out compile_error);
            if (compile_error != null)
            {
                Console.WriteLine(compile_error);
                return(false);
            }
            handle_LocalBoneMats = effect.GetParameter(null, "LocalBoneMats");

            int devw = 0;
            int devh = 0;

            using (Surface surface = device.DepthStencilSurface)
            {
                devw = surface.Description.Width;
                devh = surface.Description.Height;
            }
            Console.WriteLine("dev {0}x{1}", devw, devh);

            dev_surface = device.GetRenderTarget(0);
            dev_zbuf    = device.DepthStencilSurface;

            camera.Update();
            camera.SetTranslation(camTranslation);

            Transform_Projection = Matrix.PerspectiveFovLH(
                Geometry.DegreeToRadian(30.0f),
                (float)device.Viewport.Width / (float)device.Viewport.Height,
                1.0f,
                1000.0f);

            // xxx: for w-buffering
            device.Transform.Projection = Transform_Projection;

            if (effect != null)
            {
                effect.SetValue("proj", Transform_Projection);
            }

            device.RenderState.Lighting = false;
            device.RenderState.CullMode = Cull.CounterClockwise;

            device.RenderState.AlphaBlendEnable = true;
            device.SetTextureStageState(0, TextureStageStates.AlphaOperation, (int)TextureOperation.Modulate);
            device.SetTextureStageState(0, TextureStageStates.AlphaArgument1, (int)TextureArgument.TextureColor);
            device.SetTextureStageState(0, TextureStageStates.AlphaArgument2, (int)TextureArgument.Current);

            device.RenderState.SourceBlend      = Blend.SourceAlpha;
            device.RenderState.DestinationBlend = Blend.InvSourceAlpha;

            device.RenderState.IndexedVertexBlendEnable = true;

            current_tmo = new TMOFile();
            return(true);
        }
Ejemplo n.º 12
0
        public static int UpdateTmo(string source_file)
        {
            string dest_file = source_file + ".tmp";

            TMOFile tmo = new TMOFile();

            try
            {
                tmo.Load(source_file);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                return(-1);
            }

            if (tmo.nodes[0].ShortName != "W_Hips")
            {
                Console.WriteLine("Passed: root node is not W_Hips");
                return(1);
            }

            Dictionary <string, TMONode> nodes = new Dictionary <string, TMONode>();

            foreach (TMONode node in tmo.nodes)
            {
                try {
                    nodes.Add(node.ShortName, node);
                } catch (ArgumentException) {
                    Console.WriteLine("node {0} already exists.", node.ShortName);
                }
            }

            try {
                TMONode node;

                node = nodes["Chichi_Right1"];
                node.RotateY(DegreeToRadian(-5));
                node.RotateX(DegreeToRadian(5));

                node = nodes["Chichi_Left1"];
                node.RotateY(DegreeToRadian(10));
                node.RotateX(DegreeToRadian(10));

                node = nodes["Chichi_Right2"];
                node.Scale(1.8F, 1.8F, 2.2F);

                node = nodes["Chichi_Left2"];
                node.Scale(1.8F, 1.8F, 2.2F);

                node = nodes["W_Spine_Dummy"];
                node.Scale1(1.1F, 1.0F, 1.1F);

                node = nodes["W_Spine1"];
                node.Scale1(1.2F, 1.0F, 1.2F);

                node = nodes["W_Spine2"];
                node.Scale1(1.3F, 1.0F, 1.3F);

                node = nodes["W_Spine3"];
                node.Scale1(1.1F, 1.0F, 1.1F);
            } catch (KeyNotFoundException) {
                Console.WriteLine("node not found.");
            }

            tmo.Save(dest_file);

            System.IO.File.Delete(source_file);
            System.IO.File.Move(dest_file, source_file);
            Console.WriteLine("Boined: " + source_file);

            return(0);
        }