VEX —— Functions|Transforms and Space

目录

dihedral —— 计算旋转矩阵或四元数(将vector a旋转到vector b)

maketransform —— 构建3*3或4*4变换矩阵

packedtransform —— 对packed primtive进行变换

getpackedtransform —— 获取packed primitive的变换

setpackedtransform —— 设置packed primitive的变换

ptransform —— 从一空间到另一空间变换一矢量

ntransform —— 变换表示normal的vector

vtransform —— 变换表示方向的vector

instance —— 创建一个实例变换矩阵

lookat —— 创建旋转矩阵或角度去定向-Z轴

pretranslate —— 对矩阵应用预位移

prerotate —— 对矩阵应用预旋转

prescale —— 对矩阵应用预缩放

translate —— 对矩阵应用位移

rotate —— 对矩阵应用旋转

rotate_x_to —— 将x方向旋转指定方向

scale —— 对矩阵应用缩放

smoothrotation —— 返回欧拉旋转


solveconstraint —— 返回本地骨旋转的矩阵

solvecurve —— 返回本地骨旋转的vector/matrix3矩阵

solvefbik —— 应用full-body反向运动学算法

solvephysfbik —— 应用full-body反向运动学算法及可选的质心控制


fromNDC —— 将位置从NDC空间变换为合适空间的坐标

toNDC —— 将位置变换NDC空间坐标

ndcdepth —— 返回相机空间z-depth

orthographic —— 创建正交投射矩阵

perspective —— 创建透视投射矩阵

polardecomp —— 对矩阵计算极轴分解


getspace —— 返回从一空间到另一空间的变换矩阵

ow_space —— 将位置从object空间变换到world空间

ow_nspace —— 将normal从object空间变换到world空间

ow_vspace —— 将方向从object空间变换到world空间

tw_space —— 将位置从texture空间变换到world空间

tw_nspace —— 将normal从texture空间变换到world空间

tw_vspace —— 将方向从texture空间变换到world空间

wo_space —— 将位置从world空间变换到object空间

wo_nspace —— 将normal从world空间变换到object空间

wo_vspace —— 将方向从world空间变换到object空间

wt_space —— 将位置从world空间变换到texture空间

wt_nspace —— 将normal从world空间变换到texture空间

wt_vspace —— 将方向从world空间变换到texture空间


dihedral —— 计算旋转矩阵或四元数(将vector a旋转到vector b)

//计算旋转矩阵
matrix3 dihedral(vector a, vector b)
//计算四元数
vector4 dihedral(vector a, vector b)

maketransform —— 构建3*3或4*4变换矩阵

matrix3 maketransform(vector zaxis, vector yaxis)
//与maketransform(int trs, ...)规则一样,但仅用于旋转
matrix3 maketransform(int xyz, vector angles)
//yaxis为up,类似lookat;maketransform({0,0,1}, {0,1,0})为单位矩阵;
matrix maketransform(vector zaxis, vector yaxis, vector translate)
//按变换顺序构建4*4变换矩阵
matrix maketransform(int trs, int xyz, vector t, vector r)
matrix maketransform(int trs, int xyz, vector t, vector r, vector s)
matrix maketransform(int trs, int xyz, vector t, vector r, vector s, vector p)
matrix maketransform(int trs, int xyz, vector t, vector r, vector s, vector p, vector pr)
matrix maketransform(int trs, int xyz, vector t, vector r, vector s, vector p, vector pr, vector shears)
  • 不像大多数VEX函数,旋转单位为角度而不是弧度;

packedtransform —— 对packed primtive进行变换

void packedtransform(int input, int primnum, matrix transform)
  • 将修改P属性和transform内在属性
//等价于
// matrix to transform by
matrix transform = ident();
rotate(transform, radians(45), {0,1,0});
translate(transform, {0,1,0});

// get current packed transform
matrix3 primtf = primintrinsic(0, "transform", primnum);
setprimintrinsic(0, "transform", primnum, primtf * (matrix3)transform);
int primpoint = primpoint(0, primnum, 0);
vector pos = point(0, "P", primpoint);
setpointattrib(0, "P", primpoint, pos * transform);

getpackedtransform —— 获取packed primitive的变换

