/// <summary> /// Automatically computes bounding box for the specified vertex arrays. /// </summary> /// <param name="vertexArrayObject"> /// /// </param> /// <returns> /// It returns the <see cref="IBoundingVolume"/> for <paramref name="vertexArrayObject"/>, if possible. /// </returns> private static IBoundingVolume ComputeBoundingVolume(VertexArrayObject vertexArrayObject) { if (vertexArrayObject == null) { throw new ArgumentNullException("vertexArrayObject"); } VertexArrayObject.IVertexArray vertexArray = vertexArrayObject.GetVertexArray(VertexArraySemantic.Position); if (vertexArray == null) { return(null); } ArrayBufferObjectBase positionArray = vertexArray.Array; Type positionArrayType = positionArray.GetType(); if (positionArrayType == typeof(ArrayBufferObject <Vertex4f>)) { ArrayBufferObject <Vertex4f> positionArray4f = (ArrayBufferObject <Vertex4f>)positionArray; Vertex4f min = Vertex4f.Maximum, max = Vertex4f.Minimum; positionArray4f.MinMax(out min, out max); return(new BoundingBox((Vertex3f)min, (Vertex3f)max)); } else if (positionArrayType == typeof(ArrayBufferObject <Vertex3f>)) { ArrayBufferObject <Vertex3f> positionArray3f = (ArrayBufferObject <Vertex3f>)positionArray; Vertex3f min = Vertex3f.Maximum, max = Vertex3f.Minimum; positionArray3f.MinMax(out min, out max); return(new BoundingBox(min, max)); } else { return(null); } }