void pspRandomParticle::setBounds(CubeLimits *b){ if(b != nullptr){ bounds = b; pos = ofVec3f(rangedRandom(bounds->limits_x.min, bounds->limits_x.max), rangedRandom(bounds->limits_y.min, bounds->limits_y.max), rangedRandom(bounds->limits_z.min, bounds->limits_z.max)); posNext = ofVec3f(rangedRandom(bounds->limits_x.min, bounds->limits_x.max), rangedRandom(bounds->limits_y.min, bounds->limits_y.max), rangedRandom(bounds->limits_z.min, bounds->limits_z.max)); } }
void pspRandomParticle::specificSetup(){ bounds = nullptr; size = 0.03; pos = ofVec3f(0., 0., 0.); vel = ofVec3f(rangedRandom(0.01, 0.3), rangedRandom(0.01, 0.3), rangedRandom(0.01, 0.3)); posNext = ofVec3f(rangedRandom(-0.5, 0.5), rangedRandom(-0.5, 0.5), rangedRandom(-0.5, 0.5)); }
int main(int argc, char *argv[]) { int min, max, count = 1; int i; if (argc != 3 && argc != 4) usage(); min = getInt(argv[1]); max = getInt(argv[2]); if (min >= max) usage(); if (argc == 4) count = getInt(argv[3]); initRandom(); for (i=0; i<count; ++i) printf("%d ", rangedRandom(min, max)); printf("\n"); return 0; }
void pspRandomParticle::specificUpdate(){ bool reach = true; float dx = posNext.x - pos.x; if(fabs(dx) > 0.01) { pos.x += dx * vel.x; reach = false; } float dy = posNext.y - pos.y; if(fabs(dy) > 0.01) { pos.y += dy * vel.y; reach = false; } float dz = posNext.z - pos.z; if(fabs(dz) > 0.01) { pos.z += dz * vel.z; reach = false; } if(reach){ vel = ofVec3f(rangedRandom(0.01, 0.3), rangedRandom(0.01, 0.3), rangedRandom(0.01, 0.3)); if(bounds != nullptr){ //cout<<endl<<bounds->limits_x.min; posNext = ofVec3f(rangedRandom(bounds->limits_x.min, bounds->limits_x.max), rangedRandom(bounds->limits_y.min, bounds->limits_y.max), rangedRandom(bounds->limits_z.min, bounds->limits_z.max)); } else{ posNext = ofVec3f(rangedRandom(-0.5, 0.5), rangedRandom(-0.5, 0.5), rangedRandom(-0.5, 0.5)); } //posNext = ofVec3f(rangedRandom(-0.5, 0.5), rangedRandom(-0.5, 0.5), rangedRandom(-0.5, 0.5)); //post("%lf %lf %lf", posCarNext.x, posCarNext.y, posCarNext.z); } }