Ejemplo n.º 1
0
        //カメラ座標の設定
        public void SetCameraAxes()
        {
            CameraZ = LookatPoint - Setposition;
            CameraZ.Normalization();

            CameraX = Vector3D.Outer(Upward, CameraZ);
            CameraX.Normalization();

            CameraY = Vector3D.Outer(CameraZ, CameraX);
        }
Ejemplo n.º 2
0
        //隠面処理
        public void HiddenRemoval(Vector3D see)
        {
            Vector3D A = new Vector3D();
            Vector3D B = new Vector3D();
            Vector3D n = new Vector3D();
            Vector3D S = new Vector3D();
            double cos;

            for (int i = 0; i < FACES_NUM; i++)
            {
                A = face3D[i][0] - face3D[i][1];
                B = face3D[i][2] - face3D[i][1];
                n = Vector3D.Outer(A, B);

                S = face3D[i][1] - see;

                n.Normalization();
                S.Normalization();

                cos = Vector3D.Inner(S, n);

                if (cos > 0)
                {
                    canSee[i] = true;
                    brush[i] = new SolidBrush(Color.FromArgb((int)(basebrush[i].Color.R * cos), (int)(basebrush[i].Color.G * cos), (int)(basebrush[i].Color.B * cos)));
                }
                else
                    canSee[i] = false;
            }
        }
Ejemplo n.º 3
0
        //カメラの回転
        public void RotateCamera(double x1, double y1, double x2, double y2)
        {
            Vector2D A = new Vector2D();
            Vector3D N1 = new Vector3D();
            Vector3D N2 = new Vector3D();
            Vector3D temp = new Vector3D();

            double alpha, beta;
            float x, y, z;

            N1.X = Setposition.Y;
            N1.Y = -Setposition.X;
            N1.Z = LookatPoint.Z;

            N1.Normalization();

            N2.X = LookatPoint.X;
            N2.Y = LookatPoint.Y;
            N2.Z = 1;

            N2.Normalization();

            if (Upward.Z > 0)
            {
                A.X = (float)((x2 - x1) / w);
                A.Y = (float)((y2 - y1) / h);
            }
            if (Upward.Z < 0)
            {
                A.X = (float)((x1 - x2) / w);
                A.Y = (float)((y1 - y2) / h);
            }

            alpha = 2 * Math.PI * A.Y;
            beta = 2 * Math.PI * A.X;

            x = Setposition.X;
            y = Setposition.Y;
            z = Setposition.Z;

            rotatematrix.Set_Rotate_ArbAx(N1, alpha);

            temp = Setposition * rotatematrix;

            rotatematrix.Set_Rotate_ArbAx(N2, beta);

            temp = temp * rotatematrix;

            SetPosition(temp.X, temp.Y, temp.Z);

            if (Vector3D.Inner(temp2, Setposition - LookatPoint) > 0 && Upward.Z > 0) Upward.Z = -Upward.Z;

            if (Vector3D.Inner(temp2, Setposition - LookatPoint) < 0 && Upward.Z < 0) Upward.Z = -Upward.Z;

            if (Upward.Z > 0) temp2.Set(-Setposition.X, -Setposition.Y, LookatPoint.Z);

            if (Upward.Z < 0) temp2.Set(Setposition.X, Setposition.Y, LookatPoint.Z);
        }