No More Retake

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

メニュー

Houdini:nearpoint(VEX)

前回に続き、Houdini VEX勉強回。
今回は「近接ポイントの情報を取得する」VEX系の関数についてです。
近接ポイントとはこの場合、単純に距離の近いポイントのことを指します。

近接ポイントを取得するVEX関数は幾つかあります。
ここではnearpoint()とnearpoints()を取り上げようとおもいます。
表記の違いは名前に”s”があるかないか。まぎらわしい。

nearpoint()

一番近いポイント番号を取得する。
”一番近い”だから、取得するポイントは1コ。
最大どこまでの距離を探すか指定する。ポイントが見つからなければ-1。

int nearpoint(検出先の入力, 検索位置, 検索距離)

「作例」
一番近いポイント取得して色と高さをかえてみた。

ネットワークはこうじゃ!

VEXコードはこうじゃ!

vector pos = point(1, "P", 0);
i@npt = nearpoint(0, pos, chf("dist"));

if(@ptnum == @npt){
   @Cd = {0, 0, 1};
   @P += {0, 0.25, 0};
}

次じゃ!

 

nearpoints()

近接ポイントを探して、見つかったポイントを配列で返す。
先述のnearpoint()の配列版。
1番近いポイントに限らず、2番目3番目・・・と見つかった分だけ配列に格納する。
最大で何個のポイントを探すが指定する。

int nearpoints(検出先の入力, 検索位置, 検索距離, 見つけるポイントの最大個数)

「作例」
パーティクルの各点つないでみた。
(同様結果はConnect Adjacent Pieces(SOP)でもできる)

ネットワークはこうじゃ!

VEXコードはこうじゃ!

vector pos = point(0, "P", @ptnum);
i[]@npts = nearpoints(0, pos, chf("dist"), chi("maxpt"));

foreach(int pt; @npts){
    if(pt>@ptnum && pt!=@ptnum){
        int prim = addprim(geoself(), "polyline");
        addvertex(geoself(), prim, @ptnum);
        addvertex(geoself(), prim, pt);
    }
}

以上じゃ!
間違ってたら教えてほしいのじゃ!
鵜呑みにすると危ないじゃ!

これサンプルファイルじゃ!

VEX勉強シリーズはもう少し続くじゃ そのうち書きます。


[参考] マニュアル
nearpoint()
http://www.sidefx.com/docs/houdini/vex/functions/nearpoint

nearpoints()
http://www.sidefx.com/docs/houdini/vex/functions/nearpoints

 

関連記事

このサイトについて

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%2F02%2F25%2Fhoudini_nearpoint_vex%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%2F02%2F25%2Fhoudini_nearpoint_vex%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