Permalink
Browse files

add random velocities, compute rules when the weights are grater than…

… zero
  • Loading branch information...
1 parent a0d1195 commit a2d2971970440f4ad7f0cfd42446d48ab9d47eab Myrna Merced Serrano committed May 27, 2011
Showing with 27 additions and 17 deletions.
  1. +2 −2 boids_gordon/main.cpp
  2. +1 −0 rtpslib/render/Render.cpp
  3. +1 −1 rtpslib/render/SpriteRender.cpp
  4. +15 −6 rtpslib/system/FLOCK.cpp
  5. +8 −8 test/main_flock.cpp
View
@@ -132,14 +132,14 @@ void display()
//VF& vc = boids->vel_coh;
//glColor3f(1., 0., 0.);
- //vector_field(pos, boids->vel_coh, 100.); // vel, scale
+ vector_field(pos, boids->vel_coh, 100.); // vel, scale
glColor3f(0., 1., 0.);
//vector_field(pos, boids->vel_sep, 100.); // vel, scale
glColor3f(1.,1.,0.);
//VF& va = boids->vel_align;
- //vector_field(pos, boids->vel_align, 10.); // vel, scale
+ //vector_field(pos, boids->vel_align, 100.); // vel, scale
//for (int i=0; i < va.size(); i++) {
//va[i].print("va");
//}
@@ -611,6 +611,7 @@ namespace rtps
unsigned char *im = stbi_load( texture_file.c_str(), &w, &h, &channels, force_channels );
printf("after load w: %d h: %d channels: %d\n", w, h, channels);
+ printf("im looking for the image at %s\n", texture_file.c_str());
if (im == NULL)
{
printf("fail!: %s\n", stbi_failure_reason());
@@ -12,7 +12,7 @@ namespace rtps
string filename = settings->GetSettingAs<string>("render_texture");
//path += "../../../sprites/fsu_seal.jpg";
//path += "../../../sprites/firejet_blast.png"; //borrowed from http://homepage.mac.com/nephilim/sw3ddev/additive_blending.html
- path += "../../sprites/" + filename;
+ path = "../../sprites/" + filename;
//path += "../../../sprites/firejet_smoke.png";
//path += "../../../sprites/tomek.jpg";
//path += "../../../sprites/enjalot.jpg";
View
@@ -335,7 +335,7 @@ void FLOCK::updateGPU()
timers["rules"]->start();
// add a bool variable for each rule
- if(1){
+ if(flock_params.w_sep > 0.f || flock_params.w_align > 0.f || flock_params.w_coh > 0.f){
rules.executeFlockmates( num,
cl_position_s,
cl_flockmates_s,
@@ -346,7 +346,7 @@ void FLOCK::updateGPU()
clf_debug,
cli_debug);
}
- if(1){
+ if(flock_params.w_sep > 0.f){
rules.executeSeparation( num,
cl_position_s,
cl_separation_s,
@@ -358,7 +358,7 @@ void FLOCK::updateGPU()
clf_debug,
cli_debug);
}
- if(1){
+ if(flock_params.w_align > 0.f){
rules.executeAlignment( num,
cl_position_s,
cl_velocity_s,
@@ -371,7 +371,7 @@ void FLOCK::updateGPU()
clf_debug,
cli_debug);
}
- if(1){
+ if(flock_params.w_coh > 0.f){
rules.executeCohesion( num,
cl_position_s,
cl_cohesion_s,
@@ -383,7 +383,7 @@ void FLOCK::updateGPU()
clf_debug,
cli_debug);
}
- if(1){
+ if(0){
rules.executeLeaderFollowing( num,
cl_position_s,
cl_velocity_s,
@@ -878,7 +878,16 @@ void FLOCK::pushParticles(vector<float4> pos, float4 velo, float4 color)
{
int nn = pos.size();
std::vector<float4> vels(nn);
- std::fill(vels.begin(), vels.end(), velo);
+ float ms = flock_params.max_speed;
+ //std::fill(vels.begin(), vels.end(), velo);
+ for(int i=0; i < nn; i++){
+ vels[i] = float4(rand()/*(ms - velo.x) + rand()/double(RAND_MAX)*/, /*(ms + velo.y) + rand()/double(RAND_MAX)*/ rand(), rand()/*(ms - velo.z) + rand()/double(RAND_MAX)*/, velo.w);
+ vels[i] = normalize3(vels[i]);
+ vels[i] = vels[i] * ms;
+ }
+ vels[1].print("\n\n *** vel 1 ***\n");
+ vels[2].print("*** vel 2 ***\n");
+ vels[3].print("*** vel 3 ***\n\n");
pushParticles(pos, vels, color);
}
View
@@ -104,8 +104,8 @@ rtps::RTPS* ps;
#define DT 0.001f
-#define maxspeed 3.0f
-#define mindist .10f
+#define maxspeed 2.0f
+#define mindist 1.0f
#define searchradius 1.0f
float4 color = float4(255.f, 0.f, 0.f, 0.f);
@@ -149,9 +149,9 @@ int main(int argc, char** argv)
printf("before we call enjas functions\n");
- float w_sep = .40f; //15
- float w_align = .80f; //7.5
- float w_coh = 1.0f; //2.5
+ float w_sep = .0f; //15
+ float w_align = 1.0f; //7.5
+ float w_coh = .0f; //2.5
float w_leadfoll = 0.f;
float slow_dist = .01f;
@@ -169,14 +169,14 @@ int main(int argc, char** argv)
//printf("arvg[0]: %s\n", argv[0]);
#endif
- settings->setRenderType(RTPSettings::RENDER);
- //settings->setRenderType(RTPSettings::SPRITE_RENDER);
+ //settings->setRenderType(RTPSettings::RENDER);
+ settings->setRenderType(RTPSettings::SPRITE_RENDER);
settings->setRadiusScale(1.0);
settings->setBlurScale(1.0);
settings->setUseGLSL(1);
- settings->SetSetting("render_texture", "boid.png");
+ settings->SetSetting("render_texture", "nemo.png");
settings->SetSetting("render_frag_shader", "boid_tex_frag.glsl");
//settings->SetSetting("render_use_alpha", true);
settings->SetSetting("render_use_alpha", false);

0 comments on commit a2d2971

Please sign in to comment.