当前位置: 首页>>代码示例>>C#>>正文


C# Point3d.Set方法代码示例

本文整理汇总了C#中Point3d.Set方法的典型用法代码示例。如果您正苦于以下问题:C# Point3d.Set方法的具体用法?C# Point3d.Set怎么用?C# Point3d.Set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Point3d的用法示例。


在下文中一共展示了Point3d.Set方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ISectData

 public ISectData(Object3d o, Polygon p, Point3d isect, Point3d orgin, Vector3d dir) 
 {
     intersect = new Point3d();
     intersect.Set(isect);
     origin = new Point3d();
     direction = new Vector3d();
     origin.Set(orgin);
     direction.Set(dir);
     obj = o;
     poly = p;
 }
开发者ID:RFranta,项目名称:UVDLPSlicerController,代码行数:11,代码来源:ISectData.cs

示例2: FindIntersection

        /*
        public class Config
        {
            int xres, yres;
           // double
        }
         * */
        public static bool FindIntersection(Vector3d direction, Point3d origin, ref Point3d intersect)
        {
            UVDLPApp.Instance().CalcScene();
            //bool intersected = false;

              //  Point3d bpoint, tpoint;
              //  Point3d lowest = new Point3d(); // the lowest point of intersection on the z axis
            direction.Normalize();
            direction.Scale(100.0);
            Point3d endp = new Point3d();
            endp.Set(origin);
            endp.x += direction.x;
            endp.y += direction.y;
            endp.z += direction.z;
            /*
            intersect = new Point3d();
            intersect.x = 0.0d;
            intersect.y = 0.0d;
            intersect.z = 0.0d;
            */
            //intersect the scene with a ray

               // intersected = false;
            foreach (Polygon p in UVDLPApp.Instance().Scene.m_lstpolys)
            {
                intersect = new Point3d();
                // try a less- costly sphere intersect here
                if (RTUtils.IntersectSphere(origin, endp, ref intersect, p.m_center, p.m_radius))
                {
                    // if it intersects,
                    if (RTUtils.IntersectPoly(p, origin, endp, ref intersect))
                    {
                        return true;
                        /*
                        // and it's the lowest one
                        if (intersect.z <= lowest.z)
                        {
                            //save this point
                            intersected = true;
                            lowest.Set(intersect);
                        }
                         * */
                    }
                }
            }

            return false;
        }
开发者ID:Elph,项目名称:UVDLPSlicerController,代码行数:55,代码来源:SupportGenerator.cs

示例3: CalcCenter

        public Point3d CalcCenter()
        {
            Point3d center = new Point3d();
            center.Set(0, 0, 0, 0);
            foreach (Point3d p in m_lstpoints)
            {
                center.x += p.x;
                center.y += p.y;
                center.z += p.z;

            }

            center.x /= m_lstpoints.Count;
            center.y /= m_lstpoints.Count;
            center.z /= m_lstpoints.Count;

            return center;
        }
开发者ID:tojoevan,项目名称:UVDLPSlicerController,代码行数:18,代码来源:Object3d.cs

