Dec 7, 2016

Houdini | VEX : Rotate Control Each Points







I needed to adjust some rotation each points in copy sop. And I did not use random function in VEX. I challenged to use VEX in Attribute Wrangle. I've had to use several functions. I'll explanation that functions in this article.


[.hip file : CopyRotateControl.hip]












[ VEX Code ] : Using matrix3, radians(), rotate(), quatanion(), and multiply 3 matrix. Then I prepared @speed and @offset at the same time. 



3@matx = ident(); //ident() 指定したマトリックスタイプの単位行列を返す
3@maty = ident();
3@matz = ident();

//X-Roll
f@anglex = radians(@Time*chf("X")*@speed+@offset); //radians 引数をラジアンに変換
v@axisx=set(1,0,0);
rotate(@matx, @anglex, @axisx); //rotate : rotate(matrix3, float amount, vector axis)  指定したマトリックスに回転を適用

//Y-Roll
f@angley = radians(@Time*chf("Y")*@speed+@offset); //radians 引数をラジアンに変換
v@axisy = set(0,1,0);
rotate(@maty, @angley, @axisy); //rotate : rotate(matrix3, float amount, vector axis)  指定したマトリックスに回転を適用

//Z-Roll
f@anglez = radians(@Time*chf("Z")*@speed+@offset); //radians 引数をラジアンに変換
v@axisz = set(0,0,1);
rotate(@matz, @anglez, @axisz); //rotate : rotate(matrix3, float amount, vector axis)  指定したマトリックスに回転を適用

3@mat = @matx * @maty * @matz;

@rot = quaternion(@mat);  //vector4のクォータニオンを作成する。









No comments:

Post a Comment