Commit 266aa74ada4907b2d53faaa654c252ef562a73d8

Authored by Pavel Govyadinov
1 parent f304d6de

CHECKPOINT: Minor bug fixes, clean up, and organization. Added a way of getting …

…the size of the volume (num of slices) instead of hard coding.
Showing 2 changed files with 291 additions and 232 deletions   Show diff stats
stim/gl/gl_spider.h
... ... @@ -19,6 +19,11 @@
19 19 #include <iostream>
20 20 #include <fstream>
21 21  
  22 +
  23 +
  24 +/* Technically since gl_spider inherits from gl_texture, we could
  25 + call the init with a path to an image stack, and upload
  26 + the images while creating the spider (calling init) */
22 27 namespace stim
23 28 {
24 29  
... ... @@ -40,76 +45,225 @@ class gl_spider : public virtual gl_texture&lt;T&gt;
40 45 double currentTransform[16];
41 46 using gl_texture<T>::texID;
42 47 using gl_texture<T>::S;
  48 + using gl_texture<T>::R;
43 49 cudaArray* c_Array;
44 50 cudaGraphicsResource_t resource;
  51 +
45 52 GLuint fboID;
46 53 GLuint texbufferID;
47 54 int iter; //temporary for testing
48 55 int numSamples;
  56 +
  57 + /// Method for finding the best scale for the spider.
  58 + /// changes the x, y, z size of the spider to minimize the cost
  59 + /// function.
  60 + void
  61 + findOptimalDirection()
  62 + {
  63 + genTemplate(dirVectors, 0);
  64 + int best = getCost();
  65 +
  66 +
  67 + }
  68 +
  69 + /// Method for finding the best direction for the spider.
  70 + /// Not sure if necessary since the next position for the spider
  71 + /// will be at direction * magnitude.
49 72 void
50 73 findOptimalPosition()
51 74 {
52   - /* Method for finding the best direction for the spider.
53   - Not sure if necessary since the next position for the spider
54   - will be at direction * magnitude. */
55 75  
56   - positionTemplate(position, direction, magnitude);
  76 + genTemplate(magVectors, 1);
57 77 int best = getCost();
58 78 }
59 79  
  80 + /// Method for finding the best scale for the spider.
  81 + /// changes the x, y, z size of the spider to minimize the cost
  82 + /// function. */
60 83 void
61 84 findOptimalScale()
62 85 {
63   - /* Method for finding the best scale for the spider.
64   - changes the x, y, z size of the spider to minimize the cost
65   - function. */
66 86 genTemplate(magVectors, 2);
67 87 int best = getCost();
68 88 }
69 89  
  90 +
  91 +
70 92 void
71   - findOptimalDirection()
  93 + Optimize()
72 94 {
73   - /* Method for finding the best scale for the spider.
74   - changes the x, y, z size of the spider to minimize the cost
75   - function. */
76   - //getSample(position, direction, magnitude);
77   - genTemplate(dirVectors, 0);
78   - int best = getCost();
79   - //getSample(position, direction, magnitude);
80   - //int best = getCost();
  95 + /*find the optimum direction and scale */
81 96 }
82 97  
83 98  
  99 +
  100 +
  101 +//--------------------------------------------------------------------------//
  102 +//---------------------TEMPLATE CREATION METHODS----------------------------//
  103 +//--------------------------------------------------------------------------//
  104 +
  105 + ///@param solidAngle, the size of the arc to sample.
  106 + ///Method for populating the vector arrays with sampled vectors.
  107 + ///uses the default direction vector <0,0,1>
84 108 void
85   - Optimize()
  109 + genDirectionVectors(float solidAngle = M_PI/2)
86 110 {
87   - /*find the optimum direction and scale */
  111 +
  112 + vec<float> d_s = direction.cart2sph().norm();
  113 + vec<float> temp;
  114 + int dim = (sqrt(numSamples)-1)/2;
  115 + float p0 = M_PI/3;
  116 + float dt = solidAngle/(2.0 * (dim + 1));
  117 + float dp = p0/(2.0*(dim + 1));
  118 +
  119 + for(int i = -dim; i <= dim; i++){
  120 + for(int j = -dim; j <= dim; j++){
  121 + //Create linear index
  122 +
  123 + temp[0] = d_s[0]; //rotate vector
  124 + temp[1] = d_s[1]+dt*i;
  125 + temp[2] = d_s[2]+dp*j;
  126 +
  127 + temp = (temp.sph2cart()).norm(); //back to cart
  128 + dirVectors.push_back(temp);
  129 + }
  130 + }
88 131 }
89 132  
90   - ///@param width sets the width of the buffer.
91   - ///@param height sets the height of the buffer.
92   - ///Function for setting up the 2D buffer that stores the samples.
  133 + ///@param solidAngle, the size of the arc to sample.
  134 + ///Method for populating the buffer with the sampled texture.
  135 + ///uses the default vector <0,0,0>
93 136 void
94   - GenerateFBO(unsigned int width, unsigned int height)
  137 + genPositionVectors(float delta = 0.2)
95 138 {
96   - glGenFramebuffers(1, &fboID);
97   - glBindFramebuffer(GL_FRAMEBUFFER, fboID);
98   - int numChannels = 1;
99   - unsigned char* texels = new unsigned char[width * height * numChannels];
100   - glGenTextures(1, &texbufferID);
101   - glBindTexture(GL_TEXTURE_2D, texbufferID);
102   - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
103   - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
104   - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
105   - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
106   - glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE,
107   - width, height, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, texels);
108   - delete[] texels;
109   - glBindFramebuffer(GL_FRAMEBUFFER, 0);
110   - glBindTexture(GL_TEXTURE_2D, 0);
  139 +
  140 + vec<float> temp;
  141 + int dim = (sqrt(numSamples)-1)/2;
  142 + stim::rect<float> samplingPlane =
  143 + stim::rect<float>(magnitude[0]*delta, position, direction);
  144 + float step = 1.0/(dim);
  145 + //Loop over the samples, keeping the original position sample
  146 + //in the center of the resulting texture.
  147 +
  148 + int idx;
  149 + for(int i = -dim; i <= dim; i++){
  150 + for(int j = -dim; j <= dim; j++){
  151 + //Create linear index
  152 +
  153 + temp = samplingPlane.p(
  154 + 0.5+step*i,
  155 + 0.5+step*j
  156 + );
  157 + posVectors.push_back(temp);
  158 + }
  159 + }
  160 + }
  161 +
  162 + ///@param solidAngle, the size of the arc to sample.
  163 + ///Method for populating the buffer with the sampled texture.
  164 + ///uses the default magnitude <1,1,0>
  165 + void
  166 + genMagnitudeVectors(float delta = 0.5)
  167 + {
  168 +
  169 + int dim = (sqrt(numSamples)-1)/2;
  170 + float min = 1.0-delta;
  171 + float max = 1.0+delta;
  172 + float step = (max-min)/(numSamples-1);
  173 + float factor;
  174 + vec<float> temp;
  175 +
  176 + for(int i = 0; i < numSamples; i++){
  177 + //Create linear index
  178 + factor = (min+step*i)*magnitude[0];
  179 + temp[0] = factor;
  180 + temp[1] = factor;
  181 + magVectors.push_back(temp);
  182 + }
  183 + }
  184 + ///@param vector of stim::vec in that stores all of the samplable vectors.
  185 + ///@param type, one of three operations, 0 for Direction vectors
  186 + /// 1 for Position, 2 for Magnitude.
  187 + ///Function for filling the buffer up with the data based on the vectors
  188 + ///Each vector represents a two rectangular templates.
  189 + ///Loops through all of the vectors and transfers rect. associated with it
  190 + ///Into buffer-space.
  191 + void
  192 + genTemplate(std::vector<stim::vec<float> > in, int type)
  193 + {
  194 + float x = 0.0;
  195 + vec<float> Y(1.0,0.0,0.0);
  196 + vec<float> pos(0.0,0.0,0.0);
  197 + vec<float> mag(1.0, 1.0, 1.0);
  198 + switch(type) {
  199 + case 0: //Direction
  200 + Bind();
  201 + positionTemplate(); ///this can be placed anywhere
  202 + ///as long as the GL_TEXTURE
  203 + ///is not cleared after this call.
  204 +
  205 + for(int i = 0; i < in.size(); i++)
  206 + {
  207 + if(cos(Y.dot(in[i]))< 0.087){ Y[0] = 0.0; Y[1] = 1.0;}
  208 + else{Y[0] = 1.0; Y[1] = 0.0;}
  209 +
  210 + hor = stim::rect<float>(mag,
  211 + pos, in[i],
  212 + ((Y.cross(in[i])).cross(in[i])).norm());
  213 + ver = stim::rect<float>(mag,
  214 + pos, in[i],
  215 + hor.n());
  216 + UpdateBuffer(x, x+i*10.0);
  217 + }
  218 + //getSample();
  219 + Unbind();
  220 + break;
  221 + case 1: //Position
  222 + Bind();
  223 + positionTemplate();
  224 + if(cos(Y.dot(direction))< 0.087){ Y[0] = 0.0; Y[1] = 1.0;}
  225 + else{Y[0] = 1.0; Y[1] = 0.0;}
  226 +
  227 + for(int i = 0; i < in.size(); i++)
  228 + {
  229 + hor = stim::rect<float>(magnitude,
  230 + in[i], direction,
  231 + ((Y.cross(direction)).cross(direction))
  232 + .norm());
  233 + ver = stim::rect<float>(magnitude,
  234 + in[i], direction,
  235 + hor.n());
  236 + UpdateBuffer(x, x+i*10.0);
  237 + }
  238 + Unbind();
  239 + break;
  240 + case 2: //Scale
  241 + Bind();
  242 + positionTemplate();
  243 + if(cos(Y.dot(direction))< 0.087){ Y[0] = 0.0; Y[1] = 1.0;}
  244 + else{Y[0] = 1.0; Y[1] = 0.0;}
  245 +
  246 + for(int i = 0; i < in.size(); i++)
  247 + {
  248 + hor = stim::rect<float>(in[i],
  249 + position, direction,
  250 + ((Y.cross(direction)).cross(direction))
  251 + .norm());
  252 + ver = stim::rect<float>(in[i],
  253 + position, direction,
  254 + hor.n());
  255 + UpdateBuffer(x, x+i*10.0);
  256 + }
  257 + Unbind();
  258 + break;
  259 + default:
  260 + std::cout << "unknown case have been passed"
  261 + << std::endl;
  262 + break;
  263 + }
  264 + Unbind();
  265 + CHECK_OPENGL_ERROR
111 266 }
112   -
113 267 ///@param v_x x-coordinate in buffer-space,
114 268 ///@param v_y y-coordinate in buffer-space.
115 269 ///Samples the texturespace and places a sample in the provided coordinates
... ... @@ -186,84 +340,35 @@ class gl_spider : public virtual gl_texture&lt;T&gt;
186 340 CHECK_OPENGL_ERROR
187 341 }
188 342  
189   - ///@param vector of stim::vec in that stores all of the samplable vectors.
190   - ///@param type, one of three operations, 0 for Direction vectors
191   - /// 1 for Position, 2 for Magnitude.
192   - ///Function for filling the buffer up with the data based on the vectors
193   - ///Each vector represents a two rectangular templates.
194   - ///Loops through all of the vectors and transfers rect. associated with it
195   - ///Into buffer-space.
196   - void
197   - genTemplate(std::vector<stim::vec<float> > in, int type)
198   - {
199   - float x = 0.0;
200   - vec<float> Y(1.0,0.0,0.0);
201   - vec<float> pos(0.0,0.0,0.0);
202   - vec<float> mag(1.0, 1.0, 1.0);
203   - switch(type) {
204   - case 0: //Direction
205   - Bind();
206   - positionTemplate();
207   - for(int i = 0; i < in.size(); i++)
208   - {
209   - if(cos(Y.dot(in[i]))< 0.087){ Y[0] = 0.0; Y[1] = 1.0;}
210   - else{Y[0] = 1.0; Y[1] = 0.0;}
211 343  
212   - hor = stim::rect<float>(mag,
213   - pos, in[i],
214   - ((Y.cross(in[i])).cross(in[i])).norm());
215   - ver = stim::rect<float>(mag,
216   - pos, in[i],
217   - hor.n());
218   - // std::cout<< (x+i*10.0) << std::endl;
219   - UpdateBuffer(x, x+i*10.0);
220   - }
221   - //getSample();
222   - Unbind();
223   - break;
224   - case 1: //Position
225   - Bind();
226   - if(cos(Y.dot(direction))< 0.087){ Y[0] = 0.0; Y[1] = 1.0;}
227   - else{Y[0] = 1.0; Y[1] = 0.0;}
228 344  
229   - for(int i = 0; i < in.size(); i++)
230   - {
231   - hor = stim::rect<float>(magnitude, in[i], direction,
232   - ((Y.cross(direction)).cross(direction))
233   - .norm());
234   - ver = stim::rect<float>(magnitude, in[i], direction,
235   - hor.n());
236   - //UpdateBuffer(x, x+i*10.0);
237   - std::cout<< "Hmmm" << std::endl;
238   - }
239   - Unbind();
240   - break;
241   - case 2: //Scale
242   - Bind();
243   - if(cos(Y.dot(direction))< 0.087){ Y[0] = 0.0; Y[1] = 1.0;}
244   - else{Y[0] = 1.0; Y[1] = 0.0;}
  345 +//--------------------------------------------------------------------------//
  346 +//--------------------------------GL METHODS--------------------------------//
  347 +//--------------------------------------------------------------------------//
245 348  
246   - for(int i = 0; i < in.size(); i++)
247   - {
248   - hor = stim::rect<float>(in[i], position, direction,
249   - ((Y.cross(direction)).cross(direction))
250   - .norm());
251   - ver = stim::rect<float>(in[i], position, direction,
252   - hor.n());
253   - //UpdateBuffer(x, x+i*10.0);
254   - std::cout<< "Hmmm" << std::endl;
255   - }
256   - Unbind();
257   - break;
258   - default:
259   - std::cout << "unknown case have been passed"
260   - << std::endl;
261   - break;
262   - }
263   - Unbind();
264   - CHECK_OPENGL_ERROR
  349 + ///@param width sets the width of the buffer.
  350 + ///@param height sets the height of the buffer.
  351 + ///Function for setting up the 2D buffer that stores the samples.
  352 + void
  353 + GenerateFBO(unsigned int width, unsigned int height)
  354 + {
  355 + glGenFramebuffers(1, &fboID);
  356 + glBindFramebuffer(GL_FRAMEBUFFER, fboID);
  357 + int numChannels = 1;
  358 + unsigned char* texels = new unsigned char[width * height * numChannels];
  359 + glGenTextures(1, &texbufferID);
  360 + glBindTexture(GL_TEXTURE_2D, texbufferID);
  361 + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
  362 + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
  363 + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
  364 + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
  365 + glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE,
  366 + width, height, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, texels);
  367 + delete[] texels;
  368 + glBindFramebuffer(GL_FRAMEBUFFER, 0);
  369 + glBindTexture(GL_TEXTURE_2D, 0);
265 370 }
266   -
  371 +
