toto.skp contains just a textured rectangle in a XZ plane.
model.jpg shows what toto.skp looks like in SketchUp. I name the 4 extremity points of the rectangle “0”, “x”, “z” and “xz”.
texture.jpg is the image used to texture the front face of the rectangle. I reported the 4 extremity points of the rectangle in this image.
params.xlsx and params.jpg show the different coordinates of the 4 rectangle vertices and the parameters given by SUTextureGetDimensions.
The x,z (and y) coordinates are given by SUVertexGetPosition.
The u,v,q ones are given by SUUVHelperGetFrontUVQ.
The s,t ones are the coordinates in the texture image I estimated by watching the rendering in SketchUp.
Please what is the relation between these coordinates and parameters ?
I want to import SketchUp models in a CAD software with the texture images rightly positioned on the faces. Given a geometric point on a textured face, which texture pixel is used to color this point ?
… therefore the two APIs have UV (texture space) coordinate getter methods / functions that return the texel coordinates for the given geometric position (SUPoint3D in the case of the C API) on a face.
SketchUp uses OpenGL. So there are tutorials out there on texture mapping with OpenGL …
I am sorry, I do not own a SketchUp license. So I think I cannot use the extensions you suggested. But I had a look at their source code. They use an UVHelper like I did to get the (u,v,q) coordinates.
In my example, we see that the (u,v,q) coordinates do not vary much compared to the expected texel coordinates (s,t). So what do I miss ? Giving a SUTextureWriterRef or not to SUFaceGetUVHelper do not seem to change the (u,v,q).
On the first one, I think we see the texture is applied on the front face.
On the second and the third one, we see the real UV coordinates from the font face, displayed by the extension Probes. These values are the ones in my xlsx.
So why do these (u,v) coordinates not vary much compared to the expected texel coordinates ?
On this face, the texture is mapped from the texel (80,77) to the texel (365,327) whereas the face (u,v) box is (119.203,7.116)-(119.789,7.48). Isn’t there a relation between the (u,v) coordinates and the texel coordinates ? How to get or compute the values (80,77) and (365,327) with the SketchUp C API ?
With my example, SUMeshHelperGetFrontSTQCoords() returns the same values as SUUVHelperGetFrontUVQ.
I have read, registered, downloaded all what yout told me to. Yet I am still asking the same simple question since the beginning of this thread : on my simple example, how to get or compute the correct texel coordinates that should look like the rectangle [(80,77),(365,327)]. Please would you be so kind as to show us ?
I am sorry, no. I am not an expert at Texture application and I’m not a C programmer.
(I can read it, but try to avoid coding in it as it doesn’t “agree with me”.)
It seems to me a very general question how all “these” things are related. A famous person said:
I interprete the question as how the t, s coordinates of pixels in the image are related to u, v coordinates.
In SketchUp, texture images are tiled and repeated over the surface of a face. UV coordinates specify the “repetition step” at a given XYZ point, considering the image origin as 0 and the end as 1 (not the pixel dimensions). Since it is repeated, it does not matter whether the origin is shifted by a full step.
So let’s ignore the potential shift and say the UVs at the face corners are:
Should I sell my soul or anything more expensive to know whether u and v can be negative ? And if they can, what happens when the sign of u or v changes ? Is there a symmetry or does the periodicity just go on ?
The UVs can be negative, yes. The texture coordinates for each face has an origin. And when you query the UV for a point they will be relative to that origin.