PDA

View Full Version : Expression help: Dissolve when Speed is 0



raw-m
07-10-2018, 10:25 AM
Hello. I want to automate the Dissolve on a few objects, basically, when an objects speed hits 0 (no movement) I want Dissolve to equal 100%.

Anyone know how to accomplish this, via an expression or nodal (sorry, 2018, no DP Kit)? It would also be nice to add some time offset , if possible (i.e. object comes to a rest and is dissolved 1 sec later)!

There's an "Speed" option in the expression builder but the description and example is a bit cryptic and haven't been able to find any other reference to it in context anywhere.

MonroePoteet
07-10-2018, 12:18 PM
Yes, the Expression editor "Speed" function doesn't appear to parse or work. I tried a variety of syntaxes, parameters, etc. and couldn't get it to parse.

You can calculate the speed of an Object (e.g. BlueBall) using the Expression:

(BlueBall.pos(Time) - BlueBall.pos(-1.0+Time))? 0.0 : 1.0

which subtracts one second from the current Time, gets the BlueBall position (as a 3-dimension vector reflecting all motion), subtracts that from the BluBall position at the current time, and uses the Conditional Function (the <test>?<true value>:<false value> to return 1.0 when the ball has stopped and 0.0 otherwise.

Sample scene attached.

142175

The strange syntax for subtracting 1.0 from the Time (-1.0+Time) is due to a long-lasting bug in the Expression syntax parser, which doesn't allow subtraction in parameter formulae.

This expression will dissolve to 100% the instant the Ball stops. Indeed, if you watch the BlueBall in VPR in the sample scene, it vanishes momentarily at frame 54. This is because the X position is a TCB spline which overshoots the final position, coming briefly to a rest before it backtracks. One second later, it vanishes for that momentary rest stop.

mTp

raw-m
07-10-2018, 01:05 PM
Many thanks, MTP, I would have never arrived at that :D I’ll check it out in the morning. I had thought you always needed to use specify an X,Y or Z channel which had me confused so thanks for the pointer.

MonroePoteet
07-10-2018, 03:30 PM
You bet, glad to help! Thank *you* again (and AGAIN) for the excellent tutorials out on YouTube!

mTp

raw-m
07-11-2018, 04:25 AM
Just out of interest, is there a way to specify "self" in an expression, rather than an exact object name?

raw-m
07-11-2018, 05:51 AM
PS really nice solution using Time minus an offset :D

MonroePoteet
07-11-2018, 09:23 AM
I don't know of any way to specify the "current object" in an expression, which would be REALLY nice to be able to do. A handicap of the current implementation is that if you build a really nice Expression setup, and then clone the object or instance it, the Expression(s) still reference the original object.

As I'm sure you know, you can use the keyword Value to get the keyframed value of the current channel. It'd be great to be able to just specify [Position.X], for example, and have it extract the current item's X position which would then be cloneable.

RE: the -1 time offset, that's the delay in the dissolve as you know. If you want only a 0.2 second delay before the dissolve, just change that value.

mTp

raw-m
07-12-2018, 02:11 AM
Thanks again mTp! I use Value*Time all the time for linear movements (useful on animated textures), means I donít have to use key frames and just adjust the base value, with the added bonus of one expression being used in lots of places.

Iíve tried the example but it seems to only take into account the x movement. If I animate down the z it doesnít work. Does it do that your end?

MonroePoteet
07-12-2018, 08:04 AM
Sigh! Yes, the Expression I posted doesn't work - apparently the equation processor doesn't do vector math and implies the X channel. Sadly, that means you'll have to explicitly include each channel with the expression:

(BlueBall.pos(Time).x - BlueBall.pos(-1.0+Time).x)+(BlueBall.pos(Time).y - BlueBall.pos(-1.0+Time).y)+(BlueBall.pos(Time).z - BlueBall.pos(-1.0+Time).z)? 0.0 : 1.0

Note the (to me) strange syntax where the channel is specified *after* the Time parameter in parentheses. Sample scene attached using the equation above where the BlueBall moves in three dimension and doesn't become still in all of them until frame 90, dissolving at frame 114 (24fps). Sorry!

mTp

raw-m
07-12-2018, 09:06 AM
MTp, don’t be sorry, you’ve helped me (not to mention everyone else) more than you know. Thank you!! I suspected this script update might be the case - I think the Dissolve 0/100% script will actually be quicker, for now :D

MonroePoteet
07-12-2018, 12:30 PM
Is that an LScript you wrote, or is it in the Content / website?

mTp

raw-m
07-12-2018, 12:35 PM
I think there’s one in OD tools but Mike Green’s is equally as good “Dissolve v1”;
http://www.mikegreen.name/Lscripts.html

MonroePoteet
07-12-2018, 06:47 PM
OK, thanks. I've got to remember there's an LScript modifier under the E button, and when I get frustrated at the lack of a T / Texture button (as on Dissolve), try whipping up an LScript!

mTp