public void GetNormal_PlanarPolygon_ReturnsCorrectResult()
 {
     var p = new Polygon3D();
     p.Points.Add(new Point3D(0, 0, 0));
     p.Points.Add(new Point3D(1, 0, 0));
     p.Points.Add(new Point3D(1, 1, 0));
     p.Points.Add(new Point3D(0, 1, 0));
     Assert.AreEqual(new Vector3D(0, 0, 1), p.GetNormal());
 }
Exemple #2
0
        public void Polygon_GetNormal_NotThrows()
        {
            var points = new List <Vector3>()
            {
                new Vector3(-1.39943f, 0.328622f, 0.97968f),
                new Vector3(-1.39969f, 0.328622f, 0.99105f),
                new Vector3(-1.39963f, 0.328631f, 0.99105f),
                new Vector3(-1.39954f, 0.328631f, 0.98726f),
                new Vector3(-1.39937f, 0.328631f, 0.97968f),
            };

            var     polygon = new Polygon3D(points);
            Vector3 normal  = polygon.GetNormal();
        }
Exemple #3
0
        public void Polygon_GetNormal_NotThrows()
        {
            var points = new List <Point3D>()
            {
                new Point3D(-1.39943, 0.328622, 0.97968),
                new Point3D(-1.39969, 0.328622, 0.99105),
                new Point3D(-1.39963, 0.328631, 0.99105),
                new Point3D(-1.39954, 0.328631, 0.98726),
                new Point3D(-1.39937, 0.328631, 0.97968),
            };

            var      polygon = new Polygon3D(points);
            Vector3D normal  = polygon.GetNormal();
        }
Exemple #4
0
        static protected Faces ConvertSidePlanesToFaces(WorldcraftObject wo, WorldcraftSidePlanes sidePlanes, Textures textures)
        {
            Faces faces = new Faces();

            for (int i = 0; i < sidePlanes.Count; i++)
            {
                //Consider this side plane and it's associated heavily used parts.
                WorldcraftSidePlane sp = sidePlanes[i];

                Polygon3D polygon = sp.plane.CreatePolygon(10000);
                if (Vector3D.Dot(polygon.GetNormal(), sp.plane.Normal) > 0)
                {
                    polygon.Flip();
                }
                CutPolygonByPlanes(polygon, sidePlanes, i);

                if (polygon.Points.Count >= 3)
                {
                    Face face = new Face();
                    face.Texture   = sp.texture;
                    face.SAxis     = sp.sAxis;
                    face.TAxis     = sp.tAxis;
                    face.Plane     = sp.plane.GetFlipped();
                    face.GroupName = wo.ClassName;

                    foreach (Vector3D pt in polygon.Points)
                    {
                        face.Points.Add(face.Plane.ProjectOntoPlane(pt));
                    }

                    faces.Add(face);
                }
            }

            return(faces);
        }