3

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() のメソッドがないことです。どうすれば同じ結果を達成できますか?

4

1 に答える 1

0

セキュリティ上の理由から、Microsoft は GPU へのアクセスを拒否しています。そのため、 GetData()メソッドを中断しています。Silverlight 5 でこの問題を解決するには、カスタム コンテンツ パイプラインを記述してオブジェクトをロードし、頂点データの読み取りを試みることで問題を解決できます。

于 2013-04-17T03:08:53.000 に答える