示例#1
0
        public Face(List<Vertex> v, Plane p)
        {
            vertices = v;
            //Console.WriteLine("Face has " + vertices.Count + " vertices");
            plane = p;

            //fix the plane's first, second and third points
            Vector3 x = Vector3.Normalize(plane.meshThird - plane.meshSecond),
                    y = Vector3.Normalize(plane.meshFirst - plane.meshSecond);

            //find the minCorner as a (x,y)
            Vector2 minCorner = new Vector2(float.MaxValue, float.MaxValue);
            Vector2 maxCorner = new Vector2(-float.MaxValue, -float.MaxValue);
            foreach (Vertex c in vertices) {
                Vector2 cc = new Vector2(Vector3.Dot(c.position - plane.meshSecond, x), Vector3.Dot(c.position - plane.meshSecond, y));
                minCorner.X = Math.Min(cc.X, minCorner.X);
                minCorner.Y = Math.Min(cc.Y, minCorner.Y);
                maxCorner.X = Math.Max(cc.X, maxCorner.X);
                maxCorner.Y = Math.Max(cc.Y, maxCorner.Y);
            }

            plane.meshSecond = minCorner.X * x + minCorner.Y * y + plane.meshSecond;
            plane.meshThird = (maxCorner.X - minCorner.X) * x + plane.meshSecond;
            plane.meshFirst = (maxCorner.Y - minCorner.Y) * y + plane.meshSecond;

            windVertices();
            computeTexCoords();
        }
示例#2
0
 public Vertex getIntersection(Plane p1, Plane p2, Plane p3)
 {
     return getIntersection(p1.getNormal(), p2.getNormal(), p3.getNormal(), (float)(p1.getD()), (float)(p2.getD()), (float)(p3.getD()));
 }