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?