コード例 #1
0
        public void Create(float spokeLen, float spokeRad, float centerRad, float arrowLen, float arrowRad)
        {
            float      ang90 = (float)(Math.PI / 2.0);
            Cylinder3d cn;

            axisInd = new List <Object3d>();

            // x arrow
            cn = new Cylinder3d();
            cn.Create(arrowRad, 0.0f, arrowLen, 8, 2);
            cn.SetColor(Color.Red);
            cn.Rotate(0, ang90, 0);
            cn.Translate(spokeLen + arrowLen / 2 - 0.1f, 0, -arrowLen / 2);
            axisInd.Add(cn);
            cn = new Cylinder3d();
            cn.Create(spokeRad, spokeRad, spokeLen, 8, 2);
            cn.Rotate(0, ang90, 0);
            cn.Translate(spokeLen / 2, 0, -spokeLen / 2);
            cn.SetColor(Color.Red);
            axisInd.Add(cn);

            // y arrow
            cn = new Cylinder3d();
            cn.Create(arrowRad, 0.0f, arrowLen, 8, 2);
            cn.SetColor(Color.Green);
            cn.Rotate(-ang90, 0, 0);
            cn.Translate(0, spokeLen + arrowLen / 2 - 0.1f, -arrowLen / 2);
            axisInd.Add(cn);
            cn = new Cylinder3d();
            cn.Create(spokeRad, spokeRad, spokeLen, 8, 2);
            cn.Rotate(-ang90, 0, 0);
            cn.Translate(0, spokeLen / 2, -spokeLen / 2);
            cn.SetColor(Color.Green);
            axisInd.Add(cn);

            // z arrow
            cn = new Cylinder3d();
            cn.Create(arrowRad, 0.0f, arrowLen, 8, 2);
            cn.SetColor(Color.Blue);
            cn.Translate(0, 0, spokeLen);
            axisInd.Add(cn);
            cn = new Cylinder3d();
            cn.Create(spokeRad, spokeRad, spokeLen, 8, 2);
            cn.SetColor(Color.Blue);
            axisInd.Add(cn);

            // center
            //Object3d sp = Primitives.Sphere(centerRad, 7, 8);
            //sp.SetColor(Color.Yellow);
            //axisInd.Add(sp);
            float r = centerRad;

            axisCent            = Quad3d.CreateQuadBox(-r, r, -r, r, -r, r);
            axisCent[0].imgname = "axisx";
            axisCent[1].imgname = "axisx";
            axisCent[2].imgname = "axisy";
            axisCent[3].imgname = "axisy";
            axisCent[4].imgname = "axisz";
            axisCent[5].imgname = "axisz";
        }
コード例 #2
0
        public void Create(float spokeLen, float spokeRad, float centerRad, float arrowLen, float arrowRad)
        {
            float ang90 = (float)(Math.PI / 2.0);
            Cylinder3d cn;
            axisInd = new List<Object3d>();

            // x arrow
            cn = new Cylinder3d();
            cn.Create(arrowRad, 0.0f, arrowLen, 8, 2);
            cn.SetColor(Color.Red);
            cn.Rotate(0, ang90, 0);
            cn.Translate(spokeLen + arrowLen / 2 - 0.1f, 0, -arrowLen / 2);
            axisInd.Add(cn);
            cn = new Cylinder3d();
            cn.Create(spokeRad, spokeRad, spokeLen, 8, 2);
            cn.Rotate(0, ang90, 0);
            cn.Translate(spokeLen / 2, 0, -spokeLen / 2);
            cn.SetColor(Color.Red);
            axisInd.Add(cn);

            // y arrow
            cn = new Cylinder3d();
            cn.Create(arrowRad, 0.0f, arrowLen, 8, 2);
            cn.SetColor(Color.Green);
            cn.Rotate(-ang90, 0, 0);
            cn.Translate(0, spokeLen + arrowLen / 2 - 0.1f, -arrowLen / 2);
            axisInd.Add(cn);
            cn = new Cylinder3d();
            cn.Create(spokeRad, spokeRad, spokeLen, 8, 2);
            cn.Rotate(-ang90, 0, 0);
            cn.Translate(0, spokeLen / 2, -spokeLen / 2);
            cn.SetColor(Color.Green);
            axisInd.Add(cn);

            // z arrow
            cn = new Cylinder3d();
            cn.Create(arrowRad, 0.0f, arrowLen, 8, 2);
            cn.SetColor(Color.Blue);
            cn.Translate(0, 0, spokeLen);
            axisInd.Add(cn);
            cn = new Cylinder3d();
            cn.Create(spokeRad, spokeRad, spokeLen, 8, 2);
            cn.SetColor(Color.Blue);
            axisInd.Add(cn);

            // center
            //Object3d sp = Primitives.Sphere(centerRad, 7, 8);
            //sp.SetColor(Color.Yellow);
            //axisInd.Add(sp);
            float r = centerRad;
            axisCent = Quad3d.CreateQuadBox(-r, r, -r, r, -r, r);
            axisCent[0].imgname = "axisx";
            axisCent[1].imgname = "axisx";
            axisCent[2].imgname = "axisy";
            axisCent[3].imgname = "axisy";
            axisCent[4].imgname = "axisz";
            axisCent[5].imgname = "axisz";

        }