示例4: TestHitTest

        private List<ISectData> TestHitTest(int X, int Y)
        {
            String mess = "";
            mess = "Screen X,Y = (" + X.ToString() + "," + Y.ToString() + ")\r\n";

            /*
            (Note that most window systems place the mouse coordinate origin in the upper left of the window instead of the lower left.
            That's why window_y is calculated the way it is in the above code. When using a glViewport() that doesn't match the window height,
            the viewport height and viewport Y are used to determine the values for window_y and norm_y.)

            The variables norm_x and norm_y are scaled between -1.0 and 1.0. Use them to find the mouse location on your zNear clipping plane like so:

            float y = near_height * norm_y;
            float x = near_height * aspect * norm_x;
            Now your pick ray vector is (x, y, -zNear).
             */
            int w = glControl1.Width;
            int h = glControl1.Height;
            mess += "Screen Width/Height = " + w.ToString() + "," + h.ToString() + "\r\n";
            float aspect = ((float)glControl1.Width) / ((float)glControl1.Height);
            //mess += "Screen Aspect = " + aspect.ToString() + "\r\n";

            int window_y = (h - Y) - h/2;
            double norm_y = (double)(window_y)/(double)(h/2);
            int window_x = X - w/2;
            double norm_x = (double)(window_x)/(double)(w/2);
            float near_height = .2825f; // no detectable error

            float y = (float)(near_height * norm_y);
            float x = (float)(near_height * aspect * norm_x);

            /*
            To transform this eye coordinate pick ray into object coordinates, multiply it by the inverse of the ModelView matrix in use
            when the scene was rendered. When performing this multiplication, remember that the pick ray is made up of a vector and a point,
            and that vectors and points transform differently. You can translate and rotate points, but vectors only rotate.
            The way to guarantee that this is working correctly is to define your point and vector as four-element arrays,
            as the following pseudo-code shows:

            float ray_pnt[4] = {0.f, 0.f, 0.f, 1.f};
            float ray_vec[4] = {x, y, -near_distance, 0.f};
            The one and zero in the last element determines whether an array transforms as a point or a vector when multiplied by the
            inverse of the ModelView matrix.*/
            Vector4 ray_pnt = new Vector4(0.0f, 0.0f, 0.0f, 1.0f);
            //Vector4 ray_vec = new Vector4((float)norm_x, (float)norm_y, -1.0f, 0);
            Vector4 ray_vec = new Vector4((float)x, (float)y, -1f, 0);
            ray_vec.Normalize();

            //mess += "Eye Pick Vec =  (" + String.Format("{0:0.00}", ray_vec.X) + ", " + String.Format("{0:0.00}", ray_vec.Y) + "," + String.Format("{0:0.00}", ray_vec.Z) + ")\r\n";

            Matrix4 modelViewMatrix;
            GL.GetFloat(GetPName.ModelviewMatrix, out modelViewMatrix);
            Matrix4 viewInv = Matrix4.Invert(modelViewMatrix);

            Vector4 t_ray_pnt = new Vector4();
            Vector4 t_ray_vec = new Vector4();

            Vector4.Transform(ref ray_vec, ref viewInv, out t_ray_vec);
            Vector4.Transform(ref ray_pnt, ref viewInv, out t_ray_pnt);
            //mess += "World Pick Vec =  (" + String.Format("{0:0.00}", t_ray_vec.X) + ", " + String.Format("{0:0.00}", t_ray_vec.Y) + "," + String.Format("{0:0.00}", t_ray_vec.Z) + ")\r\n";
            //mess += "World Pick Pnt =  (" + String.Format("{0:0.00}", t_ray_pnt.X) + ", " + String.Format("{0:0.00}", t_ray_pnt.Y) + "," + String.Format("{0:0.00}", t_ray_pnt.Z) + ")\r\n";

            Point3d origin = new Point3d();
            Point3d intersect = new Point3d();
            Engine3D.Vector3d dir = new Engine3D.Vector3d();

            origin.Set(t_ray_pnt.X, t_ray_pnt.Y, t_ray_pnt.Z);
            dir.Set(t_ray_vec.X, t_ray_vec.Y, t_ray_vec.Z); // should this be scaled?

            List<ISectData> isects = RTUtils.IntersectObjects(dir, origin, UVDLPApp.Instance().Engine3D.m_objects, true);
            if (isects.Count > 0)
            {
                ISectData isect = (ISectData)isects[0]; // get the first
                ix = (float)isect.intersect.x; // show the closest
                iy = (float)isect.intersect.y;
                iz = (float)isect.intersect.z;
            }

            return isects;
        }
开发者ID:BenjaminRaymond,项目名称:UVDLPSlicerController,代码行数:79,代码来源:frmMain.cs

