Silverlight 5和VertexBuffer.GetData()

时间:2013-01-23 10:10:45

标签: c# silverlight silverlight-5.0 xna-4.0

我正在尝试在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;
    }

1 个答案:

答案 0 :(得分:0)

出于安全原因,Microsoft已拒绝访问GPU。所以他们暂停了GetData()方法。要在Silverlight 5中克服此问题,您可以编写自定义内容管道来加载对象并尝试读取顶点数据,它可以解决您的问题。