I am using SUTextureGetDimensions to retrieve the size and scale of a texture. But I have a scale problem.
For example, if I use the Sketchup material “Antique Brick”, the Sketchup GUI says it is 1.47 meters wide and 0.94 meters high, but when getting the scales with the SDK I get values such as 0.0172 and 0.027.
Some of your told me to multiply those values by a factor to be able to get from inch to meters and, from a visual point of view it looks OK even if the scales in meters are not the same as the ones in the Sketchup GUI. But for internal reasons, I really have to get the same value as the ones in the GUI.
(I hope I am clear in my explanation )
Does someone have an idea of how I can compute the GUI values from the values I get from the SDK function ?
The GUI displays the dimensional values in the current model units. This will vary to how the user set the units. Internally the values are still in inches.
No, I told you to multiply the dimensional values by a conversion factor (0.0254 meters per inch) to get from inches to meters.
Scaling factors are not in any units ! They are just a scalar value (ie, a ratio.)
However, the GUI does not display the scale factor(s), it displays the dimensional values.
The width of the texture is 58.0 inches. Multiplied by 0.0254 (meters per inch) equals 1.4732 meters.
The height of the texture is 37.0 inches. Multiplied by 0.0254 (meters per inch) equals 0.9398 meters.
(This is exactly what the GUI is doing for it’s display in the Edit panel of the Materials inspector.)
Now … normally the scale factors for X (width) and Y (height) are the same if the aspect ratio between them is the same. (Ie, the chain symbol in the GUI is unbroken. If the chain symbol is broken then the texture is not uniformly scaled.)
Please be specific about what are the exact return values from calling the SUTextureGetDimensions function for the "Brick Antique 01" material’s texture.
And … whether the material is applied to the face directly or applied to the parent (group or component instance.)
Also whether the face (or parent) has been scaled.
Note that this function (according to the documentation) returns the texture dimensions in pixels not inches.
Be aware that there are issues in the API tracker …
Thank you Dan for your answer and for setting me straight: it seems I had not understood everything (and may be still do not).
So now I get that the GUI displays value based on the internal texture dimensions in inches. And also that the SUTextureGetDimensions gives me the size in pixels and also scales.
So in my case, the texture is directly applied to the face, no inheritance. The parent of the face is a component without any material.
When examining the material “Brick Antique 01” I get a pixel size of 384 x 256, a s_scale of 0.01724138 and a t_scale of 0.027 (I rounded the values). What I don’t understand is how I get the inch dimensions from those dimensions.