Esempio n. 1
0
        public static void beginstonevox()
        {
            print("info", "StoneVox starting...");
            try
            {
                window = new GLWindow(1280, 720, new GraphicsMode(new ColorFormat(32), 8, 0, 4));
            }
            catch
            {
                window = new GLWindow(1280, 720, new GraphicsMode(new ColorFormat(32), 8, 0, 0));
            }
            window.Context.SwapInterval = 0;

#if DEBUG
            window.Run_NoErrorCatching(120);
#else
            window.Run_WithErrorCatching(120);
#endif
        }
Esempio n. 2
0
        public static void beginstonevox()
        {
            print("info", "StoneVox starting...");
            try
            {
                window = new GLWindow(1280, 720, new GraphicsMode(new ColorFormat(32), 8, 0, 4));
            }
            catch
            {
                window = new GLWindow(1280, 720, new GraphicsMode(new ColorFormat(32), 8, 0, 0));
            }
            window.Context.SwapInterval = 0;

#if DEBUG
            window.Run_NoErrorCatching(120);
#else
            window.Run_WithErrorCatching(120);
#endif

        }
Esempio n. 3
0
        public Raycaster(GLWindow window, Camera camera, Selection selection, Floor floor, Input input, QbManager manager, GUI gui)
        {
            this.window    = window;
            this.camera    = camera;
            this.input     = input;
            this.floor     = floor;
            this.selection = selection;
            this.manager   = manager;
            this.gui       = gui;

            clientwidth    = window.Width;
            clientheight   = window.Height;
            window.Resize += (e, o) =>
            {
                clientwidth  = window.Width;
                clientheight = window.Height;
            };

            thread = new Thread(RaycastTask);
            thread.Start();
        }
Esempio n. 4
0
 public Input(GLWindow window)
     : base()
 {
     this.window = window;
 }
Esempio n. 5
0
        public Camera(GLWindow window, Input input, QbManager manager)
            : base()
        {
            this.input   = input;
            this.manager = manager;

            window.Resize += (e, s) =>
            {
                projection = Matrix4.CreatePerspectiveFieldOfView(MathHelper.DegreesToRadians(fov), (float)window.Width / (float)window.Height, nearPlane, farPlane);
            };

            position  = new Vector3(0f, 0f, 10f);
            direction = new Vector3(0f, 0f, 1f);
            direction.Normalize();

            projection          = Matrix4.CreatePerspectiveFieldOfView(MathHelper.DegreesToRadians(fov), (float)window.Width / (float)window.Height, nearPlane, farPlane);
            view                = Matrix4.LookAt(position, position + direction, VectorUtils.UP);
            modelviewprojection = projection * view;

            InputHandler handler = new InputHandler()
            {
                Keydownhandler = (e) =>
                {
                    var gui = Singleton <GUI> .INSTANCE;

                    if (gui.FocusingWidget)
                    {
                        // OMG FIX THIS... NEED TO CENTERALIZE THIS TYPE OF CHECKING
                        var possibletextbox = gui.lastWidgetFocused as TextBox;
                        if (possibletextbox != null)
                        {
                            return;
                        }

                        Label possiblelabe = gui.lastWidgetFocused as Label;
                        if (possiblelabe != null)
                        {
                            return;
                        }
                    }

                    //freecam is super interesting... but need a bit of work
                    //if (e.Key == Key.C)
                    //{
                    //    freecam = !freecam;

                    //    if (freecam)
                    //    {
                    //        Client.window.CursorVisible = false;
                    //    }
                    //    else
                    //    {
                    //        Client.window.CursorVisible = true;
                    //    }
                    //}
                },


                mousewheelhandler = (e) =>
                {
                    if (!Singleton <GUI> .INSTANCE.OverWidget)
                    {
                        if (e.Delta < 0)
                        {
                            position -= direction * 6 * 1f;
                        }
                        else if (e.Delta > 0)
                        {
                            position += direction * 6 * 1f;
                        }
                    }
                    else if (Singleton <GUI> .INSTANCE.lastWidgetOver.Drag)
                    {
                        if (e.Delta < 0)
                        {
                            position -= direction * 6 * 1f;
                        }
                        else if (e.Delta > 0)
                        {
                            position += direction * 6 * 1f;
                        }
                    }
                }
            };

            input.AddHandler(handler);
        }
