Ren*_*ien 5 c# silverlight xna-4.0 silverlight-5.0
我试图在silverlight 5中实现3D模型冲突.为此,我创建了一个BoundingBox(就像在XNA4.0中一样):
我在此链接中看到了相同的问题VertexBuffer.GetData()和Silverlight 5,但未找到答案.
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;
}
Run Code Online (Sandbox Code Playgroud)
出于安全原因,微软拒绝访问 GPU。所以他们暂停了 GetData() 方法。为了解决 Silverlight 5 中的这个问题,您可以编写一个自定义内容管道来加载对象并尝试读取顶点数据,它可以解决您的问题。
| 归档时间: |
|
| 查看次数: |
119 次 |
| 最近记录: |