我正在尝试在silverlight 5中实现3D模型冲突。为此,我创建了一个BoundingBox(就像在XNA4.0中一样):
我在此链接中看到了相同的问题VertexBuffer.GetData() and 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;
}
答案 0 :(得分:0)
出于安全原因,Microsoft已拒绝访问GPU。所以他们暂停了GetData()方法。要在Silverlight 5中克服此问题,您可以编写自定义内容管道来加载对象并尝试读取顶点数据,它可以解决您的问题。