示例5: glControl1_MouseMove

        private void glControl1_MouseMove(object sender, MouseEventArgs e)
        {
            List<ISectData> hits = TestHitTest(e.X,e.Y);
            double dx = 0, dy = 0;
            if (lmdown || rmdown || mmdown)
            {
                dx = e.X - mdx;
                dy = e.Y - mdy;
                mdx = e.X;
                mdy = e.Y;

            }
            dx /= 2;
            dy /= 2;

            if (lmdown)
            {
                orbitypos += (float)dx;
                orbitxpos += (float)dy;
                Vector2 vec = new Vector2(mdx,mdy);
                m_quat += arcball.Drag(vec);
                arcball.Click(vec);
                m_camera.RotateRightFlat((float)dx);
                m_camera.RotateUp((float)dy);
                //arcball.Click(vec);
                //ArcBall.drag(&MousePt, &ThisQuat);                  // Update End Vector And Get Rotation As Quaternion
                /*
                Matrix3fSetRotationFromQuat4f(&ThisRot, &ThisQuat);         // Convert Quaternion Into Matrix3fT
                Matrix3fMulMatrix3f(&ThisRot, &LastRot);                // Accumulate Last Rotation Into This One
                Matrix4fSetRotationFromMatrix3f(&Transform, &ThisRot);          // Set Our Final
                 * */
                // do the rotation
            }
            else if (mmdown)
            {
                orbitdist += (float)dy;
                m_camera.MoveForward((float)dy);
            }
            else if (rmdown)
            {
                yoffset += (float)dy / 2;
                xoffset += (float)dx / 2;
                m_camera.Move((float)dx, (float)dy);
            }

            if (UVDLPApp.Instance().SelectedObject != null)
            {
                if (m_movingobjectmode) // if we're moving an object
                {
                    // examine the last isect data
                    foreach (ISectData dat in hits)
                    {
                        if (dat.obj.tag == Object3d.OBJ_GROUND) //found the ground plane
                        {

                            UVDLPApp.Instance().SelectedObject.Translate(
                                (float)(dat.intersect.x - UVDLPApp.Instance().SelectedObject.m_center.x),
                                (float)(dat.intersect.y - UVDLPApp.Instance().SelectedObject.m_center.y),
                                0.0f);
                        }

                    }
                    if (UVDLPApp.Instance().SelectedObject.tag == Object3d.OBJ_SUPPORT)  // if the current selected object is a support
                    {
                        Support tmpsup = (Support)UVDLPApp.Instance().SelectedObject;
                        Point3d pnt = new Point3d();
                        pnt.Set(tmpsup.m_center.x, tmpsup.m_center.y, 0);
                        Engine3D.Vector3d vec = new Engine3D.Vector3d();
                        vec.Set(0, 0, 1); // create a vector striaght up
                        // hit test from the selected objects center x/y/0 position straight up
                        //see if it hits any object in the scene,
                        // if it does, scale the object from the ground plane to the closest intersection point
                        List<ISectData> iss = RTUtils.IntersectObjects(vec, pnt, UVDLPApp.Instance().Engine3D.m_objects, false);
                        foreach (ISectData htd in iss)
                        {
                            if (htd.obj.tag != Object3d.OBJ_SUPPORT )  // if this is not another support or the ground
                            {
                                if (htd.obj.tag != Object3d.OBJ_GROUND)
                                {
                                    // this should be it...
                                    tmpsup.ScaleToHeight(htd.intersect.z);
                                    break;
                                }
                            }
                        }
                    }
                }
            }
            DisplayFunc();
        }
开发者ID:BenjaminRaymond,项目名称:UVDLPSlicerController,代码行数:90,代码来源:frmMain.cs

示例6: GenerateSupportObjects

        public List<Object3d> GenerateSupportObjects()
        {
            // 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
            List<Object3d> lstsupports = new List<Object3d>();

            float ZVal = (float)UVDLPApp.Instance().m_printerinfo.m_PlatZSize;
            m_model.Update();
            float MinX = m_model.m_min.x;
            float MaxX = m_model.m_max.x;
            float MinY = m_model.m_min.y;
            float 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 (float x = (float)(MinX + (m_sc.xspace / 2.0f)); x < MaxX; x += (float)m_sc.xspace)
            {
                // say we're doing stuff
                RaiseSupportEvent(UV_DLP_3D_Printer.SupportEvent.eProgress, "" + curstep + "/" + its, null);
                curstep++;
                for (float y = (float)(MinY + (m_sc.yspace / 2)); y < MaxY; y += (float)m_sc.yspace)
                {
                    Point3d origin;
                    origin = new Point3d(); // bottom point
                    origin.Set(x, y, 0.0f);
                    //intersected = false; // reset the intersected flag to be false

                    Vector3d up = new Vector3d(); // the up vector
                    up.x = 0.0f;
                    up.y = 0.0f;
                    up.z = 1.0f;

                    List<ISectData> lstISects = RTUtils.IntersectObjects(up, origin, UVDLPApp.Instance().Engine3D.m_objects, false);
                    //check for cancelling
                    if (m_cancel)
                    {
                        RaiseSupportEvent(UV_DLP_3D_Printer.SupportEvent.eCancel, "Support Generation Cancelled", null);
                        return lstsupports;
                    }

                    foreach (ISectData htd in lstISects)
                    {
                        if (htd.obj.tag != Object3d.OBJ_SUPPORT)  // if this is not another support or the ground
                        {
                            if (htd.obj.tag != Object3d.OBJ_GROUND) // if it's not the ground
                            {
                                if (m_sc.m_onlydownward && htd.poly.tag != Polygon.TAG_MARKDOWN)
                                    break; // not a downward facing and we're only doing downward
                                // this should be the closest intersected
                                Support s = new Support();
                                float lz = (float)htd.intersect.z;
                                s.Create((float)m_sc.fbrad, (float)m_sc.ftrad, (float)m_sc.hbrad, (float)m_sc.htrad, lz * .2f, lz * .6f, lz * .2f, 11);
                                s.Translate((float)x, (float)y, 0);
                                s.Name = "Support " + scnt;
                                s.SetColor(Color.Yellow);
                                scnt++;
                                lstsupports.Add(s);
                                RaiseSupportEvent(UV_DLP_3D_Printer.SupportEvent.eSupportGenerated, s.Name, s);
                                break; // only need to make one support
                            }
                        }
                    }

                }
            }
            // return objects;
            RaiseSupportEvent(UV_DLP_3D_Printer.SupportEvent.eCompleted, "Support Generation Completed", lstsupports);
            m_generating = false;
            return lstsupports;
        }
