Problem with texture coordinates
-
Hello,
I'm trying to match a texture to the corner points of a quadrangle (no rectangle). Somehow the texture does not display immediately how I expect it (image 1).
When I right click -> position texture and cancel without moving the texture position, it suddenly displays correctly (image 2). There is something that I miss and I don't know what. Can someone help me?c=[Point3d(0, 0, 0), Point3d(6.13575e+006, -2.05147e+006, 0), Point3d(4.22755e+006, 450980, 0), Point3d(-295726, 698978, 0)] face=entities.add_face(*c).reverse! # create material m=materials.add "material1" m.texture=imghref face.material=m # I want to match the texture coordinates to the corners of the face # c[i] are the corner points of the face pt_array = [] pt_array[0] = c[0] pt_array[1] = Geom;;Point3d.new(0,0,0) pt_array[2] = c[1] pt_array[3] = Geom;;Point3d.new(1,0,0) pt_array[4] = c[2] pt_array[5] = Geom;;Point3d.new(1,1,0) pt_array[6] = c[3] pt_array[7] = Geom;;Point3d.new(0,1,0) on_front = true face.position_material m, pt_array, on_front
-
I'm in a rush - so just a quick drive-by-post:
I don't have time to analyse your code right now - but I have some code that does what you want to do in UV Toolkit: http://forums.sketchucation.com/viewtopic.php?f=323&t=18992&p=155759
"Fit Texture to Quadface" -
Thanks! I found the essential step in your code (
TT::Face.corners( e )
).
It seems to work for me just fine when I change the order of the points to (the array c contains always exactly 4 points in the same order).pt_array[0] = c[0] pt_array[1] = Geom;;Point3d.new(0,0,0) pt_array[2] = c[1] pt_array[3] = Geom;;Point3d.new(1,0,0) pt_array[4] = c[2] pt_array[5] = Geom;;Point3d.new(1,1,0) pt_array[6] = c[3] pt_array[7] = Geom;;Point3d.new(0,1,0)
Advertisement