Skip to content

Commit

Permalink
add random velocities, compute rules when the weights are grater than…
Browse files Browse the repository at this point in the history
… zero
  • Loading branch information
Myrna Merced Serrano committed May 27, 2011
1 parent a0d1195 commit a2d2971
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 17 deletions.
4 changes: 2 additions & 2 deletions boids_gordon/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
//}
Expand Down
1 change: 1 addition & 0 deletions rtpslib/render/Render.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
2 changes: 1 addition & 1 deletion rtpslib/render/SpriteRender.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
21 changes: 15 additions & 6 deletions rtpslib/system/FLOCK.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -383,7 +383,7 @@ void FLOCK::updateGPU()
clf_debug,
cli_debug);
}
if(1){
if(0){
rules.executeLeaderFollowing( num,
cl_position_s,
cl_velocity_s,
Expand Down Expand Up @@ -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);
}

Expand Down
16 changes: 8 additions & 8 deletions test/main_flock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand All @@ -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);
Expand Down

0 comments on commit a2d2971

Please sign in to comment.