From 7bbd4da3eeb572ff63d96cb231e9dbb63fb3d143 Mon Sep 17 00:00:00 2001 From: Sylvain Thery Date: Thu, 6 Jun 2013 10:10:15 +0200 Subject: [PATCH] render topo3 primal final --- include/Algo/Render/GL2/topo3PrimalRender.h | 7 ++ include/Algo/Render/GL2/topo3PrimalRender.hpp | 90 +++++++++++-------- src/Algo/Render/topo3PrimalRender.cpp | 8 +- 3 files changed, 65 insertions(+), 40 deletions(-) diff --git a/include/Algo/Render/GL2/topo3PrimalRender.h b/include/Algo/Render/GL2/topo3PrimalRender.h index 6677b19a..d9fb96d3 100644 --- a/include/Algo/Render/GL2/topo3PrimalRender.h +++ b/include/Algo/Render/GL2/topo3PrimalRender.h @@ -106,6 +106,11 @@ protected: */ Geom::Vec3f m_dartsColor; + /** + * initial darts color for boundary (set in update) + */ + Geom::Vec3f m_boundaryDartsColor; + /** * attribute index to get easy correspondence dart/color */ @@ -203,6 +208,8 @@ public: */ void setInitialDartsColor(float r, float g, float b); + void setInitialBoundaryDartsColor(float r, float g, float b); + /** * overdraw a dart with given width and color * @param d the dart diff --git a/include/Algo/Render/GL2/topo3PrimalRender.hpp b/include/Algo/Render/GL2/topo3PrimalRender.hpp index a8c8736a..8172be64 100644 --- a/include/Algo/Render/GL2/topo3PrimalRender.hpp +++ b/include/Algo/Render/GL2/topo3PrimalRender.hpp @@ -56,27 +56,24 @@ void Topo3PrimalRender::setDartsIdColor(typename PFP::MAP& map) for (Dart d = map.begin(); d != map.end(); map.next(d)) { - if ( !map.isBoundaryMarked3(d)) // topo3 Render do not traverse boundary + if (nb < m_nbDarts) { - if (nb < m_nbDarts) - { - float r,g,b; - dartToCol(d, r,g,b); - - float* local = colorBuffer+3*m_attIndex[d]; // get the right position in VBO - *local++ = r; - *local++ = g; - *local++ = b; - *local++ = r; - *local++ = g; - *local++ = b; - nb++; - } - else - { - CGoGNerr << "Error buffer too small for color picking (change the selector parameter ?)" << CGoGNendl; - break; - } + float r,g,b; + dartToCol(d, r,g,b); + + float* local = colorBuffer+3*m_attIndex[d]; // get the right position in VBO + *local++ = r; + *local++ = g; + *local++ = b; + *local++ = r; + *local++ = g; + *local++ = b; + nb++; + } + else + { + CGoGNerr << "Error buffer too small for color picking (change the selector parameter ?)" << CGoGNendl; + break; } } glUnmapBuffer(GL_ARRAY_BUFFER); @@ -91,18 +88,15 @@ void Topo3PrimalRender::updateColors(typename PFP::MAP& map, const VertexAttribu for (Dart d = map.begin(); d != map.end(); map.next(d)) { - if ( !map.isBoundaryMarked3(d)) // topo3 Render do not traverse boundary + if (nb < m_nbDarts) { - if (nb < m_nbDarts) - { - colorBuffer[m_attIndex[d]] = colors[d]; - nb++; - } - else - { - CGoGNerr << "Error buffer too small for color picking (change the selector parameter ?)" << CGoGNendl; - break; - } + colorBuffer[m_attIndex[d]] = colors[d]; + nb++; + } + else + { + CGoGNerr << "Error buffer too small for color picking (change the selector parameter ?)" << CGoGNendl; + break; } } glUnmapBuffer(GL_ARRAY_BUFFER); @@ -198,22 +192,40 @@ void Topo3PrimalRender::updateData(typename PFP::MAP& mapx, const VertexAttribut *positionDartBuf++ = P; *positionDartBuf++ = PP; - *positionDartBuf++ = Q; - *positionDartBuf++ = QQ; - *colorDartBuf++ = m_dartsColor; - *colorDartBuf++ = m_dartsColor; - *colorDartBuf++ = m_dartsColor; - *colorDartBuf++ = m_dartsColor; + if (map.isBoundaryMarked3(d)) + { + *colorDartBuf++ = m_boundaryDartsColor; + *colorDartBuf++ = m_boundaryDartsColor; + } + else + { + *colorDartBuf++ = m_dartsColor; + *colorDartBuf++ = m_dartsColor; + } m_attIndex[d] = posDBI; posDBI+=2; - fv2[d] = (P+PP)*0.5f; + + + *positionDartBuf++ = Q; + *positionDartBuf++ = QQ; + Dart dx = map.phi3(d); - fv2[dx] = (Q+QQ)*0.5f; + if (map.isBoundaryMarked3(dx)) + { + *colorDartBuf++ = m_boundaryDartsColor; + *colorDartBuf++ = m_boundaryDartsColor; + } + else + { + *colorDartBuf++ = m_dartsColor; + *colorDartBuf++ = m_dartsColor; + } m_attIndex[dx] = posDBI; posDBI+=2; + fv2[dx] = (Q+QQ)*0.5f; d = mapx.phi1(d); } diff --git a/src/Algo/Render/topo3PrimalRender.cpp b/src/Algo/Render/topo3PrimalRender.cpp index 22f26f6a..6397f96f 100644 --- a/src/Algo/Render/topo3PrimalRender.cpp +++ b/src/Algo/Render/topo3PrimalRender.cpp @@ -48,6 +48,7 @@ Topo3PrimalRender::Topo3PrimalRender(): m_topo_relation_width(3.0f), m_color_save(NULL), m_dartsColor(1.0f,1.0f,1.0f), + m_boundaryDartsColor(0.5f,0.5f,0.5f), m_bufferDartPosition(NULL) { m_vbo0 = new Utils::VBO(); @@ -127,7 +128,6 @@ void Topo3PrimalRender::setAllDartsColor(float r, float g, float b) *colorDartBuf++ = b; } glUnmapBufferARB(GL_ARRAY_BUFFER); - } void Topo3PrimalRender::setInitialDartsColor(float r, float g, float b) @@ -135,6 +135,12 @@ void Topo3PrimalRender::setInitialDartsColor(float r, float g, float b) m_dartsColor = Geom::Vec3f(r,g,b); } +void Topo3PrimalRender::setInitialBoundaryDartsColor(float r, float g, float b) +{ + m_boundaryDartsColor = Geom::Vec3f(r,g,b); +} + + void Topo3PrimalRender::drawDarts() { if (m_nbDarts==0) -- GitLab