20th October 2003, 10:11  #161 
Major Dude
Join Date: May 2003
Location: Australia
Posts: 1,353

gaekwad2: what?

13th November 2003, 15:06  #162 
Member

Is there any way I can use rand to generate a random number on each beat, andf be able to use the random numbers in two different scopes? IE,
Scope 1: beat: q=(rand(21)10)*0.01; Scope 2: q=(random nubmer that was generated in scope 1. Is this at all possible? 
13th November 2003, 15:16  #163 
Junior Member
Join Date: Oct 2003
Posts: 3

yeah you can...
I'm not sure how to do it on preavs2.7 visualisations...but if you have avs2.7, I'm pretty sure you could just assign the random number to a reg##....eg:
beat (scope 1): reg01=rand(100)/1000; frame (scope 2): x=reg01....or whatever you wanna do with it 
13th November 2003, 17:33  #164 
Member

Wow, I didn't know 2.7 could do that! Anyway, I'm gonna stick to 2.5 till Winamp 5 gets offically released. Any other ideas?

13th November 2003, 18:08  #165 
Foorum King
Join Date: Jul 2003
Location: bar2000
Posts: 11,345

search for "random", there's an explanation somewhere (I just can't remember where)
Just build a wall around your whole country and put a roof on top, but make sure it's airtight. Then you can pollute all you want. Don't worry, God won't let you suffocate. Last edited by gaekwad2; 13th November 2003 at 18:24. 
13th November 2003, 20:08  #166 
Junior Member
Join Date: Jun 2003
Location: Washington, PA
Posts: 26

While your using AVS 2.5 you could use an almost fake number generator.
(getosc(0.47,0,0)*8753%100)/5000.1  This function will take the sound value and do some modulos division to give you a random number. Atero showed me this, and its very helpful when you want to syhcnronize ssc or dms. 
13th November 2003, 21:10  #167 
Forum King

real hue mod:
red=abs(asin(sin(hue)))/$pi*40.333; green=abs(asin(sin(hue+$pi*0.333)))/$pi*40.333; blue=abs(asin(sin(hue$pi*0.333)))/$pi*40.333; hue is 0..2pi i'm not sure about sat and lum yet, anyone care to experiment with this? "guilt is the cause of more disauders than history's most obscene marorders" E. E. Cummings 
13th November 2003, 21:56  #168 
Senior Member
Join Date: Oct 2003
Posts: 272

I've used sine waves to create hue but then you get large portions that are red, green, or blue... I've also done it with straight interpolation where the values change like this:
Red: ¯\__/¯ Green: /¯¯\__ Blue: __/¯¯\ As far as lumination goes, you interpolate all the values from (0,0,0) or black, up to the values of your main color, say (1,1,0), and then interpolate the remains up to (1,1,1) or white. For saturation you interpolate your color down to (.5,.5,.5) or gray. I haven't really seen any set rules on how to change colors or anything but this is what I've gathered from the palettes they use in photoshop to let you pick colors. Obviously you can add a lot more to these if you want. 
14th November 2003, 03:26  #169 
Forum King

yar!
hue: red=min(max(abs(asin(cos(hue)))/$pi*40.333,0),1); green=min(max(abs(asin(cos(hue+$pi*0.333)))/$pi*40.333,0),1); blue=min(max(abs(asin(cos(hue$pi*0.333)))/$pi*40.333,0),1); sat: red=red*sat+0.5*(1sat); blue=blue*sat+0.5*(1sat); green=green*sat+0.5*(1sat); lum: red=red*min(lum,1lum)*2+(lum0.5)*2*above(lum,0.5); blue=blue*min(lum,1lum)*2+(lum0.5)*2*above(lum,0.5); green=green*min(lum,1lum)*2+(lum0.5)*2*above(lum,0.5); has to be done in that order or else things go fuxery. hue=0..2pi, lum/sat=0..1. could be sped up/simplified, but i'm too lazy right now.... <edit> fixed the hue filter, before it was pi..pi "guilt is the cause of more disauders than history's most obscene marorders" E. E. Cummings 
14th November 2003, 03:48  #170 
Forum King

i made a demonstration preset...forgot to attach it :F
(nPostCount+=1) "guilt is the cause of more disauders than history's most obscene marorders" E. E. Cummings 
14th November 2003, 04:07  #171 
Senior Member
Join Date: Oct 2003
Posts: 272

You mind explaining all that junk? It seems rather excessive to me...