matrix getpackedtransform(int input, int primnum)
  • 此函数构建一变换,从P属性和transform内在属性,忽略packedfulltransform内的各种细节;
    • pivot内在属性;
    • 实例instance属性如orient(当pointinstancetransform使用,crowd agent);
    • packedlocaltransform内在属性(alembic);
  • 此函数不会返回预期的变换在这几种情况;
  • setpackedtransform函数也有同样的问题,如有非零的packed pivot或以上情况,packedfulltransform将不会包含所期望的矩阵;
// matrix to transform by
matrix transform = ident();
rotate(transform, radians(45), {0,1,0});
translate(transform, {0,1,0});

matrix tf = getpackedtransform(0, @primnum);
setpackedtransform(0, @primnum, transform * tf);

setpackedtransform —— 设置packed primitive的变换

void setpackedtransform(int input, int primnum, matrix transform)
  • 修改P属性和transform内在属性
// matrix to transform by
matrix tf = ident();
rotate(tf, radians(45), {0,1,0});
translate(tf, {0,1,0});

matrix transform = getpackedtransform(0, @primnum);
setpackedtransform(0, @primnum, transform * tf);

ptransform —— 从一空间到另一空间变换一矢量

//使用给定矩阵变换矢量
vector ptransform(vector vec, matrix transform)
vector4 ptransform(vector4 vec, matrix transform)
//从当前空间变换
vector ptransform(string tospace, vector vec)
vector4 ptransform(string tospace, vector4 vec)
//从一空间到另一空间变换矢量
vector ptransform(string fromspace, string tospace, vector vec)
vector4 ptransform(string fromspace, string tospace, vector4 vec)
  • ptransform,将vector解释为位置;
  • vtransform,将vector解释为方向;
  • ntransform,将vector解释为normal;
Pworld = ptransform("space:world", P);
//等价于
Pworld = ptransform("space:current", "space:world", P);

ospace = ptransform("space:object", P)
ospace = ptransform("space:object", "space:current", P)

ntransform —— 变换表示normal的vector

vector ntransform(vector v, matrix transform)
vector ntransform(string tospace, vector v)
vector ntransform(string fromspace, string tospace, vector v)

vtransform —— 变换表示方向的vector

vector vtransform(vector v, matrix transform)
vector vtransform(string tospace, vector v)
vector vtransform(string fromspace, string tospace, vector v)

instance —— 创建一个实例变换矩阵

matrix instance(vector P, vector N)
matrix instance(vector P, vector N, vector scale)
matrix instance(vector P, vector N, vector scale, vector pivot)
matrix instance(vector P, vector N, vector scale, vector4 rotate, vector up)
matrix instance(vector P, vector N, vector scale, vector4 rotate, vector up, vector pivot)
matrix instance(vector P, vector N, vector scale, vector4 rotate, vector4 orient)
matrix instance(vector P, vector N, vector scale, vector4 rotate, vector4 orient, vector pivot)
  • 类似Copy节点,变换其实例;
  • 支持两种方法设置旋转
    • 方法一,要求显式的矢量up(应是N的切线方向),与N一起确定方向;
    • 方法二,使用显式的orientation(相对的XYZ轴);

lookat —— 创建旋转矩阵或角度去定向-Z轴

matrix3 lookat(vector from, vector to)
matrix3 lookat(vector from, vector to, float roll)
matrix3 lookat(vector from, vector to, vector up)
vector lookat(vector from, vector to, float roll, int xyz)
vector lookat(vector from, vector to, vector up, int xyz)
  • -Z轴匹配from-to矢量;

pretranslate —— 对矩阵应用预位移

void pretranslate(matrix &m, vector amount)

prerotate —— 对矩阵应用预旋转

void prerotate(matrix3 &m, float amount, vector axis)
void prerotate(matrix &m, float amount, vector axis)
void prerotate(matrix3 &m, vector angles, int xyz)
void prerotate(matrix &m, vector angles, int xyz)
void prerotate(matrix3 &m, float angle, int axis)
void prerotate(matrix &m, float angle, int axis)
  • 单位需为弧度,轴应为标准化;
  • XAXIS=1、YAXIS=2、ZAXIS=4;

prescale —— 对矩阵应用预缩放

void prescale(matrix &m, vector scale_vector)
void prescale(matrix3 &m, vector scale_vector)

translate —— 对矩阵应用位移

void translate(matrix &m, vector amount)
void translate(matrix &m, vector4 amount)

rotate —— 对矩阵应用旋转