267 372 ///Method for controling the buffer and texture binding in order to properly
268 373 ///do the render to texture.
269 374 void
... ... @@ -306,86 +411,51 @@ class gl_spider : public virtual gl_texture&lt;T&gt;
306 411 glBindTexture(GL_TEXTURE_2D, 0);
307 412 }
308 413  
309   - ///@param solidAngle, the size of the arc to sample.
310   - ///Method for populating the vector arrays with sampled vectors.
311   - ///uses the default direction vector <0,0,1>
312   - void
313   - genDirectionVectors(float solidAngle = M_PI/2)
314   - {
315   -
316   - vec<float> d_s = direction.cart2sph().norm();
317   - //dirVectors.resize(numSamples); //THIS LINE ADDS AN ERROR
318   - vec<float> temp;
319   - int dim = (sqrt(numSamples)-1)/2;
320   - float p0 = M_PI/3;
321   - float dt = solidAngle/(2.0 * (dim + 1));
322   - float dp = p0/(2.0*(dim + 1));
323   -
324   - for(int i = -dim; i <= dim; i++){
325   - for(int j = -dim; j <= dim; j++){
326   - //Create linear index
327   -
328   - temp[0] = d_s[0]; //rotate vector
329   - temp[1] = d_s[1]+dt*i;
330   - temp[2] = d_s[2]+dp*j;
331   -
332   - temp = (temp.sph2cart()).norm(); //back to cart
333   - dirVectors.push_back(temp);
334   - }
335   - }
336   - }
337   -
338   - ///@param solidAngle, the size of the arc to sample.
339   - ///Method for populating the buffer with the sampled texture.
340   - ///uses the default vector <0,0,0>
341   - void
342   - genPositionVectors(float delta = 0.2)
  414 + ///Method for using the gl manipulation to alighn templates from
  415 + ///Template space (-0.5 0.5) to Texture space (0.0, 1.0),
  416 + ///Based on the position of the spider in real space (arbitrary).
  417 + void positionTemplate()
