示例#1
0
        public void DisposeRenderingStarted()
        {
            var viewport = new GLViewport();

            viewport.RestartRendering();
            viewport.Dispose();
        }
示例#2
0
        protected override void OnMouseUp(MouseEventArgs e)
        {
            switch (e.Button)
            {
            case Forms.MouseButtons.Left:
                _mouseDown = false;
                if (_draggingViewports)
                {
                    _draggingViewports = false;
                    int range = 8;
                    for (int i = 0; i < _viewports.Count; i++)
                    {
                        GLViewport v = _viewports[i];
                        if (v.Region.Width < range || v.Region.Height < range)
                        {
                            v.OnInvalidate -= Invalidate;
                            RemoveViewport(i--);
                        }
                    }
                }
                else
                {
                    CurrentViewport.HandleLeftMouseUp(e);
                }
                break;

            case Forms.MouseButtons.Right:
                CurrentViewport._grabbing = false;
                break;

            case Forms.MouseButtons.Middle:
                CurrentViewport._scrolling = false;
                break;

            default:
                base.OnMouseUp(e);
                return;
            }

            Invalidate();
            base.OnMouseUp(e);
        }
示例#3
0
        private void modelPanel_OnCurrentViewportChanged(GLViewport p)
        {
            ModelPanelViewport v = p as ModelPanelViewport;

            stretchToolStripMenuItem1.Checked = p.BackgroundImageType == BGImageType.Stretch;
            centerToolStripMenuItem1.Checked  = p.BackgroundImageType == BGImageType.Center;
            resizeToolStripMenuItem1.Checked  = p.BackgroundImageType == BGImageType.ResizeWithBars;

            bool camDefaultSet =
                p.Camera._defaultRotate != p.GetDefaultRotate() ||
                p.Camera._defaultScale != p.GetDefaultScale() ||
                p.Camera._defaultTranslate != new Vector3();

            btnSaveCam.Text = camDefaultSet ? "Clear Camera" : "Save Camera";

            modelPanel_RenderBonesChanged(ModelPanel, v.RenderBones);
            modelPanel_RenderFloorChanged(ModelPanel, v.RenderFloor);
            modelPanel_RenderModelBoxChanged(ModelPanel, v.RenderModelBox);
            modelPanel_RenderNormalsChanged(ModelPanel, v.RenderNormals);
            modelPanel_RenderObjectBoxChanged(ModelPanel, v.RenderObjectBox);
            modelPanel_RenderOffscreenChanged(ModelPanel, v.DontRenderOffscreen);
            ModelPanel_RenderPolygonsChanged(ModelPanel, v.RenderPolygons);
            ModelPanel_RenderVerticesChanged(ModelPanel, v.RenderVertices);
            modelPanel_RenderVisBoneBoxChanged(ModelPanel, v.RenderVisBoneBox);
            ModelPanel_RenderWireframeChanged(ModelPanel, v.RenderWireframe);
            ModelPanel_ScaleBonesChanged(ModelPanel, v.ScaleBones);
            ModelPanel_ApplyBillboardBonesChanged(ModelPanel, v.ApplyBillboardBones);
            modelPanel_FirstPersonCameraChanged(ModelPanel, v._firstPersonCamera);
            ModelPanel_RenderShadersChanged(ModelPanel, v._renderAttrib._renderShaders);
            ModelPanel_UseBindStateBoxesChanged(ModelPanel, v.UseBindStateBoxes);
            sCN0ToolStripMenuItem.Checked = v.RenderSCN0Controls;

            _currentProjBox.Checked = false;
            switch (p.ViewType)
            {
            case ViewportProjection.Perspective:
                _currentProjBox = perspectiveToolStripMenuItem; break;

            case ViewportProjection.Orthographic:
                _currentProjBox = orthographicToolStripMenuItem; break;

            case ViewportProjection.Top:
                _currentProjBox = topToolStripMenuItem; break;

            case ViewportProjection.Bottom:
                _currentProjBox = bottomToolStripMenuItem; break;

            case ViewportProjection.Left:
                _currentProjBox = leftToolStripMenuItem; break;

            case ViewportProjection.Right:
                _currentProjBox = rightToolStripMenuItem; break;

            case ViewportProjection.Front:
                _currentProjBox = frontToolStripMenuItem; break;

            case ViewportProjection.Back:
                _currentProjBox = backToolStripMenuItem; break;
            }
            _currentProjBox.Checked = true;

            showCameraCoordinatesToolStripMenuItem.Checked = v._showCamCoords;
            loadImageToolStripMenuItem.Text = v.BackgroundImage == null ? "Load Image" : "Clear Image";
        }
 public static Vector3 CameraFacingRotation(GLViewport viewport, Vector3 pos = new Vector3())
 {
     return(CameraFacingRotation(viewport.Camera, pos));
 }
        //public float VertexOrbRadius(GLViewport viewport, float radius = _orbRadius) { if (VertexLoc().HasValue) return CamDistance(VertexLoc().Value, viewport.Camera, radius); else return 0; }
        //public float VertexOrbRadius(GLCamera cam, float radius = _orbRadius) { if (VertexLoc().HasValue) return CamDistance(VertexLoc().Value, cam, radius); else return 0; }

        public static Matrix CameraFacingRotationMatrix(GLViewport viewport, Vector3 pos = new Vector3())
        {
            return(CameraFacingRotationMatrix(viewport.Camera, pos));
        }
 public static float OrbRadius(Vector3 b, GLViewport viewport, float radius = _orbRadius)
 {
     return(CamDistance(b, viewport.Camera, radius));
 }
 public static float OrbRadius(IBoneNode b, GLViewport viewport, float radius = _orbRadius)
 {
     return(CamDistance(BoneLoc(b), viewport.Camera, radius));
 }