コード例 #3
0
 /// <summary>
 /// Adds a new dummy support
 /// </summary>
 public void AddSupport()
 {
     Cylinder3d cyl = new Cylinder3d();
     cyl.Create(2.5, 1.5, 10, 15, 2);
     m_engine3d.AddObject(cyl);
     RaiseAppEvent(eAppEvent.eModelAdded, "Model Created");
 }
コード例 #4
0
        /*
         To start, we're going to intersect the entire scene and generate support objects
         * we can change this to generate support for individual objects if needed.
         */
        public ArrayList GenerateSupportObjects()
        {
            // ArrayList objects = new ArrayList();
            // iterate over the platform size by indicated mm step; // projected resolution in x,y
            // generate a 3d x/y point on z=0,
            // generate another on the z=zmax
            // use this ray to intersect the scene
            // foreach intersection point, generate a support
            // we gott make sure supports don't collide
            // I also have to take into account the
            // interface between the support and the model
            ArrayList lstsupports = new ArrayList();

               // double HX =  UVDLPApp.Instance().m_printerinfo.m_PlatXSize / 2; // half X size
              //  double HY =  UVDLPApp.Instance().m_printerinfo.m_PlatYSize / 2; // half Y size
            double ZVal = UVDLPApp.Instance().m_printerinfo.m_PlatZSize;

            //UVDLPApp.Instance().CalcScene();
            m_model.Update();
            double MinX = m_model.m_min.x;
            double MaxX = m_model.m_max.x;
            double MinY = m_model.m_min.y;
            double MaxY = m_model.m_max.y;

            bool intersected = false;
            int scnt = 0; // support count
            // iterate from -HX to HX step xtep;
            double dts = (MaxX - MinX) / m_sc.xspace;
            int its = (int)dts;
            int curstep = 0;

            for (double x = (MinX + (m_sc.xspace/2)); x < MaxX; x += m_sc.xspace)
            {

                RaiseSupportEvent(UV_DLP_3D_Printer.SupportEvent.eProgress, "" + curstep + "/" + its, null);
                curstep++;
                for (double y = (MinY + (m_sc.yspace / 2)); y < MaxY; y += m_sc.yspace)
                {
                    Point3d bpoint,tpoint;
                    Point3d lowest = new Point3d(); // the lowest point of intersection on the z axis

                    bpoint = new Point3d(); // bottom point
                    tpoint = new Point3d(); // top point
                    bpoint.Set(x, y, 0.0 , 1);
                    tpoint.Set(x, y, ZVal, 1); // set to the max height
                    //intersect the scene with a ray

                    lowest.Set(0, 0, ZVal, 0);
                    intersected = false; // reset the intersected flag to be false
                    foreach (Polygon p in m_model.m_lstpolys)
                    {
                        Point3d intersect = new Point3d();
                        // try a less- costly sphere intersect here
                        if (RTUtils.IntersectSphere(bpoint, tpoint, ref intersect, p.m_center, p.m_radius))
                        {
                            // if it intersects,
                            if(RTUtils.IntersectPoly(p,bpoint,tpoint,ref intersect))
                            {
                                // and it's the lowest one
                                if(intersect.z <= lowest.z)
                                {
                                    //save this point
                                    intersected = true;
                                    lowest.Set(intersect);
                                }
                            }
                        }
                    }
                    // for some reason, we're getting negatively generating cylinders
                    // that extend to the -Z world axis
                    // and we're also unnessary support generate on the y -axis that
                    // do not intersect objects vertically in the x/y plane

                    if ((lowest.z < ZVal) && intersected && (lowest.z >= 0))
                    {
                        // now, generate and add a cylinder here
                        Cylinder3d cyl = new Cylinder3d();
                        cyl.Create(m_sc.brad, m_sc.trad, lowest.z, 20, m_sc.vdivs);
                        cyl.Translate((float)x,(float)y,0);
                        cyl.Name = "Support " + scnt;
                        cyl.IsSupport = true;
                        cyl.SetColor(Color.Yellow);
                        scnt++;
                        lstsupports.Add(cyl);
                        RaiseSupportEvent(UV_DLP_3D_Printer.SupportEvent.eSupportGenerated, cyl.Name, cyl);
                    }
                }
            }
               // return objects;
            RaiseSupportEvent(UV_DLP_3D_Printer.SupportEvent.eCompleted, "Support Generation Completed", null);
            m_generating = false;
            return lstsupports;
        }
