Exemplo n.º 1
0
        /// <summary>
        /// Computes from vertices.
        /// </summary>
        /// <param name="vertices">The vertices.</param>
        public void ComputeFromVertices(IEnumerable<Vector3> vertices)
        {
            Minimum = new Vector3(vertices.First().X,
                                  vertices.First().Y,
                                  vertices.First().Z);

            Maximum = new Vector3(vertices.First().X,
                                  vertices.First().Y,
                                  vertices.First().Z);

            foreach(var vertex in vertices)
            {
                if (vertex.X <= Minimum.X)
                    Minimum = Minimum.UpdateX(vertex.X);

                if (vertex.Y <= Minimum.Y)
                    Minimum = Minimum.UpdateY(vertex.Y);

                if (vertex.Z <= Minimum.Z)
                    Minimum = Minimum.UpdateZ(vertex.Z);

                if (vertex.X >= Maximum.X)
                    Maximum = Maximum.UpdateX(vertex.X);

                if (vertex.Y >= Maximum.Y)
                    Maximum = Maximum.UpdateY(vertex.Y);

                if (vertex.Z >= Maximum.Z)
                    Maximum = Maximum.UpdateZ(vertex.Z);
            }
        }