UVs and Textures in point sample

Feel free to ask any question here
Post Reply
dezavou
Posts: 1
Joined: Thu Apr 08, 2021 10:12 am

UVs and Textures in point sample

Post 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
Attachments
point cloud with custom colours
point cloud with custom colours
mysampledpoints.png (169.03 KiB) Viewed 1318 times
point cloud with colours extracted from CloudCompare
point cloud with colours extracted from CloudCompare
ccsampledpoints.png (166.36 KiB) Viewed 1318 times
daniel
Site Admin
Posts: 7711
Joined: Wed Oct 13, 2010 7:34 am
Location: Grenoble, France
Contact:

Re: UVs and Textures in point sample

Post 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
Daniel, CloudCompare admin
Post Reply