Old 24th February 2002, 01:31   #1
dirkdeftly
Forum King
 
dirkdeftly's Avatar
 
Join Date: Jun 2001
Location: Cydonia, Mars
Posts: 2,651
Send a message via AIM to dirkdeftly
Multiple settings superscope

I'm trying to make a superscope that changes between a number of different settings (i.e., ring, anchored scope, cross, flying vu, etc.). But I can't figure out the timing. Any help...?

"guilt is the cause of more disauders
than history's most obscene marorders" --E. E. Cummings
dirkdeftly is offline   Reply With Quote
Old 24th February 2002, 23:55   #2
UnConeD
Whacked Moderator
 
UnConeD's Avatar
 
Join Date: Jun 2001
Posts: 2,104
Suppose you have four different 'shapes'. Let 'sh' be a number from 0 to 3 that defines which shape you're drawing. You can either increase it every beat (sh=(sh+1)%4) or set it randomly (sh=rand(4)), or whatever.

Calculate your shapes like this:
PHP Code:
csh=sh;
x=if(csh,0,xcode for 1st shape);
y=if(csh,0,ycode for 1st shape);
csh=csh-1;
x=if(csh,x,xcode for 2nd shape);
y=if(csh,y,ycode for 2nd shape);
csh=csh-1;
x=if(csh,x,xcode for 3rd shape);
y=if(csh,y,ycode for 3rd shape);
csh=csh-1;
x=if(csh,x,xcode for 4th shape);
y=if(csh,y,ycode for 4th shape); 
What happens is this...
First, csh is set to the current shape number. We do this because we're going to work with the shape number, but we don't want to change the original value.
Then we check if csh is zero. We do this by using the variable as the condition: this has the effect that anything non-zero is 'true', and zero is 'false'.
So, if 'sh = 0', then the 1st shape-code gets executed (the condition is false). In any other case (sh = 1, 2 or 3), the condition will be true and x,y will be zero. Then, we decrease the shape number (in csh). Now, when we evaluate 'csh', it will be zero only when the 2nd shape is selected. In the other cases, csh will either be -1, 1 or 2.
We decrease again, and it'll only be true when the 3rd shape is selected, and so on.

A simpler approach is to calculate x1,y1,x2,y2,... and assign x,y depending on 'sh', but that way, you calculate 4 shapes regardless of which is selected. In my approach, you'll always calculate exactly one shape, which is fastest.
UnConeD is offline   Reply With Quote
Old 25th February 2002, 07:20   #3
dirkdeftly
Forum King
 
dirkdeftly's Avatar
 
Join Date: Jun 2001
Location: Cydonia, Mars
Posts: 2,651
Send a message via AIM to dirkdeftly
I knew how to calculate the shapes, I just needed to find out how to time it correctly. What I'm trying to get is something that will morph between the shapes, like in your "Reflect on it," just with 5 shapes (more or less) instead of 2. I've figured out how to fade between two, it's fairly simple (i'll use a circle and a cross here):

init:

n=579; tpi=acos(-1)*2

frame:

t=t-0.01;

pixel:

circ=i*tpi; sx1=sin(c); sy1=cos(c);
test=above(i,0.5); sx2=if(test,i*4-3,0); sy2=if(test,0,i*4-1);
x1=sx1*sin(t)+sx2*cos(t); y1=sy1*sin(t)+sy2*cos(t); z1=v/3;
continue...

But it's when you add the third shape that things get confusing. My best guess is that you need to create 3 timers; one for each shape. So what you get is this (i'll now add the "anchored scope"):

init:

n=579; tpi=acos(-1)*2

frame:

at=(at+0.1)%100; s=(s+equal(at,0))%3; ts1=if(s,if(above(ts1,0.04),ts1-0.05,0),if(below(ts1,0.96),ts1+0.05,1)); ts2=if(s-1,if(above(ts2,0.04),ts1-0.05,0),if(below(ts2,0.96),ts1+0.05,1)); ts3=if(s-2,if(above(ts1,0.04),ts1-0.05,0),if(below(ts1,0.96),ts1+0.05,1));

