Using the cross product to manipulate particles.
Spinning particles with cross products in VEX.
Date Created:Friday December 29th, 2006 03:41 AM
Date Modified:Tuesday July 29th, 2008 09:04 PM
/*
*
* Author: Dan Lynch
*
*/
#pragma range switcher 0 2
#pragma hint axis direction
#pragma choice switcher "0" "Add Velocity"
#pragma choice switcher "1" "Set Acceleration"
#pragma choice switcher "2" "Set Velocity"
#pragma hint sinswitch toggle
#pragma hint normalizeswitch toggle
#define DEGTORAD 3.14/360
pop
d_spin
(
vector axis = {0,1,0};
string switcher="0";
int sinswitch=0, normalizeswitch=0;
)
{
// this when multiplied at the end gives each particle
// their own speed instead of setting all particles to the same speed.
float nspeed = length(v);
if (age==0 && sinswitch) {
P = sin(Frame*(15 * DEGTORAD))*sin(Frame * DEGTORAD)*(10);
}
vector nP = -P * {1,0,1};
if ( P.x == 0 && P.z == 0 ) {
} else {
if (switcher == "0") {
v += cross(nP, axis);
} else if (switcher == "1") {
accel = cross(nP, axis);
} else {
v = cross(nP, axis);
}
}
if (normalizeswitch) v = normalize(v)*nspeed;
}
Downloads:
Download: crazy_spinner.vfl 1 KB
Please login or Click Here to register for downloads
Crazy Spinner by Dan Lynch
is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 United States License
Based on a work at www.3daet.com
Permissions beyond the scope of this license may be available at http://www.3daet.com
