AJ Sindri
26th November 2007 01:35 UTC
Mouse Swirls: Drawing in AVS
This preset is the cornerstone of a few project I've been working on. It basicaly attaches about 30 points to your mouse via a spring like force. The farther away the point is from the mouse, the more force is applied. Each point's "spring" has a different tension.
The Code:
[
//init:
n=2;
det=20;
// How strong the spring is
c=1
//frame:
lpx=px;
lpy=py;
// The position of the point in the last frame
px=px/1.05+cx/2;
py=py/1.05+cy/2;
// Modifies the x and y position of the point based on the momentum of the point and friction (1/1.05)
cx=cx-(px-mx)/det;
cy=cy-(py-my)/det;
// Calculates the acceleration of the point bases on it's position and the mouse's position
c=(px-lpx)/abs(px-lpx)
// Switiches the line around (for a drawing error)
//point:
mx=getkbmouse(1);
my=getkbmouse(2);
ang=atan((py-lpy)/(px-lpx));
dist=sqrt(sqr(lpx-px)+sqr(lpy-py));
x=cos(ang)*i*dist*-c+px;
y=sin(ang)*i*dist*-c+py;
]
For each superscope, "det" is set from 13 to 21 with 1/4 increase from scope to scope.
:igor: this got really really old when i would find an error is the code and the would have to modify each superscope seperatly :igor: . If you have an easyer way of doing this PLEASE post a comment.
With this you can draw swrils, matrixs, tornadoes etc. It's pretty addictive.
What I'm working on now is the same concept but istead of using spring, i'm trying to use gravity fields (not fun). right now i'm convenced that newtons is a fruad and his gravity = force/(r squared) doesn't work.
The file attached is a remix of mouse swirls. Have fun
Here is my equation as of now for two plantets with the position of your mouse and at .5,-.5 (sorry it's really messy):
init:
n=2;
divis=1.01;
det=15;
c=1
frame:
mx=getkbmouse(1);
my=getkbmouse(2);
lpx=px;
lpy=py;
px=px+cx/2+cxb/2;
py=py+cy/2+cyb/2;
ang1=atan((lpy-my)/(lpx-mx));
ang2=atan((lpy-.5)/(lpx-.5));
cx=cx/divis-(px-mx)/det/(pow(abs(mx-px),2)*15+1)*abs(cos(ang1));
cy=cy/divis-(py-my)/det/(pow(abs(my-py),2)*15+1)*abs(sin(ang1));
cxb=cxb/divis-(px-.5)/det/(pow(abs(.5-px),2)*15+1)*abs(cos(ang2));
cyb=cyb/divis-(py-.5)/det/(pow(abs(.5-py),2)*15+1)*abs(sin(ang2));
c=(px-lpx)/abs(px-lpx);
ang=atan((py-lpy)/(px-lpx));
dist=sqrt(sqr(lpx-px)+sqr(lpy-py));
point:
x=cos(ang)*i*dist*-c+px;
y=sin(ang)*i*dist*-c+py;
It too complicated :weird:
If you have any advice, I'd happily accept it!
Nanakiwurkz
28th November 2007 00:59 UTC
hmm this one seems to be in the language of the pros.
sorry man my ssc skills are only limited. but i like the concept.
Grandchild
28th November 2007 12:58 UTC
very nice. i really enjoyed playing with it and the galaxy-like shapes you can create when you leave the mouse still for some time.
the thing you're looking for to put it into one scope is called loop() and megabuf(). the first being a sort of "while" loop and the second one is one of the two built-in arrays.
i'd do it but i've got to so some homework first.
maybe i'll look into it again later tody or tomorrow...
amazing work!
gc
/edit: made this :) i like this preset!
http://img440.imageshack.us/my.php?i...ringavswm4.png
AJ Sindri
29th November 2007 02:14 UTC
Thx
Thank for your comment. I saw you picture, Pretty sweet :cool:. Once you get your acceleration up, move your mouse in a line as the points are swrilling toward it to make a kind of tornado effect.
ShatteredView
30th November 2007 16:32 UTC
This is an awesome concept!
I think it would be cool to add some music response to it, possibly by fading or color change, but it's still awesome.
AJ Sindri
30th November 2007 23:00 UTC
Music Based Mouse Swirl
Thank for your comment. I seems that we think alike because I have already maded a music based swirl attractor, but I didn't post it because I'm still working on it, but I guess that that's what this forum is for.
Sorry it's not the best. I'd love to hear your comments and criticism. I hope you like it:
PAK-9
1st December 2007 21:16 UTC
AJ there is a simpler way than having to duplicate superscopes, it basically involves caching each line segment into the gmegabuf and reading them out to render in a loop. I recommend you read the programming guide for more help on loops in avs. Unfortunately the language gets very ugly with loops so I recommend getting avstrans... and to be honest, this particular problem wouldnt make for a simple introduction.
There is an alternative time saver.. you can set a register (for example reg01) to 13 in a ssc right at the top of your preset, then in your ssc's that do the actual work, increment the register by 0.25 and use that as your det value. You would still need to delete and recreate each ssc on code chages, but it would just be deleting them and hitting x2 a load of times rather than manually editing each scope.
[edit] nice preset btw :)[/edit]
HuRriC4nE
23rd December 2007 17:29 UTC
that could be very cool in 3d...
but the movement would have to be created in random.
hm maybe i'll try something...
right now i'm doing my 3d-flow stuff..
Nanakiwurkz
24th December 2007 02:01 UTC
hmm i have a windows bounce detection on this so far in my remix but now that i think about the movement would be very easy to tranlaste to 3d. speaking of which that the lines move in a sort of fashion that reminds me of a delay effect that was used by Nic in his cubic ligation.
No one please use that theme till i try it out. i want to see what it would be like. i'm currently experimenting with counters and delay effects so i might be able to pull something out of my idiotic mind. rfol