I want to be able to determine the color of a vertex using Python on a canvas in a scene using Dynamic Painting. In my scene I want to have a number of objects acting as canvases and one object acting as the brush. When the brush object touches a canvas I want to know it’s color. How do I get the color of a painted vertex or face on a canvas object. Thanks for any pointers.
This is a pretty specific request. Is there a motivated problem that you’re trying to solve? Some context? There may be a way to solve the problem that works around writing a big old python script.
I haven’t used dynamic paint much, so there may be easier ways to do this, but what I think you have to do is:
First, find where your meshes intersect using something like Object.closest_point_on_mesh
Or, if your Dynamic Paint is targeting an Image sequence:
- look up the UV coordinate of the intersection point
- read the target texture image into Python’s working memory
- look up the nearest pixels and interpret the raw RGBA data as a color, potentially applying a resampling algorithm if aliasing will be a problem for your application
Thanks so much for the help. I worked out another way using BVHTree instead of Dynamic Paint. I wonder if under the hood Dynamic Paint uses BVHTree? I ended up using Animation Nodes. So far my solution doesn’t give me RGB values directly but indices to the material. From this I made a lookup table. I posted my solution herehttps://blender.stackexchange.com/questions/123353/getting-the-color-of-an-object-an-empty-collides-with
The vertex color does not have the dynamic painted values. It has only the vertex painted colors. Any way to find the dynamic paint colors