Houdini VEXメモ


vexの頻度の高い内容をメモ書き ➀ -加筆中-

HIPファイル

データ型

int     a  = 2;
float   b  = 2.1;
vector  c  = (2.1, 2.1, 2.1);
vector2 c2 = (2.1, 2.1);
string  d  = "two";
matrix3 m3 = { {1,1,1}, {2,2,2}, {3,3,3} };
matrix  m4 = { {1,1,1,1}, {2,2,2,2}, {3,3,3,3}, {4,4,4,4} };

配列

int     a[]  = {1, 2, 3};
float   b[]  = {1.1, 2.1, 3.1};
vector  c[]  = {{1.0, 1.0, 1.0}, {2.0, 2.0, 2.0}};
vector2 c2[] = {{1.0, 1.0}, {2.0, 2.0}};
string  d[]  = {"one", "two", "three"};

アトリビュートの型指定

i@a  = 2;
f@b  = 2.1;
v@c  = (2.1, 2.1, 2.1);
u@c2 = (2.0, 2.0);
s@d  = "two";
3@m3 = { {1,1,1,}, {2,2,2}, {3,3,3} };
4@m4 = { {1,1,1,1}, {2,2,2,2}, {3,3,3,3}, {4,4,4,4} };

頻度の高い関数

ch() チャンネルの値

float colorRed   = ch("red");
float colorGreen = ch("green");
float colorBlue  = ch("blue");

v@Cd = set( colorRed, colorGreen, colorBlue );

chv() vectorチャンネルの値

vector translate= chv("translate");

chramp() ランプの値

floatまたはvectorの値を出力する
入力値は0~1に収めないといけない

float red = chramp("red",@P.y); 
@Cd = set(red, 0, 0); 

もし0以下や1以上の値を入力するとリピートした値が出力される

カラーランプ(vector)の値を出力させたい時は、vectorを指定

vector color = vector(chramp("color",@P.y)); 
@Cd = color;

fit() 範囲指定して別の範囲にラッピング

@P.y = fit(@P.y, -0.35, 0.35, 0, 1);

fit01()

rand() 0~1の乱数

floatやvectorの型に合わせて出力してくれる

@Cd = set(rand(i@primnum), 0, 0);
@Cd = rand(i@primnum);

relbbox() バウンディングボックス(0~1)の相対位置

@Cd = relbbox(0, @P);

getbbox_size() バウンディングボックスのサイズ

vector v = getbbox_size(0);
printf("%f", v);

getbbox_center() バウンディングボックスの中心

vector center = getbbox_center(0);
printf("%f", center);

addpoint() ポイントの追加

addpoint(0, set(0, 0, 0));

removepoint() ポイントの削除

removepoint(0,i@ptnum);

removepoint() ポイントの参照

ノードパスを指定したい場合は、op:をパスに付ける

vector getPosition = point(0, "P", 0);
printf("input 0    %f \n",getPosition);

getPosition = point('op:/obj/func_point/transform1', "P", 0);
printf("input path %f \n",getPosition);

maketransform() トランスフォームマトリックス

パラメータが特に多いので難しく感じるけど、transformノードと一緒で移動、回転、スケールを入れるだけ
赤がtransformで緑がmaketransform、両方とも同じ値

vector translate= chv("translate");
vector rotate   = chv("rotate");
vector scale    = chv("scale");
vector pivot    = chv("pivot");

@P *= maketransform(0,0, translate, rotate, scale, pivot);