我正在尝试在 silverlight 5 中实现 3d 模型碰撞。为此,我正在创建一个 BoundingBox(就像在 XNA4.0 中一样):
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;
}
问题是 Silverlight 5 没有 GetData() 方法连接到 XNA4 中的 VertexBuffer。一个人怎样才能达到同样的结果?