Incorrect UV values exported


#1

Hi, I’m getting wrong texture mapping when exporting models to SketchUp. After querying in SketchUp Pro, I noticed that I get different UV values from what I fed into the exporter.

I added this snippet to check the values right before I set the face material:

for (size_t i = 0; i < mat_input_front.num_uv_coords; i++)
{
	pointF vp = face.faceInfo_.vertices[i].vertexPoint;
	SUPoint2D uv = mat_input_front.uv_coords[i];
	cout << "vertex point: " << vp.x << ", " << vp.y << ", " << vp.z << endl;
	cout << "uv:" << uv.x << ", " << uv.y << endl << endl;
}
SUGeometryInputFaceSetFrontMaterial(inputG, face_index, &mat_input_front);

This is the output of the code above for a particular face with 3 vertices:

vertex point: 7.97078, 27.105, 45.3901
uv: 0.202458, -0.688466

vertex point: 7.97078, 44.8277, 45.3646
uv: 0.202458, -1.13862

vertex point: 7.97078, 27.105, 37.6935
uv: 0.202458, -0.688466

This is the Ruby script to check the UV values of the same face:

model = Sketchup.active_model
selection = model.selection
face = selection.at(0)
uvh = face.get_UVHelper
v = face.vertices
uv0 = uvh.get_front_UVQ(v[0].position)
uv1 = uvh.get_front_UVQ(v[1].position)
uv2 = uvh.get_front_UVQ(v[2].position)

puts "v0=" + v[0].position.to_s
puts "v1=" + v[1].position.to_s
puts "v2=" + v[2].position.to_s
puts "uv0=" + uv0.to_s
puts "uv1=" + uv1.to_s
puts "uv2=" + uv2.to_s

And this is the output:

