Sign in to follow this  
data2

PatchMesh.CreateNPatchMesh crashes

Recommended Posts

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

Share this post


Link to post
Share on other sites
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#?

Share this post


Link to post
Share on other sites
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).

Share this post


Link to post
Share on other sites
Yep, activated it in the properties pane. However, no message is prompted. I get other DirectX warnings, so the debug output works generally.

Share this post


Link to post
Share on other sites
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


Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this