PDA

View Full Version : Single channel expression for wave made from many objects?



Archigram
10-06-2007, 09:03 AM
I am an artist LW user and not very savvy about all the powerful programming tools built into this amazing program. I would be grateful for suggestions on how to make a fairly simple wave motion out of a long row of (let's say) rectangles that elongate and shrink in turn as the "wave" passes through like a digital oscilloscope with bar graphs. The animating channel (in this case it will be a multi-target morph channel) will be, as I understand waves, the same (sine?) curve in each succeeding bar but out of phase--starting on a later frame.

I'm pretty sure there are ways of setting up expressions or sliders to help me automate the process of adjusting the speed, amplitude, wavelength (etc?)across all my bars without having to reprogram each one individually. Can anyone point me in the right direction?

Many thanks.

vfxwizard
10-06-2007, 02:34 PM
Try applying the Oscillate modifier to the morph envelope. There is minimal math involved, just apply it, set max frames, and to offset the phase enter in the phase field of each object:

(360/TOTAL)*CURRENT

Replace TOTAL with the number of objects you have, and CURRENT with the one you are editing, starting at zero. IE for 7 objects, 360/7=51.43, phase for first object 0, second 51.43, third 51.43*2 etc...

However you mention controls, sliders and a "long" row. Oscillate can't be controlled without changing the values by hand and phase has to be set up for each object, thus it's only practical for a small number of items.

I'm not even sure I understood correctly the effect you'r looking for, so I have attached an example scene, using oscillator and endomorphs (but MTSE will work the same you'll have to scale the values to the max morph which will be over 100%).

If you need more control or have a lot of objects, an expression can automate everything. Can you align your objects in a straight line along one of the main axes and space them regularly?

Hope this helps!

Archigram
10-06-2007, 07:53 PM
Yes the bar graph animation you sent is just the sort of thin I meant, and I see how the math field can make things faster. However, I will be animating some 40 objects for each of maybe 20 differently shaped waves, so I'd like to see if I can get some insight into how to create a single expression that would be linked to each object. And yes, they are aligned along a single axis and spaced regularly.

Many thanks for your time and trouble!

vfxwizard
10-07-2007, 01:41 AM
Okay, with so many objects you need expressions. The following process seems complex because I'm verbose and tried to explain it step by step so that it may be useful for everybody, but it will only take a min to do in practice.

In layout add a null, call it Control, go to Properties/Geometry, add the Sliders control and double click it.

From the list on the left add the null's position x,y,z channels and also the x scale channel.

Rename the four selected channels changing the Label field. Name them Frequency, Amplitude, Spacing and Number of items.

Also change the Range max to say 5 for spacing and 100 for Number of items. If using endomorphs use 1 as Amplitude max, if using MTSE use the number of morph states minus 1.

Save (in attached scenes this is setup.lws).

Now load your endomorph/MTSE objects for one bar. Setup the morph, make sure you have the envelope on. [setup_v001.lws]

Open graph editor, find the MorphAmount property for the first object in MTSE and add to it the Rel_Channeler modifier.

Select [Ask a professor], pick Dr. Chan Oscillator and pick for both controllers the control null.

By default this creates a simple sine wave expression, whose frequency and amplitude are controlled by the control item's position on X.

X(control,t)*sin(6.2832*t*X(control,t))

The first part "X(control,t)" is the amplitude. It multiples, scales, what follows. We used just one null and Amplitude is its Y channel, so change it to Y(control,t).

We also want the effect to start at 0, no negative morphs, and go exactly to 100% when amplitude is set to 1 (so for MTSE amplitude=2 would be third morph, etc...). Just add half the amplitude back as an offset, and scale it by half. The expression is now:

.5*Y(control,t)+.5*Y(control,t)*sin(6.2832*t*X(con trol,t))

Test it (make sure the slider's frequency and amplitude are > 0). It should have applied a sine wave to your morph [setup_v003.lws].

The second part "sin(6.2832*t*X(control,t))" is the actual sine function. It takes the sine of time "t" so it's animated. 6.28 is a radians conversion. And the control null's X channel changes the frequency because it "multiplies time".

If you add an offset inside the sin function, you'll change the phase. The trick here is to avoid having to edit this value in each clone.

We'll make the offset proportional to the X axis position, and use the Spacing control to set how far apart items are.

.5*Y(control,t)+.5*Y(control,t)*sin(6.2832*t*X(con trol,t)+(X(SELF,t)/Z(control,t))*(6.2832/XS(control,t)))

Ouch! I know it hurts, but bear with me just a second more.

(X(SELF,t)/Z(control,t))

this part takes the X position of the current clone (hence the SELF reference) and divides it by the spacing (if you align on another axis use Y(SELF... or Z(SELF... instead). If items are placed at 1 mt 2mt 3mt and spacing is set to 1 this becomes an automatic "item counter". And works also if your spacing is something weird as 1.376 because 1.376/1.376=1 and 2.752/1.376=2 and so on.

This "count" is multiplied by this other part to generate the final offset:

(6.2832/XS(control,t))

6.28, PI times 2, is just 360 degrees in radians, as above. XS is control null's X scale, which we set to the number of clones.

The net result is that we will add a little offset to the wave phase to each clone and this offset will be proportional to the number of clones so a complete sine wave will be generated for all of them. [setup_v004.lws]

Done! Now clone the object and distribute its clones along X, as you move them they'll conform to the wave and even if you add or remove clones you won't have to go back to graph editor. [setup_v005.lws]

Since you are going to have multiple rows, repeat for each row pasting the expression and changing "control" to each row's controller name.

Enjoy, and if something does not work as expected drop me a line.

Archigram
10-07-2007, 06:41 AM
Awesome post vfxwizard! I am so grateful. I will get back to you when I have had a chance to work through this.

geothefaust
10-07-2007, 09:46 PM
vfxwizard, I just want to say thanks for the beautiful post.

I may not use it in the immediate future, but I know, at some point, I will definitely be using this information.

So a BIG thanks to you!

Archigram
10-08-2007, 10:17 AM
OK, I've had a chance to explore your step-by-step lesson a bit and I'm hitting some walls. All went well up to setup_003 My MTSE does morph according to Control's amplitude slider bar--amazing!. (For some reason, though, I had to double the number of the targets objects in the amplitude range to get the full morph.)

(Also, I haven't figured out how to edit the keys I've made with the slider: they don't seem to be accessible, say if I want to delete one, either in the slider, the timeline or the graph editor. There must be a way to do this that I'm missing. I wanted to examine this in the sample setup scenes you provided but for some reason I can't drag on the handle of the Control slider to pull it out of the lower right hand corner for a look see.)

Next I added the math you provided for the channel modifier to account for the clone objects. I checked my entry several times, and even checked it against the modifier in your setup_004 scene. But after this the amplitude slider no longer modified my MTSE object. I continued by cloning my object and the spacer slider bar did move the clones along the x axis, but again, the amplitude no longer adjusted the morph. So I am stuck here.

I should also explain that my clone objects will actually be spaced at a predetermined constant interval--so maybe I don't need a channnel to modify that? I am also wondering if I will still be able to animate the morph channels in my clones independently once the expression modifier is linked to them; there will be stretches of my scene where the wave is not active and I will want to do other things with my morphs. (If this isn't possible I can always break my animation down into separate scenes.)

Sorry for my long post but I wanted to be clear with my questions. And again, I am truly grateful for your taking the time to teach me this seriously (to me) complicated stuff.

vfxwizard
10-08-2007, 03:29 PM
edit the keys I've made with the slider: they don't seem to be accessible, [...] in the sample setup scenes you provided but for some reason I can't drag on the handle of the Control slider to pull it out of the lower right hand corner for a look see..

To reposition the slider panel, use CTRL-D it's slider mode (in modify tab, tools submenu). Now you can drag the handle, jump between keys, open all the envelopes at once in Graph Editor etc. Just remember to go back to move, scale, rotate mode as slider mode is alternative to them.

You should be able to edit keys in graph editor, the control null in my scenes was locked (habit...) and that explains why you can't modify them. But in your scene or using graph editor keys should be accessible.


spacer slider bar did move the clones along the x axis, but again, the amplitude no longer adjusted the morph.

It should not move the clones... it is used to modulate the morph according to the spacing you set manually dragging clones around the scene. Check my final scene, you'll see how the sliders only control the distribution and amplitude of the wave, objects are not distributed in space.

I'm shooting in the dark here, but check if by chance you have applied Rel_Channeler to the X POSITION channel of your main object instead of the morph amount channel. Happens often, if you open graph editor the X position channel is selected by default.


my clone objects will actually be spaced at a predetermined constant interval--so maybe I don't need a channnel to modify that?

You don't need them in fact. You can enter a constant value for spacing and also for number of clones. Yet, controlling them with an expression allows for unlimited tweaks or last minute changes, with no modifications to the scene.


I am also wondering if I will still be able to animate the morph channels in my clones independently once the expression modifier is linked to them

You can remove the rel_channeler from the clones you don't want to be affected and animate them manually. If you are going to have many of them, of course, it would be better not to remove the modifier by hand on all of them but to clone the object just once, remove the modifier, then clone and arrange all the objects you need to be hand animated.

Thanks for your kind words, and also for Faust's. I'm glad if i can help on this matter. Expressions really boosts productivity and are worth the effort.

Of course, if the X channel mentioned above is not the culprit, or you run in other problems, let me know (if so, it would help if you could post a stripped down .lws, no need for the object files).

Archigram
10-09-2007, 09:25 AM
It's all up and running now, just as you diagrammed. Once I saw how your slider was set up (sorry about my denseness with the control-D thing--I should have found that in the manual) I got the idea and everything went smoothly. I'm still playing around with how the channels affect the wave motion--spacing and number of items seem to interact to affect wavelength. But thanks to you I can go forward and really play around. The LW community is the best!

Archigram
10-17-2007, 09:10 AM
Hi vfxwizard

In case you have some extra time: the way I'm setting up my wave object has changed a bit and, despite trying to learn expression syntax, I've been unable to successfully update your complex expression to my new parameters.

First, my clone objects will be offset (linearly) on both X and Y axes. (in fact, I am working in a kind of isometric, fake 3-D space for what it's worth.)

Second, each "bar" is actually made up of 5 layered MTSE objects, so it would be convenient to parent groups of 5 to a null which sets them in correct position. There will be 20 or so bars=20 nulls, 100 objects. (I tried replacing SELF in your expression with PARENT but that seemed to disable the wave functions. Also, of course, I would want to add the Y offset.) Perhaps the 20 parent nulls could be clones and their extensions (#EX) could be incorporated into the expression? Otherwise, I can change the name for each group of 5.)

I only ask because you seem to be pretty ingenious about this stuff. Otherwise, it looks like I can just set all the objects individually in the right intial position (no parent nulls) and still get some kind of wave action even without incorporating the Y offset.

Thanks...

vfxwizard
10-17-2007, 01:51 PM
First, my clone objects will be offset (linearly) on both X and Y axes. [...] (I tried replacing SELF in your expression with PARENT but that seemed to disable the wave functions. Also, of course, I would want to add the Y offset.) Perhaps the 20 parent nulls could be clones and their extensions (#EX) could be incorporated into the expression?

Hi,
I'm not sure I have got it right, you are trying to auto-position all the clones? If so you are right, #EX is a great timesaver when dealing with many clones and is what you need. But you should apply it to position channels, not changing the morph amount's expression.

Have a look at the attached scenes. The one called "autoclone and wave" makes use of the same wave expression as before, nothing has changed, but has 2 relativity expressions added to X and Z channels of the first clone.

X: ((#ex-1)-(floor((#ex-1)/4)*4))
Z: floor((#ex-1)/4)

It's hardcoded to 4 items in a row, so when you clone the base object enter 15 for a 4x4 grid as the base will be the 16th. The offset is 1 meter per item, but just add a multiplication by wathever your spacing is.

The clones will auto position in a grid. How many items in each row is controlled by the constant "4" in both expressions. Change that value to 10 in your example (and of course apply the Z channel expression to Y since you arrange them on Y).

I was going to prepare a tutorial on the subject, inspired by your original post, but unfortunatly it's not ready yet. In short the two expressions are modulos, so that Z changes only every 4 items, while X changes for each item and resets to 0 when a new row starts.

I may have completly misunderstood the question (expecially the parent issue), if so just let me know.

vfxwizard
10-17-2007, 02:04 PM
Too late to edit the first post. Maybe you are trying to offset the wave in two dimensions, and not to auto position the clones?

If so see the attached scene. It uses an offset based on Z position to spread the wave over several rows.

Archigram
10-18-2007, 02:03 PM
Hi vfxwizard,

Thanks again for your interest in helping me. I'm still in the process of digesting your last post, but meanwhile I thought I'd send a jpeg to help clarify what I'm up to. This image was made in illustrator, so it's flat. But the LW version will also be flat, the camera shooting from above, the objects skewed isometrically. (In past projects I've translated this kind of isometric image into true 3-d in LW, skewing the camera instead of the objects, but this time I am actually using LW to render flat layers in fake 3-D).

The alternating "tines" in my scene will be the MTSE objects (comprising 5 layers each, since I will need to render some colors as particle/lines of varying thickness). Note that the spaces between extended tines are also tines that happen to be recessed. When all are equally extended the tines form a continuous wall. (There are white "screen" layers to block out overlaps, rather tricky but effective.) There will be 20 tines facing down and 20 more facing up, but each group will be animating independently.

So: when I distribute my 19 clones (per side), they will form an isometric axis simply by adding a constant X and Y factor. The wave motion would travel along this axis as before. If I understand correctly, your original wave controller expression would work fine (so far, my set ups seem to confirm this.)

I am seeing if I can play with the new X and Y #ex expressions you sent to acheive this distribution, so I will post in a day or so to let you know.

Archigram
10-18-2007, 02:41 PM
OK--

it was really simple, I should have got this sooner. I just added the constants times #ex-1 to the X and Y channels of my morph object, and it clones out in an isometric line. Then the wave expression works perfectly. Looks like smooth sailing from here. I did think your 2-D wave across the grid was nice, maybe I'll use that another time.