No More Retake

3DCG屋さん向けTips&Referenceサイト

メニュー

Houdini:Wrangle Memo 03

Houdini回。Wrangle(SOP)のVEX例文。メモより抜粋その3。
脈絡はないです。
あと、時々コードが文字化けしてます。すいません。

ローカル変数のマッピング

i@test = 0;
addvariablename(geoself(), "test", "TEST");

自分で作ったアトリビュートをローカル変数として定義する。
ここで定義したローカル変数は、このaddvariablenameという関数をサポートしたノードで利用可能らしい。
最近の仕様では、あまりローカル変数使わないようになってるんだっけか?

 

プリミティブ毎に含まれるポイントにID番号をふる

int primpts[] = primpoints(geoself(), @primnum);
int i =0;
foreach(int ptnum; primpts){
    setpointattrib(geoself(), "id", ptnum, i, "set");
    i++;
} 

Run OverはPrimitiveで、idというポイントアトリビュートの存在を前提賭しています。
使い道は、例えば図のような沢山ある六角形の各ポイントに0~5までの番号を付けるとかね。

 

閾値とランダム値を使ってポイントを消す

if ( rand(@ptnum)<ch('threshold') ) {
   removepoint(0,@ptnum);
}

Run OverはPoint。

数値の丸め込み

0.5間隔で小数点以下1桁まで。scaleの値で丸め込みの桁と数値の間隔が変わる。

float scale = ch("scale");
@P = rint(@P * scale)/scale;

一番近い整数に丸め込む、rint()。vector、float両方で使える。
他にも似た関数で以下のようなものがある。

floor()・・・入力の値以下で一番大きい整数を返す
ceil()・・・ 入力の値以上で一番小さい整数を返す
frunc()・・・ 少数点以下を切り捨てる
frac()・・・ 小数点以下を返す。よく使う。

 

入力からアトリビュート取得

vector Value1 = @opinput0_P; //1番めの入力からPアトリビュートを取得
vector Value2 = @opinput1_Cd; //2番めの入力からCdアトリビュートを取得

いつから、この記述がいけるようになったか知らないけど、便利!

 

カメラに映らない範囲のポイントを消す

vector ndc=toNDC(chs("CAM"),@P);
float pad = -0.5;

if(ndc[0]-pad<0 || ndc[0]+pad>1 || ndc[1]-pad<0 || ndc[1]+pad>1 || ndc[2]>0){
  removepoint(geoself(),@ptnum);
}

 

Intrinsic(組み込み)アトリビュートの取得と変更

たとえば、Intrinsicの”Transform”の取得とセットの例。

//取得
matrix3 mat = primintrinsic(@OpInput1, "transform", @primnum);
//セット
setprimintrinsic(geoself(), "transform", @primnum, mat, "set");

 

wrangle memo01
wrangle memo02

 

関連記事

コメントをお待ちしております

このサイトについて

3DCG Tipsサイト。Houdiniの記事が多めです。

RSS

follow us in feedly

Archives

  • 2024 (1)
  • 2023 (2)
  • 2022 (9)
  • 2021 (14)
  • 2020 (46)
  • 2019 (17)
  • 2018 (33)
  • 2017 (29)
  • 2016 (36)
  • 2015 (64)
  • 2014 (54)
  • 2013 (60)
  • 2012 (55)

スポンサードリンク

言語切り替え

  • English (United States)
  • 日本語

スポンサードリンク

言語切り替え

  • English (United States)
  • 日本語

Houdiniを使えるようになる本


Warning: file_get_contents(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed in /usr/home/nomorere/nomoreretake.net/wordpress/wp-content/themes/n1-custom/functions/social.php on line 132

Warning: file_get_contents(): Failed to enable crypto in /usr/home/nomorere/nomoreretake.net/wordpress/wp-content/themes/n1-custom/functions/social.php on line 132

Warning: file_get_contents(http://api.facebook.com/restserver.php?method=links.getStats&urls=http%3A%2F%2Fnomoreretake.net%2F2017%2F12%2F23%2Fhoudini_wrangle-memo-03%2F): failed to open stream: operation failed in /usr/home/nomorere/nomoreretake.net/wordpress/wp-content/themes/n1-custom/functions/social.php on line 132

Warning: file_get_contents(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed in /usr/home/nomorere/nomoreretake.net/wordpress/wp-content/themes/n1-custom/functions/social.php on line 132

Warning: file_get_contents(): Failed to enable crypto in /usr/home/nomorere/nomoreretake.net/wordpress/wp-content/themes/n1-custom/functions/social.php on line 132

Warning: file_get_contents(http://api.b.st-hatena.com/entry.count?url=http%3A%2F%2Fnomoreretake.net%2F2017%2F12%2F23%2Fhoudini_wrangle-memo-03%2F): failed to open stream: operation failed in /usr/home/nomorere/nomoreretake.net/wordpress/wp-content/themes/n1-custom/functions/social.php on line 132