Commit 1915119d authored by Maire Nicolas's avatar Maire Nicolas

Gestion dans le code du clipping à n plans avec des std::vector.

Codage et rajout du shader de clipping à n plans.
parent 4e10917d
......@@ -233,7 +233,7 @@ void StageShader::cb_initGL()
registerShader(m_shader);
m_shader->addPlaneClippingToShaderSource();
m_shader->setPlaneClipping(1);
}
void StageShader::updateVBOprimitives(int upType)
......
......@@ -123,7 +123,7 @@ void Stage_shader_number_two::cb_initGL()
registerShader(m_simpleColorShader) ;
registerShader(m_pointSprite) ;
m_phongShader->addPlaneClippingToShaderSource();
m_phongShader->setPlaneClipping(1);
}
void Stage_shader_number_two::cb_redraw()
......@@ -200,8 +200,8 @@ void Stage_shader_number_two::cb_mouseMove(int button, int x, int y)
if (button == Qt::LeftButton)
{
Geom::Vec4f clipPlane = m_phongShader->getClippingPlaneEquation();
clipPlane[0] += (m_mouseLastX - x)/20.0;
clipPlane[1] += (m_mouseLastY - y)/20.0;
clipPlane[0] += (m_mouseLastX - x)/40.0;
clipPlane[1] += (m_mouseLastY - y)/40.0;
m_phongShader->setClippingPlaneEquation(clipPlane);
......
......@@ -34,6 +34,8 @@
#include "Utils/shaderMutator.h"
#include "Utils/drawer.h"
#include <string>
#include <sstream>
#include <vector>
namespace CGoGN
{
......@@ -57,25 +59,29 @@ public:
/**
* set the plane equation for plane clipping
* @warning planeIndex starts at 0
* @param clipPlane plane equation
* @param planeIndex index of plane to modify
*/
void setClippingPlaneEquation(Geom::Vec4f clipPlane);
void setClippingPlaneEquation(Geom::Vec4f clipPlane, int planeIndex = 0);
/**
* get the plane equation for plane clipping
* @warning planeIndex starts at 0
* @param planeIndex index of plane to get
*/
Geom::Vec4f getClippingPlaneEquation();
Geom::Vec4f getClippingPlaneEquation(int planeIndex = 0);
/**
* set the plane quaternion for plane clipping
* @param quat plane quaternion
*/
void setClippingPlaneQuaternion(float quat[4]);
//void setClippingPlaneQuaternion(float quat[4]);
/**
* get the plane quaternion for plane clipping
*/
Geom::Vec4f getClippingPlaneQuaternion();
//Geom::Vec4f getClippingPlaneQuaternion();
/**
* set the color attenuation factor for clipping
......@@ -91,10 +97,16 @@ public:
/**
* insert plane clipping instructions into vertex and fragment shader source code
* - does not modify the geometry shader source code
* @warning this function is designed for shaders which do not use a geometry shader
* @param planesCount the clipping planes count to use
* @warning this function is designed for shaders which *do not* use a geometry shader
*/
void addPlaneClippingToShaderSource();
void setPlaneClipping(int planesCount);
/**
* get the clipping planes count used for plane clipping
*/
int getClippingPlanesCount() { return (int)m_clipPlanesEquations.size(); }
/**
* update uniforms (get their locations and resend their values) for clipping
*/
......@@ -109,19 +121,29 @@ public:
private:
/**
* clip plane vector (a, b, c, d)
* sends the clipping planes uniform to shader
*/
void sendClippingPlanesUniform();
/**
* sends the color attenuation factor uniform to shader
*/
void sendColorAttenuationFactorUniform();
/**
* clip planes equations (a, b, c, d)*planes count
*/
Geom::Vec4f m_clipPlaneEquation;
std::vector<float> m_clipPlanesEquations;
/**
* clip plane quaternion
*/
float m_clipPlaneQuaternion[4];
//float m_clipPlaneQuaternion[4];
/**
* clip plane vector uniform id
* clip planes vector uniform id
*/
GLint m_unif_clipPlane;
GLint m_unif_clipPlanes;
/**
* color attenuation factor
......
This diff is collapsed.
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