generate texture (u,v) coordinates from the (x,y) coordinates of a mesh's nodes
module DVmesh_uv {
Mesh+IPort2 ∈
int+IPort2 uv_switch = 0;
int+IPort2 u_flip = 0;
int+IPort2 v_flip = 0;
float+IPort2 u_shift = 0;
float+IPort2 v_shift = 0;
float+IPort2 u_scale = 1;
float+IPort2 v_scale = 1;
.
. (internal subobjects omitted for brevity)
.
Node_Data uv_data {
nnodes => <-.in.nnodes;
nnode_data = 1;
node_data {
veclen = 2;
id = 670;
values => combine_array(switch_uv.out.values,switch_vu.out.values);
};
};
Mesh+Node_Data+OPort2 &out => merge(uv_data, in);
};
DVmesh_uv takes an input field and generates texture coordinates based on the physical (X,Y) coordinates of the mesh. The input Z coordinate is ignored. The resulting texture data is merged into the field and output. The output field can then accept a texture map.
Controls are provided to position the texture on the mesh by shifting and scaling the mapping from physical to texture space.
Field. The mesh to be textured.
int. Switch U and V (or X and Y) when generating the texture coordinates.
int. Flip U so that the texture is applied backwards in X.
int. Flip V so that the texture is applied backwards in Y.
float. Scale U by this amount. The larger this value, the less space in X the texture takes up. In other words, decreasing this value stretches the texture, increasing it compresses the texture.
float. Scale V by this amount. The larger this value, the less space in Y the texture takes up. In other words, decreasing this value stretches the texture, increasing it compresses the texture.
float. Shift U by this amount. Positive shift shifts the texture to the left, negative shifts to the right.
float. Shift V by this amount. Positive shift shifts the texture down, negative shifts up.
Mesh+Node_Data. Contains the input mesh and data, as well as the generated texture coordinates.