コード例 #5
0
        /*
         To start, we're going to intersect the entire scene and generate support objects
         * we can change this to generate support for individual objects if needed.
         */
        public static void GenerateSupportObjects(double xstep, double ystep)
        {
            // ArrayList objects = new ArrayList();
            // iterate over the platform size by indicated mm step; // projected resolution in x,y
            // generate a 3d x/y point on z=0,
            // generate another on the z=zmax
            // use this ray to intersect the scene
            // foreach intersection point, generate a support
            // we gott make sure supports don't collide
            // I also have to take into account the
            // interface between the support and the model

            double HX =  UVDLPApp.Instance().m_printerinfo.m_PlatXSize / 2; // half X size
            double HY =  UVDLPApp.Instance().m_printerinfo.m_PlatYSize / 2; // half Y size
            double ZVal = UVDLPApp.Instance().m_printerinfo.m_PlatZSize;
            UVDLPApp.Instance().CalcScene();
            bool intersected = false;
            // iterate from -HX to HX step xtep;
            for(double x = -HX; x < HX; x += xstep)
            {
                for(double y = -HY; y <  0 /*HY*/; y += ystep)
                {
                    Point3d bpoint,tpoint;
                    Point3d lowest = new Point3d(); // the lowest point of intersection on the z axis

                    bpoint = new Point3d(); // bottom point
                    tpoint = new Point3d(); // top point
                    bpoint.Set(x,y,0.0,1);
                    tpoint.Set(x, y, ZVal, 1); // set to the max height
                    //intersect the scene with a ray

                    lowest.Set(0, 0, ZVal, 0);
                    intersected = false;
                    foreach(Polygon p in UVDLPApp.Instance().Scene.m_lstpolys)
                    {
                        Point3d intersect = new Point3d();
                        // try a less- costly sphere intersect here
                        if (RTUtils.IntersectSphere(bpoint, tpoint, ref intersect, p.m_center, p.m_radius))
                        {
                            // if it intersects,
                            if(RTUtils.IntersectPoly(p,bpoint,tpoint,ref intersect))
                            {
                                // and it's the lowest one
                                if(intersect.z <= lowest.z)
                                {
                                    //save this point
                                    intersected = true;
                                    lowest.Set(intersect);
                                }
                            }
                        }
                    }
                    // for some reason, we're getting negatively generating cylinders
                    // that extend to the -Z world axis
                    // and we're also unnessary support generate on the y -axis that
                    // do not intersect objects vertically in the x/y plane

                    if ((lowest.z < ZVal) && intersected && (lowest.z >= 0))
                    {
                        // now, generate and add a cylinder here
                        Cylinder3d cyl = new Cylinder3d();
                        cyl.Create(1, .5, lowest.z, 20, 1);
                        cyl.Translate((float)x,(float)y,0);
                        UVDLPApp.Instance().Engine3D.AddObject(cyl);
                    }
                }
            }
               // return objects;
        }
コード例 #6
0
        private void cmdCreatePrim_Click(object sender, EventArgs e)
        {
            //            Object3d newobj = null;
            float h, rad;
            int ring, sector;
            switch (m_primtype)
            {
                case ePrimType.eCone:
                    rad = nbrCNRad.FloatVal;
                    h = nbrCNHeight.FloatVal;
                    ring = nbrCNVdivs.IntVal;
                    Cylinder3d cn = new Cylinder3d();
                    cn.Create(rad, 0.0f, h, ring, 2);
                    if (cn != null)
                    {
                        UVDLPApp.Instance().Engine3D.AddObject(cn);
                        UVDLPApp.Instance().SelectedObject = cn;
                    }

                    break;
                case ePrimType.eCube:
                    break;
                case ePrimType.eCylinder:
                    rad = nbrCNRad.FloatVal;
                    h = nbrCNHeight.FloatVal;
                    ring = nbrCNVdivs.IntVal;
                    Cylinder3d cy = new Cylinder3d();
                    cy.Create(rad, rad, h, ring, 2);
                    if (cy != null)
                    {
                        UVDLPApp.Instance().Engine3D.AddObject(cy);
                        UVDLPApp.Instance().SelectedObject = cy;
                    }

                    break;
                case ePrimType.eSphere:
                    rad = nbrSPRad.FloatVal;
                    ring = nbrSPHdivs.IntVal;
                    sector = nbrSPVdivs.IntVal;
                    Object3d newobj = Primitives.Sphere(rad, ring, sector);
                    if (newobj != null)
                    {
                        UVDLPApp.Instance().Engine3D.AddObject(newobj);
                        UVDLPApp.Instance().SelectedObject = newobj;
                    }
                    break;
                case ePrimType.eTorus:
                    break;
            }
            UVDLPApp.Instance().RaiseAppEvent(eAppEvent.eModelAdded, "");
            UVDLPApp.Instance().RaiseAppEvent(eAppEvent.eUpdateSelectedObject, "updateobject");
        }