Sign in to follow this  
PezMutanT

mesh - select polygons with mouse and paint

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;
m_pMesh->UnlockAttributeBuffer();



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

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