Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # A G'MIC implementation of a system of 3D repulsive particules
- # (Author: David Tschumperlé, April 2020).
- #-----------------------------------------------------------------
- particles3d :
- 512,512,1,3
- 1,900,1,3,u(w#-1-1)
- t=0
- do
- xrep,yrep,zrep={w#0*(0.5+0.3*[cos(4.2*$t),sin(2.7*$t),cos(1.9*$t)])}
- t+=0.01
- # Render particles.
- N=$!
- repeat h circle3d {"I[#1,"$>"]"},4 done
- +3d[$N--1] col3d. 255 o3d. 0.75
- circle3d $xrep,$yrep,$zrep,20 col3d. 255,0,0
- +3d[-2,-1]
- box3d 512,512,512 p3d. 1 o3d. 0.4 +3d[-2,-1]
- -3d. {0,[w,w,w]/2} r3d. 1,1,0,34 #r3d. 0,1,0,{80*$t}
- f3d 400
- +f[0] 0 j3d. ..,50%,50%,150,1,2
- *[0] 'd=y/h;[0.24+0.75*d,0.92,0.99-0.3*d]' max[0,-1]
- rm. w[0]
- # Compute and apply particle velocity.
- +. '"*
- add_veloc(Q,strength,sigma) = (
- U = P - Q;
- nU = norm(U);
- U/=max(1e-5,nU);
- w = strength*(sigma>0?gauss(nU,sigma,0):1/(1e-5+nU));
- sumw+=w;
- V+=w*U;
- );
- P = I(#1);
- V = [ 0,0,0 ];
- sumw = 0;
- for (p = 0, p<h, ++p, p!=y?add_veloc(I[#1,p],5,20));
- const W = w#0-1;
- add_veloc([0,P[1],P[2]],10,0);
- add_veloc([P[0],0,P[2]],10,0);
- add_veloc([P[0],P[1],0],10,0);
- add_veloc([W,P[1],P[2]],10,0);
- add_veloc([P[0],W,P[2]],10,0);
- add_veloc([P[0],P[1],W],10,0);
- add_veloc(["$xrep,$yrep,$zrep"],50,70);
- 2.8*V/sumw"'
- wait 30
- while {*}" && "!{*,ESC}
- rm w[] 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement