Esempio n. 1
0
 public List<FillFace3D> getOrded(List<FillFace3D> fillFace)
 {
     List<FillFace3D> orderedFillingFace = new List<FillFace3D>();
     if (fillFace.Count==6)
     {
         
         for (int j = 0; j < 6; j++)
         {
             FillFace3D f3 = fillFace[0];
             for (int i = 0; i < fillFace.Count; i++)
             {
                 if (fillFace[i].depth < f3.depth)
                 {
                     f3 = fillFace[i];
                 }
             }
             orderedFillingFace.Add(f3);
             fillFace.Remove(f3);
         }
     }
     return orderedFillingFace;
 }
Esempio n. 2
0
        public void drawc(Graphics g)
        {
            mainBitmap = new Bitmap(pictureBox1.Width,pictureBox1.Height);
            pictureBox1.Image = mainBitmap;


            Point temp = new Point();
            Point temp2 = new Point();
            Pen mypen = new Pen(Brushes.Red);
            List<Point> l = new List<Point>();//fill face 

            List<FillFace3D> fillFace = new List<FillFace3D>();//record the 6 faces and it's points
            for (int nface = 0; nface < 6; nface++)
            {
                FillFace3D face3D = new FillFace3D();
                for (int nedge = 0; nedge < f1[nface].m_enum; nedge++)
                {
                    face3D.pointSets3D.Add(new point3(p2[f1[nface].p[nedge]].x, p2[f1[nface].p[nedge]].y, p2[f1[nface].p[nedge]].z));

                    temp.X = (int)p2[f1[nface].p[nedge]].x + 300;
                    temp.Y = (int)p2[f1[nface].p[nedge]].y + 300;
                    if (nedge == 0)
                    {
                        temp2 = temp;
                    }
                    else
                    {
                       // g.DrawLine(mypen, temp2, temp);
                        temp2 = temp;
                        if (nedge == 3)
                        {
                            temp.X = (int)p2[f1[nface].p[0]].x + 300;
                            temp.Y = (int)p2[f1[nface].p[0]].y + 300;
                           // g.DrawLine(mypen, temp2, temp);
                        }
                    }
                    //l.Add(temp2);
                    face3D.pointSets2D.Add(temp2);
                }
                //Geometry.fillPolygon(l, colorSets[nface], mainBitmap);
                //pictureBox1.Refresh();
                //l.Clear();          
                face3D.calcuDepth();
                face3D.faceColor = colorSets[nface];   
                fillFace.Add(face3D);


            }

            fillFace = getOrded(fillFace);

            for (int i=0; i<6;i++)
            {
                Geometry.fillPolygon(fillFace[i].pointSets2D, fillFace[i].faceColor, mainBitmap);
            }
             pictureBox1.Refresh();

            //List<Point> cubicPointSets=new List<Point>();

            //for(int i=0;i<f1.Length;i++)
            //{
            //    Point tmp;
            //    foreach(int j in f1[i].p)
            //    {
            //        cubicPointSets.Add(new Point(p2[j]));
            //    }
            //    Geometry.fillPolygon();
            //}


        }