343 418 {
  419 + stim::vec<float, 4> rot = getRotation(direction);
  420 + glMatrixMode(GL_TEXTURE);
  421 + glLoadIdentity();
344 422  
345   - vec<float> temp;
346   - int dim = (sqrt(numSamples)-1)/2;
347   - stim::rect<float> samplingPlane =
348   - stim::rect<float>(magnitude[0]*delta, position, direction);
349   - float step = 1.0/(dim);
350   - //Loop over the samples, keeping the original position sample
351   - //in the center of the resulting texture.
  423 + glTranslatef(position[0]/512/S[1],
  424 + position[1]/512/S[2],
  425 + position[2]/426/S[3]);
  426 + glScalef(magnitude[0]/512/S[1],
  427 + magnitude[1]/512/S[2],
  428 + magnitude[0]/426/S[3]);
  429 + glRotatef(rot[0], rot[1], rot[2], rot[3]);
352 430  
353   - int idx;
354   - for(int i = -dim; i <= dim; i++){
355   - for(int j = -dim; j <= dim; j++){
356   - //Create linear index
  431 +/*
  432 + glTranslatef(position[0],
  433 + position[1],
  434 + position[2]);
  435 + glScalef(magnitude[0],
  436 + magnitude[1],
  437 + magnitude[0]);
  438 + glRotatef(rot[0], rot[1], rot[2], rot[3]);
  439 + glScalef(1/512/0.6, 1/512/0.6, 1/426/2.0); //this does not work
  440 +*/
357 441  
358   - temp = samplingPlane.p(
359   - 0.5+step*i,
360   - 0.5+step*j
361   - );
362   - posVectors.push_back(temp);
  442 + glGetDoublev(GL_TEXTURE_MATRIX, currentTransform);
  443 + int c = 0;
  444 + for(int i = 0; i < 16; i++){
  445 + if(c<3){
  446 + std::cerr << "[" << currentTransform[i] << "]" << " ";
  447 + c++;
  448 + } else {
  449 + std::cerr << "[" << currentTransform[i] << "]" << "\n";
  450 + c = 0;
363 451 }
364 452 }
  453 + CHECK_OPENGL_ERROR
  454 + glMatrixMode(GL_MODELVIEW);
365 455 }
  456 +
  457 +
366 458  
367   - ///@param solidAngle, the size of the arc to sample.
368   - ///Method for populating the buffer with the sampled texture.
369   - ///uses the default magnitude <1,1,0>
370   - void
371   - genMagnitudeVectors(float delta = 0.5)
372   - {
373   -
374   - int dim = (sqrt(numSamples)-1)/2;
375   - float min = 1.0-delta;
376   - float max = 1.0+delta;
377   - float step = (max-min)/(numSamples-1);
378   - float factor;
379   - vec<float> temp;
380   -
381   - for(int i = 0; i < numSamples; i++){
382   - //Create linear index
383   - factor = (min+step*i)*magnitude[0];
384   - temp[0] = factor;
385   - temp[1] = factor;
386   - magVectors.push_back(temp);
387   - }
388   - }
389 459  
390 460 //--------------------------------------------------------------------------//
391 461 //--------------------------------CUDA METHODS------------------------------//
... ... @@ -428,10 +498,14 @@ class gl_spider : public virtual gl_texture&lt;T&gt;
428 498 }
429 499  
430 500 public:
431   -
432 501 stim::rect<float> hor;
433 502 stim::rect<float> ver;
434 503  
  504 +//--------------------------------------------------------------------------//
  505 +//-----------------------------CONSTRUCTORS---------------------------------//
  506 +//--------------------------------------------------------------------------//
  507 +
  508 +
435 509 ///Default Constructor
436 510 gl_spider
437 511 ()
... ... @@ -441,8 +515,10 @@ class gl_spider : public virtual gl_texture&lt;T&gt;
441 515 setMagnitude(1.0);
442 516 //numSamples = 1089;
443 517 numSamples = 9;
444   - std::cout << "I did this" <<std::endl;
445 518 }
  519 + ///@param samples, the number of samples this spider is going to use.
  520 + ///best results if samples is can create a perfect root.
  521 + ///Default Constructor
