コード例 #1
0
        public Drawing3DViewForm()
        {
            InitializeComponent();
            camera = new Camera();
            grid3D = new Grid3D();
            grid2D = new Grid2D();
            objects = new Object3D();
            isClicked_pb1 = false;
            isClicked_pb2 = false;
            isAdd = true;
            isDelete = false;

            camera.SetLookatPoint(0.0f, 0.0f, 0.0f);
            camera.SetAspect(this.pictureBox1.Width, this.pictureBox1.Height);
        }
コード例 #2
0
ファイル: Square.cs プロジェクト: shotaATF/Drawing3D
 //2次元座標へ変換
 public void Translate(Camera c)
 {
     vertex2D = c.Translate(vertex3D);
 }
コード例 #3
0
ファイル: Grid3D.cs プロジェクト: shotaATF/Drawing3D
        //3次元上の座標を作成
        public void CreateGrid3D(Camera c)
        {
            Vector3D tempX = new Vector3D();
            Vector3D tempY = new Vector3D();
            Vector3D Grid3D1 = new Vector3D();
            Vector3D Grid3D2 = new Vector3D();
            Vector2D Grid2D1 = new Vector2D();
            Vector2D Grid2D2 = new Vector2D();

            grid3D.Clear();
            grid2D.Clear();

            for (float i = -Xunit; i > MinY; i -= Xunit)
            {
                Grid3D1.Set(i, MaxY, 0.0f);
                grid3D.Add(new Vector3D(Grid3D1));

                Grid3D2.Set(i, MinY, 0.0f);
                grid3D.Add(new Vector3D(Grid3D2));

                tempX = c.ViewTranslate(Grid3D1);
                tempX = c.ProjectionTranslate(tempX);
                Grid2D1 = c.ViewPortTranslate(tempX);
                grid2D.Add(new Vector2D(Grid2D1));

                tempY = c.ViewTranslate(Grid3D2);
                tempY = c.ProjectionTranslate(tempY);
                Grid2D2 = c.ViewPortTranslate(tempY);
                grid2D.Add(new Vector2D(Grid2D2));
            }

            for (float i = Xunit; i < MaxX; i += Xunit)
            {
                Grid3D1.Set(i, MaxY, 0.0f);
                grid3D.Add(new Vector3D(Grid3D1));

                Grid3D2.Set(i, MinY, 0.0f);
                grid3D.Add(new Vector3D(Grid3D2));

                tempX = c.ViewTranslate(Grid3D1);
                tempX = c.ProjectionTranslate(tempX);
                Grid2D1 = c.ViewPortTranslate(tempX);
                grid2D.Add(new Vector2D(Grid2D1));

                tempY = c.ViewTranslate(Grid3D2);
                tempY = c.ProjectionTranslate(tempY);
                Grid2D2 = c.ViewPortTranslate(tempY);
                grid2D.Add(new Vector2D(Grid2D2));
            }

            for (float i = -Yunit; i > MinY; i -= Yunit)
            {
                Grid3D1.Set(MaxX, i, 0.0f);
                grid3D.Add(new Vector3D(Grid3D1));

                Grid3D2.Set(MinX, i, 0.0f);
                grid3D.Add(new Vector3D(Grid3D2));

                tempX = c.ViewTranslate(Grid3D1);
                tempX = c.ProjectionTranslate(tempX);
                Grid2D1 = c.ViewPortTranslate(tempX);
                grid2D.Add(new Vector2D(Grid2D1));

                tempY = c.ViewTranslate(Grid3D2);
                tempY = c.ProjectionTranslate(tempY);
                Grid2D2 = c.ViewPortTranslate(tempY);
                grid2D.Add(new Vector2D(Grid2D2));
            }

            for (float i = Yunit; i < MaxY; i += Yunit)
            {
                Grid3D1.Set(MaxX, i, 0.0f);
                grid3D.Add(new Vector3D(Grid3D1));

                Grid3D2.Set(MinX, i, 0.0f);
                grid3D.Add(new Vector3D(Grid3D2));

                tempX = c.ViewTranslate(Grid3D1);
                tempX = c.ProjectionTranslate(tempX);
                Grid2D1 = c.ViewPortTranslate(tempX);
                grid2D.Add(new Vector2D(Grid2D1));

                tempY = c.ViewTranslate(Grid3D2);
                tempY = c.ProjectionTranslate(tempY);
                Grid2D2 = c.ViewPortTranslate(tempY);
                grid2D.Add(new Vector2D(Grid2D2));
            }

            Grid3D1.Set(MaxX, 0.0f, 0.0f);
            Axis3D[0] = new Vector3D(Grid3D1);

            Grid3D2.Set(MinX, 0.0f, 0.0f);
            Axis3D[1] = new Vector3D(Grid3D2);

            tempX = c.ViewTranslate(Grid3D1);
            tempX = c.ProjectionTranslate(tempX);
            Grid2D1 = c.ViewPortTranslate(tempX);
            Axis2D[0] = new Vector2D(Grid2D1);

            tempY = c.ViewTranslate(Grid3D2);
            tempY = c.ProjectionTranslate(tempY);
            Grid2D2 = c.ViewPortTranslate(tempY);
            Axis2D[1] = new Vector2D(Grid2D2);

            Grid3D1.Set(0.0f, MaxY, 0.0f);
            Axis3D[2] = new Vector3D(Grid3D1);

            Grid3D2.Set(0.0f, MinY, 0.0f);
            Axis3D[3] = new Vector3D(Grid3D2);

            tempX = c.ViewTranslate(Grid3D1);
            tempX = c.ProjectionTranslate(tempX);
            Grid2D1 = c.ViewPortTranslate(tempX);
            Axis2D[2] = new Vector2D(Grid2D1);

            tempY = c.ViewTranslate(Grid3D2);
            tempY = c.ProjectionTranslate(tempY);
            Grid2D2 = c.ViewPortTranslate(tempY);
            Axis2D[3] = new Vector2D(Grid2D2);
        }
コード例 #4
0
ファイル: Object3D.cs プロジェクト: shotaATF/Drawing3D
 //隠面処理
 public void HiddenRemoval(Camera c)
 {
     foreach (Cube C in cube) C.HiddenRemoval(c.Setposition);
 }
コード例 #5
0
ファイル: Object3D.cs プロジェクト: shotaATF/Drawing3D
 //描画前の変換処理
 public void DrawingPreparation(Camera c)
 {
     Translate(c);
     HiddenRemoval(c);
     cube.Sort((cb1, cb2) => cb2.center.Getdistance(c.Setposition).CompareTo(cb1.center.Getdistance(c.Setposition)));
 }
コード例 #6
0
ファイル: Object3D.cs プロジェクト: shotaATF/Drawing3D
 //3次元上の座標軸を作成
 public void CreateGrid3D(Camera c)
 {
     grid3D.CreateGrid3D(c);
 }
コード例 #7
0
ファイル: Object3D.cs プロジェクト: shotaATF/Drawing3D
        //2次元座標に変換
        public void Translate(Camera c)
        {
            foreach (Cube C in cube) C.Translate(c);

            if (pointer != null) pointer.Translate(c);
        }
コード例 #8
0
ファイル: Cube.cs プロジェクト: shotaATF/Drawing3D
 //2次元座標へ変換
 public void Translate(Camera c)
 {
     vertex2D = c.Translate(vertex3D);
     SetFace2D();
 }