pixel:

circ=i*tpi;
sx1=sin(circ); sy1=cos(circ); sz1=v/3;
test=above(i,0.5); sx2=if(test,i*4-3,0); sy2=if(test,i*4-1,0); sz2=v/3;
sx3=i; sy3=v*i;
x1=sx1*ts1+sx2*ts2+sx3*ts3;
y1=sy1*ts1+sy2*ts2+sy3*ts3;
z1=sz1*ts1+sz2*ts2;
continue...

which makes at ("alarm timer") hit zero every thousanth frame, which increments s, which sets off the shape timers. This really should work, but apparently it doesn't...

"guilt is the cause of more disauders
than history's most obscene marorders" --E. E. Cummings
dirkdeftly is offline   Reply With Quote
Old 25th February 2002, 07:54   #4
UnConeD
Whacked Moderator
 
UnConeD's Avatar
 
Join Date: Jun 2001
Posts: 2,104
It really depends on what you want to do. If you want to morph between the 5 shapes independantly, you'll need 'n' weights in the range of 0-1 that add up to 1 (for the most desirable effect). You'll need to find a function that passes through most of the n-space containing all possible values.

If you just want to go from A to B, then from B to C, etc., you can use the code I wrote below for jumping from one shape into another. Simply use "from A to B" as shape one, "from B to C" as shape two, etc.

Something like this (I use PHP style code for hilighting):
PHP Code:
init {
  
ip 0;
  
sh 0;
}

