Jump to content
  • Advertisement
Sign in to follow this  
compiler

[MDX] Cloning Mesh

This topic is 4676 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hello, i want to clone a mesh (to get a mesh with diffuse color) and then read from the vertexbuffer. my code looks like this: rope = Mesh.Cylinder(device, 0.01f, 0.01f, 1f, 40, 1); Mesh tmpMesh = rope.Clone(rope.Options.Value, VertexFormats.Position | VertexFormats.Diffuse, device); rope.Dispose(); rope = tmpMesh; VertexBuffer vb = rope.VertexBuffer; CustomVertex.PositionColored[] verts = (CustomVertex.PositionColored[])vb.Lock(0, LockFlags.None); vb.Unlock(); as u can see its really quite simple. i create the mesh, clone it, get the vertexbuffer and try to lock the buffer. but in the line with the lock call i get this exception: An unhandled exception of type 'System.NullReferenceException' occurred in mscorlib.dll Additional information: Object reference not set to an instance of an object. i have absolutely NO idea why i get this exception. what am i doing wrong?

Share this post


Link to post
Share on other sites
Advertisement
I have found that the managed DirectX Mesh primitives are somewhat buggy -- trying to work with the internal vertex buffers often doesn't work right. Even functions like SetVertexBufferData() don't seem to work right.

Instead, I've written a managed C++ library which can take the vertex and index buffers from the mesh and operate on them, and that works right.

To make sure that you're not doing something wrong in your own code, though, I would put a breakpoint in the code where you Lock(), and make sure that "vb" is in fact not NULL.

Share this post


Link to post
Share on other sites
i guess thats the right point to tell u my generel problem with mdx debugging.
on the dx control panel i checked the box "use debug version of d3d" and pulled the "debug output level" slider to the right. in vs.net i use the debug build (not the release build) and show the debug output window (ctrl+alt+o). althought i dont get any debug informations about directx! no INFO, no WARN, no ERROR - just nothing. so besides my problem with the mesh: does anybody know what i have forgotten to turn of debugging information?

Share this post


Link to post
Share on other sites
Quote:
Original post by compiler
i guess thats the right point to tell u my generel problem with mdx debugging.
on the dx control panel i checked the box "use debug version of d3d" and pulled the "debug output level" slider to the right. in vs.net i use the debug build (not the release build) and show the debug output window (ctrl+alt+o). althought i dont get any debug informations about directx! no INFO, no WARN, no ERROR - just nothing. so besides my problem with the mesh: does anybody know what i have forgotten to turn of debugging information?

Enable "Unmanaged Code Debugging" for your project.

Share this post


Link to post
Share on other sites
shame on me. thx for the hint. at least debugging works now ;)
anyway, i dont get any specific error message on the lock line. its still just the following message:
An unhandled exception of type 'System.NullReferenceException' occurred in mscorlib.dll

Additional information: Object reference not set to an instance of an object.

could this be a bug in the dx runtime?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!