00001
00006 #include "RandomForce.h"
00007 using namespace GraphicsLib;
00008 using namespace ParticleSystems;
00009 RandomForce::RandomForce(Vector *f, float a) : Force(f, a) {
00010 }
00011
00012 RandomForce::~RandomForce(){
00013 delete force;
00014 }
00015
00016 void RandomForce::applyForce(Vector *direction) {
00017
00018 if(attenuation) {
00019 (*direction).x += RandomNum((*force).x);
00020 (*direction).y += RandomNum((*force).y);
00021 (*direction).z += RandomNum((*force).z);
00022 (*direction).w += RandomNum((*force).w);
00023 } else {
00024 (*direction).x += (attenuation * RandomNum((*force).x));
00025 (*direction).y += (attenuation * RandomNum((*force).y));
00026 (*direction).z += (attenuation * RandomNum((*force).z));
00027 (*direction).w += (attenuation * RandomNum((*force).w));
00028 }
00029 }
00030
00031 void RandomForce::applyForce(GraphicsLib::Vector *direction, float *mass) {
00032
00033 if(attenuation) {
00034 (*direction).x += (RandomNum((*force).x))/(*mass);
00035 (*direction).y += (RandomNum((*force).y))/(*mass);
00036 (*direction).z += (RandomNum((*force).z))/(*mass);
00037 (*direction).w += (RandomNum((*force).w))/(*mass);
00038 } else {
00039 (*direction).x += (attenuation * RandomNum((*force).x))/(*mass);
00040 (*direction).y += (attenuation * RandomNum((*force).y))/(*mass);
00041 (*direction).z += (attenuation * RandomNum((*force).z))/(*mass);
00042 (*direction).w += (attenuation * RandomNum((*force).w))/(*mass);
00043 }
00044 }