Commit 887a3e490bdd73e2b1d9a80c478ba1f807909242

Authored by Pavel Govyadinov
1 parent 385d2447

fixed some order of operations issues that resulted in inpropper creation of the…

… sampling buffer. There is still a bug with the texture not being sample properly, (i.e. glTranslate, glRotate and glScale operations) resulting in bogus bufferdata.
Showing 1 changed file with 26 additions and 16 deletions   Show diff stats
stim/gl/gl_spider.h
... ... @@ -53,7 +53,8 @@ class gl_spider : public virtual gl_texture<T>
53 53 /* Method for finding the best direction for the spider.
54 54 Not sure if necessary since the next position for the spider
55 55 will be at direction * magnitude. */
56   - genTemplate(posVectors, 1);
  56 +
  57 + getSample(position, direction, magnitude);
57 58 int best = getCost();
58 59 }
59 60  
... ... @@ -236,6 +237,8 @@ class gl_spider : public virtual gl_texture<T>
236 237 hor.n());
237 238 UpdateBuffer(x, x+i*10.0);
238 239 }
  240 + std::cout<< "Hmmm" << std::endl;
  241 + Update();
239 242 break;
240 243 case 1: //Position
241 244 if(cos(Y.dot(direction))< 0.087){ Y[0] = 0.0; Y[1] = 1.0;}
... ... @@ -451,9 +454,9 @@ class gl_spider : public virtual gl_texture&lt;T&gt;
451 454 (float pos_x, float pos_y, float pos_z, float dir_x, float dir_y, float dir_z,
452 455 float mag_x)
453 456 {
454   - //setPosition(pos_x, pos_y, pos_z);
455   - //setDirection(dir_x, dir_y, dir_z);
456   - //setMagnitude(mag_x);
  457 + setPosition(pos_x, pos_y, pos_z);
  458 + setDirection(dir_x, dir_y, dir_z);
  459 + setMagnitude(mag_x);
457 460 }
458 461 ///@param GLuint id texture that is going to be sampled.
459 462 ///@param numSamples number of samples per operation.
... ... @@ -466,7 +469,10 @@ class gl_spider : public virtual gl_texture&lt;T&gt;
466 469 GenerateFBO(20, numSamples*10);
467 470 //sampleDirection();
468 471 genDirectionVectors();
469   - gl_texture<T>::setDims(0.6, 0.6, 1.0);
  472 + genTemplate(posVectors, 1);
  473 + genPositionVectors();
  474 + genMagnitudeVectors();
  475 + gl_texture<T>::setDims(0.6, 0.6, 2.0);
470 476 //gl_texture<T>::setDims(1.0, 1.0,1.0);
471 477 }
472 478  
... ... @@ -523,7 +529,21 @@ class gl_spider : public virtual gl_texture&lt;T&gt;
523 529 position[1] = y;
524 530 position[2] = z;
525 531 }
526   -
  532 +
  533 + void getSample(vec<float> pos, vec<float> dir, vec<float> mag)
  534 + {
  535 + Bind();
  536 + glMatrixMode(GL_TEXTURE);
  537 + glLoadIdentity();
  538 + vec<float> temp = dir.sph2cart();
  539 + glScalef(mag[0], mag[1], mag[0]);
  540 + //glRotatef(rotz, 0.0, 0.0, 1.0);
  541 + //glRotatef(roty, 0.0, 1.0, 0.0);
  542 + //glRotatef(rotx, 1.0, 0.0 ,0.0);
  543 + glTranslatef(pos[0], pos[1], pos[2]);
  544 + glScalef(1/512/S[0], 1/512/S[1], 1/512/S[2]);
  545 + Unbind();
  546 + }
527 547  
528 548 ///@param vector dir, the new direction.
529 549 ///Sets the direction vector to input vector dir.
... ... @@ -577,16 +597,6 @@ class gl_spider : public virtual gl_texture&lt;T&gt;
577 597 }
578 598  
579 599  
580   - void
581   - findOptimalDirection()
582   - {
583   - /* Method for finding the best direction for the spider.
584   - Uses the camera to rotate. Then Calls Evaluate to find new cost.
585   - */
586   - //sampleDirection();
587   - //samplePosition();
588   - //sampleMagnitude();
589   - }
590 600  
591 601 /* Method for initializing the cuda devices, necessary only
592 602 there are multiple cuda devices */
... ...