   Painting onto a model to change texture
  Let me describe the problem: we have a model with multiple meshes and textures, and a brush of sorts, which is basically just a point and a radius in screen space.What we want to do is be able to essentially paint the colour of the model's texture. In theory, we could do as follows:1. Keep an extra copy of the texture/s in memory.2. When we attempt to paint on it, do a bunch of raycasts to determine how much of the brush is over the model.3. Using those raycasts, determine which polys of each mesh the brush is over.4. Get the texture coords of the poly and calculate how much of the poly the brush is over.5. Using the copy of the texture we have in memory, copy whatever colour we want over the parts of the texture that belongs to the polys that the brush was over.Of course, for this to work, each poly needs to be assigned a separate part of the texture, none of it can be used for more than 1 poly.Now, this sounds feasible, but does anyone have any idea how I would do things like calculate the texture coords of part of a poly (most likely triangles)? Also, I've never really done any blitting (which is essentially what this is, right?), so do I need to look out for anything in particular there?Or, does anyone have a better/easier way to do something like this?   
  I think Hugues Hoppe did a paper a couple of years ago about perfect spatial hashing, which you might be interested in.  The demo of the paper showed models being airbrushed in a very similar manner that you are describing.The idea was that you make a secondary hash texture to help you look up the texture coordinates based on the 3D position of the point you were querying.  This could help reduce the number of steps in your pseudo code.  Good luck!   ;this might also be interesting   ;  just make 2d texture in uvSpace, where each texel is given value of points 3d coordinate value in model space.While painting, paint full quad over uvSpace texture, and calculate distance of each pixel/texel from brush center./Tyrian Tip: propagate broder values of uvMap for better results   ;  Another option, depending on the resolution of your mesh and what this is for you could bake the colour into the vertices. Just do a collision check with the mouse ray and the vertices and set that vertices colour. Then in a shader you can do what you want with that colour value.   