Advertisement Jump to content
Sign in to follow this  

mesh - select polygons with mouse and paint

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

Hi everyone! Long time no posting here. I'm working with a mesh loaded from an .X file and what I need is to be able to select with the mouse (like you do in a 3D modelling app, like 3D Studio MAX). After that I need to be able to tell the app to "paint" these polygons with certain texture. I've been reading the SDK sample about ray-picking and I think it's perfect for what I'm looking for with my first problem. I could use some hints, though. But when it comes to applying a new texture only to certain polygons in a mesh, I am clueless. I was able to change one face's material to another defined material with this code.
DWORD *buf;
m_pMesh->LockAttributeBuffer(D3DLOCK_DISCARD, &buf);
buf[face] = 2;

But what I need to do regards textures and I'm a little bit lost. Of course, the texture changing I'm talking about should be at runtime, and the texture should fill only one polygon. That way, I could have the very same texture in different polygons in the mesh. Hope to have been clear. Any suggestions will be very appreciated. Thanks a lot! ;) EDIT: I suppose I need to have texture coordinates in vertex info so, how can I load my own FVF into the mesh's vertex buffer? [Edited by - PezMutanT on November 12, 2008 6:30:05 AM]

Share this post

Link to post
Share on other sites
I'd try to get the triangle needed with ray picking, copy that into a separate buffer and render it over the mesh just pinding a different texture. Like you were drawing a wireframe over something. This seems to me the easier way. In DX10 you could get the primitive ID of the picked triangle and in the pixel shader just use a different texture when drawing that triangle. Like using SV_PirimitiveID as a texture array index or something.

Share this post

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

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!