we currently developing an application where we need to know, which texture color i have on a specific point on the surface.
i found some code snippets where the texture color is calculated from a colored mesh which is generated with the command ComputeVertexColors.
But i think it would be more straight forward to calculate the color directly from the texture and the corresponding texture mapping.
Do you have a code example where this is basically shown?
Do you need an answer that is general for all Rhino models, or for a specific case?
The answer is basically that you need to look at the texture mapping (ON_MappingRef on m_rendering_attributes) and find the ON_TextureMapping. If there is no custom mapping, use the surface parameters to calculate the texture coordinate (see comments on ON_Mesh::m_S / m_T).
Once you have that, you need to find the material. And from there the texture in the diffuse channel. You will then be able to get a texture evaluator into which you can pass your UVW coordinates, and this will give you a color.
That code explains a lot of the texturing in the RDK. But unfortunately this code does not run in my environment.
The class CRhRdkContent::TextureChannelInfo is missing and also the function ::RhRdkFindContentInstance has another declaration.
Is this code already for @serengeti or do i miss some SDK?
Anyway, i will try to adapt it and i think i manage to fix this code…
If i change the UVW rotation in the mapping channel, i do not get the right result. If i change the UVW repeat it works perfect, also with the UVW offset. @andy do you have any clue what is wrong?