2011-01-13 11 views
1

私は風景を生成し、それをメッシュに変換してレンダリングするコードをいくつか持っています。Managed Direct3DXメッシュ頂点/インデックスの制限?

ランドスケープは、3次元テーブルに基づいており、正のテーブルエントリごとに4つの頂点を生成します。私は最初にテーブルサイズを定義します。インデックスは、インデックスと頂点のためのショートパンツのアレイは私の頂点を保持CustomVertex.PositionNormalTexturedの配列である

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

問題があります。

私のコードは、小さいサイズ(例えば32x32x32)のために正常に動作しますが、64x64x64のようなもののためにそれはそれはインデックスが231480のカウントがクラッシュした時点で次のエラー

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: 

と上の行にクラッシュします頂点の数が154,320

の場合、Zレベルごとに1つずつ64個のメッシュに分割することをお勧めしますか?

+0

32x32x32ブロックに風景を分割すると、エラーが発生するという不思議な動きがあるようです。 –

+0

DirectX9に32ビットインデックスバッファを有効にする方法を教えてください。 – zionpi

答えて

0

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

関連する問題