开发者

Managed Direct3DX Mesh Vertex / Index limit?

I have some code that generates a landscape, transforms it into a mesh and then renders it.

The landscape is based on a three-dimensional table and generates 4 vertices per positive table entry. I define the table size at the start.

The problem there is

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

where indexes is an array of shorts for indices and vertexes is an array of CustomVertex.PositionNormalTextured holding my vertices.

My code works fine for small sizes (e.g. 32x32x32) but for something like 64x64x64 it crashes on the above line with the following error

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: 

At the point at which it crashes indexes has a count of 231,480 and vertexes has a count of 154,320

would it be a better idea to split it into 64 meshes, one for each Z level?


Sounds like your mesh is defaulting to a 16-bit index buffer. I can't find the documentation for Managed DirectX anymore (MS removed it most everywhere) but see if you can explicitly tell it to use a 32-bit index buffer.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