Page 1 of 1

UVs and Textures in point sample

Posted: Thu Apr 08, 2021 10:42 am
by dezavou
Hello,

I have an .obj file together with its .mtl and few texture images.
I need to sample points on this mesh, while annotating each point with a colour, and a face id.
I have an extra tool that does the sampling and keeps track of the face ids.

Now, I need to find for each sampled point its colour. My .obj file contains UVs that are not in [0,1] and I supposed the textures used by those vertices are just being repeated (i.e. a uv of [0.5, 1.6] will point to the same uv as [0.5, 0.6].
Using this approach to go from each sampled point (with uv interpolated from the face uvs) I get colours that point to incorrect texture image pixels.
(the code should not contain any bugs, since it works well for textures that use only UVs in [0,1])

I've opened the model in CloudCompare and it looked to be loaded correctly. Then I used Edit --> Mesh --> Sample Points with colours, and the sampled points seemed to have correct colours!

Therefore, I'm wondering if you could point me to the code CloudCompare is using, in order to find out how it is dealing with the textures and the uvs.

You can see in the attachments the point cloud with my custom colours and the point cloud with colours extracted from CloudCompare.

Thanks

Re: UVs and Textures in point sample

Posted: Thu Apr 08, 2021 4:52 pm
by daniel
At first I was surprised that it would work with (u,v) coordinates above 1, but then looking at my own code, I see that I had to take this issue into account :D

The code is here: https://github.com/CloudCompare/CloudCo ... .cpp#L3337