MAXON CINEMA 4D: Cinema 4D Forum Adobe After Effects Forum

# Cinema 4d C.O.F.F.E.E. timer reset / flip flop randomisation

VIEW ALL
 Cinema 4d C.O.F.F.E.E. timer reset / flip flop randomisation on Feb 11, 2013 at 9:52:52 pm

Hello All,

I'm having a little trouble trying to automate an idea I had involving lighting and their intensity.

My idea was that a group of lights would vary in intensity over time as the scene progresses.
I thought my best way of doing so would be to use Xpresso. I got as far as having all the lights change in intensity individually, but I came upon a problem. they would change every single frame which made them flicker as opposed to more smooth transitions I was looking for.

I then figured that I could change when the sequence started by using a flip flop at the beginning of the sequence so that it wasn't changing each frame. I then came upon another problem. with this new addition, the lights would either flicker, or be solid on for a period of time, there was no constant 'movement' of the lights.

I then thought that if I could use an equation or script to reset the flip flop, I could get the results I desired. My idea was that I could change the state of the flip flop every 0.134 seconds (4 frames).

(FPS=30
1 second/ 30 = 0.0333333333
ans*4 = 0.13333333)

time = x
constant = 0.134 = y
output = n

I tried (x-y=0)=1 and other variations. my friend, who is studying Comp Sci, tried some script he had written,

```main() { if(x%y==0){ n=1; } else { n=0; } }```

and

```main() { n = if ((x%y)==0) then 1 else 0 } ```

but alas they did not work.

This is where I am stuck, both me and my friend cannot write a script that will do such that.

If anyone has any ideas on anything I can do, it would be most appreciated. As long as the output of the flip flop can be 1 every 0.134 seconds, I will be happy.

I have linked a picture of my Xpresso editor and C.O.F.F.E.E. editor.
In the bottom you will see my C.O.F.F.E.E. test area where the output will replace the Random connected to the Switch on the flip flop.

http://i.imgur.com/estGlIV.png

Josh

 Re: Cinema 4d C.O.F.F.E.E. timer reset / flip flop randomisationon Feb 12, 2013 at 8:28:44 pm

I'm not where I can test but here are some thoughts

- use Frames from the Time node not time run that through a Math:Modulo to output a continuous/repeating stream of 1,2,3,4 and activate your change on 4. The COFFEE looks to simple to not do in Nodes...

- another node to consider, staying in that realm, is the Formula Node which does that sort of thing (but I don't really understand it myself, maybe your friend will)

- a third possibility is to feed a Noise node into the light brightness directly and avoid the math but finding the right parameters might no be possible

 Re: Cinema 4d C.O.F.F.E.E. timer reset / flip flop randomisationon Feb 12, 2013 at 10:03:03 pm

Thanks for the response,

I'll have a look at math:modulo and see if I can get a result that way.

I tried the formula node but it only worked when time was 0.134, any time after output was 0.

EDIT: That was perfect! Thank you so much.

This isn't vital, but more of a curiosity. do you know any way in which the intensity can be changed more smoothly than a sudden random change?

 Re: Cinema 4d C.O.F.F.E.E. timer reset / flip flop randomisationon Feb 13, 2013 at 3:42:13 pm

what kind of changes are you looking for? I understand smoothly getting to each new setting but are you looking for regular up/down of any one light or random changes in any one light?

 Re: Cinema 4d C.O.F.F.E.E. timer reset / flip flop randomisationon Feb 13, 2013 at 6:26:39 pm

Ignore the bad quality, but imagine all the squares are the same colour. Something like this if possible?

 Re: Cinema 4d C.O.F.F.E.E. timer reset / flip flop randomisationon Feb 14, 2013 at 4:44:01 am

Here's an example (simple, nothing complex going on) of a FlipFlop controlling a light up and down but your video looks a lot like animated Mod noise so here's a fast example of that.

5451_flipflop.c4d.zip
5452_modnoise.c4d.zip

 Re: Cinema 4d C.O.F.F.E.E. timer reset / flip flop randomisationon Feb 14, 2013 at 4:45:42 pm

If there was some way to combine the two, that would be perfect.

If I could have a grid array of lights that behaved like the mod noise, it would be the end of all problems.

Is there a way where I can combine the flip flop light you made and the one I made to control all lights together?

 Re: Cinema 4d C.O.F.F.E.E. timer reset / flip flop randomisationon Feb 15, 2013 at 8:05:15 pm

I'd have to see your setup to see if moving the FlipFlop into it was possible. Are you recreating that screen or something totally different?

 Re: Cinema 4d C.O.F.F.E.E. timer reset / flip flop randomisationon Feb 15, 2013 at 10:34:34 pm

It will look somewhat similar, but in hexagon shapes.
http://imgur.com/a/cIWJP

I will fit it so that the light shines through the blue glass and you see the hexagon shape and not a round blob, but it's simply just for a test.

https://dl.dropbox.com/u/108958894/Lights%20test.c4d

here is a copy of my project file if you wish to tinker.

 Re: Cinema 4d C.O.F.F.E.E. timer reset / flip flop randomisationon Feb 19, 2013 at 3:43:26 pm

is the hex grid to keep the light 'contained' or part of the design/model?
What about a hexagonal gobo (light mask) so all the lights are the right shape?
The code is going to be tough (I think) if the lights are clones since to get the flipflop type behaviour you would have to remember diferent targets for each light. Possible but not trivial. It may be a lot easier to have all the lights as separate objects that have one xpresso each that is nearly identical but randomized (somehow) to have different timing. How many lights are there going to be?

 Re: Cinema 4d C.O.F.F.E.E. timer reset / flip flop randomisationon Feb 19, 2013 at 4:29:36 pm

The hexagonal tubes are my attempt to contain the light so that when viewed from the other side, it looks like illuminated hexagons, not light spots.

Are you thinking that with slight alteration to the Xpresso I have, put that on every light as an individual, not trying to control all lights at once?

Well currently there are 35 lights. 5 rows, 7 columns as seen in the picture. I don't plan on adding more.