3

I am trying to achieve 3d model collision in silverlight 5. To do that I am creating a BoundingBox (just like 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 method of GetData() connected to VertexBuffer in XNA4. How can one achieve the same result?

Siddharth Rout
  • 147,039
  • 17
  • 206
  • 250

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