Silverlight 5 で 3D モデルの衝突を実現しようとしています。そのために、BoundingBox を作成しています (XNA4.0 と同様):
このリンクで同じ質問VertexBuffer.GetData() と Silverlight 5を見ましたが、回答が見つかりませんでした。
public BoundingBox GetBoundingBoxFromModel(Model model)
{
BoundingBox boundingBox = new BoundingBox();
foreach (ModelMeshPart part in model.Meshes[0].MeshParts)
{
VertexPositionNormalTexture[] vertices = new VertexPositionNormalTexture[part.NumVertices];
Vector3[] vertexs = new Vector3[vertices.Length];
part.VertexBuffer.GetData<VertexPositionNormalTexture>(vertices);
for (int index = 0; index < vertexs.Length; index++)
{
vertexs[index] = vertices[index].Position;
}
boundingBox = BoundingBox.CreateMerged(boundingBox, BoundingBox.CreateFromPoints(vertexs));
}
return boundingBox;
}