// create att
s@primvars_myAtt="coucou"
// lire att
string attB = s@myAtt;
// inputs & setup
int frame = chi("../frame");
string attr_name = chs("../attr_name");
string cam_path = chs("../cam_prim");
float mult = 0.01;
float focalLength = usd_attrib(0, cam_path, "focalLength", frame) * mult;
float horizontalAperture = usd_attrib(0, cam_path, "horizontalAperture", frame) * mult;
float verticalAperture = usd_attrib(0, cam_path, "verticalAperture", frame) * mult;
float screenWindow_width = tan(horizontalAperture / (2 * focalLength)) * 2;
float screenWindow_height = screenWindow_width * verticalAperture / horizontalAperture;
matrix m_prim = usd_worldtransform(0, @primpath, frame);
vector pos_prim = cracktransform(0,0,0,{0,0,0}, m_prim);
usd_addprimvar(0, @primpath, attr_name, "texCoord3f[]", "vertex");
matrix m_cam = usd_worldtransform(0, cam_path, frame);
for(int ptnum = 0; ptnum < usd_attriblen(0, @primpath, "points"); ptnum++) {
vector pos_pnt_rel = usd_attribelement(0, @primpath, "points", ptnum);
vector pos_pnt_abs = m_prim * pos_pnt_rel;
// ndc coordinates
vector pos_pnt_cs = pos_pnt_abs * invert(m_cam);
vector pos_pnt_ss = set(pos_pnt_cs.x / pos_pnt_cs.z, pos_pnt_cs.y / pos_pnt_cs.z, pos_pnt_cs.z * -1);
vector pos_pnt_ndc = set(0.5 - (pos_pnt_ss.x / screenWindow_width), 0.5 - (pos_pnt_ss.y / screenWindow_height), pos_pnt_ss.z/100);
usd_setprimvarelement(0, @primpath, attr_name, ptnum, pos_pnt_ndc);
}
VEX