Commit 7893575b authored by Pierre Kraemer's avatar Pierre Kraemer

allow PointSprite to draw transparent spheres

parent e6fb3a99
......@@ -128,7 +128,7 @@ void Viewer::cb_redraw()
{
float size = vertexScaleFactor ;
m_pointSprite->setSize(size) ;
m_pointSprite->predraw(Geom::Vec3f(0.0f, 0.0f, 1.0f)) ;
m_pointSprite->predraw(Geom::Vec4f(0.0f, 0.0f, 1.0f, 1.0f)) ;
m_render->draw(m_pointSprite, Algo::Render::GL2::POINTS) ;
m_pointSprite->postdraw() ;
}
......
......@@ -200,7 +200,7 @@ void MyQT::cb_redraw()
if (render_balls)
{
m_sprite->predraw(Geom::Vec3f(1.0f, 0.0f ,0.0f));
m_sprite->predraw(Geom::Vec4f(1.0f, 0.0f , 0.0f, 1.0f));
m_render->draw(m_sprite, Algo::Render::GL2::POINTS);
m_sprite->postdraw();
}
......
......@@ -99,7 +99,7 @@ void RenderPlugin::redraw(View* view)
{
m_pointSprite->setSize(m->getBBdiagSize() / 200.0f * p->verticesScaleFactor);
m_pointSprite->setAttributePosition(p->positionVBO);
m_pointSprite->predraw(CGoGN::Geom::Vec3f(0.0f, 0.0f, 1.0f));
m_pointSprite->predraw(CGoGN::Geom::Vec4f(0.0f, 0.0f, 1.0f, 1.0f));
m->draw(m_pointSprite, CGoGN::Algo::Render::GL2::POINTS);
m_pointSprite->postdraw();
}
......
......@@ -8,13 +8,14 @@
#include "mapHandler.h"
#include "Utils/pointSprite.h"
#include "Container/fakeAttribute.h"
#include "NL/nl.h"
#include "Algo/LinearSolving/basic.h"
#include "Eigen/Dense"
namespace CGoGN
{
......@@ -111,8 +112,11 @@ protected:
SurfaceDeformationDockTab* m_dockTab;
QHash<View*, ParameterSet*> h_viewParams;
Utils::PointSprite* m_pointSprite;
Utils::Drawer* m_drawer;
Utils::VBO* selectionSphereVBO;
bool selecting;
PFP2::VEC3 selectionCenter;
PFP2::REAL selectionRadius;
......
......@@ -110,6 +110,11 @@ bool SurfaceDeformationPlugin::enable()
m_dockTab = new SurfaceDeformationDockTab(m_window, this);
addTabInDock(m_dockTab, "Surface Deformation");
selectionSphereVBO = new Utils::VBO();
m_pointSprite = new CGoGN::Utils::PointSprite();
registerShader(m_pointSprite);
m_drawer = new Utils::Drawer();
registerShader(m_drawer->getShader());
......@@ -122,6 +127,7 @@ bool SurfaceDeformationPlugin::enable()
void SurfaceDeformationPlugin::disable()
{
delete m_pointSprite;
delete m_drawer;
}
......@@ -129,25 +135,22 @@ void SurfaceDeformationPlugin::redraw(View* view)
{
if(selecting)
{
glDisable(GL_LIGHTING) ;
m_drawer->newList(GL_COMPILE_AND_EXECUTE) ;
m_drawer->lineWidth(2.0f) ;
m_drawer->begin(GL_LINES) ;
m_drawer->color3f(0.0f, 0.0f, 1.0f) ;
m_drawer->vertex(selectionCenter) ;
m_drawer->vertex(selectionCenter + selectionRadius * PFP2::VEC3(1,0,0)) ;
m_drawer->vertex(selectionCenter) ;
m_drawer->vertex(selectionCenter + selectionRadius * PFP2::VEC3(-1,0,0)) ;
m_drawer->vertex(selectionCenter) ;
m_drawer->vertex(selectionCenter + selectionRadius * PFP2::VEC3(0,1,0)) ;
m_drawer->vertex(selectionCenter) ;
m_drawer->vertex(selectionCenter + selectionRadius * PFP2::VEC3(0,-1,0)) ;
m_drawer->vertex(selectionCenter) ;
m_drawer->vertex(selectionCenter + selectionRadius * PFP2::VEC3(0,0,1)) ;
m_drawer->vertex(selectionCenter) ;
m_drawer->vertex(selectionCenter + selectionRadius * PFP2::VEC3(0,0,-1)) ;
m_drawer->end() ;
m_drawer->endList() ;
std::vector<PFP2::VEC3> selectionPoint;
selectionPoint.push_back(selectionCenter);
selectionSphereVBO->updateData(selectionPoint);
m_pointSprite->setSize(selectionRadius);
m_pointSprite->setAttributePosition(selectionSphereVBO);
m_pointSprite->predraw(CGoGN::Geom::Vec4f(0.0f, 0.0f, 1.0f, 0.5f));
m_pointSprite->enableVertexAttribs();
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glDrawArrays(GL_POINTS, 0, 1);
glDisable(GL_BLEND);
m_pointSprite->disableVertexAttribs();
m_pointSprite->postdraw();
}
ParameterSet* params = h_viewParams[view];
......
......@@ -12,7 +12,7 @@ uniform float size;
#ifdef WITH_COLOR_PER_VERTEX
VARYING_FRAG vec3 colorsprite;
#else
uniform vec3 colorsprite;
uniform vec4 colorsprite;
#endif
VARYING_FRAG vec2 spriteCoord;
......@@ -51,6 +51,8 @@ void main(void)
vec3 L = normalize (lightPos - frag_position_eye);
float lambertTerm = dot(N,L);
gl_FragColor = vec4(colorsprite*lambertTerm + ambiant ,1.0);
vec4 result = colorsprite*lambertTerm;
result.xyz += ambiant;
gl_FragColor = result;
}
......@@ -88,7 +88,7 @@ public:
* call once before sending points to gpu
* @param color set global color of sprites
*/
void predraw(const Geom::Vec3f& color);
void predraw(const Geom::Vec4f& color);
/**
* call once before sending points to gpu
......
......@@ -124,11 +124,11 @@ unsigned int PointSprite::setAttributeColor(VBO* vbo)
return bindVA_VBO("VertexColor", vbo);
}
void PointSprite::predraw(const Geom::Vec3f& color)
void PointSprite::predraw(const Geom::Vec4f& color)
{
bind();
glUniform1i(*m_uniform_texture, 0);
glUniform3fv(*m_uniform_color, 1, color.data());
glUniform4fv(*m_uniform_color, 1, color.data());
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, *m_idTexture);
glEnable(GL_TEXTURE_2D);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment