C# 管理的Direct3DX网格顶点/索引限制?

C# 管理的Direct3DX网格顶点/索引限制?,c#,directx,rendering,mesh,vertex,C#,Directx,Rendering,Mesh,Vertex,我有一些生成风景的代码,将其转换为网格,然后进行渲染 景观基于三维表格,每个正表格条目生成4个顶点。我在开始时定义表格大小 问题是 Mesh mesh = new Mesh(indexes.Count/3,vertexes.Count, MeshFlags.Managed, CustomVertex.PositionNormalTextured.Format, device); 其中,indexes是索引的一个简短数组,Vertex是包含我的顶点的CustomVertex.PositionNo

我有一些生成风景的代码,将其转换为网格,然后进行渲染

景观基于三维表格,每个正表格条目生成4个顶点。我在开始时定义表格大小

问题是

Mesh mesh = new Mesh(indexes.Count/3,vertexes.Count, MeshFlags.Managed, CustomVertex.PositionNormalTextured.Format, device);
其中,indexes是索引的一个简短数组,Vertex是包含我的顶点的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: 
在崩溃点,索引的计数为231480,顶点的计数为154320


将其拆分为64个网格(每个Z级别一个网格)是否更好?

听起来您的网格默认为16位索引缓冲区。我再也找不到托管DirectX的文档了(MS几乎在所有地方都删除了它),但看看你是否可以明确告诉它使用32位索引缓冲区。

好吧,将横向分割成32x32x32块似乎奏效了,但奇怪的是,竟然发生了错误。如何告诉DirectX9启用32位索引缓冲区?