446 522 gl_spider
447 523 (int samples)
448 524 {
... ... @@ -464,7 +540,8 @@ class gl_spider : public virtual gl_texture&lt;T&gt;
464 540 }
465 541 ///@param GLuint id texture that is going to be sampled.
466 542 ///Attached the spider to the texture with the given GLuint ID.
467   - ///Samples in the default direction acting as the init method.
  543 + ///Samples in the default direction acting as the init method.
  544 + ///Also acts an init.
468 545 void
469 546 attachSpider(GLuint id)
470 547 {
... ... @@ -478,19 +555,9 @@ class gl_spider : public virtual gl_texture&lt;T&gt;
478 555 genTemplate(dirVectors, 0);
479 556 }
480 557  
481   - ///temporary Method necessary for visualization and testing.
482   - void
483   - Update()
484   - {
485   - vec<float> Y(1.0,0.0,0.0);
486   - if(cos(Y.dot(direction))< 0.087){
487   - Y[0] = 0.0; Y[1] = 1.0;}
488   - hor = stim::rect<float>(magnitude, position, direction.norm(),
489   - ((Y.cross(direction)).cross(direction)).norm());
490   - ver = stim::rect<float>(magnitude, position, direction.norm(),
491   - hor.n());
492   - }
493   -
  558 +//--------------------------------------------------------------------------//
  559 +//-----------------------------ACCESS METHODS-------------------------------//
  560 +//--------------------------------------------------------------------------//
