Commit a67bbdf2 authored by Thery Sylvain's avatar Thery Sylvain
Browse files

Merge branch 'master' of cgogn:CGoGN

parents 81751915 2433e28a
...@@ -212,7 +212,7 @@ void verticesRaySelection(typename PFP::MAP& map, const VertexAttribute<typename ...@@ -212,7 +212,7 @@ void verticesRaySelection(typename PFP::MAP& map, const VertexAttribute<typename
template<typename PFP> template<typename PFP>
void volumesRaySelection(typename PFP::MAP& map, const VertexAttribute<typename PFP::VEC3>& position, const FunctorSelect& good, const typename PFP::VEC3& rayA, const typename PFP::VEC3& rayAB, std::vector<Dart>& vecVolumes) void volumesRaySelection(typename PFP::MAP& map, const VertexAttribute<typename PFP::VEC3>& position, const FunctorSelect& good, const typename PFP::VEC3& rayA, const typename PFP::VEC3& rayAB, std::vector<Dart>& vecVolumes)
{ {
std::vector<Dart>& vecFaces; std::vector<Dart> vecFaces;
std::vector<typename PFP::VEC3> iPoints; std::vector<typename PFP::VEC3> iPoints;
// get back intersected faces // get back intersected faces
...@@ -425,7 +425,7 @@ void facesPlanSelection(typename PFP::MAP& map, const VertexAttribute<typename P ...@@ -425,7 +425,7 @@ void facesPlanSelection(typename PFP::MAP& map, const VertexAttribute<typename P
* @param angle angle of the code in degree. * @param angle angle of the code in degree.
*/ */
template<typename PFP> template<typename PFP>
void verticesConeSelection(typename PFP::MAP& map, const VertexAttribute<typename PFP::VEC3>& position, const typename PFP::VEC3& rayA, const typename PFP::VEC3& rayAB, float angle, std::vector<Dart>& vecVertices, const FunctorSelect& good= allDarts) void verticesConeSelection(typename PFP::MAP& map, const VertexAttribute<typename PFP::VEC3>& position, const typename PFP::VEC3& rayA, const typename PFP::VEC3& rayAB, float angle, std::vector<Dart>& vecVertices, const FunctorSelect& good)
{ {
typename PFP::REAL AB2 = rayAB * rayAB; typename PFP::REAL AB2 = rayAB * rayAB;
...@@ -533,7 +533,7 @@ void edgesConeSelection(typename PFP::MAP& map, const VertexAttribute<typename P ...@@ -533,7 +533,7 @@ void edgesConeSelection(typename PFP::MAP& map, const VertexAttribute<typename P
template<typename PFP> template<typename PFP>
Dart verticesBubbleSelection(typename PFP::MAP& map, const VertexAttribute<typename PFP::VEC3>& position, const typename PFP::VEC3& cursor, typename PFP::REAL radiusMax, const FunctorSelect& good=allDarts) Dart verticesBubbleSelection(typename PFP::MAP& map, const VertexAttribute<typename PFP::VEC3>& position, const typename PFP::VEC3& cursor, typename PFP::REAL radiusMax, const FunctorSelect& good)
{ {
typename PFP::REAL l2max = radiusMax*radiusMax; typename PFP::REAL l2max = radiusMax*radiusMax;
typename PFP::REAL l2min(std::numeric_limits<float>::max()); typename PFP::REAL l2min(std::numeric_limits<float>::max());
...@@ -555,7 +555,7 @@ Dart verticesBubbleSelection(typename PFP::MAP& map, const VertexAttribute<typen ...@@ -555,7 +555,7 @@ Dart verticesBubbleSelection(typename PFP::MAP& map, const VertexAttribute<typen
template<typename PFP> template<typename PFP>
Dart edgesBubbleSelection(typename PFP::MAP& map, const VertexAttribute<typename PFP::VEC3>& position, const typename PFP::VEC3& cursor, typename PFP::REAL radiusMax, const FunctorSelect& good=allDarts) Dart edgesBubbleSelection(typename PFP::MAP& map, const VertexAttribute<typename PFP::VEC3>& position, const typename PFP::VEC3& cursor, typename PFP::REAL radiusMax, const FunctorSelect& good)
{ {
typename PFP::REAL l2max = radiusMax*radiusMax; typename PFP::REAL l2max = radiusMax*radiusMax;
typename PFP::REAL l2min(std::numeric_limits<float>::max()); typename PFP::REAL l2min(std::numeric_limits<float>::max());
...@@ -661,7 +661,7 @@ Dart edgesBubbleSelection(typename PFP::MAP& map, const VertexAttribute<typename ...@@ -661,7 +661,7 @@ Dart edgesBubbleSelection(typename PFP::MAP& map, const VertexAttribute<typename
// //
// //
//template<typename PFP> //template<typename PFP>
//void verticesRaySelection(typename PFP::MAP& map, const VertexAttribute<typename PFP::VEC3>& position, const typename PFP::VEC3& rayA, const typename PFP::VEC3& rayAB, std::vector<Dart>& vecVertices, float dist, const FunctorSelect& good= allDarts, unsigned int nbth=0, unsigned int current_thread=0) //void verticesRaySelection(typename PFP::MAP& map, const VertexAttribute<typename PFP::VEC3>& position, const typename PFP::VEC3& rayA, const typename PFP::VEC3& rayAB, std::vector<Dart>& vecVertices, float dist, const FunctorSelect& good , unsigned int nbth=0, unsigned int current_thread=0)
//{ //{
// typename PFP::REAL dist2 = dist * dist; // typename PFP::REAL dist2 = dist * dist;
// typename PFP::REAL AB2 = rayAB * rayAB; // typename PFP::REAL AB2 = rayAB * rayAB;
......
...@@ -42,6 +42,8 @@ class ShaderPhong : public ClippingShader ...@@ -42,6 +42,8 @@ class ShaderPhong : public ClippingShader
protected: protected:
// flag color per vertex or not // flag color per vertex or not
bool m_with_color; bool m_with_color;
// flag color per vertex or not
bool m_with_eyepos;
// shader sources OGL3 // shader sources OGL3
static std::string vertexShaderText; static std::string vertexShaderText;
...@@ -53,6 +55,7 @@ protected: ...@@ -53,6 +55,7 @@ protected:
CGoGNGLuint m_unif_specular; CGoGNGLuint m_unif_specular;
CGoGNGLuint m_unif_shininess; CGoGNGLuint m_unif_shininess;
CGoGNGLuint m_unif_lightPos; CGoGNGLuint m_unif_lightPos;
CGoGNGLuint m_unif_eyePos;
//values //values
Geom::Vec4f m_ambiant; Geom::Vec4f m_ambiant;
...@@ -60,6 +63,7 @@ protected: ...@@ -60,6 +63,7 @@ protected:
Geom::Vec4f m_specular; Geom::Vec4f m_specular;
float m_shininess; float m_shininess;
Geom::Vec3f m_lightPos; Geom::Vec3f m_lightPos;
Geom::Vec3f m_eyePos;
VBO* m_vboPos; VBO* m_vboPos;
VBO* m_vboNormal; VBO* m_vboNormal;
...@@ -72,7 +76,7 @@ protected: ...@@ -72,7 +76,7 @@ protected:
void restoreUniformsAttribs(); void restoreUniformsAttribs();
public: public:
ShaderPhong(bool doubleSided = false); ShaderPhong(bool doubleSided = false, bool withEyePosition=false);
// inviduals parameter setting functions // inviduals parameter setting functions
void setAmbiant(const Geom::Vec4f& ambiant); void setAmbiant(const Geom::Vec4f& ambiant);
...@@ -83,7 +87,10 @@ public: ...@@ -83,7 +87,10 @@ public:
void setShininess(float shininess); void setShininess(float shininess);
void setLightPosition(Geom::Vec3f lp); void setLightPosition(const Geom::Vec3f& lp);
/// set eye position for VR environement
void setEyePosition(const Geom::Vec3f& ep);
const Geom::Vec4f& getAmbiant() const { return m_ambiant; } const Geom::Vec4f& getAmbiant() const { return m_ambiant; }
......
...@@ -9,18 +9,28 @@ uniform mat4 ModelViewMatrix; ...@@ -9,18 +9,28 @@ uniform mat4 ModelViewMatrix;
uniform mat4 NormalMatrix; uniform mat4 NormalMatrix;
uniform vec3 lightPosition; uniform vec3 lightPosition;
VARYING_VERT vec3 EyeVector, Normal, LightDir; VARYING_VERT vec3 EyeVector, Normal, LightDir;
#ifdef WITH_COLOR #ifdef WITH_COLOR
VARYING_VERT vec3 Color; VARYING_VERT vec3 Color;
#endif #endif
#ifdef WITH_EYEPOSITION
uniform vec3 eyePosition;
#endif
INVARIANT_POS; INVARIANT_POS;
void main () void main ()
{ {
Normal = vec3 (NormalMatrix * vec4 (VertexNormal, 0.0)); Normal = vec3 (NormalMatrix * vec4 (VertexNormal, 0.0));
vec3 Position = vec3 (ModelViewMatrix * vec4 (VertexPosition, 1.0)); vec3 Position = vec3 (ModelViewMatrix * vec4 (VertexPosition, 1.0));
LightDir = lightPosition - Position; LightDir = lightPosition - Position;
EyeVector = -Position; #ifdef WITH_EYEPOSITION
EyeVector = eyePosition-Position;
#else
EyeVector = -Position;
#endif
#ifdef WITH_COLOR #ifdef WITH_COLOR
Color = VertexColor; Color = VertexColor;
#endif #endif
gl_Position = ModelViewProjectionMatrix * vec4 (VertexPosition, 1.0); gl_Position = ModelViewProjectionMatrix * vec4 (VertexPosition, 1.0);
} }
...@@ -19,8 +19,10 @@ void main(void) ...@@ -19,8 +19,10 @@ void main(void)
if (lum==0.0) if (lum==0.0)
discard; discard;
vec2 v = texCoord-vec2(0.5,0.5); vec2 v = texCoord-vec2(0.5,0.5);
#ifndef WITH_PLANE
float z = size * sqrt(1.0-dot(v,v)); float z = size * sqrt(1.0-dot(v,v));
vec2 zfrag = positionFragIn + vec2(z,0.0); vec2 zfrag = positionFragIn + vec2(z,0.0);
gl_FragDepth = 0.5 + 0.5 * dot(zfrag, mvpFragIn.xy) / dot(zfrag, mvpFragIn.zw); gl_FragDepth = 0.5 + 0.5 * dot(zfrag, mvpFragIn.xy) / dot(zfrag, mvpFragIn.zw);
#endif
gl_FragColor = vec4(colorsprite,0.0)*lum; gl_FragColor = vec4(colorsprite,0.0)*lum;
} }
...@@ -12,31 +12,58 @@ VARYING_OUT vec4 mvpFragIn; ...@@ -12,31 +12,58 @@ VARYING_OUT vec4 mvpFragIn;
VARYING_OUT vec3 colorsprite; VARYING_OUT vec3 colorsprite;
#endif #endif
#ifdef WITH_PLANE
uniform vec3 planeX;
uniform vec3 planeY;
#endif
void main() void main()
{ {
vec4 posCenter = ModelViewMatrix * POSITION_IN(0);
vec4 pos = posCenter + vec4(-size, size, 0.0, 0.0); #ifdef WITH_COLOR_PER_VERTEX
positionFragIn = posCenter.zw; colorsprite = color[0];
#endif
mvpFragIn.x = ProjectionMatrix[2][2]; mvpFragIn.x = ProjectionMatrix[2][2];
mvpFragIn.y = ProjectionMatrix[3][2]; mvpFragIn.y = ProjectionMatrix[3][2];
mvpFragIn.z = ProjectionMatrix[2][3]; mvpFragIn.z = ProjectionMatrix[2][3];
mvpFragIn.w = ProjectionMatrix[3][3]; mvpFragIn.w = ProjectionMatrix[3][3];
texCoord = vec2(0.0,1.0);
vec4 posCenter = ModelViewMatrix * POSITION_IN(0);
positionFragIn = posCenter.zw;
#ifdef WITH_COLOR_PER_VERTEX texCoord = vec2(0.0,1.0);
colorsprite = color[0]; #ifdef WITH_PLANE
#endif vec4 pos = posCenter - size*vec4(planeX,0.0) + size*vec4(planeY,0.0) + size*vec4(0.0,0.0,0.5,0.0);
#else
vec4 pos = posCenter + vec4(-size, size, 0.0, 0.0);
#endif
gl_Position = ProjectionMatrix * pos; gl_Position = ProjectionMatrix * pos;
EmitVertex(); EmitVertex();
pos = posCenter + vec4(-size, -size, 0.0, 0.0);
#ifdef WITH_PLANE
pos = posCenter - size*vec4(planeX,0.0) - size*vec4(planeY,0.0) + size*vec4(0.0,0.0,0.5,0.0);
#else
pos = posCenter + vec4(-size, -size, 0.0, 0.0);
#endif
texCoord = vec2(0.0,0.0); texCoord = vec2(0.0,0.0);
gl_Position = ProjectionMatrix * pos; gl_Position = ProjectionMatrix * pos;
EmitVertex(); EmitVertex();
pos = posCenter + vec4( size, size, 0.0, 0.0);
#ifdef WITH_PLANE
pos = posCenter + size*vec4(planeX,0.0) + size*vec4(planeY,0.0) + size*vec4(0.0,0.0,0.5,0.0);
#else
pos = posCenter + vec4(size, size, 0.0, 0.0);
#endif
texCoord = vec2(1.0,1.0); texCoord = vec2(1.0,1.0);
gl_Position = ProjectionMatrix * pos; gl_Position = ProjectionMatrix * pos;
EmitVertex(); EmitVertex();
pos = posCenter + vec4( size,-size, 0.0, 0.0);
#ifdef WITH_PLANE
pos = posCenter + size*vec4(planeX,0.0) - size*vec4(planeY,0.0) + size*vec4(0.0,0.0,0.5,0.0);
#else
pos = posCenter + vec4(size, -size, 0.0, 0.0);
#endif
texCoord = vec2(1.0,0.0); texCoord = vec2(1.0,0.0);
gl_Position = ProjectionMatrix * pos; gl_Position = ProjectionMatrix * pos;
EmitVertex(); EmitVertex();
......
...@@ -61,6 +61,10 @@ protected: ...@@ -61,6 +61,10 @@ protected:
CGoGNGLuint m_idTexture; CGoGNGLuint m_idTexture;
CGoGNGLuint m_uniform_texture; CGoGNGLuint m_uniform_texture;
CGoGNGLuint m_uniform_planeX;
CGoGNGLuint m_uniform_planeY;
public: public:
/** /**
...@@ -69,7 +73,7 @@ public: ...@@ -69,7 +73,7 @@ public:
* @param radius of sphere * @param radius of sphere
*/ */
PointSprite(bool withColorPerVertex=false, float radius=1.0f); PointSprite(bool withColorPerVertex=false, float radius=1.0f, bool with_plane=false);
/** /**
* clean shaders, texture and variables * clean shaders, texture and variables
...@@ -97,6 +101,12 @@ public: ...@@ -97,6 +101,12 @@ public:
* @param radius * @param radius
*/ */
void setSize(float radius); void setSize(float radius);
/**
* set the plane of rendering for VR rendering
*/
void setPlane(const Geom::Vec3f& ox, const Geom::Vec3f& oy);
/** /**
* set position attribute * set position attribute
......
...@@ -80,9 +80,13 @@ protected: ...@@ -80,9 +80,13 @@ protected:
CGoGNGLuint m_uniform_position; CGoGNGLuint m_uniform_position;
CGoGNGLuint m_uniform_color; CGoGNGLuint m_uniform_color;
CGoGNGLuint m_uniform_planeX;
CGoGNGLuint m_uniform_planeY;
public: public:
Strings3D(bool withBackground = true, const Geom::Vec3f& bgc = Geom::Vec3f(0)); Strings3D(bool withBackground = true, const Geom::Vec3f& bgc = Geom::Vec3f(0), bool with_plane=false);
~Strings3D(); ~Strings3D();
...@@ -112,7 +116,7 @@ public: ...@@ -112,7 +116,7 @@ public:
void sendToVBO(); void sendToVBO();
/** /**
* draw on string * draw one string
* @param idSt the id of string * @param idSt the id of string
* @param pos the position of text * @param pos the position of text
*/ */
...@@ -140,6 +144,11 @@ public: ...@@ -140,6 +144,11 @@ public:
* @param scale * @param scale
*/ */
void setScale(float scale); void setScale(float scale);
/**
* set the plane of rendering for VR rendering
*/
void setPlane(const Geom::Vec3f& ox, const Geom::Vec3f& oy);
void toSVG(Utils::SVG::SVGOut& svg); void toSVG(Utils::SVG::SVGOut& svg);
......
...@@ -7,9 +7,22 @@ uniform vec3 strPos; ...@@ -7,9 +7,22 @@ uniform vec3 strPos;
uniform float scale; uniform float scale;
VARYING_VERT vec2 tex_coord; VARYING_VERT vec2 tex_coord;
INVARIANT_POS; INVARIANT_POS;
#ifdef WITH_PLANE
uniform vec3 planeX;
uniform vec3 planeY;
#endif
void main () void main ()
{ {
#ifdef WITH_PLANE
vec4 pos = ModelViewMatrix * vec4(strPos,1.0);
pos += scale*VertexPosition[0]*vec4(planeX,0.0);
pos += scale*VertexPosition[1]*vec4(planeY,0.0);
#else
vec4 pos = ModelViewMatrix * vec4(strPos,1.0) + vec4(VertexPosition[0]*scale,VertexPosition[1]*scale,0.0,0.0); vec4 pos = ModelViewMatrix * vec4(strPos,1.0) + vec4(VertexPosition[0]*scale,VertexPosition[1]*scale,0.0,0.0);
#endif
tex_coord = vec2(VertexPosition[2],VertexPosition[3]); tex_coord = vec2(VertexPosition[2],VertexPosition[3]);
gl_Position = ProjectionMatrix * pos; gl_Position = ProjectionMatrix * pos;
} }
......
...@@ -34,8 +34,9 @@ namespace Utils ...@@ -34,8 +34,9 @@ namespace Utils
#include "shaderPhong.frag" #include "shaderPhong.frag"
ShaderPhong::ShaderPhong(bool doubleSided): ShaderPhong::ShaderPhong(bool doubleSided, bool withEyePosition):
m_with_color(false), m_with_color(false),
m_with_eyepos(withEyePosition),
m_ambiant(Geom::Vec4f(0.05f,0.05f,0.1f,0.0f)), m_ambiant(Geom::Vec4f(0.05f,0.05f,0.1f,0.0f)),
m_diffuse(Geom::Vec4f(0.1f,1.0f,0.1f,0.0f)), m_diffuse(Geom::Vec4f(0.1f,1.0f,0.1f,0.0f)),
m_specular(Geom::Vec4f(1.0f,1.0f,1.0f,0.0f)), m_specular(Geom::Vec4f(1.0f,1.0f,1.0f,0.0f)),
...@@ -53,6 +54,8 @@ ShaderPhong::ShaderPhong(bool doubleSided): ...@@ -53,6 +54,8 @@ ShaderPhong::ShaderPhong(bool doubleSided):
// get choose GL defines (2 or 3) // get choose GL defines (2 or 3)
// ans compile shaders // ans compile shaders
std::string glxvert(*GLSLShader::DEFINES_GL); std::string glxvert(*GLSLShader::DEFINES_GL);
if (m_with_eyepos)
glxvert.append("#define WITH_EYEPOSITION");
glxvert.append(vertexShaderText); glxvert.append(vertexShaderText);
std::string glxfrag(*GLSLShader::DEFINES_GL); std::string glxfrag(*GLSLShader::DEFINES_GL);
// Use double sided lighting if set // Use double sided lighting if set
...@@ -75,6 +78,8 @@ void ShaderPhong::getLocations() ...@@ -75,6 +78,8 @@ void ShaderPhong::getLocations()
*m_unif_specular = glGetUniformLocation(this->program_handler(), "materialSpecular"); *m_unif_specular = glGetUniformLocation(this->program_handler(), "materialSpecular");
*m_unif_shininess = glGetUniformLocation(this->program_handler(), "shininess"); *m_unif_shininess = glGetUniformLocation(this->program_handler(), "shininess");
*m_unif_lightPos = glGetUniformLocation(this->program_handler(), "lightPosition"); *m_unif_lightPos = glGetUniformLocation(this->program_handler(), "lightPosition");
if (m_with_eyepos)
*m_unif_eyePos = glGetUniformLocation(this->program_handler(), "eyePosition");
} }
void ShaderPhong::sendParams() void ShaderPhong::sendParams()
...@@ -84,6 +89,8 @@ void ShaderPhong::sendParams() ...@@ -84,6 +89,8 @@ void ShaderPhong::sendParams()
glUniform4fv(*m_unif_specular, 1, m_specular.data()); glUniform4fv(*m_unif_specular, 1, m_specular.data());
glUniform1f(*m_unif_shininess, m_shininess); glUniform1f(*m_unif_shininess, m_shininess);
glUniform3fv(*m_unif_lightPos, 1, m_lightPos.data()); glUniform3fv(*m_unif_lightPos, 1, m_lightPos.data());
if (m_with_eyepos)
glUniform3fv(*m_unif_eyePos, 1, m_eyePos.data());
} }
void ShaderPhong::setAmbiant(const Geom::Vec4f& ambiant) void ShaderPhong::setAmbiant(const Geom::Vec4f& ambiant)
...@@ -114,13 +121,23 @@ void ShaderPhong::setShininess(float shininess) ...@@ -114,13 +121,23 @@ void ShaderPhong::setShininess(float shininess)
m_shininess = shininess; m_shininess = shininess;
} }
void ShaderPhong::setLightPosition( Geom::Vec3f lightPos) void ShaderPhong::setLightPosition(const Geom::Vec3f& lightPos)
{ {
this->bind(); this->bind();
glUniform3fv(*m_unif_lightPos,1,lightPos.data()); glUniform3fv(*m_unif_lightPos,1,lightPos.data());
m_lightPos = lightPos; m_lightPos = lightPos;
} }
void ShaderPhong::setEyePosition(const Geom::Vec3f& eyePos)
{
if (m_with_eyepos)
{
this->bind();
glUniform3fv(*m_unif_eyePos,1,eyePos.data());
m_eyePos = eyePos;
}
}
void ShaderPhong::setParams(const Geom::Vec4f& ambiant, const Geom::Vec4f& diffuse, const Geom::Vec4f& specular, float shininess, const Geom::Vec3f& lightPos) void ShaderPhong::setParams(const Geom::Vec4f& ambiant, const Geom::Vec4f& diffuse, const Geom::Vec4f& specular, float shininess, const Geom::Vec3f& lightPos)
{ {
m_ambiant = ambiant; m_ambiant = ambiant;
......
...@@ -41,7 +41,7 @@ PointSprite* PointSprite::m_instance0 = NULL; ...@@ -41,7 +41,7 @@ PointSprite* PointSprite::m_instance0 = NULL;
PointSprite::PointSprite(bool withColorPervertex, float radius) PointSprite::PointSprite(bool withColorPervertex, float radius, bool with_plane)
{ {
std::string defineColor("#define WITH_COLOR_PER_VERTEX 1\n"); std::string defineColor("#define WITH_COLOR_PER_VERTEX 1\n");
...@@ -53,11 +53,16 @@ PointSprite::PointSprite(bool withColorPervertex, float radius) ...@@ -53,11 +53,16 @@ PointSprite::PointSprite(bool withColorPervertex, float radius)
std::string glxgeom = GLSLShader::defines_Geom("points","triangle_strip",4); std::string glxgeom = GLSLShader::defines_Geom("points","triangle_strip",4);
if (withColorPervertex) if (withColorPervertex)
glxgeom.append(defineColor); glxgeom.append(defineColor);
if (with_plane)
glxgeom.append("#define WITH_PLANE 1\n");
glxgeom.append(geometryShaderText); glxgeom.append(geometryShaderText);
std::string glxfrag(*GLSLShader::DEFINES_GL); std::string glxfrag(*GLSLShader::DEFINES_GL);
if (withColorPervertex) if (withColorPervertex)
glxfrag.append(defineColor); glxfrag.append(defineColor);
if (with_plane)
glxfrag.append("#define WITH_PLANE 1\n");
glxfrag.append(fragmentShaderText); glxfrag.append(fragmentShaderText);
loadShadersFromMemory(glxvert.c_str(), glxfrag.c_str(), glxgeom.c_str(), GL_POINTS, GL_TRIANGLE_STRIP,4); loadShadersFromMemory(glxvert.c_str(), glxfrag.c_str(), glxgeom.c_str(), GL_POINTS, GL_TRIANGLE_STRIP,4);
...@@ -85,6 +90,12 @@ PointSprite::PointSprite(bool withColorPervertex, float radius) ...@@ -85,6 +90,12 @@ PointSprite::PointSprite(bool withColorPervertex, float radius)
} }
*m_uniform_texture = glGetUniformLocation(program_handler(),"SpriteTexture"); *m_uniform_texture = glGetUniformLocation(program_handler(),"SpriteTexture");
if (with_plane)
{
*m_uniform_planeX = glGetUniformLocation(program_handler(),"planeX");
*m_uniform_planeY = glGetUniformLocation(program_handler(),"planeY");
}
} }
PointSprite::~PointSprite() PointSprite::~PointSprite()
...@@ -138,6 +149,15 @@ void PointSprite::setSize(float radius) ...@@ -138,6 +149,15 @@ void PointSprite::setSize(float radius)
unbind(); unbind();
} }
void PointSprite::setPlane(const Geom::Vec3f& ox, const Geom::Vec3f& oy)
{
bind();
glUniform3fv(*m_uniform_planeX, 1, ox.data());
glUniform3fv(*m_uniform_planeY, 1, oy.data());
unbind();
}
void PointSprite::computeSphere() void PointSprite::computeSphere()
{ {
if (m_ptrSphere == NULL) // normally useless if (m_ptrSphere == NULL) // normally useless
......
...@@ -43,7 +43,7 @@ std::string Strings3D::fragmentShaderText2 = ...@@ -43,7 +43,7 @@ std::string Strings3D::fragmentShaderText2 =
Strings3D* Strings3D::m_instance0 = NULL; Strings3D* Strings3D::m_instance0 = NULL;
Strings3D::Strings3D(bool withBackground, const Geom::Vec3f& bgc) : m_nbChars(0),m_scale(1.0f) Strings3D::Strings3D(bool withBackground, const Geom::Vec3f& bgc, bool with_plane) : m_nbChars(0),m_scale(1.0f)
{ {
if (m_instance0 == NULL) if (m_instance0 == NULL)
{ {
...@@ -67,6 +67,8 @@ Strings3D::Strings3D(bool withBackground, const Geom::Vec3f& bgc) : m_nbChars(0) ...@@ -67,6 +67,8 @@ Strings3D::Strings3D(bool withBackground, const Geom::Vec3f& bgc) : m_nbChars(0)
} }
std::string glxvert(*GLSLShader::DEFINES_GL); std::string glxvert(*GLSLShader::DEFINES_GL);
if (with_plane)
glxvert.append("#define WITH_PLANE 1");
glxvert.append(vertexShaderText);