v0=(7.970784", 27.104979", 45.39006")
v1=(7.970784", 27.104979", 37.693497")
v2=(7.970782", 44.827747", 45.364613")
uv0=(27.104977", 45.39006", 1")
uv1=(27.104977", 37.693497", 1")
uv2=(44.827746", 45.364613", 1")

Seems like it took the Y and Z values of the vertices instead. Any idea what’s the problem here?


#2

Hi
I had a look at the file you provided Bryce, when I opened it I got a dialogbox saying something was no right in the model. When I then choose to Fix It it reports that it corrected a good number of UV coordinates:

Results of Validity Check.

The front or back texture coordinates for CFaceTextureCoords (2293) is not valid - fixed
The front or back texture coordinates for CFaceTextureCoords (2301) is not valid - fixed
The front or back texture coordinates for CFaceTextureCoords (2522) is not valid - fixed
The front or back texture coordinates for CFaceTextureCoords (2533) is not valid - fixed
The front or back texture coordinates for CFaceTextureCoords (2550) is not valid - fixed
The front or back texture coordinates for CFaceTextureCoords (2564) is not valid - fixed
The front or back texture coordinates for CFaceTextureCoords (2572) is not valid - fixed
The front or back texture coordinates for CFaceTextureCoords (2792) is not valid - fixed
The front or back texture coordinates for CFaceTextureCoords (2800) is not valid - fixed
The front or back texture coordinates for CFaceTextureCoords (2807) is not valid - fixed
The front or back texture coordinates for CFaceTextureCoords (2816) is not valid - fixed
The front or back texture coordinates for CFaceTextureCoords (2830) is not valid - fixed
The front or back texture coordinates for CFaceTextureCoords (2838) is not valid - fixed
The front or back texture coordinates for CFaceTextureCoords (2846) is not valid - fixed
The front or back texture coordinates for CFaceTextureCoords (2854) is not valid - fixed
The front or back texture coordinates for CFaceTextureCoords (3037) is not valid - fixed
The front or back texture coordinates for CFaceTextureCoords (3045) is not valid - fixed
The front or back texture coordinates for CFaceTextureCoords (3052) is not valid - fixed
The front or back texture coordinates for CFaceTextureCoords (3065) is not valid - fixed
The front or back texture coordinates for CFaceTextureCoords (3652) is not valid - fixed
The front or back texture coordinates for CFaceTextureCoords (3660) is not valid - fixed
The front or back texture coordinates for CFaceTextureCoords (3808) is not valid - fixed
The front or back texture coordinates for CFaceTextureCoords (3817) is not valid - fixed
The front or back texture coordinates for CFaceTextureCoords (3982) is not valid - fixed
The front or back texture coordinates for CFaceTextureCoords (3996) is not valid - fixed
The front or back texture coordinates for CFaceTextureCoords (4004) is not valid - fixed
The front or back texture coordinates for CFaceTextureCoords (4012) is not valid - fixed
The front or back texture coordinates for CFaceTextureCoords (4251) is not valid - fixed
The front or back texture coordinates for CFaceTextureCoords (4258) is not valid - fixed
The front or back texture coordinates for CFaceTextureCoords (4267) is not valid - fixed
The front or back texture coordinates for CFaceTextureCoords (4281) is not valid - fixed
The front or back texture coordinates for CFaceTextureCoords (4289) is not valid - fixed
The front or back texture coordinates for CFaceTextureCoords (4297) is not valid - fixed
The front or back texture coordinates for CFaceTextureCoords (4305) is not valid - fixed
The front or back texture coordinates for CFaceTextureCoords (4485) is not valid - fixed
The front or back texture coordinates for CFaceTextureCoords (4504) is not valid - fixed
The front or back texture coordinates for CFaceTextureCoords (4511) is not valid - fixed
The front or back texture coordinates for CFaceTextureCoords (10064) is not valid - fixed
The front or back texture coordinates for CFaceTextureCoords (10083) is not valid - fixed
The front or back texture coordinates for CFaceTextureCoords (10183) is not valid - fixed
The front or back texture coordinates for CFaceTextureCoords (10193) is not valid - fixed
The front or back texture coordinates for CFaceTextureCoords (10347) is not valid - fixed
The front or back texture coordinates for CFaceTextureCoords (10357) is not valid - fixed
The front or back texture coordinates for CFaceTextureCoords (10589) is not valid - fixed
The front or back texture coordinates for CFaceTextureCoords (10597) is not valid - fixed
The front or back texture coordinates for CFaceTextureCoords (10615) is not valid - fixed
The front or back texture coordinates for CFaceTextureCoords (10631) is not valid - fixed
The front or back texture coordinates for CFaceTextureCoords (10640) is not valid - fixed
The front or back texture coordinates for CFaceTextureCoords (10699) is not valid - fixed
The front or back texture coordinates for CFaceTextureCoords (10710) is not valid - fixed
The front or back texture coordinates for CFaceTextureCoords (12108) is not valid - fixed
The front or back texture coordinates for CFaceTextureCoords (12115) is not valid - fixed
The front or back texture coordinates for CFaceTextureCoords (12123) is not valid - fixed
The front or back texture coordinates for CFaceTextureCoords (12131) is not valid - fixed
The front or back texture coordinates for CFaceTextureCoords (12138) is not valid - fixed
The front or back texture coordinates for CFaceTextureCoords (12146) is not valid - fixed
The front or back texture coordinates for CFaceTextureCoords (12154) is not valid - fixed
The front or back texture coordinates for CFaceTextureCoords (12162) is not valid - fixed
The front or back texture coordinates for CFaceTextureCoords (12170) is not valid - fixed
The front or back texture coordinates for CFaceTextureCoords (12328) is not valid - fixed
The front or back texture coordinates for CFaceTextureCoords (12342) is not valid - fixed
The front or back texture coordinates for CFaceTextureCoords (12356) is not valid - fixed
The front or back texture coordinates for CFaceTextureCoords (12370) is not valid - fixed
The front or back texture coordinates for CFaceTextureCoords (12378) is not valid - fixed
The front or back texture coordinates for CFaceTextureCoords (12425) is not valid - fixed
The front or back texture coordinates for CFaceTextureCoords (12449) is not valid - fixed
The front or back texture coordinates for CFaceTextureCoords (12504) is not valid - fixed
The front or back texture coordinates for CFaceTextureCoords (12524) is not valid - fixed
The front or back texture coordinates for CFaceTextureCoords (12947) is not valid - fixed
The front or back texture coordinates for CFaceTextureCoords (12957) is not valid - fixed
The front or back texture coordinates for CFaceTextureCoords (12968) is not valid - fixed
The front or back texture coordinates for CFaceTextureCoords (12976) is not valid - fixed
The front or back texture coordinates for CFaceTextureCoords (12986) is not valid - fixed
The front or back texture coordinates for CFaceTextureCoords (13004) is not valid - fixed
The front or back texture coordinates for CFaceTextureCoords (13080) is not valid - fixed
The front or back texture coordinates for CFaceTextureCoords (13091) is not valid - fixed
The front or back texture coordinates for CFaceTextureCoords (13100) is not valid - fixed
The front or back texture coordinates for CFaceTextureCoords (13108) is not valid - fixed
The front or back texture coordinates for CFaceTextureCoords (14565) is not valid - fixed
The front or back texture coordinates for CFaceTextureCoords (14579) is not valid - fixed
The front or back texture coordinates for CFaceTextureCoords (14593) is not valid - fixed
The front or back texture coordinates for CFaceTextureCoords (14607) is not valid - fixed
The front or back texture coordinates for CFaceTextureCoords (14615) is not valid - fixed
The front or back texture coordinates for CFaceTextureCoords (14756) is not valid - fixed
The front or back texture coordinates for CFaceTextureCoords (14763) is not valid - fixed
The front or back texture coordinates for CFaceTextureCoords (14771) is not valid - fixed
The front or back texture coordinates for CFaceTextureCoords (14779) is not valid - fixed
The front or back texture coordinates for CFaceTextureCoords (14786) is not valid - fixed
The front or back texture coordinates for CFaceTextureCoords (14794) is not valid - fixed
The front or back texture coordinates for CFaceTextureCoords (14802) is not valid - fixed
The front or back texture coordinates for CFaceTextureCoords (14810) is not valid - fixed
The front or back texture coordinates for CFaceTextureCoords (14818) is not valid - fixed
The front or back texture coordinates for CFaceTextureCoords (14826) is not valid - fixed
The front or back texture coordinates for CFaceTextureCoords (14877) is not valid - fixed
The front or back texture coordinates for CFaceTextureCoords (27792) is not valid - fixed
The front or back texture coordinates for CFaceTextureCoords (27802) is not valid - fixed
The front or back texture coordinates for CFaceTextureCoords (28378) is not valid - fixed
The front or back texture coordinates for CFaceTextureCoords (28386) is not valid - fixed
The front or back texture coordinates for CFaceTextureCoords (32594) is not valid - fixed
The front or back texture coordinates for CFaceTextureCoords (32604) is not valid - fixed
The front or back texture coordinates for CFaceTextureCoords (33176) is not valid - fixed
The front or back texture coordinates for CFaceTextureCoords (33186) is not valid - fixed
The front or back texture coordinates for CFaceTextureCoords (33194) is not valid - fixed
The front or back texture coordinates for CFaceTextureCoords (35822) is not valid - fixed
The front or back texture coordinates for CFaceTextureCoords (35831) is not valid - fixed
The front or back texture coordinates for CFaceTextureCoords (35839) is not valid - fixed
The front or back texture coordinates for CFaceTextureCoords (35848) is not valid - fixed
The front or back texture coordinates for CFaceTextureCoords (35856) is not valid - fixed
The front or back texture coordinates for CFaceTextureCoords (36272) is not valid - fixed
The front or back texture coordinates for CFaceTextureCoords (36279) is not valid - fixed
The front or back texture coordinates for CFaceTextureCoords (36287) is not valid - fixed
The front or back texture coordinates for CFaceTextureCoords (36294) is not valid - fixed
The front or back texture coordinates for CFaceTextureCoords (36302) is not valid - fixed
The front or back texture coordinates for CFaceTextureCoords (36344) is not valid - fixed
The front or back texture coordinates for CFaceTextureCoords (36352) is not valid - fixed
The front or back texture coordinates for CFaceTextureCoords (36361) is not valid - fixed
The front or back texture coordinates for CFaceTextureCoords (36369) is not valid - fixed
The front or back texture coordinates for CFaceTextureCoords (36378) is not valid - fixed
The front or back texture coordinates for CFaceTextureCoords (36788) is not valid - fixed
The front or back texture coordinates for CFaceTextureCoords (36795) is not valid - fixed
The front or back texture coordinates for CFaceTextureCoords (36803) is not valid - fixed
The front or back texture coordinates for CFaceTextureCoords (36810) is not valid - fixed
The front or back texture coordinates for CFaceTextureCoords (36818) is not valid - fixed
The front or back texture coordinates for CFaceTextureCoords (36825) is not valid - fixed
The front or back texture coordinates for CFaceTextureCoords (36877) is not valid - fixed

This indicate there is an issue with the data being set.

Are you able to verify the UV mapping you assign to the faces?
Can you provide a simplified example, code and input data?