diff --git a/include/Algo/Render/GL2/explodeVolumeRender.h b/include/Algo/Render/GL2/explodeVolumeRender.h index 91b0756ea71ecaffab62d4e30ce884d836696e47..68b9c760acb3ab5a6ff7254998e1c9a5899057a6 100644 --- a/include/Algo/Render/GL2/explodeVolumeRender.h +++ b/include/Algo/Render/GL2/explodeVolumeRender.h @@ -107,15 +107,21 @@ public: void updateData(typename PFP::MAP& map, typename PFP::TVEC3& positions, const FunctorSelect& good = allDarts); /** - * draw + * draw edges */ void drawEdges(); + /** + * draw edges + */ void drawFaces(); - void setExplodeVolumes(float explode) { m_shader->setExplodeVolumes(explode);m_shaderL->setExplodeVolumes(explode);} + void setClippingPlane(const Geom::Vec4f& p) {m_shader->setClippingPlane(p); m_shaderL->setClippingPlane(p);} + + void setNoClippingPlane() { Geom::Vec4f p(0.0f,0.0f,10000.0f,100000000000000000000000000.0f); m_shader->setClippingPlane(p); m_shaderL->setClippingPlane(p);} + void setAmbiant(const Geom::Vec4f& ambiant) { m_shader->setAmbiant(ambiant);} void setDiffuse(const Geom::Vec4f& diffuse) { m_shader->setDiffuse(diffuse);} diff --git a/include/Utils/Shaders/shaderExplodeVolumes.geom b/include/Utils/Shaders/shaderExplodeVolumes.geom index 4dd68f23a3fd3a498b618f93c4ecec7e3ab6b4a1..217169b2c79eac0e586021c79ffbc70331814abc 100644 --- a/include/Utils/Shaders/shaderExplodeVolumes.geom +++ b/include/Utils/Shaders/shaderExplodeVolumes.geom @@ -6,30 +6,35 @@ uniform mat4 ModelViewMatrix; uniform vec3 lightPosition; uniform vec4 diffuse; uniform vec4 ambient; +uniform vec4 plane; VARYING_OUT vec4 ColorFS; void main(void) { - - vec3 v1 = POSITION_IN(2).xyz - POSITION_IN(1).xyz; - vec3 v2 = POSITION_IN(3).xyz - POSITION_IN(1).xyz; - vec3 N = cross(v1,v2); - N = normalize (vec3(NormalMatrix*vec4(N,0.0))); + float d = dot(plane,POSITION_IN(0)); -// compute face center & lighting informations - vec4 newPos = ModelViewMatrix * POSITION_IN(1); - vec3 L = normalize (lightPosition - newPos.xyz); - float lambertTerm = dot(N,L); - ColorFS = ambient; - if (lambertTerm > 0.0) - ColorFS += diffuse * lambertTerm; - -// Explode in face - - for (int i=1; i=0.0) { - vec4 P = explodeV * POSITION_IN(i) + (1.0-explodeV)* POSITION_IN(0); - gl_Position = ModelViewProjectionMatrix * P; - EmitVertex(); + vec3 v1 = POSITION_IN(2).xyz - POSITION_IN(1).xyz; + vec3 v2 = POSITION_IN(3).xyz - POSITION_IN(1).xyz; + vec3 N = cross(v1,v2); + N = normalize (vec3(NormalMatrix*vec4(N,0.0))); + + // compute face center & lighting informations + vec4 newPos = ModelViewMatrix * POSITION_IN(1); + vec3 L = normalize (lightPosition - newPos.xyz); + float lambertTerm = dot(N,L); + ColorFS = ambient; + if (lambertTerm > 0.0) + ColorFS += diffuse * lambertTerm; + + // Explode in face + + for (int i=1; i=0.0) { - vec4 P = explodeV * POSITION_IN(i) + (1.0-explodeV)* POSITION_IN(0); - gl_Position = ModelViewProjectionMatrix * P; - EmitVertex(); - } - EndPrimitive(); + ColorFS = color; + + for (int i=1; i