前回LifeSpanにバリエーションをつけずにすべて60fとしたもので作りました。それが以下です。
VIDEO
そこでLifeSpanのVariationを50%にしてみる。
すると以下のようになる。
VIDEO
variationによって短くなっているヤツの消え方がおかしいですね。
ログを見てみると。
t = 0 dt = 160
birth >> *Age = Frames=0 Ticks=0
t = 160 dt = 160
birth >> *Age = Frames=1 Ticks=0
t = 320 dt = 160
birth >> *Age = Frames=2 Ticks=0
t = 480 dt = 160
birth >> *Age = Frames=3 Ticks=0
t = 640 dt = 160
birth >> *Age = Frames=4 Ticks=0
t = 800 dt = 160
birth >> *Age = Frames=5 Ticks=0
t = 960 dt = 160
birth >> *Age = Frames=6 Ticks=0
t = 1120 dt = 160
birth >> *Age = Frames=7 Ticks=0
t = 1280 dt = 160
birth >> *Age = Frames=8 Ticks=0
t = 1440 dt = 160
birth >> *Age = Frames=9 Ticks=0
t = 1600 dt = 160
birth >> *Age = Frames=10 Ticks=0
t = 1760 dt = 160
birth >> *Age = Frames=11 Ticks=0
t = 1920 dt = 160
birth >> *Age = Frames=12 Ticks=0
t = 2080 dt = 160
birth >> *Age = Frames=13 Ticks=0
t = 2240 dt = 160
birth >> *Age = Frames=14 Ticks=0
t = 2400 dt = 160
birth >> *Age = Frames=15 Ticks=0
birth >> *Age = Frames=0 Ticks=0
t = 2560 dt = 160
birth >> *Age = Frames=16 Ticks=0
birth >> *Age = Frames=1 Ticks=0
t = 2720 dt = 160
birth >> *Age = Frames=17 Ticks=0
birth >> *Age = Frames=2 Ticks=0
t = 2880 dt = 160
birth >> *Age = Frames=18 Ticks=0
birth >> *Age = Frames=3 Ticks=0
t = 3040 dt = 160
birth >> *Age = Frames=19 Ticks=0
birth >> *Age = Frames=4 Ticks=0
t = 3200 dt = 160
birth >> *Age = Frames=20 Ticks=0
birth >> *Age = Frames=5 Ticks=0
t = 3360 dt = 160
birth >> *Age = Frames=21 Ticks=0
birth >> *Age = Frames=6 Ticks=0
t = 3520 dt = 160
birth >> *Age = Frames=22 Ticks=0
birth >> *Age = Frames=7 Ticks=0
t = 3680 dt = 160
birth >> *Age = Frames=23 Ticks=0
birth >> *Age = Frames=8 Ticks=0
t = 3840 dt = 160
birth >> *Age = Frames=24 Ticks=0
birth >> *Age = Frames=9 Ticks=0
t = 4000 dt = 160
birth >> *Age = Frames=25 Ticks=0
birth >> *Age = Frames=10 Ticks=0
t = 4160 dt = 160
birth >> *Age = Frames=26 Ticks=0
birth >> *Age = Frames=11 Ticks=0
t = 4320 dt = 160
birth >> *Age = Frames=27 Ticks=0
birth >> *Age = Frames=12 Ticks=0
t = 4480 dt = 160
birth >> *Age = Frames=28 Ticks=0
birth >> *Age = Frames=13 Ticks=0
t = 4640 dt = 160
birth >> *Age = Frames=29 Ticks=0
birth >> *Age = Frames=14 Ticks=0
t = 4800 dt = 160
birth >> *Age = Frames=30 Ticks=0
birth >> *Age = Frames=15 Ticks=0
birth >> *Age = Frames=0 Ticks=0
t = 4960 dt = 160
birth >> *Age = Frames=31 Ticks=0
birth >> *Age = Frames=16 Ticks=0
birth >> *Age = Frames=1 Ticks=0
t = 5120 dt = 160
birth >> *Age = Frames=32 Ticks=0
birth >> *Age = Frames=17 Ticks=0
birth >> *Age = Frames=2 Ticks=0
t = 5280 dt = 160
birth >> *Age = Frames=33 Ticks=0
birth >> *Age = Frames=18 Ticks=0
birth >> *Age = Frames=3 Ticks=0
t = 5440 dt = 160
birth >> *Age = Frames=34 Ticks=0
birth >> *Age = Frames=19 Ticks=0
birth >> *Age = Frames=4 Ticks=0
t = 5600 dt = 160
birth >> *Age = Frames=35 Ticks=0
birth >> *Age = Frames=20 Ticks=0
birth >> *Age = Frames=5 Ticks=0
t = 5760 dt = 160
birth >> *Age = Frames=36 Ticks=0
birth >> *Age = Frames=21 Ticks=0
birth >> *Age = Frames=6 Ticks=0
t = 5920 dt = 160
birth >> *Age = Frames=37 Ticks=0
birth >> *Age = Frames=22 Ticks=0
birth >> *Age = Frames=7 Ticks=0
t = 6080 dt = 160
birth >> *Age = Frames=38 Ticks=0
birth >> *Age = Frames=23 Ticks=0
birth >> *Age = Frames=8 Ticks=0
t = 6240 dt = 160
birth >> *Age = Frames=39 Ticks=0
birth >> *Age = Frames=24 Ticks=0
birth >> *Age = Frames=9 Ticks=0
t = 6400 dt = 160
birth >> *Age = Frames=40 Ticks=0
birth >> *Age = Frames=25 Ticks=0
birth >> *Age = Frames=10 Ticks=0
t = 6560 dt = 160
birth >> *Age = Frames=41 Ticks=0
birth >> *Age = Frames=26 Ticks=0
birth >> *Age = Frames=11 Ticks=0
t = 6720 dt = 160
birth >> *Age = Frames=42 Ticks=0 一個目終了age42
birth >> *Age = Frames=27 Ticks=0
birth >> *Age = Frames=12 Ticks=0
t = 6880 dt = 160
birth >> *Age = Frames=0 Ticks=-1
birth >> *Age = Frames=28 Ticks=0
birth >> *Age = Frames=13 Ticks=0
t = 7040 dt = 160
birth >> *Age = Frames=29 Ticks=0
birth >> *Age = Frames=14 Ticks=0
t = 7200 dt = 160
birth >> *Age = Frames=30 Ticks=0
birth >> *Age = Frames=15 Ticks=0
t = 7360 dt = 160
birth >> *Age = Frames=31 Ticks=0
birth >> *Age = Frames=16 Ticks=0
t = 7520 dt = 160
birth >> *Age = Frames=32 Ticks=0
birth >> *Age = Frames=17 Ticks=0
t = 7680 dt = 160
birth >> *Age = Frames=33 Ticks=0
birth >> *Age = Frames=18 Ticks=0
t = 7840 dt = 160
birth >> *Age = Frames=34 Ticks=0
birth >> *Age = Frames=19 Ticks=0
t = 8000 dt = 160
birth >> *Age = Frames=35 Ticks=0
birth >> *Age = Frames=20 Ticks=0
t = 8160 dt = 160
birth >> *Age = Frames=36 Ticks=0
birth >> *Age = Frames=21 Ticks=0
t = 8320 dt = 160
birth >> *Age = Frames=37 Ticks=0
birth >> *Age = Frames=22 Ticks=0
t = 8480 dt = 160
birth >> *Age = Frames=38 Ticks=0
birth >> *Age = Frames=23 Ticks=0
t = 8640 dt = 160
birth >> *Age = Frames=39 Ticks=0
birth >> *Age = Frames=24 Ticks=0
t = 8800 dt = 160
birth >> *Age = Frames=40 Ticks=0
birth >> *Age = Frames=25 Ticks=0
t = 8960 dt = 160
birth >> *Age = Frames=41 Ticks=0
birth >> *Age = Frames=26 Ticks=0
t = 9120 dt = 160
birth >> *Age = Frames=42 Ticks=0
birth >> *Age = Frames=27 Ticks=0
t = 9280 dt = 160
birth >> *Age = Frames=43 Ticks=0 2個目終了age43
birth >> *Age = Frames=28 Ticks=0
t = 9440 dt = 160
birth >> *Age = Frames=0 Ticks=-1
birth >> *Age = Frames=29 Ticks=0
t = 9600 dt = 160
birth >> *Age = Frames=30 Ticks=0
t = 9760 dt = 160
birth >> *Age = Frames=31 Ticks=0
t = 9920 dt = 160
birth >> *Age = Frames=32 Ticks=0
t = 10080 dt = 160
birth >> *Age = Frames=33 Ticks=0
t = 10240 dt = 160
birth >> *Age = Frames=34 Ticks=0
t = 10400 dt = 160
birth >> *Age = Frames=35 Ticks=0
t = 10560 dt = 160
birth >> *Age = Frames=36 Ticks=0
t = 10720 dt = 160
birth >> *Age = Frames=37 Ticks=0
t = 10880 dt = 160
birth >> *Age = Frames=38 Ticks=0
t = 11040 dt = 160
birth >> *Age = Frames=39 Ticks=0
t = 11200 dt = 160
birth >> *Age = Frames=40 Ticks=0
t = 11360 dt = 160
birth >> *Age = Frames=41 Ticks=0
t = 11520 dt = 160
birth >> *Age = Frames=42 Ticks=0
t = 11680 dt = 160
birth >> *Age = Frames=43 Ticks=0
t = 11840 dt = 160
birth >> *Age = Frames=44 Ticks=0
t = 12000 dt = 160
birth >> *Age = Frames=45 Ticks=0
t = 12160 dt = 160
birth >> *Age = Frames=46 Ticks=0
t = 12320 dt = 160
birth >> *Age = Frames=47 Ticks=0
t = 12480 dt = 160
birth >> *Age = Frames=48 Ticks=0
t = 12640 dt = 160
birth >> *Age = Frames=49 Ticks=0
t = 12800 dt = 160
birth >> *Age = Frames=50 Ticks=0 3個目終了age50
t = 12960 dt = 160
birth >> *Age = Frames=0 Ticks=-1
となっています。
3個パーティクルがあって1つめから順番に
LifeSpan(age)が42、43、50となっています。
そのため本来60まであることを想定されたValue To TimeとFloatの仕組みが途中で切れているので最後の縮小までいけてません。
つまりLifeSpanのVariationが0%なら全部60なので問題がないのだけど、Variationが入っちゃうと60以外の数字が入ってきちゃうのでなんとかしなければいけないというわけみたいです。
じゃあどうするかというと、
ここで米岡さんのサイトには
(TP Basic)Value To Timeの基本
ライフスパンのノーマライズとは「パーティクルエイジ÷ライフスパン」の計算をして0から1の結果を求めることです 。
とあります。
ちょっとやってみてDebugで数値をみてみましょう。
わかりやすいようにパーティクルは一個。
O birthのLifeSpanとAgeからAdd&Multiplyに繋いでA/Bの計算をします。
その計算結果をDebugで見てみましょう。
Debugはどこかに繋がないと出ないのでちょっとFloatに繋がせてもらいましょう。
それでこの計算結果ですが、0fからタイムスライダーを進めていくと以下のようになりました。
Add&Multiply >> Value = 0
t = 160 dt = 160
Add&Multiply >> Value = 0.0233952
t = 320 dt = 160
Add&Multiply >> Value = 0.0467905
t = 480 dt = 160
Add&Multiply >> Value = 0.0701857
t = 640 dt = 160
Add&Multiply >> Value = 0.0935809
t = 800 dt = 160
Add&Multiply >> Value = 0.116976
t = 960 dt = 160
Add&Multiply >> Value = 0.140371
t = 1120 dt = 160
Add&Multiply >> Value = 0.163767
t = 1280 dt = 160
Add&Multiply >> Value = 0.187162
t = 1440 dt = 160
Add&Multiply >> Value = 0.210557
t = 1600 dt = 160
Add&Multiply >> Value = 0.233952
t = 1760 dt = 160
Add&Multiply >> Value = 0.257348
t = 1920 dt = 160
Add&Multiply >> Value = 0.280743
t = 2080 dt = 160
Add&Multiply >> Value = 0.304138
t = 2240 dt = 160
Add&Multiply >> Value = 0.327533
t = 2400 dt = 160
Add&Multiply >> Value = 0.350928
t = 2560 dt = 160
Add&Multiply >> Value = 0.374324
t = 2720 dt = 160
Add&Multiply >> Value = 0.397719
t = 2880 dt = 160
Add&Multiply >> Value = 0.421114
t = 3040 dt = 160
Add&Multiply >> Value = 0.444509
t = 3200 dt = 160
Add&Multiply >> Value = 0.467905
t = 3360 dt = 160
Add&Multiply >> Value = 0.4913
t = 3520 dt = 160
Add&Multiply >> Value = 0.514695
t = 3680 dt = 160
Add&Multiply >> Value = 0.53809
t = 3840 dt = 160
Add&Multiply >> Value = 0.561486
t = 4000 dt = 160
Add&Multiply >> Value = 0.584881
t = 4160 dt = 160
Add&Multiply >> Value = 0.608276
t = 4320 dt = 160
Add&Multiply >> Value = 0.631671
t = 4480 dt = 160
Add&Multiply >> Value = 0.655066
t = 4640 dt = 160
Add&Multiply >> Value = 0.678462
t = 4800 dt = 160
Add&Multiply >> Value = 0.701857
t = 4960 dt = 160
Add&Multiply >> Value = 0.725252
t = 5120 dt = 160
Add&Multiply >> Value = 0.748647
t = 5280 dt = 160
Add&Multiply >> Value = 0.772043
t = 5440 dt = 160
Add&Multiply >> Value = 0.795438
t = 5600 dt = 160
Add&Multiply >> Value = 0.818833
t = 5760 dt = 160
Add&Multiply >> Value = 0.842228
t = 5920 dt = 160
Add&Multiply >> Value = 0.865624
t = 6080 dt = 160
Add&Multiply >> Value = 0.889019
t = 6240 dt = 160
Add&Multiply >> Value = 0.912414
t = 6400 dt = 160
Add&Multiply >> Value = 0.935809
t = 6560 dt = 160
Add&Multiply >> Value = 0.959205
t = 6720 dt = 160
Add&Multiply >> Value = 0.9826
t = 6880 dt = 160
Add&Multiply >> Value = -0.00014622
となりました。0から始まってほぼ1まで進んでいますね。
つまりこうすることによってそのパーティクルが寿命のうちどの位置にいるのかわかるということですね。
0がスタートで1がゴールです。
じゃあこの数値をどのように活用するのか。
先ほどの米岡さんのページには以下のように書いてあります。
そしてそこから出された計算結果をValue To Timeに送ります。Add&Multiplyから出力される値は常に0から1なのでValue1には0をValue2には1を設定します。後は先ほど使ったfloatノードのアニメーションを再利用します。
Value To TimeのValueに繋いげばいいのか。今までlifspanの数値で0から60fとしていたところをAdd&Multiplyから出た0から1に変更してやるんですね。
する動画はこうなりました。状態をおさらいすると
・LifeSpanは60。variationは50%
・パーティクルはわかりやすいように10個出している
・Value To Timeにはノーマライズされた0から1の値が入る。
VIDEO
やっとできました。うまくいってますね。
これはスケール以外のものにも幅広く使えそうですね。