Esempio n. 6
0
        public BrushManager(GLWindow window, Input input)
            : base()
        {
            this.window = window;

            brushes = new Dictionary <VoxelBrushType, IVoxelBrush>();
            brushes.Add(VoxelBrushType.Add, new BrushAdd());
            brushes.Add(VoxelBrushType.Remove, new BrushRemove());
            brushes.Add(VoxelBrushType.Recolor, new BrushRecolor());
            brushes.Add(VoxelBrushType.MatrixSelect, new BrushMatrixSelection());
            brushes.Add(VoxelBrushType.ColorSelect, new BrushColorSelection());
            brushes.Add(VoxelBrushType.Select, new BrushVoxelSelection());

            input.AddHandler(new InputHandler()
            {
                Keydownhandler = (e) =>
                {
                    if (e.Key == Key.Tab)
                    {
                        NextBrush();
                    }

                    var gui = Singleton <GUI> .INSTANCE;

                    if (gui.FocusingWidget)
                    {
                        // OMG FIX THIS... NEED TO CENTERALIZE THIS TYPE OF CHECKING
                        var possibletextbox = gui.lastWidgetFocused as TextBox;
                        if (possibletextbox != null)
                        {
                            return;
                        }

                        Label possiblelabe = gui.lastWidgetFocused as Label;
                        if (possiblelabe != null)
                        {
                            return;
                        }
                    }

                    if (e.Key == Key.B)
                    {
                        SetCurrentBrush(VoxelBrushType.Add);
                    }
                    else if (e.Key == Key.R)
                    {
                        SetCurrentBrush(VoxelBrushType.Recolor);
                    }
                    else if (e.Key == Key.F)
                    {
                        SetCurrentBrush(VoxelBrushType.Remove);
                    }
                }
            });

            window.SVReizeEvent += (e, o) =>
            {
                var values = Enum.GetValues(typeof(VoxelBrushType));
                var enumer = values.GetEnumerator();
                while (enumer.MoveNext())
                {
                    string path = brushes[(VoxelBrushType)enumer.Current].CursorPath;

                    if (string.IsNullOrEmpty(path))
                    {
                        brushes[(VoxelBrushType)enumer.Current].Cursor = OpenTK.MouseCursor.Default;
                        continue;
                    }

                    Bitmap bitmap = new Bitmap(path);

                    if (window.Width <= 1280)
                    {
                        bitmap = bitmap.ResizeImage(new Size((int)(bitmap.Width * .75f), (int)(bitmap.Height * .75f)));
                    }
                    else if (window.Width <= 1400)
                    {
                        bitmap = bitmap.ResizeImage(new Size((int)(bitmap.Width * .8f), (int)(bitmap.Height * .8f)));
                    }

                    bitmap.RotateFlip(RotateFlipType.RotateNoneFlipY);
                    var data = bitmap.LockBits(
                        new Rectangle(0, 0, bitmap.Width, bitmap.Height),
                        System.Drawing.Imaging.ImageLockMode.ReadOnly,
                        System.Drawing.Imaging.PixelFormat.Format32bppPArgb);

                    // super hacks
                    if ((VoxelBrushType)enumer.Current == VoxelBrushType.MatrixSelect)
                    {
                        brushes[(VoxelBrushType)enumer.Current].Cursor = new OpenTK.MouseCursor(
                            data.Width / 2, data.Height / 2, data.Width, data.Height, data.Scan0);
                    }
                    else
                    {
                        brushes[(VoxelBrushType)enumer.Current].Cursor = new OpenTK.MouseCursor(
                            0, 0, data.Width, data.Height, data.Scan0);
                    }

                    bitmap.Dispose();
                }
            };

            NextBrush();
        }