diff --git a/stim/gl/gl_spider.h b/stim/gl/gl_spider.h index c792fe6..b7524b8 100644 --- a/stim/gl/gl_spider.h +++ b/stim/gl/gl_spider.h @@ -603,6 +603,36 @@ class gl_spider // : public virtual gl_texture ///Method for controling the buffer and texture binding. ///Clears the buffer upon binding. + void + Bind() + { + glBindFramebuffer(GL_FRAMEBUFFER, direction_buffID);//set up GL buffer + glFramebufferTexture2D( + GL_FRAMEBUFFER, + GL_COLOR_ATTACHMENT0, + GL_TEXTURE_2D, + direction_texID, + 0); + glBindFramebuffer(GL_FRAMEBUFFER, direction_buffID); + GLenum DrawBuffers[1] = {GL_COLOR_ATTACHMENT0}; + glDrawBuffers(1, DrawBuffers); + glBindTexture(GL_TEXTURE_2D, direction_texID); + glClearColor(1,1,1,1); + glClear(GL_COLOR_BUFFER_BIT); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + glViewport(0,0,2.0*n_pixels, numSamples*n_pixels); + gluOrtho2D(0.0,2.0*n_pixels,0.0,numSamples*n_pixels); + glEnable(GL_TEXTURE_3D); + glBindTexture(GL_TEXTURE_3D, texID); + + CHECK_OPENGL_ERROR + } + + ///Method for controling the buffer and texture binding. + ///Clears the buffer upon binding. ///@param GLuint &textureID, texture to be bound. ///@param GLuint &framebufferID, framebuffer used for storage. ///@param int nSamples, number of rectanges to create. @@ -800,7 +830,7 @@ class gl_spider // : public virtual gl_texture CHECK_OPENGL_ERROR GenerateFBO(16, 216, cylinder_texID, cylinder_buffID); CHECK_OPENGL_ERROR - t_dir.MapCudaTexture(texbufferID, GL_TEXTURE_2D); + t_dir.MapCudaTexture(direction_texID, GL_TEXTURE_2D); t_dir.Alloc(numSamples); t_pos.MapCudaTexture(position_texID, GL_TEXTURE_2D); t_pos.Alloc(numSamplesPos); @@ -819,7 +849,7 @@ class gl_spider // : public virtual gl_texture genMagnitudeVectors(); Unbind(); Bind(cylinder_texID, cylinder_buffID, 27); - DrawCylinder(); +// DrawCylinder(); Unbind(); } @@ -841,7 +871,7 @@ class gl_spider // : public virtual gl_texture } ///Returns the m vector. - stim::vec + float getMagnitude() { return m; @@ -1190,6 +1220,7 @@ class gl_spider // : public virtual gl_texture int Step() { + std::cerr << "Took a step" << std::endl; Bind(direction_texID, direction_buffID, numSamples, n_pixels); CHECK_OPENGL_ERROR findOptimalDirection(); @@ -1336,16 +1367,15 @@ class gl_spider // : public virtual gl_texture seeds.pop(); seedsvecs.pop(); seedsmags.pop(); -// std::cout << "The current seed Vector is " << curSeedVec << std::endl; setPosition(curSeed); setDirection(curSeedVec); setMagnitude(curSeedMag); - std::cout << "This was done" << std::endl; findOptimalScale(); // cL.push_back(curSeed); // cM.push_back(curSeedMag); // cD.push_back(curSeedMag); + std::cout << p << m << std::endl; traceLine(p, m, min_cost); } } @@ -1504,14 +1534,14 @@ class gl_spider // : public virtual gl_texture } */ void - addToNetwork(std::vector > L, std::vector > M) + addToNetwork(std::vector > L, std::vector M) { if(L.size() > 3) { sk.Begin(stim::OBJ_LINE); for(int i = 0; i < L.size(); i++) { - sk.TexCoord(M[i][0]); + sk.TexCoord(M[i]); sk.Vertex(L[i][0], L[i][1], L[i][2]); } sk.End(); @@ -1530,13 +1560,14 @@ class gl_spider // : public virtual gl_texture } void - traceLine(stim::vec3 pos, stim::vec mag, int min_cost) + traceLine(stim::vec3 pos, float mag, int min_cost) { //starting (seed) position and magnitude. stim::vec3 spos = getPosition(); stim::vec smag = getMagnitude(); stim::vec3 sdir = getDirection(); + Bind(); // sk.Begin(stim::OBJ_LINE); @@ -1583,7 +1614,7 @@ class gl_spider // : public virtual gl_texture } //Has the template size gotten unreasonable? mag = getMagnitude(); - if(mag[0] > 75 || mag[0] < 1){ + if(mag > 75 || mag < 1){ running = false; branchDetection2(); addToNetwork(cL, cM); @@ -1604,6 +1635,7 @@ class gl_spider // : public virtual gl_texture else { cL.push_back(stim::vec3(p[0], p[1],p[2])); cM.push_back(m); + Unbind(); CHECK_OPENGL_ERROR } } diff --git a/stim/visualization/cylinder.h b/stim/visualization/cylinder.h index bff9f04..24bc778 100644 --- a/stim/visualization/cylinder.h +++ b/stim/visualization/cylinder.h @@ -214,13 +214,30 @@ class cylinder init(inP, inM); } + ///constructor to create a cylinder from a set of points, radii, and the number of sides for the cylinder. + ///@param inP: Vector of stim vec3 composing the points of the centerline. + ///@param inM: Vector of stim vecs composing the radii of the centerline. + cylinder(std::vector > inP, std::vector< T > inM) + : centerline(inP) + { + std::vector > temp; + stim::vec zero; + temp.resize(inM.size(), zero); + for(int i = 0; i < inM.size(); i++) + { + std::cerr << inP[i] << " " << inM[i] << std::endl; + temp[i][0] = inM[i]; + } + init(inP, temp); + } + ///Constructor defines a cylinder with centerline inP and magnitudes of zero ///@param inP: Vector of stim vec3 composing the points of the centerline cylinder(std::vector< stim::vec3 > inP) : centerline(inP) { - std::vector< stim::vec > inM; //create an array of arbitrary magnitudes + std::vector< T > inM; //create an array of arbitrary magnitudes stim::vec zero; zero.push_back(0); -- libgit2 0.21.4