开发者ID:kampos91,项目名称:UVDLPSlicerController,代码行数:81,代码来源:SupportGenerator.cs

示例7: GenerateSupportObjects

        /*
         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;
        }
开发者ID:ramkanna,项目名称:UVDLPSlicerController,代码行数:97,代码来源:SupportGenerator.cs

示例8: GenerateSupportObjects

        /*
         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;
        }
开发者ID:Elph,项目名称:UVDLPSlicerController,代码行数:73,代码来源:SupportGenerator.cs

示例9: TestHitTest

        private void TestHitTest(int X, int Y)
        {
            // show 2d coords
            // convert from screen 2d to
            lblDebug.Text = "Screen X,Y = (" + X.ToString() + "," + Y.ToString() + ")\r\n";

            int w = glControl1.Width;
            int h = glControl1.Height;
            lblDebug.Text += "Screen Width/Height = " + w.ToString() + "," + h.ToString() + "\r\n";
            float aspect = ((float)glControl1.Width) / ((float)glControl1.Height);
            lblDebug.Text += "Screen Aspect = " + aspect.ToString() + "\r\n";
            int window_y = (h - Y) - h/2;
            double norm_y = (double)(window_y)/(double)(h/2);
            int window_x = X - w/2;
            double norm_x = (double)(window_x)/(double)(w/2);
            // the x/y coordinate is now un-projected from screen to camara space
            //lblDebug.Text += "Normalized X/Y = (" + String.Format("{0:0.00}", norm_x) + "," + String.Format("{0:0.00}", norm_y) + ")\r\n";
            lblDebug.Text += "Eye Pick Vec =  (" + String.Format("{0:0.00}", norm_x) + ", " + String.Format("{0:0.00}", norm_y) + ", -1 )\r\n";
            // now multiply it by the inverse of the projection matrix
            // to get it into world space.
            Matrix4 modelViewMatrix;//, projectionMatrix;
            GL.GetFloat(GetPName.ModelviewMatrix, out modelViewMatrix);
            Vector4 vec,vecpnt;

            vec.X = (float)norm_x;
            vec.Y = (float)norm_y;
            vec.Z = -1.0f;
            vec.W = 0.0f;// 1.0f;

            //vec.Normalize();
               // vecpnt.X = 0.0f;
               // vecpnt.Y = 0.0f;
            vecpnt.X = (float)norm_x;
            vecpnt.Y = (float)norm_y;
            vecpnt.Z = 0.0f;
            vecpnt.W = 1.0f;

            Matrix4 viewInv = Matrix4.Invert(modelViewMatrix);
            //Matrix4 projInv = Matrix4.Invert(projection);
            //Vector4.Transform(ref vec, ref projInv, out vec);
            //vec.Normalize();
            //vec.Scale(.5f, .5f, .5f, .5f);
            Vector4.Transform(ref vec, ref viewInv, out vec);
            Vector4.Transform(ref vecpnt, ref viewInv, out vecpnt);

            lblDebug.Text += "World Pick Vec =  (" + String.Format("{0:0.00}", vec.X) + ", " + String.Format("{0:0.00}", vec.Y) + "," + String.Format("{0:0.00}", vec.Z) + ")\r\n";
            lblDebug.Text += "World Pick Pnt =  (" + String.Format("{0:0.00}", vecpnt.X) + ", " + String.Format("{0:0.00}", vecpnt.Y) + "," + String.Format("{0:0.00}", vecpnt.Z) + ")\r\n";
            // ray vector
            /*
            ix = vec.X + vecpnt.X ;
            iy = vec.Y + vecpnt.Y ;
            iz = vec.Z + vecpnt.Z;

            ipx = vecpnt.X;
            ipy = vecpnt.Y;
            ipz = vecpnt.Z;
            */
            Point3d origin = new Point3d();
            Point3d intersect = new Point3d();
            Engine3D.Vector3d dir = new Engine3D.Vector3d();

            origin.Set(vecpnt.X, vecpnt.Y, vecpnt.Z,0);
            dir.Set(vec.X, vec.Y, vec.Z, 0);

            if (SupportGenerator.FindIntersection(dir, origin, ref intersect))
            {
                lblDebug.Text += "Intersection @ =  (" + String.Format("{0:0.00}", intersect.x) + ", " + String.Format("{0:0.00}", intersect.y) + "," + String.Format("{0:0.00}", intersect.z) + ")\r\n";
                ix = (float)intersect.x;
                iy = (float)intersect.y;
                iz = (float)intersect.z;
            }
            //ray point
            //GL.GetFloat(GetPName.ProjectionMatrix, out projectionMatrix);
            /*
            (Note that most window systems place the mouse coordinate origin in the upper left of the window instead of the lower left.
            That's why window_y is calculated the way it is in the above code. When using a glViewport() that doesn't match the window height,
            the viewport height and viewport Y are used to determine the values for window_y and norm_y.)

            The variables norm_x and norm_y are scaled between -1.0 and 1.0. Use them to find the mouse location on your zNear clipping plane like so:

            float y = near_height * norm_y;
            float x = near_height * aspect * norm_x;
            Now your pick ray vector is (x, y, -zNear).

            To transform this eye coordinate pick ray into object coordinates, multiply it by the inverse of the ModelView matrix in use
            when the scene was rendered. When performing this multiplication, remember that the pick ray is made up of a vector and a point,
            and that vectors and points transform differently. You can translate and rotate points, but vectors only rotate.
            The way to guarantee that this is working correctly is to define your point and vector as four-element arrays,
            as the following pseudo-code shows:

            float ray_pnt[4] = {0.f, 0.f, 0.f, 1.f};
            float ray_vec[4] = {x, y, -near_distance, 0.f};
            The one and zero in the last element determines whether an array transforms as a point or a vector when multiplied by the
            inverse of the ModelView matrix.*/
        }
