Cycles in the animation script?

Cycles in the animation script?

Postby Skinnytorus » Wednesday, 29.August 2012, 09:09

Hi, all.

1) I have been trying to create a simple cycle with condition within the animation script in yello Transform op:
k:float;
k=time/0.5;
if(k==int(k))
trans.x=3;
else
trans.x=1;

As I can see, the condition is checked just once when time=0 and if(k==int(k)) is true because 0/(any value) = 0 which is integer which gives me 'trans.x=3'.
Then the script considers that trans.x=1. I just wonder if it is possible to make a cycle here? Say, I want to make trans.x=3 when time=0.5 (and k=0.5/0.5 =1 which is integer).
I tried Loop op, but to no avail. :(

2) Since it is not possible to view changes of animated params and variables in real time, is it hard to create an Output op that, when stacked beneath an animated op,
could output to para window all the animated params and variables in real time?
Thank you.
Skinnytorus
Operator
Operator
 
Posts: 1300
Joined: Monday, 06.February 2012, 17:46

Re: Cycles in the animation script?

Postby ikam » Wednesday, 29.August 2012, 19:15

try this :

k:float;
k= time*50; // animation speed
if(k%2 > 1 ) // as time always increment a modulo by 2 return a value ranging 0 to 2 so you can have a cyclic condition (as by ranging >1 from 0.001 to 1.999, you can affect proportionnality)
trans.x=3;
else
trans.x=1;
ikam
Operator
Operator
 
Posts: 911
Joined: Friday, 14.October 2011, 13:00
Location: France

Re: Cycles in the animation script?

Postby Skinnytorus » Wednesday, 29.August 2012, 19:30

Thanks, man.
Could you please expand a bit more on if(k%2 > 1 ) expression? What does k%2 mean?
Edit: Alreay answered. Thanx again!
Skinnytorus
Operator
Operator
 
Posts: 1300
Joined: Monday, 06.February 2012, 17:46

Re: Cycles in the animation script?

Postby ikam » Wednesday, 29.August 2012, 19:34

in programming languages % it's a modulo math operation.

I think wikipedia should explain this more than me and my english :)

http://en.wikipedia.org/wiki/Modulo_operation
ikam
Operator
Operator
 
Posts: 911
Joined: Friday, 14.October 2011, 13:00
Location: France

Re: Cycles in the animation script?

Postby ikam » Wednesday, 29.August 2012, 19:35

by the way, I do not know you, but copy/paste into script crach for me, need to paste line by line :p
ikam
Operator
Operator
 
Posts: 911
Joined: Friday, 14.October 2011, 13:00
Location: France

Re: Cycles in the animation script?

Postby Skinnytorus » Wednesday, 29.August 2012, 19:36

Ahhh. I see now! A very handy thing! :)
Thanks.
Skinnytorus
Operator
Operator
 
Posts: 1300
Joined: Monday, 06.February 2012, 17:46

Re: Cycles in the animation script?

Postby Skinnytorus » Wednesday, 29.August 2012, 20:09

ikam
I tried your solution. It's working, but I want some more from it :)
Here is my code:
k:float;
g:float=0.5;
trans.x=0.5;
k= localtime;
if(k%2 < 1 )
{
g=g+1;
trans.x=g;
}
I want the object to 'cumulatively' move (step) 1 unit on x axis if the remainder of localtime/2 is 0 (i.e. I want the object be at x=1,5 on beat 2,
x=2,5 on beat 4, x=3,5 on beat 6 etc.). Is that possible?
Skinnytorus
Operator
Operator
 
Posts: 1300
Joined: Monday, 06.February 2012, 17:46

Re: Cycles in the animation script?

Postby reEto » Wednesday, 29.August 2012, 23:16

always remember: do not make simple operations toooo complex :)
User avatar
reEto
Partikelmeister
Partikelmeister
 
Posts: 75
Joined: Monday, 14.December 2009, 18:20


Return to Development and contribution



Who is online

Users browsing this forum: No registered users and 16 guests

cron