14th November 2003, 08:15  #172 
Foorum King
Join Date: Jul 2003
Location: bar2000
Posts: 11,345

Apparently there are 2 types of HSL color spaces. Atero's is used by eg Windows whereas eg Gimp uses a different HSV scheme that can be calculated this way:
red=(min(max(abs(asin(cos(hue)))/$pi*40.333,0),1)*sat+1sat)*lum; green=(min(max(abs(asin(cos(hue+$pi*0.333)))/$pi*40.333,0),1)*sat+1sat)*lum; blue=(min(max(abs(asin(cos(hue$pi*0.333)))/$pi*40.333,0),1)*sat+1sat)*lum; Just build a wall around your whole country and put a roof on top, but make sure it's airtight. Then you can pollute all you want. Don't worry, God won't let you suffocate. 
15th November 2003, 06:00  #173 
Forum King

yarhar!
i fixed the hue thing again. befoe it wasn't scaled right. red=min(max(abs(asin(cos(hue)))/$pi*61,0),1); green=min(max(abs(asin(cos(hue+$pi*0.333)))/$pi*61,0),1); blue=min(max(abs(asin(cos(hue$pi*0.333)))/$pi*61,0),1); <edit> i THINK this is the last fix. the hue setting on the luminosity bar wasn't right. "guilt is the cause of more disauders than history's most obscene marorders" E. E. Cummings Last edited by dirkdeftly; 15th November 2003 at 06:24. 
7th December 2003, 22:33  #174 
Senior Member
Join Date: May 2003
Posts: 101

My particle
code: Make a texer2 like this with a faded particle image between 50x50 and 65x65. Now copy this Texer2 ~2030 times, make a couple with smaller images, and you have a firewerkstyle! Than change reg00 and reg01 (better from SSC with n=0) to move the source of particles! [edit] plese do not use in your pack *directly this piece of code*, I'll be using it in BuggyAVS2 . Get the idea and make your own [/edit] 
28th December 2003, 19:46  #175 
Junior Member

CHESS
I can make my fastest chess!
My old chess is slow, because it was an superscope with w*2 points... ...but now it have two movements, and two points. 
2nd January 2004, 02:03  #176 
Senior Member
Join Date: May 2003
Posts: 101

oh, and one more, related to 2.8 now:
if you want to switch enable/disable effectlist on mouse click, use this code: code: ...this way even if a user holds a mousebutton down for many frames, the enable state won't change until next click. 
7th January 2004, 10:22  #177 
Forum King
Join Date: Aug 2002
Location: The Netherlands
Posts: 4,047

Want to know the exact value of a "random" number?
The new text offers to write reg## numbers! example: SSC: code: Text: code: Jesus loves you [yes, you] so much, he even died for you so that you will not need to die, but live forever 
17th January 2004, 10:51  #178 
Major Dude
Join Date: Jan 2003
Location: Mumbai, India
Posts: 787

Hey, if you want the number of seconds elapsed after starting the AVS preset, use:
init: sec=gettime(0); frame: t=gettime(sec); http://home.iitb.ac*****~shreyaspotnis 
17th January 2004, 20:04  #179 
Major Dude

