VertexBuffer.GetData()和Silverlight 5

时间:2012-06-27 11:04:21

标签: silverlight xna

我正在尝试在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没有连接到XNA4中的VertexBuffer的GetData()方法。如何才能达到相同的效果?

1 个答案:

答案 0 :(得分:0)

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