TOC PREV NEXT INDEX

DVmesh_uv

Synopsis

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;
group u0 {
float values[in.nnodes][1] => u_shift + u_scale*(
(in.coordinates.values[][0] - in.coordinates.min_vec[0]) /
(in.coordinates.max_vec[0] - in.coordinates.min_vec[0]));
};
group v0 {
float values[in.nnodes][1] => v_shift + v_scale*(
(in.coordinates.values[][1] - in.coordinates.min_vec[1]) /
(in.coordinates.max_vec[1] - in.coordinates.min_vec[1]));
};
group u1 {
float values[in.nnodes][1] => u_shift + u_scale*(
(in.coordinates.max_vec[0] - in.coordinates.values[][0]) /
(in.coordinates.max_vec[0] - in.coordinates.min_vec[0]));
};
group v1 {
float values[in.nnodes][1] => v_shift + v_scale*(
(in.coordinates.max_vec[1] - in.coordinates.values[][1]) /
(in.coordinates.max_vec[1] - in.coordinates.min_vec[1]));
};
DVswitch switch_u {
in => {u0, u1};
index =>u_flip;
};
DVswitch switch_v {
in => {v0, v1};
index =>v_flip;
};
DVswitch switch_uv {
in => {switch_u.out, switch_v.out};
index =>uv_switch;
};
DVswitch switch_vu {
in => {switch_v.out, switch_u.out};
index =>uv_switch;
};
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);
};

Description

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.

Input

in

Field. The mesh to be textured.

uv_switch

int. Switch U and V (or X and Y) when generating the texture coordinates.

u_flip

int. Flip U so that the texture is applied backwards in X.

v_flip

int. Flip V so that the texture is applied backwards in Y.

u_scale

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.

v_scale

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.

u_shift

float. Shift U by this amount. Positive shift shifts the texture to the left, negative shifts to the right.

v_shift

float. Shift V by this amount. Positive shift shifts the texture down, negative shifts up.

Output

out

Mesh+Node_Data. Contains the input mesh and data, as well as the generated texture coordinates.

Example

Libraries.Visualization.Primitives

File

v/dv.v

See also



TOC PREV NEXT INDEX