5

I am trying to achieve 3d model collision in silverlight 5. To do that I am creating a BoundingBox (just like in XNA4.0):

I saw the same question VertexBuffer.GetData() and Silverlight 5 in this link but no answers found.

 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;
    }
Community
  • 1
  • 1
Renien
  • 551
  • 4
  • 19

1 Answers1

0

For security reason Microsoft has access denied toward GPU. So they have suspend GetData() method. To overcome this issue in Silverlight 5 you can write a custom content pipeline to load the object and try to read the vertex data and it solves your problem.

Renien
  • 551
  • 4
  • 19