VertexBuffer.GetData () and Silverlight 5

I am trying to achieve a 3d model collision in silverlight 5. For this, I create a BoundingBox (as in 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;
    }

The problem is that Silverlight 5 does not have a GetData () method connected to VertexBuffer in XNA4. How to achieve the same result?

+3
source share
1 answer

For security reasons, Microsoft has access to the GPU. Therefore, they pause the GetData () method . To overcome this problem in Silverlight 5, you can write a content pipeline to load the object and try to read the vertex data, and it solves your problem.

0
source

All Articles