frame {
  
ip ip+0.01next=equal(ip,1);
  
sh = if(next, (sh+1)%4sh);
  
ip = if(next,0,ip);

This will have a value 'ip' that just goes from 0 to 1 and returns to 0 afterwards, and a value 'sh' that will increase every time 'ip' is wrapped around. So if your first shape uses 'ip' to interpolate between x1 and x2, and the second shape uses 'ip' to interpolate between x2 and x3, you'll get a nice morph from x1 to x3, passing through x2.
UnConeD is offline   Reply With Quote
Old 25th February 2002, 21:21   #5
LittleBuddy88
Member
 
Join Date: Aug 2001
Posts: 66
Send a message via AIM to LittleBuddy88
Atero, I think I've done a similar morphing sequence once, reacting on beat, but otherwise equal to what you did.
And I can see but one problem with your code, I don't know if more exists, I just looked through it quickly, but simple, I think AVS sets ANY non-zero value to TRUE, this means that all of your scopes are executed, except one...
Not sure if that's the case though :/
1 more thing, I'm not 100% sure if the % operator works with float values...


Linus
LittleBuddy88 is offline   Reply With Quote
Old 26th February 2002, 01:54   #6
BlurPak2k1
Senior Member
 
Join Date: Jun 2001
Location: well you got to find me first :D
Posts: 201
okay i got the first one (random number change (and i even used it ))
but the other two....


...well you, eh, lost me

I am the one Armed Man in the Grassy knoll
I run a Non-Profeit Organisation that makes Coisters.
BlurPak2k1 is offline   Reply With Quote
Old 26th February 2002, 02:54   #7
dirkdeftly
Forum King
 
dirkdeftly's Avatar
 
Join Date: Jun 2001
Location: Cydonia, Mars
Posts: 2,651
Send a message via AIM to dirkdeftly
I think I've finally figured it out! I used this exact code for a color changing circle, cross, and anchored scope:

init:
n=579; tpi=acos(-1)*2; ixyt=rand(100)/1000-0.05; ixzt=rand(100)/1000-0.05; iyzt=rand(100)/1000-0.05; sr=rand(100)/200; sg=rand(100)/200; sb=rand(100)/200;

beat:
ixyt=rand(100)/1000-0.05; ixzt=rand(100)/1000-0.05; iyzt=rand(100)/1000-0.05; sr=rand(100)/200; sg=rand(100)/200; sb=rand(100)/200;

frame:
at=(at+1)%1000; c=equal(at,0); s=if(c,s+1,s)%3; s1=equal(s,0); s2=equal(s,1); s3=equal(s,2); ts1=t*s1+(1-t)*s2; ts2=t*s2+(1-t)*s3; ts3=t*s3+(1-t)*s1; t=if(c,0,t+0.01*below(t,1)); xyt=xyt+ixyt; xzt=xzt+ixzt; yzt=yzt+iyzt; r=r*0.9+sr/10; g=g*0.9+sg/10; bl=bl*0.9+sb/10;

pixel:
circ=i*tpi; sx1=sin(circ); sy1=cos(circ); sz1=v/3;
test=above(i,0.5);
sx2=if(test,i*4-3,0); sy2=if(test,0,i*4-1);
sz2=v/3; sx3=i; sy3=v*i; sz3=0;
x1=sx1*ts1+sx2*ts2+sx3*ts3;
y1=sy1*ts1+sy2*ts2+sy3*ts3;
z1=sz1*ts1+sz2*ts2+sz3*ts3;
x2=x1*sin(xyt)-y1*cos(xyt); y2=x1*cos(xyt)+y1*sin(xyt);
x3=x2*sin(xzt)-z1*cos(xzt); z2=x2*cos(xzt)+z1*sin(xzt);
y3=y2*sin(yzt)-z2*cos(yzt); z3=y2*cos(yzt)+z2*sin(yzt);
x=x3/(z3/2+1); y=y3/(z3/2+1);
red=r*2; green=g*2; blue=bl*2;


And it works, perfectly! Yay happy. Thanx for the code, though, UnConeD, I learned from it (seriously; i've been trying to figure out ways of speeding up these kinds of things)
I was going to add in a flying VU, but then AVS turned nazi on me, and when I was about to add the code, it brought up the "Winamp tried to buy drugs from an illegal alien prostitute in a chop shop and will be shut down" message and I hit spacebar before I could read it, so Windows (which was nazi in the first place) closed the program before I could save. Anyway, if anyone wants to use this code, go ahead...

Edit:
This means the code for morphing scopes is this:

frame:
at=(at+1)%HT; c=equal(at,0); s=if(c,s+1,s)%NS; s1=equal(s,0); s2=equal(s,1); s3=equal(s,2);
...repeat this type of statement NS times
ts1=t*s1+(1-t)*s2; ts2=t*s2+(1-t)*s3; ts3=t*s3+(1-t)*s4;
...repeat this type of statement NS times, making sure the last one ends with ...+(1-t)*s1
t=if(c,0,t+0.01*below(t,1));

pixel:
(shapes go here, label them s(AXIS)(SHAPE))
x=sx1*ts1+sx2*ts2+sx3*ts3...; repeat that block (sxn*tsn) NS times
and you can repeat that entire statement for 2 or 3 axes, replacing x with y and z, of course.

MT=time taken for the shape to change, in frames
NS=number of shapes used
AXIS=the axis (x and y, and z if you're using a 3D scope)
SHAPE=the shape number you're coding

If anyone still finds this vague, just ask...

"guilt is the cause of more disauders
than history's most obscene marorders" --E. E. Cummings

Last edited by dirkdeftly; 26th February 2002 at 03:26.
dirkdeftly is offline   Reply With Quote
Old 27th February 2002, 18:24   #8
BlurPak2k1
Senior Member
 
Join Date: Jun 2001
Location: well you got to find me first :D
Posts: 201
i cant really tell where your circle is in your code there but...

code:

int:
x=sin(t+i)+v;
y=cos(t+i);
red=cos(tan(t)+x);
green=sin(tan(-t)+y);
blue=cos(tan(x-y));


I am the one Armed Man in the Grassy knoll
I run a Non-Profeit Organisation that makes Coisters.
BlurPak2k1 is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Visualizations > AVS

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump