+ vector<Vector3> points;
+ for(vector<RefPtr<const Mesh> >::const_iterator i=meshes.begin(); i!=meshes.end(); ++i)
+ {
+ const VertexArray &vertices = (*i)->get_vertices();
+ int offset = vertices.get_format().offset(VERTEX3);
+ if(offset<0)
+ {
+ // TODO Handle two-dimensional meshes
+ bounding_sphere = Geometry::BoundingSphere<float, 3>();
+ return;
+ }
+
+ unsigned n_vertices = vertices.size();
+ points.reserve(points.size()+n_vertices);
+ for(unsigned j=0; j<n_vertices; ++j)
+ {
+ const float *v = vertices[j];
+ points.push_back(Vector3(v[offset], v[offset+1], v[offset+2]));
+ }
+ }
+
+ bounding_sphere = Geometry::BoundingSphere<float, 3>::from_point_cloud(points.begin(), points.end());