void rotate(matrix2 &m, float amount)
void rotate(matrix3 &m, float amount, vector axis)
void rotate(matrix &m, float amount, vector axis)
void rotate(matrix3 &m, vector angles, int xyz)
void rotate(matrix &m, vector angles, int xyz)
void rotate(matrix3 &m, float angle, int axis)
void rotate(matrix &m, float angle, int axis)
  • 单位需为弧度,轴应为标准化;
  • XAXIS=1、YAXIS=2、ZAXIS=4;

rotate_x_to —— 将x方向旋转指定方向

vector2 rotate_x_to(vector2 direction, vector2 v)
vector rotate_x_to(vector direction, vector v)
vector4 rotate_x_to(vector4 direction, vector4 v)
  • 可被函数sample_direction_cone和sample_sphere_cone使用;
vector2 u = set(rand(@ptnum+0.1),rand(@ptnum-0.1));
@N = sample_direction_cone({1,0,0},0.2,u);
@N = rotate_x_to({0,1,0},@N);

scale —— 对矩阵应用缩放

void scale(matrix2 &m, vector2 scale_vector)
void scale(matrix &m, vector scale_vector)
void scale(matrix3 &m, vector scale_vector)

smoothrotation —— 返回欧拉旋转

vector smoothrotation(int order, vector r, vector r_reference)

solveconstraint —— 返回本地骨旋转的矩阵

vector[] solveconstraint(float lengths[], vector targetpos, float tolerance, matrix relmat, vector constraints[])

solvecurve —— 返回本地骨旋转的vector/matrix3矩阵

vector [] solvecurve(float lengths[], int closed, int orienttonormal, vector tangent, vector points[], vector normals[])
matrix3 [] solvecurve(float lengths[], int closed, int orienttonormal, vector tangent, vector points[], vector normals[])
vector [] solvecurve(float &outlength, vector &outpos, float lengths[], int closed, int orienttonormal, int normalmode, vector tangent, vector points[], vector normals[])
matrix3 [] solvecurve(float &outlength, vector &outpos, float lengths[], int closed, int orienttonormal, int normalmode, vector tangent, vector points[], vector normals[])
vector [] solvecurve(float &outlength, vector &outpos, float lengths[], int closed, int orienttonormal, int normalmode, vector tangent, vector points[], vector normals[], float twists[], float initialtwists[], int fmt, int order, float lod)
matrix3 [] solvecurve(float &outlength, vector &outpos, float lengths[], int closed, int orienttonormal, int normalmode, vector tangent, vector points[], vector normals[], float twists[], float initialtwists[], int fmt, int order, float lod)
vector [] solvecurve(string op, float lengths[], int closed, int orienttonormal, vector tangent, int normalcalcmethod, matrix relmat)
matrix3 [] solvecurve(string op, float lengths[], int closed, int orienttonormal, vector tangent, int normalcalcmethod, matrix relmat)
vector [] solvecurve(string op, float lengths[], int closed, int orienttonormal, vector tangent, int normalcalcmethod, matrix relmat, int primnum, float lod)
matrix3 [] solvecurve(string op, float lengths[], int closed, int orienttonormal, vector tangent, int normalcalcmethod, matrix relmat, int primnum, float lod)

solveik —— 应用反向运动学算法

vector [] solveik(float lengths[], vector targetpos, vector twistpos, float twist, int twistflag, float dampen, int resiststraight, float trackingthres, matrix relmat, vector constraints[])
matrix3 [] solveik(float lengths[], vector targetpos, vector twistpos, float twist, int twistflag, float dampen, int resiststraight, float trackingthres, matrix relmat, vector constraints[])

solvefbik —— 应用full-body反向运动学算法

matrix [] solvefbik(matrix xforms[], int parents[], dict jointoptions[], matrix targetxforms[], int targets[], dict targetoptions[], int iters, float tolerance, int pinroot)
matrix [] solvefbik(matrix xforms[], int parents[], int targets[], matrix targetxforms[], int iters)
matrix [] solvefbik(matrix xforms[], int parents[], int targets[], matrix targetxforms[], int iters, float tolerance, int pinroot)
matrix [] solvefbik(matrix xforms[], int parents[], int targets[], matrix targetxforms[], int iters, float tolerance, int pinroot, float targetweights[], int targetpriorities[], int targetdepths[])
matrix [] solvefbik(matrix xforms[], int parents[], int targets[], matrix targetxforms[], int iters, float tolerance, int pinroot, float targetweights[], int targetpriorities[], int targetdepths[], int targettypes[], matrix targetoffsets[])
matrix [] solvefbik(matrix xforms[], int parents[], int targets[], matrix targetxforms[], int iters, float tolerance, int pinroot, float targetweights[], int targetpriorities[], int targetdepths[], matrix goalxforms[], vector4 constrainedxforms[], vector jointlimits[])
matrix [] solvefbik(matrix xforms[], int parents[], int targets[], matrix targetxforms[], int iters, float tolerance, int pinroot, float targetweights[], int targetpriorities[], int targetdepths[], int targettypes[], matrix targetoffsets[], matrix goalxforms[], vector4 constrainedxforms[], vector jointlimits[])

