Esempio n. 1
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);
        }