Jump to content
  • Advertisement
Sign in to follow this  
ilflyer12

Remove a triangle from a mesh

This topic is 4318 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

Hey everyone, I know how to render a mesh that was created from an X file but i need to be able to remove 1 triangle from the mesh depending on the where the user clicks on the object. Does anyone know how one would do this? I noticed you can make the mesh into triangle strips but wasnt sure if that would be helpful. Please let me know if you have any ideas since i am fairly new to direct x, esp. meshes. Thanks

Share this post


Link to post
Share on other sites
Advertisement
i can start it off by letting u know u need to use ray picking to select the triangle, as far as removing it i cant think of an easy way to do that other than locking the index buffer and taking the triangle outta there, possibly rendering some sort of degenerate triangle if its a strip, if its tri list than just removing the 3 instance of the index out should work, im sure someones got an easier way =P

Share this post


Link to post
Share on other sites
Quote:
u need to use ray picking to select the triangle
There is a sample in the SDK called "Pick" that does exactly this. I highly recommend you get familiar with the code.

In particular, part of the Pick sample will highlight just the triangle under the mouse - effectively the opposite of what you want to do. I don't know for sure, but I'd imagine you could easily tweak the code so that it does what you want instead.

Quote:
I noticed you can make the mesh into triangle strips but wasnt sure if that would be helpful
Unlikely - the default triangle list is very convenient to work with [smile]

If you want to DELETE the triangle then you'll need to lock the IB and/or VB in the way yoshscout suggests. You can use various D3DX functions to clean things up after you've gone in and messed it up.

Alternatively, if you want to simply hide the triangle (and have it still exist for later processing, or to reappear when the mouse moves to another triangle) then I recommend using the attribute buffer/table. I forget the details, but check the SDK documentation - you can redefine the subsets (corresponding to ID3DXMesh::DrawSubset()) so that it skips any number of triangles without actually modifying the raw geometry data.

hth
Jack

Share this post


Link to post
Share on other sites
Hey thanks for the reply because that will help a ton. However, i the Pick sample is not included in the recent SDK. Do you know where i can get it or is there anyway you could email me the source code? Let me know and ill pm you my email or whatnot. Thanks again

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!