jujut
Hello,
I am working on a custom node that transfert info mesh onto particle. And i am stick to a problem. I am trying to transfert vertexcolor of the given mesh onto particle emitted from surface. I am trying to do it because i would like to use "dynamic/animated" vertexColor. I know that it's possible to bake vertexColor and use bake sequence image, but i would like to avoid this step :)
 
Currentlyi have a custom node where  i inject the birth particle position and a source mesh(for getting vertexColor) and the i reinject the new Color into the particleShape node. I get the different array, this is not a problem, but how i can do to transfert the vertex color onto particle?
 
I was thinking to do it by finding the closestPoint by testing the vertex mesh position and birth Position of the particle but i am not sure if it's the right way do this and i think this can be very expensive in memory if i have a lot of particle. 
 
Perhaps i can also use the uv coord of the particle at emission and use the uv coord of the mesh?
 
Anybody have an idea or way to go?

Thanks
Quote 0 0
pshipkov
Before answering your questions i will mention that everything you are talking about can be already done very efficiently using SOuP nodes. Take a look at the pointCloudParticleEmitter in particular.

From the top of my head - to get color for given point on the surface you have to options:
MItMeshPolygon::getColor - will return the color of the face based on its vertex colors - this is the simplest way to do it, but the color interpolation can be a problem in some cases.
The slower method is to figure out the triangle "under" your point on surface, get the 3 vertex colors from it and then do the weighted interpolation by yourself. You can do that based on faces too, but it will be more expensive in general (faces most of the time have 4+ points and that's more calculations for interpolation).

Most of the time i use the first method because in the general case the mesh geometry is dense enough for decent color interpolation through the faces.
Quote 0 0