494 561 ///Returns the position vector.
495 562 vec<float>
496 563 getPosition()
... ... @@ -532,37 +599,6 @@ class gl_spider : public virtual gl_texture&lt;T&gt;
532 599 position[2] = z;
533 600 }
534 601  
535   - void positionTemplate(vec<float> pos, vec<float> dir, vec<float> mag)
536   - {
537   - stim::vec<float, 4> rot = getRotation(dir);
538   - glMatrixMode(GL_TEXTURE);
539   - glLoadIdentity();
540   - glTranslatef(position[0]/512/S[1],
541   - position[1]/512/S[2],
542   - position[2]/426/S[3]);
543   - glScalef(magnitude[0]/512/S[1],
544   - magnitude[1]/512/S[2],
545   - magnitude[0]/426/S[3]);
546   - glRotatef(rot[0], rot[1], rot[2], rot[3]);
547   - glGetDoublev(GL_TEXTURE_MATRIX, currentTransform);
548   - int c = 0;
549   - for(int i = 0; i < 16; i++){
550   - if(c<3){
551   - std::cerr << "[" << currentTransform[i] << "]" << " ";
552   - c++;
553   - } else {
554   - std::cerr << "[" << currentTransform[i] << "]" << "\n";
555   - c = 0;
556   - }
557   - }
558   - CHECK_OPENGL_ERROR
559   - glMatrixMode(GL_MODELVIEW);
560   - }
561   -
562   - void positionTemplate()
563   - {
564   - positionTemplate(position, direction, magnitude);
565   - }
566 602 ///@param vector dir, the new direction.
567 603 ///Sets the direction vector to input vector dir.
568 604 void
... ... @@ -632,6 +668,24 @@ class gl_spider : public virtual gl_texture&lt;T&gt;
632 668 return fboID;
633 669 }
634 670  
  671 +//--------------------------------------------------------------------------//
  672 +//-----------------------------TEMPORARY METHODS----------------------------//
  673 +//--------------------------------------------------------------------------//
  674 +
  675 + ///temporary Method necessary for visualization and testing.
  676 + void
  677 + Update()
  678 + {
  679 + vec<float> Y(1.0,0.0,0.0);
  680 + if(cos(Y.dot(direction))< 0.087){
  681 + Y[0] = 0.0; Y[1] = 1.0;}
  682 + hor = stim::rect<float>(magnitude, position, direction.norm(),
  683 + ((Y.cross(direction)).cross(direction)).norm());
  684 + ver = stim::rect<float>(magnitude, position, direction.norm(),
  685 + hor.n());
  686 + }
  687 +
  688 +
635 689 void
636 690 Step()
637 691 {
... ...
stim/gl/gl_texture.h
... ... @@ -207,7 +207,12 @@ class gl_texture : public virtual image_stack&lt;T&gt;
207 207 return ptr;
208 208 }
209 209  
210   -
  210 + stim::vec<int>
  211 + getSize()
  212 + {
  213 + stim::vec<int> size(R[1], R[2], R[3]);
  214 + return size;
  215 + }
211 216  
212 217 };
213 218 }
... ...