すあまの備忘録

誰得内容の自分のための非営利目的備忘録ブログ(筆者がわかっても内緒にしてください)

Houdiniの破壊を考える Constraint編

よくConstraintを忘れるのでメモがてら

Glue, Soft, Hardと基本の3つと、Pinとかいろいろほかにもあります。 とりあえず破壊でよく使う基本3つ

Houdini 17くらいまではSoftがなく、ConstraintもPrimitive Wrangleで設定してた気がする。

テストシーン

f:id:godofsuama:20200130194606p:plain
Geometry階層

f:id:godofsuama:20200130194623p:plain
sim_rbd内

hip fileはこちら(Houdini 18.0.287)

Constraint Geometryの作成

もっとも単純なConnect Adjacent Piecesを使用する。

使用する際、最低限設定する必要があることは以下2つ

  • Connection Type

以下画像を参考に、ラインを生成する場所

  • Length Attribute

これがないとSoft, Hardコンストレインが正常に動作しない

Search Radius, Max Search Points, Max Connectionsは適宜設定

f:id:godofsuama:20200130200345p:plain
Adjacent Pieces from Points

f:id:godofsuama:20200130200354p:plain
Adjacent Pieces from Surface Points

その他、Find Boundary Connectionsにチェックをいれ、

Cluster Attributeにアトリビュートを入れると指定したアトリビュートが異なるピース間でConstraint Geometryを作成できます。

窓ガラスと窓枠の間にConstraint Geometryを作成する際などに使えます。

f:id:godofsuama:20200130200846p:plain
Find Boundary Connections

他にもHoudini17.5から nameなどの条件でConstraint Geometryを作成する

RBD Constraints From Rules

自分でラインを作成してから使用する2つがある。

RBD Constraints From Curves

RBD Constraints From Lines

Constraint Attributesの作成

今は、RBD Constraint Propertiesで簡単にアトリビュートを設定できる。

まず最初にConstraint Typeで使用したいコンストレインの種類を選択する

Constraint NameはDOP内での指定に必要なので基本的には変更しない。

その他、よく使うもののみ説明

Constraint Type イメージ 効果
Glue 接着剤でくっついてる 一定以上の力で分離する
Soft スライムやバネ 柔らかく元に戻ろうとする
Hard ずれるだけで分離しない 固く元に戻ろうとする
Glueの場合


Houdini Glue Test

f:id:godofsuama:20200130201640p:plain

パラメーター 説明
Strength くっつく力の強さ。-1で絶対に離れなくなる。
Strength Variuance くっつく力にランダムさを加える
Half Life くっつく力が減衰する速さ
Propagation Rate くっつく力が広がる速さ
Propagation Iterations くっつく速さが広がる反復回数

f:id:godofsuama:20200130214257p:plain

Switch Constraint Type When Brokenにチェックをいれると

Glue Constraintが一定以上の強さで分離した箇所からSoft Constraintに移行する。

その後のパラメーターはSoft Constraintと同じで、DOP内でもGlue, Soft両方の設定をする必要がある。


Softの場合


Houdini Soft Test

f:id:godofsuama:20200130203147p:plain

パラメーター 説明
Degrees of Freedom コンストレインが位置、回転、もしくは両方に影響するか
Stiffness 低いとびろーんとした弱いバネのようになり、高いとぼよんぼよんした強いバネになる
Damping Ratio バネの力の減衰率、0は減衰なし、1が程よい感じ

Angular Stiffness, Angular Damping Ratioは回転への影響のみ変更する場合に使用

Plasticityは次回別の機能と一緒に紹介


Hardの場合


Houdini Hard Test

f:id:godofsuama:20200130204441p:plain

パラメーター 説明
Degrees of Freedom コンストレインが位置、回転、もしくは両方に影響するか
Constraint Force Mixing あげると固い感じになる
Error Reduction Parameter 元に戻ろうとする強さ

Hardはちょっとわかりづらい。

Constraint Force Mixingではなく、Error Reduction Parameterを調整することのが多いかもしれない。

Constraintを使用する

f:id:godofsuama:20200130212336p:plain
Constraint Network

  1. Constraint Networkノードを画像のように接続
  2. Geometry Sourceまたは、SOP PathでSOP上のConstraint Geometryを指定する。
  3. Constraint Networkの第二入力に使用したいコンストレインタイプのノードを接続する。
  4. 複数の種類を使う場合はMergeでつなぐ f:id:godofsuama:20200130213158p:plain

Glue Constraint Relationship

Bullet Soft Constraint Relationship

Hard Constraint Relationship

GlueとHardの際はデフォルトのままだとConstraint NameとData Nameが異なるため、

RBD Constraint Properties等で設定したConstraint Nameと、

Constraint RelationshipのData Nameを同じにする必要がある。

f:id:godofsuama:20200130225643p:plain

Constraintを削除する

Glue ConstraintはStrength以上の力が加わると自動で分離するが、

SoftとHardはDOP内で、SOP Solverを使用し切ってあげないとそのままつながり続ける。

  1. SOP Solverを作成し、Constraint Networkの第三入力につなぐ。
  2. SOP Solverの中に入り、relationship_geometryにPrimitive Wrangleを接続する。
  3. Primitive Wrangleに後述するWrangleを記述してConstraint Geometryを削除する。
  4. 必要であればPrimitive WrangleにOutputを接続する。

f:id:godofsuama:20200130220024p:plain

f:id:godofsuama:20200130220133p:plain

削除処理のWrangle

f:id:godofsuama:20200130220643p:plain

if(@distance > chf("distance")) {
    removeprim(0,@primnum,0);
}

@distanceの部分を以下のように書き換えることで距離以外で削除することができる。

複数の指定も可能で、これ以外の自作の条件で削除することもできる。

とりあえずなんでもいいのでremoveprimでPrimitiveを削除すればいい。

Attribute 説明
angle 角度(ラジアン
distance 距離
force フォースの強さ
impact 衝撃の強さ
torque 回転の大きさ