PatchMesh.CreateNPatchMesh crashes

Started by
4 comments, last by data2 14 years, 1 month ago
Hi there, I'm trying the following, which I considered fairly simple, but get an Exception (D3DERR_INVALIDCALL) when calling PatchMesh.CreateNPatchMesh: VertexElement[] VERTEX_ELEMENTS = new VertexElement[] { new VertexElement(0, 0, DeclarationType.Float3, DeclarationMethod.Default, DeclarationUsage.Position, 0), new VertexElement(0, 12, DeclarationType.Float3, DeclarationMethod.Default, DeclarationUsage.Normal, 0), new VertexElement(0, 24, DeclarationType.Float2, DeclarationMethod.Default, DeclarationUsage.TextureCoordinate, 0), new VertexElement(0, 32, DeclarationType.Float3, DeclarationMethod.Default, DeclarationUsage.TextureCoordinate, 1), new VertexElement(0, 44, DeclarationType.Float3, DeclarationMethod.Default, DeclarationUsage.TextureCoordinate, 2), new VertexElement(0, 56, DeclarationType.Float4, DeclarationMethod.Default, DeclarationUsage.TextureCoordinate, 3), VertexElement.VertexDeclarationEnd }; _mesh = new Mesh(_indices.Length / 3, _vertices.Length, MeshFlags.Dynamic | MeshFlags.Use32Bit, ProjectionVertex.VERTEX_ELEMENTS, renderDevice); using(Mesh triMesh = new Mesh(_indices.Length / 3, _vertices.Length, MeshFlags.Dynamic | MeshFlags.Use32Bit, ProjectionVertex.VERTEX_ELEMENTS, renderDevice)) { triMesh.SetVertexBufferData(_vertices, LockFlags.None); triMesh.SetIndexBufferData(_indices, LockFlags.None); using(PatchMesh patchMesh = PatchMesh.CreateNPatchMesh(triMesh)) { patchMesh.Tessellate(0.0f, _mesh); } } Are there any restrictions concerning the layout of the vertices / indices of my triMesh?? Any help would be highly appreciated, since the error isn't very helpful and I couldn't find anything useful at google. Cheers, Dataa
Advertisement
What do the Debug Runtimes say?
Nothing. In the control panel, I selected debug DLLs, but I don't get any debug output with the C# project (note that with C++ I do). Any suggestions of how to activate debug output in C#?

From the link in my last post:
Quote:Original post by Evil Steve
From sirrob:
Under Managed Projects, you need to select "Enable unmanaged debugging" in the Debug section of the project properties. If you're running C# Express 2005, you cannot view the debug output using VS, and would need to use an external tool to catch debug output (like sysinternals' dbgview).
Yep, activated it in the properties pane. However, no message is prompted. I get other DirectX warnings, so the debug output works generally.
Ok, I saved the created triMesh to X and created a small C++ app that does exactly what I'm trying to do. Interestingly, the debug output works for C++. I found a solution by changing the following:

- ID3DXPatchMesh can't use 32bit indices, triMesh has to use shorts, not ints.
- I had to create both triMesh and _mesh in system memory.
- The tesselation factor in Tesselate() has to be *greater* zero! For 0.0f, the debug output told me that it has to be between 0.0 and 32.0. Excellent. Well, with 0.0001f it works.

Cheers,
Data


This topic is closed to new replies.

Advertisement