No More Retake

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

メニュー

Houdiniレシピ:WrangleでPoint

Houdini回ね。

今回はAttribute Wrangle(SOP)を使ってPointを作ります。
最終的にはPointを並べてこんな感じのを、と。
sin()とcos()が出てくるのであしからず。

PointWrangle_gif01

では早速。
まず、AttributeWrangle(SOP)のRun Overの項目を”Detail(only once)”に変更しておきます。

PointWrangle_02

Pointを作成するコマンドはaddpoint()を使います。

addpoint(geoself(), {0, 1, 0});

上のコードで点が1コ作られます。
点を作るのはこれだけ。
肝になるのは配置の仕方ですね。

Pointを円周状に並べるために、位置座標をサインとコサイン使って求めます。
図にするとこんな感じ。

PointWrangle_03式にするとこんな感じ。
ここではxz平面の円にしてみました。

float r=ch("r");
for(float i=0; i<360; i++){
     float x = r*sin(i);
     float z = r*cos(i);
     addpoint(geoself(), set(x, 0, z));
}

1°の間隔でpointを配置してます。
一行目、「float r=ch(“r”);」、これはノードにあるパラメータを参照してます。
Attribute Wrangle(SOP)はあらかじめパラメータを追加しておくと、ch(“パラメータ名”)でその値を参照できます。
ここでは半径の意味のrというパラメータをあらかじめ作って、それを参照してます。

PointWrangle_04

パラメータを外に出しておくと、キーフレーム打ってアニメーション付けたり出来ます。

PointWrangle_gif02

同様にして、回転角度、配置間隔のパラメータも外に出します。
螺旋状にもしたいので、半径と回転角度を連動もさせます。
そのままだと半径の変化が急すぎるので、冪乗で緩和させます。
そのパラメータも外に出します。
この感じでコードにちょっと手を加えたのが、初めに載せたやつです。

PointWrangle_05

 

コードだけ抜き出すと、


float theta = radians(ch("theta"));

float interval = ch("interval");
float r = ch("r");
float pow = ch("pow");

for(float i=0; i<theta; i=i+interval){
float x = sin(i)*r*pow(i+1,pow);
float z = cos(i)*r*pow(i+1,pow);
addpoint(geoself(), set(x, 0, z));
}

PointWrangle_gif03

色付けたら、初めに載せたやつになります。

おわり

以上、今回はここまで。
サンプルファイルはこれ

では、また次回!

 

関連記事

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

このサイトについて

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%2F2015%2F08%2F09%2Fhoudini_wrangle_point%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%2F2015%2F08%2F09%2Fhoudini_wrangle_point%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