开发者ID:Elph,项目名称:UVDLPSlicerController,代码行数:95,代码来源:frmMain.cs

示例10: MoveFromTip

        /// <summary>
        /// This function is designed to move a support by it's tip
        /// it will angle up from the s5i index and position the points to intersect around the 
        /// specified tip point,
        /// all points below s5i  - 
        /// 1) could stay where they are
        /// 2) or move to be a relative distance from the tip - 5mm or so in the direction of vec
        /// </summary>
        /// <param name="tip"></param>
        public void MoveFromTip(Point3d tip, Vector3d vec)
        {
            //starting at s5i, center all points around this.
            Point3d diff = new Point3d();
            ScaleToHeight(tip.z * .85);
            Point3d center;
            // first, move along the vec in the direction of the vector
            center = CalcCentroid(0,s5i);
            diff.Set(tip.x + vec.x - center.x, tip.y + vec.y - center.y, 0.0f); // only slide along the x/y plane
            TranslateRange(diff,0, s5i);

            center = CalcCentroid(s5i, m_lstpoints.Count);
            diff.Set(tip.x - center.x,tip.y - center.y,tip.z - center.z);
            TranslateRange(diff, s5i, m_lstpoints.Count);
            Update();
        }
开发者ID:njh19,项目名称:UVDLPSlicerController,代码行数:25,代码来源:Support.cs