solvephysfbik —— 应用full-body反向运动学算法及可选的质心控制

matrix [] solvephysfbik(matrix xforms[], int parents[], dict jointoptions[], matrix targetxforms[], int targets[], dict targetoptions[], int iters, float damping, float tolerance)

fromNDC —— 将位置从NDC空间变换为合适空间的坐标

  • NDC(normal device coordinate)空间仅在以下上下文语境中很好定义,Displacement、Surface、Light;
//将矢量从NDC空间变换为当前空间
vector fromNDC(vector v)
//将矢量从NDC空间变换为指定空间
vector fromNDC(string space, vector 
space
"space:object" 当前object的物体空间
"space:light" 当前light的物体空间(当计算shadow、light shader时)
"space:world" houdini世界空间
"space:camera" mantra相机空间
"space:ndc" NDC空间
"space:lightndc" 当前light的NDC空间(当计算shadow、light shader时)
"space:current" 当前所在的空间

toNDC —— 将位置变换NDC空间坐标

vector toNDC(vector point)
vector toNDC(string camera_name, vector point)

ndcdepth —— 返回相机空间z-depth

float ndcdepth(float z)
vector ndc = ptransform("space:ndc", P);
float pz_camera = ndcspace(ndc.z);

// This value can also be computed using
float pz_camera = -ptransform("space:camera", P).z;

orthographic —— 创建正交投射矩阵

matrix orthographic(float zoom, float orthowidth, float image_aspect, float pixel_aspect, float clip_near, float clip_far)
matrix orthographic(float zoom, float orthowidth, float image_aspect, float pixel_aspect, float clip_near, float clip_far, vector4 window)

perspective —— 创建透视投射矩阵

matrix perspective(float zoom, float image_aspect, float pixel_aspect, float clip_near, float clip_far)
matrix perspective(float zoom, float image_aspect, float pixel_aspect, float clip_near, float clip_far, vector4 window)

polardecomp —— 对矩阵计算极轴分解

matrix3 polardecomp(matrix3 transform)
void polardecomp(matrix3 transform, matrix3 &rot, matrix3 &stretch, int check_determinant=1)

getspace —— 返回从一空间到另一空间的变换矩阵

matrix getspace(string fromspace, string tospace)

ow_space —— 将位置从object空间变换到world空间

matrix ow_space()
vector ow_space(vector v)
vector4 ow_space(vector4 v)

ow_nspace —— 将normal从object空间变换到world空间

vector ow_nspace(vector v)

ow_vspace —— 将方向从object空间变换到world空间

vector ow_vspace(vector v)

tw_space —— 将位置从texture空间变换到world空间

matrix tw_space()
vector tw_space(vector v)
vector4 tw_space(vector4 v)

tw_nspace —— 将normal从texture空间变换到world空间

vector tw_nspace(vector v)

tw_vspace —— 将方向从texture空间变换到world空间

vector tw_vspace(vector v)

wo_space —— 将位置从world空间变换到object空间

matrix wo_space()
vector wo_space(vector pos)
vector4 wo_space(vector4 pos)

wo_nspace —— 将normal从world空间变换到object空间

vector wo_nspace(vector v)

wo_vspace —— 将方向从world空间变换到object空间

vector wo_vspace(vector v)

wt_space —— 将位置从world空间变换到texture空间

matrix wt_space()
vector wt_space(vector v)
vector4 wt_space(vecto

wt_nspace —— 将normal从world空间变换到texture空间

vector wt_nspace(vector v)

wt_vspace —— 将方向从world空间变换到texture空间

vector wt_vspace(vector v)

你可能感兴趣的:(#,VEX,Houdini)