.get_front_UVQ return unexpected results
-
I've been playing with mapping textures via ruby the last couple of days.
I got a plugin which maps a texture to four-sided faces. I do so by taking the 3D co-ordinates of each corner and map the UV to 1 so the texture tiles exactly once across the face.
Example
When a face has been mapped and I want to retrieve the current position I face some strange results from faces that are not rectangular or parallelograms.For instance, when I set the texture position I use this value set:
1. XYZ: Point3d(0, 400, 0) - UV: Point3d(0, 0, 1) 2. XYZ: Point3d(100, 400, 0) - UV: Point3d(1, 0, 1) 3. XYZ: Point3d(100, 500, 0) - UV: Point3d(1, 1, 1) 4. XYZ: Point3d(20, 480, 0) - UV: Point3d(0, 1, 1)
But when I use
.get_front_UVQ
I get these values:
1. XYZ: Point3d(0, 400, 0) - UV: Point3d(0, 0, 1.00007) 2. XYZ: Point3d(100, 400, 0) - UV: Point3d(1.33343, 0, 1.33343) 3. XYZ: Point3d(100, 500, 0) - UV: Point3d(1.00007, 1.00007, 1.00007) 4. XYZ: Point3d(20, 480, 0) - UV: Point3d(0, 0.800056, 0.800056)
I don't understand why this happens. For rectangles, even parallelograms they are returned as I set them.
Any ideas?
-
I seem to remember position_material doesn't allow sheared UVs. You need to give it an orthogonal set of XYZ and UVs. I generally found it to be a little flakey too - if you give degenerate cases it will crash SU.
So I guess I would take an edge of your face cross face.normal to get an orthogonal frame into which you can project UVs to give to position_material.
Adam
-
@adamb said:
I seem to remember position_material doesn't allow sheared UVs. You need to give it an orthogonal set of XYZ and UVs.
So I can only position the texture in a rectangle format? In this plugin I'm working on, http://www.sketchucation.com/forums/scf/viewtopic.php?f=180&t=18992, I currently allow it to fit to any face with four corners.
@adamb said:
I generally found it to be a little flakey too - if you give degenerate cases it will crash SU.
Saying, that. I think I've experienced some oddities. But I attributed that to my Double-Cut plugin...
So what you are saying is; you can skew and warp textures by using SU's UI, but doing so via the ruby API will cause instabilities?
(Or have it misunderstood this?) -
@thomthom said:
So I can only position the texture in a rectangle format? In this plugin I'm working on, viewtopic.php?f=180&t=18992, I currently allow it to fit to any face with four corners.
Kinda - I think it will only allow an affine projection, so you're out of luck there for a general 4 point positioning.
@adamb said:
So what you are saying is; you can skew and warp textures by using SU's UI, but doing so via the ruby API will cause instabilities?
(Or have it misunderstood this?)No, I remember if you give degenerate positioning info (eg points repeated), SU dies.
But perhaps a better way of doing this is to use a PolyMesh and just explicitly set UVs.
Adam
-
@adamb said:
But perhaps a better way of doing this is to use a PolyMesh and just explicitly set UVs.
Never used Polygon Meshes before.
So to map existing faces I'd convert them to PolyMeshes?
Advertisement