NCarter
0
Setting UV coordinates from scripts
Hi Martin,
I'm working on some models for a game, and I need to be able to set very specific UV coordinates for a selection of faces.
I'm making the models by starting from a cube and using the extrusion tools to build up a more complex shape. This is ideal, because it results in each quad-shaped face having UV coordinates of {{0, 0}, {0, 1}, {1, 1}, {1, 0}}. This allows me to have once copy of my texture mapped onto each face.
There are a couple of places where this doesn't work well. For one thing, if I delete some geometry and rebuild it with Fill Hole or Polygon, I end up with all the UV coordinates of the new face being set to {0, 0} (I believe). Also, if I subdivide or slice a face, each new face gets part of the original UV mapping (which is sometimes what I want, sometimes not). In either case, I'd like to be able to reset the mapping somehow.
Also, sometimes I want to be able to specify that there are two copies of the texture in the U direction, or I want to rotate the mapping by 90°. I might also want to extract a tile from a larger texture by giving fractional coordinates.
Of course, this is all the kind of thing that version 3.0's UV editor will address, but I'm trying to find a short term solution that will allow me to continue doing all the work in Cheetah3D (instead of transferring to Blender for this purpose).
My question is: is there any way I can write a JavaScript to get and set UV coordinates for selected polygons? Assuming it's possible, if you could give me some basic pointers to the nature of the API, that would be very much appreciated.
Thanks in advance!
Hi Martin,
I'm working on some models for a game, and I need to be able to set very specific UV coordinates for a selection of faces.
I'm making the models by starting from a cube and using the extrusion tools to build up a more complex shape. This is ideal, because it results in each quad-shaped face having UV coordinates of {{0, 0}, {0, 1}, {1, 1}, {1, 0}}. This allows me to have once copy of my texture mapped onto each face.
There are a couple of places where this doesn't work well. For one thing, if I delete some geometry and rebuild it with Fill Hole or Polygon, I end up with all the UV coordinates of the new face being set to {0, 0} (I believe). Also, if I subdivide or slice a face, each new face gets part of the original UV mapping (which is sometimes what I want, sometimes not). In either case, I'd like to be able to reset the mapping somehow.
Also, sometimes I want to be able to specify that there are two copies of the texture in the U direction, or I want to rotate the mapping by 90°. I might also want to extract a tile from a larger texture by giving fractional coordinates.
Of course, this is all the kind of thing that version 3.0's UV editor will address, but I'm trying to find a short term solution that will allow me to continue doing all the work in Cheetah3D (instead of transferring to Blender for this purpose).
My question is: is there any way I can write a JavaScript to get and set UV coordinates for selected polygons? Assuming it's possible, if you could give me some basic pointers to the nature of the API, that would be very much appreciated.
Thanks in advance!