Commit 4cefeb6db2ba2fe11b6a921ef30b3ac87b8ab1ff

Authored by Pavel Govyadinov
1 parent eeebe223

Changes to the rect.h class: Added a new constructor, and some methods for scali…

…ng.       Changes to gl_spider.h. Support for two rects that generate the coordinates of the two spider templates and constructors
Showing 2 changed files with 53 additions and 12 deletions   Show diff stats
@@ -2,10 +2,12 @@ @@ -2,10 +2,12 @@
2 #define STIM_GL_SPIDER_H 2 #define STIM_GL_SPIDER_H
3 3
4 #include <GL/glut.h> 4 #include <GL/glut.h>
  5 +//#include <GL/glew.h>
  6 +#include "gl_texture.h"
5 #include "../visualization/camera.h" 7 #include "../visualization/camera.h"
6 #include "./error.h" 8 #include "./error.h"
7 #include "../math/vector.h" 9 #include "../math/vector.h"
8 - 10 +#include "../math/rect.h"
9 11
10 namespace stim 12 namespace stim
11 { 13 {
@@ -14,18 +16,20 @@ template&lt;typename T&gt; @@ -14,18 +16,20 @@ template&lt;typename T&gt;
14 class gl_spider : public virtual gl_texture<T> 16 class gl_spider : public virtual gl_texture<T>
15 { 17 {
16 //doen't use gl_texture really, just needs the GLuint id. 18 //doen't use gl_texture really, just needs the GLuint id.
  19 + //doesn't even need the texture iD really.
17 private: 20 private:
18 stim::camera rotator; 21 stim::camera rotator;
19 stim::vec<float> position; //vector designating the position of the spider. 22 stim::vec<float> position; //vector designating the position of the spider.
20 stim::vec<float> direction; //vector designating the orientation of the spider 23 stim::vec<float> direction; //vector designating the orientation of the spider
21 //always a unit vector. 24 //always a unit vector.
22 stim::vec<float> magnitude; //magnitude of the direction vector. 25 stim::vec<float> magnitude; //magnitude of the direction vector.
23 - //maybe a vector in order to scale the spider  
24 - // in the x, y, z directions.  
25 - 26 + //mag[0] = length.
  27 + //mag[1] = width.
26 // Also maybe we some texture representation of 28 // Also maybe we some texture representation of
27 // of the spider i.e [WH_pxl, BL_pxl, WH_pxl]. 29 // of the spider i.e [WH_pxl, BL_pxl, WH_pxl].
28 - stim::gl_texture<T>; 30 + using gl_texture<T>::texID;
  31 + stim::rect<float> hor;
  32 + stim::rect<float> ver;
29 33
30 34
31 void 35 void
@@ -76,8 +80,28 @@ class gl_spider : public virtual gl_texture&lt;T&gt; @@ -76,8 +80,28 @@ class gl_spider : public virtual gl_texture&lt;T&gt;
76 { 80 {
77 /* move to the new position */ 81 /* move to the new position */
78 } 82 }
79 -  
80 public: 83 public:
  84 +
  85 + gl_spider()
  86 + {
  87 + setPosition(0.0,0.0,0.0);
  88 + setDirection(1.0,1.0,1.0);
  89 + setMagnitude(1.0,1.0);
  90 + stim::vec<float> Y(1.0,0.0,0.0);
  91 + hor = stim::rect<float>(position, direction, Y);
  92 + ver = stim::rect<float>(magnitude, position, (Y.cross(direction)).norm());
  93 + }
  94 +
  95 + gl_spider(vec<float> pos, vec<float> dir, vec<float> mag)
  96 + {
  97 + position = pos;
  98 + direction = dir;
  99 + magnitude = mag;
  100 + vec<float> Y(1.0,0.0,0.0);
  101 + hor = stim::rect<float>(position, direction, Y);
  102 + ver = stim::rect<float>(magnitude, position, (Y.cross(direction)).norm());
  103 + }
  104 +
81 vec<float> 105 vec<float>
82 getCurrentPosition() 106 getCurrentPosition()
83 { 107 {
@@ -131,15 +155,12 @@ class gl_spider : public virtual gl_texture&lt;T&gt; @@ -131,15 +155,12 @@ class gl_spider : public virtual gl_texture&lt;T&gt;
131 } 155 }
132 156
133 void 157 void
134 - setPosition(float x, float y, float z) 158 + setMagnitude(float x, float y)
135 { 159 {
136 magnitude[0] = x; 160 magnitude[0] = x;
137 magnitude[1] = y; 161 magnitude[1] = y;
138 - magnitude[2] = z;  
139 } 162 }
140 -  
141 -  
142 163
143 -} 164 +};
144 } 165 }
145 #endif 166 #endif
@@ -36,6 +36,7 @@ private: @@ -36,6 +36,7 @@ private:
36 X *= factor; 36 X *= factor;
37 Y *= factor; 37 Y *= factor;
38 } 38 }
  39 +
39 40
40 CUDA_CALLABLE void normal(vec<T, N> n){ //orient the rectangle along the specified normal 41 CUDA_CALLABLE void normal(vec<T, N> n){ //orient the rectangle along the specified normal
41 42
@@ -75,8 +76,27 @@ public: @@ -75,8 +76,27 @@ public:
75 scale(size); //scale the rectangle 76 scale(size); //scale the rectangle
76 normal(n); //orient 77 normal(n); //orient
77 } 78 }
  79 +
  80 + //create a rectangle from a center point, normal, and size
  81 + CUDA_CALLABLE rect(vec<T,2> size, vec<T, N> c, vec<T, N> n = vec<T, N>(0, 0, 1)){
  82 + init(); //start with the default setting
  83 + C = c;
  84 + scale(size); //scale the rectangle
  85 + normal(n); //orient
  86 + }
78 87
79 - //Pavel - write a constructor to create a rectangle given a center point (c), direction vector (v) 88 + CUDA_CALLABLE rect(vec<T, N> center, vec<T, N> directionX, vec<T, N> directionY )
  89 + {
  90 + C = center;
  91 + X = directionX;
  92 + Y = directionY;
  93 + }
  94 +
  95 +
  96 + CUDA_CALLABLE void scale(T factor1, T factor2){
  97 + X *= factor1;
  98 + Y *= factor2;
  99 + }
80 100
81 //boolean comparison 101 //boolean comparison
82 bool operator==(const rect<T, N> & rhs) 102 bool operator==(const rect<T, N> & rhs)