public Engine3d()
 {
     m_camera = new Camera();
     m_lines = new ArrayList();
     m_objects = new ArrayList();
     AddGrid();
 }
 public void Render(Camera cam, PaintEventArgs ev,int wid, int hei)
 {
     try
     {
         ArrayList m_campnts = new ArrayList();
         //transform this from world to camera coordinates
         //project
         // then draw
         foreach (Point3d pnt in m_points)
         {
             Point3d p = cam.viewmat.Transform(pnt);
             m_campnts.Add(p);
         }
         if (m_campnts.Count > 1)
         {
             Point[] line = new Point[m_campnts.Count];
             if (cam.m_protyp == eProjectType.eParallel)
             {
                 int idx = 0;
                 foreach (Point3d pnt in m_campnts)
                 {
                     line[idx].X = (int)((cam.m_scalex * pnt.x) + (wid / 2)); // need to add x and y offsets
                     line[idx].Y = (int)((cam.m_scaley * pnt.y) + (hei / 2)); // need to add x and y offsets
                     idx++;
                 }
             }
             Pen pen = new Pen(m_color, 2);
             ev.Graphics.DrawLines(pen, line);
         }
     }
     catch (Exception) { }
 }
        public void Render(Camera cam, PaintEventArgs ev, int wid, int hei)
        {
            try
            {
                ArrayList m_campnts = new ArrayList();
                //transform this from world to camera coordinates
                //project
                // then draw
                foreach (Point3d pnt in m_points)
                {
                    Point3d p = cam.viewmat.Transform(pnt);
                    m_campnts.Add(p);
                }
                if (m_campnts.Count > 1)
                {
                    Point[] line = new Point[m_campnts.Count];
                    if (cam.m_protyp == eProjectType.eParallel)
                    {
                        int idx = 0;
                        Point first = new Point();
                        foreach (Point3d pnt in m_campnts)
                        {
                            line[idx].X = (int)((cam.m_scalex * pnt.x) + (wid / 2)); // need to add x and y offsets
                            line[idx].Y = (int)((cam.m_scaley * pnt.y) + (hei / 2)); // need to add x and y offsets
                            if (idx == 0)
                            {
                                first.X = line[idx].X;
                                first.Y = line[idx].Y;
                            }
                            idx++;
                        }
                        // line[idx].X  = first.X; // add the first on as the last as well to close it up
                        // line[idx].Y = first.Y;
                    }

                    Brush solidbrush = new SolidBrush(m_color);
                    if (m_solid == true)
                    {
                        ev.Graphics.FillPolygon(solidbrush, line);

                    }

                    Pen linepen = new Pen(m_linecolor, 2);
                    if (m_wire == true)
                    {
                        ev.Graphics.DrawPolygon(linepen, line);
                        ev.Graphics.DrawLines(linepen, line);
                    }
                }
            }
            catch (Exception) { }
        }
示例#4
0
 public void Render(Camera cam, PaintEventArgs ev, int wid, int hei)
 {
     foreach (Polygon poly in m_lstpolys)
     {
         poly.Render(cam, ev, wid, hei);
     }
 }