Ejemplo n.º 1
0
        /// <summary>
        /// コンストラクタ
        /// </summary>
        public Form1()
        {
            InitializeComponent();

            trackbars = new TrackBar[] { trbEyeX, trbEyeY, trbEyeZ,
                                         trbTargetX, trbTargetY, trbTargetZ, trbUpX, trbUpY, trbUpZ };
            labels = new Label[] { lblEyeX, lblEyeY, lblEyeZ,
                                   lblTargetX, lblTargetY, lblTargetZ, lblUpX, lblUpY, lblUpZ };

            for (int i = 0; i < trackbars.Length - 1; i++)
            {
                trackbars[i].Minimum = -(int)TRACKBAR_MAX;
                trackbars[i].Maximum = (int)TRACKBAR_MAX;
            }

            pointList = MakePointList2();

            param1 = new ViewPointParam();
            param2 = new ViewPointParam();

            glControl1.MouseWheel += new MouseEventHandler(glControl1_MouseWheel);
            MouseWheel            += new MouseEventHandler(glControl1_MouseWheel);

            timer1.Start();
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 三次元描画用に初期化する
        /// </summary>
        /// <param name="width">描画領域幅</param>
        /// <param name="height">描画領域高さ</param>
        private void InitFor3D(float width, float height)
        {
            // クリア
            GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);

            // ビューポートの設定
            GL.Viewport(0, 0, (int)width, (int)height);

            // 視点の設定
            ViewPointParam param     = viewMode == 0 ? param1 : param2;
            Matrix4        modelView = Matrix4.LookAt(param.Eye, param.Target, param.Up);

            GL.MatrixMode(MatrixMode.Modelview);
            GL.LoadMatrix(ref modelView);

            // 射影の設定
            Matrix4 projection = Matrix4.CreatePerspectiveFieldOfView(MathHelper.PiOver4, width / height, 1.0f, 64.0f);

            GL.MatrixMode(MatrixMode.Projection);
            GL.LoadMatrix(ref projection);

            // 陰面処理をONにする
            GL.Enable(EnableCap.DepthTest);

            // 物体の回転
            if (viewMode == 0)
            {
                GL.Translate(-param.Eye.X, -param.Eye.Y, -param.Eye.Z);
                GL.Rotate(beta, new Vector3d(1, 0, 0));
                GL.Rotate(alpha, new Vector3d(0, 0, 1));
                GL.Translate(param.Eye.X, param.Eye.Y, param.Eye.Z);
            }
        }