1

ランドスケープを生成し、それをメッシュに変換してからレンダリングするコードがあります。

ランドスケープは3次元テーブルに基づいており、正のテーブルエントリごとに4つの頂点を生成します。最初にテーブルサイズを定義します。

そこに問題があります

Mesh mesh = new Mesh(indexes.Count/3,vertexes.Count, MeshFlags.Managed, CustomVertex.PositionNormalTextured.Format, device);

ここで、indexesはインデックスの短縮形の配列であり、頂点は私の頂点を保持するCustomVertex.PositionNormalTexturedの配列です。

私のコードは小さいサイズ(32x32x32など)では正常に機能しますが、64x64x64のようなものでは、上記の行でクラッシュし、次のエラーが発生します

Microsoft.DirectX.Direct3D.Direct3DXException was unhandled
Message=Error in the application.
Source=Microsoft.DirectX.Direct3DX
ErrorCode=-2005530516
ErrorString=D3DERR_INVALIDCALL
StackTrace:
   at Microsoft.DirectX.Direct3D.Mesh..ctor(Int32 numFaces, Int32 numVertices, MeshFlags options, VertexFormats vertexFormat, Device device)
   at mycode.Form1.Landscape() in d:\Files\My Documents\Visual Studio 2010\Projects\mycode\mycode\Form1.cs:line 488
   at mycode.Form1.GenerateGeometry() in d:\Files\My Documents\Visual Studio 2010\Projects\mycode\mycode\Form1.cs:line 223
   at mycode.Form1..ctor() in d:\Files\My Documents\Visual Studio 2010\Projects\mycode\mycode\Form1.cs:line 40
   at mycode.Program.Main() in d:\Files\My Documents\Visual Studio 2010\Projects\mycode\mycode\Program.cs:line 20
   at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
   at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
   at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
   at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.ThreadHelper.ThreadStart()
  InnerException: 

クラッシュした時点で、インデックスの数は231,480で、頂点の数は154,320です。

Zレベルごとに1つずつ、64メッシュに分割する方がよいでしょうか。

4

1 に答える 1

0

メッシュがデフォルトで16ビットのインデックスバッファになっているようです。Managed DirectXのドキュメントが見つかりません(MSはほとんどすべての場所でドキュメントを削除しました)が、32ビットのインデックスバッファーを使用するように明示的に指示できるかどうかを確認します。

于 2011-03-29T22:53:15.430 に答える