Skip to main content
gamedev.net
🔒 Locked

C# Mesh.Sphere problem

Started by Robotan Dec 9, 2008 at 12:36 PM 4 replies 2k views
Original Post
Robotan
Robotan
Hi. I am using Visual Studio 2005, C# dot net framework. I am programming with managed DirectX, and got a problem with the Mesh class. I am trying to create and render a sphere using: Mesh mesh = Mesh.Sphere(....) and renders with mesh.DrawSubset(0) The problem is, that the mesh does not contain any subsets! the mesh.NumberAttributes returns 0, and DrawSubset(0) fails. The mesh object contains the vertices and faces if I check it, but it does not create a subset for rendering. What could be wrong? Thanks in advance, cheers!
arbitus
arbitus
You need to call Optimize on the Mesh with the attribute sort flag (cannot remember its exact name off the top of my head, but you can find it in the SDK help). This will generate an attribute buffer, which is needed for the DrawSubset() method.
Robotan
Robotan
Thanks for the quick reply :)

I used the optimizeInPlace method, and chose the OptimizeAttributeSort flag.

Now the mesh does contain 1 subset, so that seemed to work.

But I still get an "D3DERR_INVALIDCALL" exception, when I do

mesh.DrawSubset(0)
arbitus
arbitus
At this point, it should be a different problem, such as a render state improperly set, bogus data in the mesh, etc. You should enable the Direct3D Debug runtime in the control panel->DirectX->Direct3D, and specify unmanaged code debugging in Visual Studio.

This should result in a more informative error appearing in your debug output.

Otherwise, post the relevant snippits of code so we can see if there are errors there.
Robotan
Robotan

I found the problem!

Thank you for the advice on turning on the advanced debugging mode. The detailed debug output informed me, that I had not called Device.BeginScene, before I actually tried to render the mesh :P

It works now, when the beginscene and endscene methods are inserted proberly :)

thanks for your time and help. Much appreciated!

cheers!

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.