I usually get uvs of a model with the code below:
if faceEnt.material != nil && faceEnt.material.texture != nil # faceEnt is a Face
uvsFront = getUVs(true, faceEnt)
end
def getUVs(front, faceEnt)
verts = faceEnt.outer_loop.vertices
points = verts.collect {|v| v.position}
uvh = faceEnt.get_UVHelper(true,true,tw)
if front
uvs = points.collect {|p| uvh.get_front_UVQ(p)}
elsif
uvs = points.collect {|p| uvh.get_back_UVQ(p)}
end
for i in (0..uvs.length-1)
uvs[i] = uvs[i].to_a #converts the Point 3D objects to arrays so they won't be transformed
uv_w = uvs[i].z
uvs[i].x = uvs[i].x / uv_w
uvs[i].y = uvs[i].y / uv_w
uvs[i].z = uvs[i].z / uv_w
end
return uvs
end
But the model sofa.skp (3.1 MB) does not work for it. The faces in the model have no material at all (faceEnt.material == nil). The material is on the component instance. How can I get the uv of faces if exists?