Example #1
0
        public static void loadqb(string path)
        {
            if (!File.Exists(path))
            {
                Client.print("error", $"Error : loadqb -File {path}, was not found.");
                return;
            }

            Client.OpenGLContextThread.Add(() =>
            {
                ImportExportUtil.Import(path);
            });
        }
Example #2
0
        public void Drop(IDataObject dataObject, uint keyState, Point pt, ref uint effect)
        {
            FORMATETC format = new FORMATETC()
            {
                cfFormat = NativeMethods.CF_HDROP,
                dwAspect = DVASPECT.DVASPECT_CONTENT,
                tymed    = TYMED.TYMED_HGLOBAL
            };
            STGMEDIUM medium;

            string[] files;
            dataObject.GetData(ref format, out medium);
            try
            {
                IntPtr dropHandle = medium.unionmember;
                int    fileCount  = NativeMethods.DragQueryFile(new HandleRef(this, dropHandle), -1, null, 0);
                files = new string[fileCount];
                for (int x = 0; x < fileCount; ++x)
                {
                    int size = NativeMethods.DragQueryFile(new HandleRef(this, dropHandle), x, null, 0);
                    if (size > 0)
                    {
                        StringBuilder fileName = new StringBuilder(size + 1);
                        if (NativeMethods.DragQueryFile(new HandleRef(this, dropHandle), x, fileName, fileName.Capacity) > 0)
                        {
                            files[x] = fileName.ToString();
                        }
                    }
                }
            }
            finally
            {
                NativeMethods.ReleaseStgMedium(ref medium);
            }

            foreach (string file in files)
            {
                Client.OpenGLContextThread.Add(() =>
                {
                    ImportExportUtil.Import(file);
                });
            }
        }
Example #3
0
        protected override void OnKeyDown(KeyboardKeyEventArgs e)
        {
            base.OnKeyDown(e);
            input.handleKeydown(e);

            if (e.Control && e.Key == Key.O)
            {
                var open = new OpenFileDialog();
                open.Multiselect = false;
                open.Title       = "StoneVox - Open File";
                open.DefaultExt  = ".qb";

                open.FileOk += (s, o) =>
                {
                    Client.OpenGLContextThread.Add(() =>
                    {
                        ImportExportUtil.Import(open.FileName);
                    });
                };

                Thread thread = new Thread(() =>
                {
                    open.ShowDialog();
                });

                thread.SetApartmentState(ApartmentState.STA);
                thread.Start();
            }
            if (e.Control && e.Key == Key.S)
            {
                var save = new SaveFileDialog();
                save.Title      = "StoneVox - Save File";
                save.Filter     = "StoneVox Project (.svp)|*.svp|Qubicle Binary (.qb)|*.qb|Wavefront OBJ (.obj)|*.obj|All files (*.*)|*.*";
                save.DefaultExt = ".svp";

                save.FileOk += (s, t) =>
                {
                    QbModel model = manager.ActiveModel;
                    model.name = save.FileName.Split('\\').Last();
                    if (model.name.Contains('.'))
                    {
                        model.name = model.name.Split('.').First();
                    }
                    broadcaster.Broadcast(Message.ModelRenamed, model, model.name);
                    ImportExportUtil.Export(save.FileName.Split('\\').Last().Replace(model.name, ""), model.name, Path.GetDirectoryName(save.FileName), model);
                };

                Thread thread = new Thread(() =>
                {
                    save.ShowDialog();
                });

                thread.SetApartmentState(ApartmentState.STA);
                thread.Start();
            }
            else if (e.Control && e.Key == Key.F12)
            {
                GUIEditor editor = new GUIEditor();
                editor.Show();
            }
            //else if (e.Key == Key.T)
            //{
            //    Stopwatch w = Stopwatch.StartNew();
            //    var model = Singleton<QbManager>.INSTANCE.ActiveMatrix;

            //    Colort color = new Colort(1f, 0f, 0f);

            //    var volume = new VoxelVolume()
            //    {
            //        minx = 0,
            //        maxx = 100,
            //        miny = 0,
            //        maxy = 100,
            //        minz = 0,
            //        maxz = 100
            //    };

            //    model.Add(volume, ref color);

            //    w.Stop();
            //    Console.WriteLine("add " + w.ElapsedMilliseconds.ToString());
            //}
            //else if (e.Key == Key.T)
            //{
            //    Stopwatch w = Stopwatch.StartNew();
            //    var model = Singleton<QbManager>.INSTANCE.ActiveMatrix;

            //    Colort color = new Colort(1f, 0f, 0f);
            //    for (int x = 0; x < 100; x++)
            //        for (int z = 0; z < 100; z++)
            //        for (int y = 0; y< 100; y++)
            //                model.Add(x, y, z, color);

            //    w.Stop();
            //    Console.WriteLine("add " +w.ElapsedMilliseconds.ToString());
            //}

            //else if (e.Key == Key.Y)
            //{
            //    Stopwatch w = Stopwatch.StartNew();
            //    var model = Singleton<QbManager>.INSTANCE.ActiveMatrix;

            //    Colort color = new Colort(1f, 0f, 0f);
            //    for (int x = 0; x < 100; x++)
            //        for (int z = 0; z < 100; z++)
            //            for (int y = 0; y < 100; y++)

            //                model.Remove(x, y, z);

            //    w.Stop();
            //    Console.WriteLine("earse " + w.ElapsedMilliseconds.ToString());
            //}
        }