示例#8
0
        protected override void OnRenderViewport(PaintEventArgs e, GLViewport v)
        {
            ModelPanelViewport viewport = v as ModelPanelViewport;

            Rectangle r = viewport.Region;

            GL.Viewport(r);
            GL.Enable(EnableCap.ScissorTest);
            GL.Scissor(r.X, r.Y, r.Width, r.Height);

            viewport.RenderBackground();

            viewport.Camera.LoadProjection();
            viewport.Camera.LoadModelView();

            viewport.RecalcLight();

            if (PreRender != null)
            {
                PreRender(viewport);
            }

            GL.PushAttrib(AttribMask.AllAttribBits);
            GL.MatrixMode(MatrixMode.Modelview);

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

            //Allow each model to set up any data specific to this frame and viewport
            foreach (IRenderedObject o in _renderList)
            {
                o.PreRender(viewport);
            }

            //Render objects in specifically sorted order
            foreach (DrawCallBase call in _drawCalls)
            {
                call.Render(viewport);
            }

            if (viewport._renderAttrib._renderShaders)
            {
                GL.UseProgram(0);
            }

            GL.MatrixMode(MatrixMode.Texture);
            GL.LoadIdentity();

            GL.PopAttrib();

            if (PostRender != null)
            {
                PostRender(viewport);
            }

            viewport.RenderForeground(v == CurrentViewport, _viewports.Count == 1);

            GL.Disable(EnableCap.ScissorTest);
        }
        public GenericMaterialEditor() : base()
        {
            Text = "Material Editor";

            Size = new Size(300, 600);

            menu = new SBMenuBar();
            {
                var file = new SBToolStripMenuItem("Material");
                {
                    var delete = new SBToolStripMenuItem("Delete Selected");
                    delete.Click += DeleteMaterial;
                    file.DropDownItems.Add(delete);
                    var import = new SBToolStripMenuItem("Import Material");
                    import.Click += ImportMaterial;
                    file.DropDownItems.Add(import);
                    var export = new SBToolStripMenuItem("Export Material");
                    export.Click += ExportMaterial;
                    file.DropDownItems.Add(export);
                }
                menu.Items.Add(file);
            }

            //_viewport = new GLControl();
            //_viewport.Size = new Size(400, 400);
            //_viewport.Dock = DockStyle.Top;

            MinimumSize = new Size(240, 240);

            ApplicationSettings.SkinControl(this);
            //Controls.Add(_viewport);

            viewport = new GLViewport();
            viewport.OnRenderFrame += Render;
            viewport.Dock           = DockStyle.Top;
            viewport.MinimumSize    = new Size(240, 240);

            materialList                       = new SBListView();
            materialList.Dock                  = DockStyle.Top;
            materialList.MinimumSize           = new Size(240, 180);
            materialList.MultiSelect           = false;
            materialList.View                  = View.LargeIcon;
            materialList.HideSelection         = false;
            materialList.SelectedIndexChanged += SelectedMaterialChanged;

            toolTips = new ToolTip();

            TopMost = true;

            mainPanel            = new Panel();
            mainPanel.AutoSize   = true;
            mainPanel.AutoScroll = true;
            mainPanel.Dock       = DockStyle.Fill;

            vectorSection      = new SBPopoutPanel(PopoutSide.Bottom, "Vectors", "Vectors");
            vectorSection.Dock = DockStyle.Top;

            floatSection      = new SBPopoutPanel(PopoutSide.Bottom, "Floats", "Floats");
            floatSection.Dock = DockStyle.Top;

            boolSection      = new SBPopoutPanel(PopoutSide.Bottom, "Bools", "Bools");
            boolSection.Dock = DockStyle.Top;

            mainPanel.Controls.Add(vectorSection);
            mainPanel.Controls.Add(floatSection);
            mainPanel.Controls.Add(boolSection);

            typeLabel      = new Label();
            typeLabel.Dock = DockStyle.Top;

            materialLabel      = new GenericBindingTextBox <string>();
            materialLabel.Dock = DockStyle.Top;

            materialName      = new GenericBindingTextBox <string>();
            materialName.Dock = DockStyle.Top;

            Controls.Add(mainPanel);
            //Controls.Add(viewport);
            Controls.Add(materialName);
            Controls.Add(materialLabel);
            Controls.Add(materialList);
            Controls.Add(typeLabel);
            Controls.Add(menu);

            ResizeEnd   += onResize;
            FormClosing += Editor_FormClosing;
        }
示例#10
0
 public GlViewportRenderer(GLViewport viewport)
 {
     this.viewport = viewport;
 }
示例#11
0
        public void DisposeRenderingNotStarted()
        {
            var viewport = new GLViewport();

            viewport.Dispose();
        }