示例11: GetSupportParrent

        Object3d GetSupportParrent(float x, float y, float z)
        {
            //Object3d obj;
            List<Object3d> matchingObjects = new List<Object3d>();
            foreach (Object3d obj in UVDLPApp.Instance().Engine3D.m_objects)
            {
                if (obj.tag != Object3d.OBJ_NORMAL)
                    continue;
                if ((x > obj.m_min.x) && (x < obj.m_max.x) && (y > obj.m_min.y) && (y < obj.m_max.y))
                    matchingObjects.Add(obj);
            }
            if (matchingObjects.Count == 0)
                return null; // Should not happen!
            if (matchingObjects.Count == 1)
                return matchingObjects[0]; // the easy case.

            Point3d origin;
            origin = new Point3d(); // bottom point
            origin.Set(x, y, 0.0f);
            //intersected = false; // reset the intersected flag to be false

            Vector3d up = new Vector3d(); // the up vector
            up.x = 0.0f;
            up.y = 0.0f;
            up.z = 1.0f;

            List<ISectData> lstISects = RTUtils.IntersectObjects(up, origin, matchingObjects, false);
            Object3d objFound = null;
            float minzdiff = 99999999f;
            // find the intersection closest to z.
            foreach (ISectData htd in lstISects)
            {
                float zdiff = Math.Abs(htd.intersect.z - z);
                if (zdiff < minzdiff)
                {
                    minzdiff = zdiff;
                    objFound = htd.obj;
                }
            }
            return objFound;
        }
开发者ID:RFranta,项目名称:UVDLPSlicerController,代码行数:41,代码来源:SupportGenerator.cs

示例12: GenerateSupportObjects

        public List<Object3d> GenerateSupportObjects()
        {
            // 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
            List<Object3d> lstsupports = new List<Object3d>();

            float ZVal = (float)UVDLPApp.Instance().m_printerinfo.m_PlatZSize;
            m_model.Update();
            float MinX = m_model.m_min.x;
            float MaxX = m_model.m_max.x;
            float MinY = m_model.m_min.y;
            float 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 (float x = (float)(MinX + (m_sc.xspace / 2.0f)); x < MaxX; x += (float)m_sc.xspace)
            {
                // say we're doing stuff
                RaiseSupportEvent(UV_DLP_3D_Printer.SupportEvent.eProgress, "" + curstep + "/" + its, null);
                curstep++;
                for (float y = (float)(MinY + (m_sc.yspace / 2)); y < MaxY; y += (float)m_sc.yspace)
                {
                    Point3d origin;
                    origin = new Point3d(); // bottom point
                    origin.Set(x, y, 0.0f);
                    //intersected = false; // reset the intersected flag to be false

                    Vector3d up = new Vector3d(); // the up vector
                    up.x = 0.0f;
                    up.y = 0.0f;
                    up.z = 1.0f;

                    List<ISectData> lstISects = RTUtils.IntersectObjects(up, origin, UVDLPApp.Instance().Engine3D.m_objects, false);
                    //check for cancelling
                    if (m_cancel)
                    {
                        RaiseSupportEvent(UV_DLP_3D_Printer.SupportEvent.eCancel, "Support Generation Cancelled", null);
                        return lstsupports;
                    }

                    Vector3d upvec = new Vector3d();
                    double inc = 1.0 / 90.0;
                    double angle = -(1 - (m_sc.downwardAngle * inc));
                    upvec.Set(new Point3d(0, 0, 1));

                    foreach (ISectData htd in lstISects)
                    {
                        if (htd.obj.tag == Object3d.OBJ_NORMAL)  // if this is not another support or the ground
                        {
                            htd.poly.CalcNormal();
                            double d = htd.poly.m_normal.Dot(upvec);
                            if (m_sc.m_onlydownward && d >= angle) // this makes sure downward works even if polygons are not tagged
                                    break; // not a downward facing and we're only doing downward
                            // this should be the closest intersected
                            Support sup = AddNewSupport(x, y, (float)htd.intersect.z, scnt++, htd.obj, lstsupports);
                            sup.SelectionType = Support.eSelType.eTip;
                            sup.MoveFromTip(htd);

                            break; // only need to make one support
                        }
                    }

                }
            }
            // return objects;
            RaiseSupportEvent(UV_DLP_3D_Printer.SupportEvent.eCompleted, "Support Generation Completed", lstsupports);
            m_generating = false;
            return lstsupports;
        }
开发者ID:tojoevan,项目名称:BGC-CW,代码行数:80,代码来源:SupportGenerator.cs


注:本文中的Point3d.Set方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。