Krash
19th October 2001, 14:28
WARNING: This is NOT a conventional preset. In fact, as I am about to give to you, it's an extremely boring preset, and consists of a white circle in one corner. The beauty of this preset is the mathematics, and how customisable it is. So unless you want to get your hands dirty in editing presets, steer clear of this one.
Rightio, now that I've got that sorted.
Have you ever wondered just how much you could do with MilkDrop? I don't mean the blending effects that are possible - we've all seen what can be done with those. What I mean, is complex mathematics that is much more than random strings of equations. Well, I endeavoured to find out, and the result is:
A semi-realistic, and fully customisable, PHYSICS ENGINE inside milkdrop, which simulates a bouncing ball.
At this point, I'm going to explain what each of my variables actually define, and how you go about changing the preset.
right_extreme: This variable defines the invisible wall on the right hand side that the ball will bounce off. a value of 0.5 is the middle of the screeen, a value of 1 is the right side of the screen. Higher than 1 is off the screen.
left_extreme: The opposite of right_extreme. A value of 0 is the left side of the screen. Less than 0 is off the screen.
top_extreme: An invisible ceiling that the ball can bounce off. A value of 1 is the top of the screen, 0.5 is the middle of the screen.
bottom_extreme: The invisible floor - 0 is the bottom of the screen.
Note that it's the CENTRE of the ball that does the bouncing, so it's best to have the invisible walls somewhat inside the screen, or it looks a bit weird.
x_start_speed: What it says - this is the initial horizontal speed of the ball. Positive is to the right, negative is to the left. Small values (around 0.01) are recommended.
x_speed_loss: Simulates the loss (or gain) of horizontal velocity whenever the ball bounces. A value of 1 will remove the effect. Values less than 1 will slow the ball down until it eventually stops. Values greater than 1 will gradually speed it up, until it flies off the screen, never to be seen again. Negative values will just do weird stuff. Don't go there.
gravity: Exactly what it says. Negative values will work just fine.
y_start_speed: This should be obvious. Consider it proportional to the x_start_speed.
y_speed_loss: This is a boolean value - yes or no, on or off. A value of 0, and the ball will bounce forever. If you set it to 1, eventually the ball will rest on the ground. The time it takes to stop bouncing is realtive to gravity.
initialise: This is the most important value, and the one you'll need to change if you want any of your other changes to work. Note that during the preset, initialise is declared twice. ONLY change the first one.
Any time you want to change one of the values, go to the per_frame equations, set initialise to 1, and make your changes, then hit ctrl-enter. You will see the ball move to the bottom right corner. Then change initialise back to 0, and hit ctrl-enter again. The ball will start its merry journey.
Change any of the other equations at your own peril, but I will explain what the variables represent, so it's a bit easier to understand.
direction: Whether the ball is moving left or right.
x_speed: This should be obvious.
y_speed: Again, it should be obvious - it's used to allow the parabolic arcs to work properly.
wave_x_mod: Used to calculate the x position of the ball, relative to the centre of the screen.
wave_y_mod: Used to calculate the y position of the ball, relative to bottom_extreme.
bounce: detects whether or not the ball has struck the ground or ceiling, and as such, should reverse its direction.
Okay, I think that's everything. Now, it's time for the preset. Have some fun with it. I'd be pretty surprised if anyone bothered to make something pretty out of this, but by all means, give it a shot.
=============
Bouncing Ball
=============
[preset00]
fRating=3.000000
fGammaAdj=2.000000
fDecay=0.980000
fVideoEchoZoom=1.000000
fVideoEchoAlpha=0.000000
nVideoEchoOrientation=0
nWaveMode=0
bAdditiveWaves=0
bWaveDots=0
bModWaveAlphaByVolume=0
bMaximizeWaveColor=0
bTexWrap=0
bDarkenCenter=0
bMotionVectorsOn=0
bRedBlueStereo=0
nMotionVectorsX=12
nMotionVectorsY=9
bBrighten=0
bDarken=0
bSolarize=0
bInvert=0
fWaveAlpha=1.000000
fWaveScale=0.010000
fWaveSmoothing=0.750000
fWaveParam=-0.380000
fModWaveAlphaStart=0.750000
fModWaveAlphaEnd=0.950000
fWarpAnimSpeed=1.000000
fWarpScale=1.000000
fZoomExponent=1.000000
fShader=0.000000
zoom=1.000000
rot=0.000000
cx=0.500000
cy=0.500000
dx=0.000000
dy=0.000000
warp=1.000000
sx=1.000000
sy=1.000000
wave_r=0.500000
wave_g=0.500000
wave_b=0.500000
wave_x=0.500000
wave_y=0.500000
ob_size=0.000000
ob_r=0.000000
ob_g=0.000000
ob_b=0.000000
ob_a=0.000000
ib_size=0.000000
ib_r=0.000000
ib_g=0.000000
ib_b=0.000000
ib_a=0.000000
per_frame_1=warp=0;
per_frame_2=dx=-0.0005;
per_frame_3=dy=-0.0005;
per_frame_4=right_extreme = 0.9;
per_frame_5=left_extreme = 0.1;
per_frame_6=bottom_extreme = 0.1;
per_frame_7=top_extreme = 0.9;
per_frame_8=x_start_speed = 0.01;
per_frame_9=x_speed_loss = 1;
per_frame_10=gravity = 0.002;
per_frame_11=y_start_speed = 0.05;
per_frame_12=y_speed_loss = 0;
per_frame_13=initialise = 1;
per_frame_14=direction = if(equal(initialise,1),1,direction);
per_frame_15=x_speed = if(equal(initialise,1),x_start_speed,x_speed);
per_frame_16=y_speed = if(equal(initialise,1),y_start_speed,y_speed);
per_frame_17=wave_x_mod = right_extreme - 0.5;
per_frame_18=wave_y_mod = if(equal(initialise,1),0.001,wave_y_mod);
per_frame_19=initialise = 0;
per_frame_20=direction = if(above(wave_x_mod,(right_extreme - 0.5)),-1,if(below(wave_x_mod,(left_extreme - 0.5)),1,direction));
per_frame_21=bounce = below(wave_y_mod,0) + equal(wave_y_mod,0) + above(wave_y_mod,(top_extreme - bottom_extreme)) + equal(wave_y_mod,(top_extreme - bottom_extreme));
per_frame_22=x_speed = x_speed*if(equal(bounce,0),1,x_speed_loss)*if(above(wave_x_mod,(right_extreme - 0.5)),x_speed_loss,if(below(wave_x_mod,(left_extreme - 0.5)),x_speed_loss,1))*if(equal(y_speed,0),x_speed_loss,1);
per_frame_23=wave_x_mod = wave_x_mod + direction*x_speed;
per_frame_24=wave_x = wave_x + wave_x_mod;
per_frame_25=y_speed = y_speed - if(equal(bounce,0),if(equal(y_speed_loss,1),0,gravity),2*y_speed) - equal(y_speed_loss,1)*gravity;
per_frame_26=y_speed = if( above( wave_y_mod, 0 ), if( below( wave_y_mod, 0.001 ), if( below( abs( y_speed ), gravity*1.01 ), 0, y_speed ), y_speed ), if(below(y_speed, 0), -y_speed*0.9, y_speed));
per_frame_27=wave_y_mod = wave_y_mod + y_speed;
per_frame_28=wave_y = bottom_extreme + wave_y_mod;
Enjoy.
- Krash
Rightio, now that I've got that sorted.
Have you ever wondered just how much you could do with MilkDrop? I don't mean the blending effects that are possible - we've all seen what can be done with those. What I mean, is complex mathematics that is much more than random strings of equations. Well, I endeavoured to find out, and the result is:
A semi-realistic, and fully customisable, PHYSICS ENGINE inside milkdrop, which simulates a bouncing ball.
At this point, I'm going to explain what each of my variables actually define, and how you go about changing the preset.
right_extreme: This variable defines the invisible wall on the right hand side that the ball will bounce off. a value of 0.5 is the middle of the screeen, a value of 1 is the right side of the screen. Higher than 1 is off the screen.
left_extreme: The opposite of right_extreme. A value of 0 is the left side of the screen. Less than 0 is off the screen.
top_extreme: An invisible ceiling that the ball can bounce off. A value of 1 is the top of the screen, 0.5 is the middle of the screen.
bottom_extreme: The invisible floor - 0 is the bottom of the screen.
Note that it's the CENTRE of the ball that does the bouncing, so it's best to have the invisible walls somewhat inside the screen, or it looks a bit weird.
x_start_speed: What it says - this is the initial horizontal speed of the ball. Positive is to the right, negative is to the left. Small values (around 0.01) are recommended.
x_speed_loss: Simulates the loss (or gain) of horizontal velocity whenever the ball bounces. A value of 1 will remove the effect. Values less than 1 will slow the ball down until it eventually stops. Values greater than 1 will gradually speed it up, until it flies off the screen, never to be seen again. Negative values will just do weird stuff. Don't go there.
gravity: Exactly what it says. Negative values will work just fine.
y_start_speed: This should be obvious. Consider it proportional to the x_start_speed.
y_speed_loss: This is a boolean value - yes or no, on or off. A value of 0, and the ball will bounce forever. If you set it to 1, eventually the ball will rest on the ground. The time it takes to stop bouncing is realtive to gravity.
initialise: This is the most important value, and the one you'll need to change if you want any of your other changes to work. Note that during the preset, initialise is declared twice. ONLY change the first one.
Any time you want to change one of the values, go to the per_frame equations, set initialise to 1, and make your changes, then hit ctrl-enter. You will see the ball move to the bottom right corner. Then change initialise back to 0, and hit ctrl-enter again. The ball will start its merry journey.
Change any of the other equations at your own peril, but I will explain what the variables represent, so it's a bit easier to understand.
direction: Whether the ball is moving left or right.
x_speed: This should be obvious.
y_speed: Again, it should be obvious - it's used to allow the parabolic arcs to work properly.
wave_x_mod: Used to calculate the x position of the ball, relative to the centre of the screen.
wave_y_mod: Used to calculate the y position of the ball, relative to bottom_extreme.
bounce: detects whether or not the ball has struck the ground or ceiling, and as such, should reverse its direction.
Okay, I think that's everything. Now, it's time for the preset. Have some fun with it. I'd be pretty surprised if anyone bothered to make something pretty out of this, but by all means, give it a shot.
=============
Bouncing Ball
=============
[preset00]
fRating=3.000000
fGammaAdj=2.000000
fDecay=0.980000
fVideoEchoZoom=1.000000
fVideoEchoAlpha=0.000000
nVideoEchoOrientation=0
nWaveMode=0
bAdditiveWaves=0
bWaveDots=0
bModWaveAlphaByVolume=0
bMaximizeWaveColor=0
bTexWrap=0
bDarkenCenter=0
bMotionVectorsOn=0
bRedBlueStereo=0
nMotionVectorsX=12
nMotionVectorsY=9
bBrighten=0
bDarken=0
bSolarize=0
bInvert=0
fWaveAlpha=1.000000
fWaveScale=0.010000
fWaveSmoothing=0.750000
fWaveParam=-0.380000
fModWaveAlphaStart=0.750000
fModWaveAlphaEnd=0.950000
fWarpAnimSpeed=1.000000
fWarpScale=1.000000
fZoomExponent=1.000000
fShader=0.000000
zoom=1.000000
rot=0.000000
cx=0.500000
cy=0.500000
dx=0.000000
dy=0.000000
warp=1.000000
sx=1.000000
sy=1.000000
wave_r=0.500000
wave_g=0.500000
wave_b=0.500000
wave_x=0.500000
wave_y=0.500000
ob_size=0.000000
ob_r=0.000000
ob_g=0.000000
ob_b=0.000000
ob_a=0.000000
ib_size=0.000000
ib_r=0.000000
ib_g=0.000000
ib_b=0.000000
ib_a=0.000000
per_frame_1=warp=0;
per_frame_2=dx=-0.0005;
per_frame_3=dy=-0.0005;
per_frame_4=right_extreme = 0.9;
per_frame_5=left_extreme = 0.1;
per_frame_6=bottom_extreme = 0.1;
per_frame_7=top_extreme = 0.9;
per_frame_8=x_start_speed = 0.01;
per_frame_9=x_speed_loss = 1;
per_frame_10=gravity = 0.002;
per_frame_11=y_start_speed = 0.05;
per_frame_12=y_speed_loss = 0;
per_frame_13=initialise = 1;
per_frame_14=direction = if(equal(initialise,1),1,direction);
per_frame_15=x_speed = if(equal(initialise,1),x_start_speed,x_speed);
per_frame_16=y_speed = if(equal(initialise,1),y_start_speed,y_speed);
per_frame_17=wave_x_mod = right_extreme - 0.5;
per_frame_18=wave_y_mod = if(equal(initialise,1),0.001,wave_y_mod);
per_frame_19=initialise = 0;
per_frame_20=direction = if(above(wave_x_mod,(right_extreme - 0.5)),-1,if(below(wave_x_mod,(left_extreme - 0.5)),1,direction));
per_frame_21=bounce = below(wave_y_mod,0) + equal(wave_y_mod,0) + above(wave_y_mod,(top_extreme - bottom_extreme)) + equal(wave_y_mod,(top_extreme - bottom_extreme));
per_frame_22=x_speed = x_speed*if(equal(bounce,0),1,x_speed_loss)*if(above(wave_x_mod,(right_extreme - 0.5)),x_speed_loss,if(below(wave_x_mod,(left_extreme - 0.5)),x_speed_loss,1))*if(equal(y_speed,0),x_speed_loss,1);
per_frame_23=wave_x_mod = wave_x_mod + direction*x_speed;
per_frame_24=wave_x = wave_x + wave_x_mod;
per_frame_25=y_speed = y_speed - if(equal(bounce,0),if(equal(y_speed_loss,1),0,gravity),2*y_speed) - equal(y_speed_loss,1)*gravity;
per_frame_26=y_speed = if( above( wave_y_mod, 0 ), if( below( wave_y_mod, 0.001 ), if( below( abs( y_speed ), gravity*1.01 ), 0, y_speed ), y_speed ), if(below(y_speed, 0), -y_speed*0.9, y_speed));
per_frame_27=wave_y_mod = wave_y_mod + y_speed;
per_frame_28=wave_y = bottom_extreme + wave_y_mod;
Enjoy.
- Krash