Ejemplo n.º 1
0
        public Wireframe(Camera camera, Selection selection, Floor floor, Input input)
            : base()
        {
            voxelShader     = ShaderUtil.CreateShader("qb", "./data/shaders/voxel.vs", "./data/shaders/voxel.fs");
            wireframeShader = ShaderUtil.CreateShader("wireframe_qb", "./data/shaders/wireframe.vs", "./data/shaders/wireframe.fs");

            this.camera    = camera;
            this.selection = selection;
            this.floor     = floor;

            // bug mouse leaving matrix while dragging tools

            input.AddHandler(new InputHandler()
            {
                Keydownhandler = (e) =>
                {
                    bool shift = Singleton <Input> .INSTANCE.Keydown(OpenTK.Input.Key.ShiftLeft);

                    if (e.Key == Key.G && !e.Shift)
                    {
                        drawWireframe = !drawWireframe;
                    }
                    else if (e.Key == Key.G && e.Shift)
                    {
                        MoveNext();
                    }
                }
            });
        }
Ejemplo n.º 2
0
        public SSAO(int width, int height, Camera camera)
            : base()
        {
            this.camera = camera;

            random = new Random();

            geometryBuffer = new IOBuffer(width, height, true, PixelInternalFormat.Rgb32f);
            SSAOBuffer     = new IOBuffer(width, height, false, PixelInternalFormat.R32f);

            ssao_geometryDepth = ShaderUtil.CreateShader("ssao_geometryDepth", "./data/shaders/SSAO_geometry.vs", "./data/shaders/SSAO_geometry.fs");
            ssao       = ShaderUtil.CreateShader("ssao", "./data/shaders/SSAO_pass.vs", "./data/shaders/SSAO_pass.fs");
            ssao_voxel = ShaderUtil.CreateShader("qb", "./data/shaders/SSAO_voxel.vs", "./data/shaders/SSAO_voxel.fs");

            ssao.WriteUniform("gSampleRad", 1.25f);
            ssao.WriteUniform("gProj", camera.projection);
            ssao.WriteUniform("gPositionMap", 1);

            ssao_voxel.WriteUniform("gScreenSize", new Vector2(width, height));
            ssao_voxel.WriteUniform("gAOMap", 2);

            Vector3[] kernel = new Vector3[8];

            for (uint i = 0; i < kernel.Length; i++)
            {
                float   scale = (float)i / (float)(kernel.Length);
                Vector3 v;
                v.X = 2.0f * (float)random.Next(0x7fff) / 0x7fff - 1.0f;
                v.Y = 2.0f * (float)random.Next(0x7fff) / 0x7fff - 1.0f;
                v.Z = 2.0f * (float)random.Next(0x7fff) / 0x7fff - 1.0f;
                v  *= (0.1f + 0.9f * scale * scale);

                kernel[i] = v;
            }

            unsafe
            {
                fixed(float *pointer = &kernel[0].X)
                {
                    ssao.WriteUniformArray("gKernel", kernel.Length, pointer);
                }
            }

            quadBuffer = GL.GenBuffer();
            GL.BindBuffer(BufferTarget.ArrayBuffer, quadBuffer);
            GL.EnableVertexAttribArray(0);
            GL.VertexAttribPointer(0, 3, VertexAttribPointerType.Float, false, sizeof(float) * 3, 0);
            GL.BufferData(BufferTarget.ArrayBuffer, (IntPtr)(sizeof(float) * quadData.Length), quadData, BufferUsageHint.StaticDraw);
            GL.BindBuffer(BufferTarget.ArrayBuffer, 0);
        }
Ejemplo n.º 3
0
        protected override void OnLoad(EventArgs e)
        {
            string version = Assembly.GetExecutingAssembly().GetName().Version.ToString();

            Title = String.Format("StoneVox 3D - version {0}", version);

            GL.Viewport(0, 0, Width, Height);
            Qfont_1280 = new QFont("data\\fonts\\Bigfish.ttf", 11.2f, new QFontBuilderConfiguration(true, false));
            Qfont_1400 = new QFont("data\\fonts\\Bigfish.ttf", 12f, new QFontBuilderConfiguration(true, false));
            Qfont_1920 = new QFont("data\\fonts\\Bigfish.ttf", 15, new QFontBuilderConfiguration(true, false));
            if (Width <= 1280)
            {
                Qfont = Qfont_1280;
            }
            else if (Width < 1400)
            {
                Qfont = Qfont_1400;
            }
            else
            {
                Qfont = Qfont_1920;
            }

            this.Qfont.Options.Colour = Color.White;
            //this.Qfont.Options.TransformToViewport = new TransformViewport(-1,-1,2,2);

            Scale.SetHScaling(0, Width);
            Scale.SetVScaling(0, Height);

            ShaderUtil.CreateShader("quad_interpolation", "./data/shaders/QuadInterpolation.vs", "./data/shaders/QuadInterpolation.fs");

            broadcaster = new Broadcaster();
            manager     = new QbManager(broadcaster);
            input       = new Input(this);
            camera      = new Camera(this, input, manager);
            brushes     = new BrushManager(this, input);
            floor       = new Floor(camera, broadcaster);
            gui         = new GUI(this, manager, input);
            selection   = new Selection(this, brushes, input, manager, floor, gui);
            renderer    = new Wireframe(camera, selection, floor, input);
            undoredo    = new UndoRedo(input);

            selection.GenerateVertexArray();

            if (!manager.HasModel)
            {
                manager.AddEmpty();
            }
            camera.LookAtModel(true);

            backcolor = new Color4(0, 0, 0, 0);

            GL.Enable(EnableCap.DepthTest);
            GL.Enable(EnableCap.Blend);
            GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha);

            GL.Enable(EnableCap.CullFace);
            GL.CullFace(CullFaceMode.Back);

            int    ole_hresult = OleInitialize(IntPtr.Zero);
            IntPtr handle      = FindWindowByCaption(IntPtr.Zero, Title);

            dnd = new DragDropTarget();
            int dnd_hresult = RegisterDragDrop(handle, dnd);

            raycaster           = new Raycaster(this, camera, selection, floor, input, manager, gui);
            selection.raycaster = raycaster;

            Client.Initialized = true;
            base.OnLoad(e);
            SetForegroundWindow(WindowInfo.Handle);
        }