コード例 #1
0
 /// <summary> Set Perpective mode (true) or Othographic mode (false) </summary>
 public void ChangePerspectiveMode(bool on)
 {
     MatrixCalc.InPerspectiveMode = on;
     MatrixCalc.CalculateModelMatrix(PosCamera.LookAt, PosCamera.EyePosition, PosCamera.CameraRotation);
     MatrixCalc.CalculateProjectionMatrix();
     glwin.Invalidate();
 }
コード例 #2
0
        /// <summary> Start the class. Pass the GL window control, and the initial lookat/cameradirection and zoom.
        /// Control if registration of mouse and keyboard UI is performed with GL window control
        /// </summary>
        public void Start(GLWindowControl win, Vector3 lookat, Vector3 cameradirdegrees, float zoomn, bool registermouseui = true, bool registerkeyui = true)
        {
            glwin       = win;
            win.Resize += glControl_Resize;
            win.Paint  += glControl_Paint;

            if (registermouseui)
            {
                win.MouseDown  += MouseDown;
                win.MouseUp    += MouseUp;
                win.MouseMove  += MouseMove;
                win.MouseWheel += MouseWheel;
            }

            if (registerkeyui)
            {
                win.KeyDown += KeyDown;
                win.KeyUp   += KeyUp;
            }

            MatrixCalc.ResizeViewPort(this, win.Size);               // inform matrix calc of window size

            PosCamera.SetPositionZoom(lookat, new Vector2(cameradirdegrees.X, cameradirdegrees.Y), zoomn, cameradirdegrees.Z);
            MatrixCalc.CalculateModelMatrix(PosCamera.LookAt, PosCamera.EyePosition, PosCamera.CameraRotation);
            MatrixCalc.CalculateProjectionMatrix();
        }
コード例 #3
0
 // from the window, a resize event. Must have the correct context, if multiple, set glwin.EnsureCurrentPaintResize
 private void glControl_Resize(object sender)
 {
     //System.Diagnostics.Debug.WriteLine("Controller3d Resize" + glwin.Size);
     MatrixCalc.ResizeViewPort(this, glwin.Size);
     MatrixCalc.CalculateModelMatrix(PosCamera.LookAt, PosCamera.EyePosition, PosCamera.CameraRotation); // non perspective viewport changes also can affect model matrix
     MatrixCalc.CalculateProjectionMatrix();
     glwin.Invalidate();
 }
コード例 #4
0
        /// <summary>Recalc matrix if moved </summary>
        public bool RecalcMatrixIfMoved(float minmove = 0.01f, float mincamera = 1.0f)
        {
            bool moved = PosCamera.IsMoved(minmove, mincamera);

            if (moved)
            {
                MatrixCalc.CalculateModelMatrix(PosCamera.LookAt, PosCamera.EyePosition, PosCamera.CameraRotation);
            }

            return(moved);
        }
コード例 #5
0
 /// <summary> Set position camera (lookat and eye) from this setting string</summary>
 public bool SetPositionCamera(string s)     // String holds pos/eye
 {
     if (PosCamera.SetPositionCamera(s))
     {
         MatrixCalc.CalculateModelMatrix(PosCamera.LookAt, PosCamera.EyePosition, PosCamera.CameraRotation);
         return(true);
     }
     else
     {
         return(false);
     }
 }
コード例 #6
0
        /// <summary>Recalc matrix if moved </summary>
        public bool RecalcMatrixIfMoved(double minmove = 0.01f, double mincamera = 1.0f)
        {
            bool moved = PosCamera.IsMoved(minmove, mincamera);

            if (moved)
            {
                //System.Diagnostics.Debug.WriteLine("Changed");
                MatrixCalc.CalculateModelMatrix(PosCamera.LookAt, PosCamera.EyePosition, PosCamera.CameraRotation);
            }

            return(moved);
        }
コード例 #7
0
 /// <summary> Recalculate matrix - only use if changed a fundamental in matrixcalc </summary>
 public void RecalcMatrices()
 {
     MatrixCalc.CalculateModelMatrix(PosCamera.LookAt, PosCamera.EyePosition, PosCamera.CameraRotation);
     MatrixCalc.CalculateProjectionMatrix();
 }