Example #1
0
        internal static void DrawOrientationGizmo()
        {
            try
            {
                if (OrbitCamera == null)
                {
                    OrbitCamera = new OrbitCameraController(new Vector3Class());
                }

                if (OrientationGizmo == null)
                {
                    OrientationGizmo = new OrientationGizmo(4, OrientationGizmo.SideSelectionType.None, OrientationGizmo.SideSelectionType.None, true);
                    OrientationGizmo.OrientationChanged += OrientationGizmo_OrientationChanged;
                    OrientationGizmo.BindModel();
                    OrientationGizmo.UpdateBinding();
                }

                OrientationGizmo.Render(OrbitCamera.GetCameraViewWithoutTranslation());
            }
            catch (Exception exc)
            {
                Debug.WriteLine(exc.Message);
            }
        }
Example #2
0
        public static void RenderAsModelView(Controls.OpenGL.GLControl glControl, float cameraRotationX, float cameraRotationZ, float cameraZoom, float panX, float panY, bool thumbnailRendering = false, bool thumbnailLarge = false)
        {
            try
            {
                if (glControl.Context.IsCurrent)
                {
                    GL.Clear(ClearBufferMask.DepthBufferBit | ClearBufferMask.StencilBufferBit | ClearBufferMask.ColorBufferBit);

                    if (!thumbnailRendering)
                    {
                        DrawGradient(glControl);

                        //GL.ClearColor(Settings.Default.SceneBackgroundColor);
                        if (UserProfileManager.UserProfiles[0].SelectionOptions_Enable_XYZ_Axis)
                        {
                            DrawOrientationGizmo();
                        }
                    }
                    else
                    {
                        if (!thumbnailLarge)
                        {
                            GL.ClearColor(Color.White);
                        }
                        else
                        {
                            GL.ClearColor(Color.FromArgb(230, 230, 230, 230));
                        }
                    }

                    int w = glControl.Width;
                    int h = glControl.Height;

                    float aspectRatio = (float)w / (float)h;

                    GL.Viewport(0, 0, w, h);

                    ProjectionMatrix = Matrix4.CreatePerspectiveFieldOfView(0.55f, aspectRatio, 1, 2000);

                    GL.MatrixMode(MatrixMode.Projection);
                    GL.LoadIdentity();
                    GL.LoadMatrix(ref ProjectionMatrix);

                    GL.MatrixMode(MatrixMode.Modelview);
                    GL.LoadIdentity();

                    OrbitCamera = new OrbitCameraController(CameraPositionTargetCenter);
                    OrbitCamera.MouseMove(cameraRotationX, cameraRotationZ);
                    OrbitCamera.Pan(panX, panY);
                    OrbitCamera.Scroll(_defaultCameraDistance + cameraZoom);

                    var lookat = OrbitCamera.GetCameraView();
                    CameraPosition = OrbitCamera.GetCameraPosition();

                    //GL.Matrix
                    GL.LoadMatrix(ref lookat);
                }
            }
            catch (Exception exc)
            {
                Debug.WriteLine(exc.Message);
            }
        }