A guide to Cubic Ligation
For this, d/l the attached file (Cubic Ligation) (It also includes the txt file)
it is NOT the same thing as the one in the forums. do NOT replace. Prerequisite knowledge : SSC knowledge, 3D SSC knowledge, global variables. CL is mostly a technical doodle for me, but hey, it turned out sexah :P It only has two distinct scopes, an assigner and many drones. By a little coding "magic" I was able to make the cube configure itself when more drones are added... nifty huh? For tutoring purposes, I will assume that you know the "old" avs functions but has no idea on the new stuffs [namely loop(, gmegabuf(, assign(, and exec3(] Unlikely, but ah well. Read and learn. (please? :P) /////\\\\\ First, the drones (or mindless cubes in this matter). They're any of the scopes after the comment inside the list. The init only has the n value and a remnant from my SSC template (namely pi=acos(1). Never deleted that for some reason...). The point part only describes the cube, rotations, and using skip for unnecessant points instead of simple blacking out. Nifty to me, but not sure about you  We won't go into that, but tell me if you think I should... Anyways, on to the important stuff  The Frame section. For flexibility, all of the scopes are the same, and yet they correctly fade and resize according to their number. This, people, is the one of the useful uses of global variables. reg00 is a counter, going by 10s. The first drone increases reg00 by 10 once, so reg00 is 10 for that scope. The second scope adds another 10, so reg00 is 20 for that scope. Once reg00 reaches the last scope, it will pass through the assigner scope again. The assigner does some stuffs with the value and resets reg00 to zero and the cycle starts again. It works like a pcounter in a scope if you've done p2p coding before. Next is r. It's just the size of the scope  It's simply the counter times "dif" (more on that when we get to the assigner). This is how the scope adjusts itself to the crowd sizewise Then there's c1. It creates the bw gradient from the first to last. What is reg08, you ask? It is only the final value of reg00 before it is reset. This way, you can get the upper bound of reg00 and a correct gradient can be made. After that is the recall from the global array (gmegabuf). The assigned value counts down instead of counting up, more on that on the assigner section. So why was the counting done in tens? Well, for easy recalling. The recalled variable is simply the max number minus the current number plus another number. since the former two are counted in tens, there are 10 possible subvalues for each number. The third number is the subvalue number. xrotation is 1, yrotation is 2, zrotation is 3. Quite a bit easier to code than to have clusters dedicated to each rotation to me There's also subvalue #6 in the c1 line  It's the onbeat whiting. Now go back to the point section. Scroll all the way down. As you can see, there's another gmegabuf section. The xmovement is subvalue #4, and the ymovement is subvalue #5. After the gmegabuf(s, there's the rotation sines and cosines and the rgb assignment. If you need any tutoring there, you're looking at the wrong place. So how does the delay effect happen? That's next, in the assigner. (end drone section) ///\\\ Second, the (pretty huge) [and halfway 1337] assigner. It's the very first scope, if you don't know which one it is. First thing that you get to see is what most people are meant to see  dif, the distance variable, and reg51, the aspect ratio. Nothing amazing there. Now scroll down past the first comment block, down to reg01. If reg01 is now in the topmost line, you should be able to see the assigns. This set of assigns (and any further ones that begin a line) are the initial settings of the rotations. The leader cube (smallest, right after the comment) gets to use this value directly. Next, scroll until the first loop( is at top. This is the heart of the delay effect (as are the later loops). This follows p2p assigning quite closely. First, there's reg00 as the amount of times it is repeated. A bit of an overkill, but I don't care :P (Seriously though, if you're using loop yourself, use the amount of loops needed plus one just in case. don't be wasteful and lazy like me. please?) After the amount of loops, there's the exec3. I know that the help file only shows exec2, but exec3 exists. It's a bit like exec2 except that it executes two things before returning the value (of the third stuff). First is the pcounter, assigned using  surprise surprise  assign(. Just think of the comma as an equal sign. Second is the delay effect. It takes a certain part of an array and assigns to it the part of the array ten "steps" forward. (one step if you count the units as a subvalue like me). Because the assignment "sweeps" from zero up, the nth unit before the assigned unit needs n passes to be assigned. Since this is calculated per frame, it also takes n frames to be assigned, and so we have our delay effect. Gotta love niftiness. A couple lines down is another assigner for xy movement, then onbeat lighting. You may notice by now the repeated p=0. Well, p is set to a much higher number at the end of each loop, so it needs to be reset. Last is a familiar sight  reg00 and reg08/9. As you can see, reg08 is set to reg00 right before reg00 is reset to 0. There's the onBeat, nothing special there. ////// And that's... it I guess. Implement as you will, no direct ripping thank you. Coin me too Challenge : Fix the delayed start if you wish. It's fixed in the final version [soon to leave, sirs] 
22nd January 2004, 04:46  #180 
Major Dude
Join Date: May 2003
Location: Australia
Posts: 1,353

Nice work!
Very efficiently coded. Thanks for the tut nic 
30th January 2004, 04:37  #181 
Major Dude

I too would like a few pointers (not to search the forum) on how to make squares and circles with SSC...ne?

30th January 2004, 05:57  #182 
Senior Member
Join Date: Oct 2003
Posts: 272

a=2*$pi*i;
r=1; x=r*cos(a); y=r*sin(a); that'll give you a circle of radius 1. n=5;  a=2*$pi*i+$pi/4; r=1; x=r*cos(a); y=r*sin(a); little change but that'll get you a square in one scope. Just trig. 
30th January 2004, 22:46  #183 
Major Dude

A better square (in some aspects):
r=i*$pi*2; d=1/abs(cos(asin(sin(r*2))*0.5)); x=sin(r+rot)*d+movex; y=cos(r+rot)*d+movey; [soon to leave, sirs] 
13th February 2004, 22:04  #184 
Forum King
Join Date: Dec 2002
Location: Manchester
Posts: 6,470

Is using two buffers faster than using an effect list?

13th February 2004, 22:42  #185 
Forum King
Join Date: Dec 2002
Location: Manchester
Posts: 6,470

by the way, it's for this particularly slow nightmarish thing.

23rd February 2004, 08:48  #186 
Senior Member
Join Date: Nov 2002
Location: Australia
Posts: 190

<Image removed due to size. the content was also not very appropriate, even if it was intended as a joke.
 UnConeD> Last edited by VisualAgnosia; 23rd February 2004 at 09:07. 
24th February 2004, 17:19  #187 
Senior Member
Join Date: Nov 2002
Location: santiago, chile
Posts: 152

little question: how can i have an effect list enabled only for a certain amount of frames?

24th February 2004, 17:29  #188 
Senior Member
Join Date: Oct 2003
Posts: 272

use the override feature.

24th February 2004, 18:09  #189 
Senior Member
Join Date: Nov 2002
Location: santiago, chile
Posts: 152

yeah i thought about that too, but any hits on how to code it? i know it's probably easy, but everything i tried didn't work.

24th February 2004, 18:40  #190 
Senior Member
Join Date: Oct 2003
Posts: 272

int:
x=# of frames you want to run it for; frame: enabled=if(above(x,0),1,0); x=x1; 
24th February 2004, 20:45  #191 
Senior Member
Join Date: Nov 2002
Location: santiago, chile
Posts: 152

thanks a lot there

2nd March 2004, 21:44  #192 
Senior Member
Join Date: May 2003
Posts: 101

what about just
enabled=above(x,0); Actualy I like version with the smooth alpha fadeout: code: ...where s is (numberofframes+10)/10 Set outpput blend to adjustable for this one 
16th March 2004, 04:32  #193 
Forum King

In response to the post about 'making squares and circles' I thought I'd write a little something about creating geometry in general, with some example code of course.
For a start I'll quickly cover the 'point to point' method of creating a wireframe object. The idea is one that I've been using since I came into AVS (remember that dodecahedron anyone?) The basic idea is that you increment a counter every time you draw a point and then use this value with conditional structures to decide what should be drawn for each individual point. Example: (Lines SSC) init: // Square n=5; frame: // Set our point counter to 0 counter = 0; // Calculate aspect ratio of AVS display (unimportant) aspectratio = h/w; beat: <nothing> point: /* Basically for each point we want to draw we have a section in this big expresion for x (and also in the later y expression). For example, when the first point is drawn counter = 0 so the 'first line' sets x = 1 when counter = 0 since 1 is the x coord of our desired first point for the square. This is repeated for every possible value of counter until all of the required xcoords have been assigned. Since nothing is done if counter != 0 for the 'first line' we can add the subsequent expressions without affecting any of the other points. */ x = 1 * equal(counter,0) + 1 * equal(counter,1) + 1 * equal(counter,2) + 1 * equal(counter,3) + 1 * equal(counter,4); y = 1 * equal(counter,0) + 1 * equal(counter,1) + 1 * equal(counter,2) + 1 * equal(counter,3) + 1 * equal(counter,4); // Scale the square so we can see the top and bottom edges (unimportant) x=x*.5;y=y*.5; // Increment the point counter counter = counter + 1; // Correct aspect ratio (unimportant) x = x* aspectratio; (End SSC) Note that 5 points are used since AVS needs two points to draw a line so the first line goes from counter=0 to counter=1, the second from counter=1 to counter=2, the third from counter=2 to counter=3 and the final one from counter=3 to counter=4 (which is the same as counter=0 for all intents and purposes). You can optimise and tidy this up a lot, I just made a big mess to make everything as clear as possible. This method is great for a lot of objects and can be extended to 3D wireframes pretty easily (see 'Golden Dodecahedron' from Jheriko  Pack VI for an example of this done with a slightly different implementation (ifs instead of equals)). However we can't draw a circle from it or a sphere either. When you want to draw curved surfaces in AVS you have to use some maths and typically this can be difficult if you don't already know the answer. Most of us for instance know that x=sin(2*$PI*i);y=cos(2*$PI*i); creates a circle.. but why does this work? Well, you can get this from experimentation (which is how I first figured this out when I started at qbasic.. guesswork) but a much better way is logic. There is no generic way to get an equation for a shape, however some common sense and a good knowledge of maths will help a lot. For instance I can say that x=sin(t), y=cos(t) is clearly a circle due to the trig identity sin(t)^2 + cos(t)^2 = 1 so the hypotenuse of the triangle made by the points (0,0) (x,0) (x,y) is always going to be 1 (draw a diagram if you can't see this), and so this hypotenuse is always going to be the radius of a unit circle about the origin. Make sense? Lets assume for a moment that we have no idea about how to make a sphere. It would seem logical that we can somehow extend the circle definition into three dimensions to get a sphere. This infact can be done by using the sin(t)^2+cos(t)^2=1 identity. sin(t)^2 + cos(t)^2 = 1 sin(u)^2 + cos(u)^2 = 1 multiplying these together gives us something which still = 1 sin(t)^2 sin(u)^2 + cos(t)^2 sin(u)^2 + sin(t)^2 cos(u)^2 + cos(t)^2 cos(u)^2 = 1 However this has four 'components' so we must eliminate one of them to get something we can equivalate to the x^2+y^2+z^2=1 which defines a unit sphere. Noting that sin(t)^2 + cos(t)^2 = 1 and combining the last two 'components' together: sin(t)^2 sin(u)^2 + cos(t)^2 sin(u)^2 + (sin(t)^2 + cos(t)^2)cos(u)^2 = 1 sin(t)^2 sin(u)^2 + cos(t)^2 sin(u)^2 + cos(u)^2 = 1 taking each of these components and equivalating them to x^2+y^2+z^2=1 we get x=sin(t)sin(u); y=cos(t)cos(u); z=cos(u); The actual definitions of t and u in code will affect which points are drawn and a simple relation like t=2*u will create a specific curve which looks little like a sphere, using something like t=200*u will create a 'spiral sphere' type shape. When trying to make a specific shape when you can't find an equation for it the best approach is to start with what you know about that shape and then exploit that with your mathematical knowledge to create a parameterisation. Another good example would be a torus. The idea I used to make 'Space Torus' in Jheriko  Pack VIII was simply to define a circle with the torus minor radius and shift it along an axis by the major radius then to perform a matrix rotation on this to 'sweep out' a torus. All I had to do was use the appropriate rotation matrix out of the 3D transformation from the SSC to multiply with the existing offset circle definition then to use a second parameter to tell it how much to rotate by rather than using a fixed value every frame. Often once you have found a basic shape that works you can modify it too. Playing around with an equation can create interesting effects, sometimes some logical thought process can help here too, for instance the method I described for the torus above can be easily extended to create other shapes by using different rotations or initial shapes, these shapes will often be a lot more interesting because you decided to try it out for some reason... rather than just blundering upon it by random code changes. Remember that figuring something out for yourself will often give you a much deeper understanding of it than just 'learning it from a book'. If you find it really difficult to come up with your own shapes, or to convert your knowledge of a shape into code, then take a look around the internet on math resourse sites and such, you are bound to find some interesting parametric shapes eventually. Hope this helps someone out. 
10th April 2004, 04:53  #194 
Banned

I learned creating AVS from Tips&Tricks.Thanks

29th April 2004, 03:22  #195 
Major Dude

Fastest rectangle similiar to the window, ready to be scaled (maybe rotated) :
INIT: n=5 FRAME: p=0; PIXEL: p=p+1; x=(p1)&21; y=p&21; linesize=a; [aspect ratio] [rotation] ...Where a is the pixel size that you wish. (Consider multiplying both x and y by 1{1/[h or w, accordingly]} so that the pixel difference between the topleft and bottomright is nulled.) [soon to leave, sirs] 
29th April 2004, 18:44  #196 
Major Dude
Join Date: Feb 2004
Location: Germany
Posts: 580

you forgot some brackets there
and it can still be optimized x=(p&2)1; p=p+1; y=(p&2)1; If you can't say something nice, say something surrealistic. 
15th May 2004, 07:09  #197 
Junior Member
Join Date: May 2004
Location: south africa
Posts: 3

thanx man

27th May 2004, 12:45  #198 
Major Dude
Join Date: Feb 2004
Location: Germany
Posts: 580

code: this generates a fancy colorcycling triangle without any ifs or equals If you can't say something nice, say something surrealistic. 
1st June 2004, 21:36  #199 
Junior Member
Join Date: May 2004
Posts: 24


2nd June 2004, 23:19  #200 
Junior Member
Join Date: May 2004
Posts: 24

Someone might find it useful. Anyone?


Thread Tools  Search this Thread 
Display Modes  

