Commit 72f0a449 authored by Sylvain Thery's avatar Sylvain Thery

add clipping plane to pointSprite

parent 77aaa844
......@@ -67,6 +67,9 @@ public:
unsigned int setAttributePosition(VBO* vbo);
void setClippingPlane(const Geom::Vec4f& plane);
inline void setNoClippingPlane() { setClippingPlane(Geom::Vec4f(0.0f,0.0f,0.0f,0.0f)); }
};
} // namespace Utils
......
......@@ -3,6 +3,9 @@
uniform float size;
uniform mat4 ModelViewMatrix;
uniform mat4 ProjectionMatrix;
uniform vec4 planeClip;
VARYING_IN vec3 posClip[1];
#ifdef WITH_PLANE
uniform vec3 eyePos;
......@@ -37,10 +40,11 @@ void corner( vec4 center, float x, float y)
void main()
{
if (dot(planeClip,vec4(posClip[0],1.0))<0.0)
{
#ifdef WITH_COLOR_PER_VERTEX
colorsprite = color[0];
#endif
vec4 posCenter = ModelViewMatrix * POSITION_IN(0);
sphereCenter = posCenter.xyz;
......@@ -65,5 +69,6 @@ void main()
#endif
EndPrimitive();
}
}
......@@ -63,6 +63,11 @@ protected:
Geom::Vec3f m_ambiant;
Geom::Vec3f m_eyePos;
/// clipping
CGoGNGLuint m_unif_planeClip;
Geom::Vec4f m_planeClip;
void getLocations();
void sendParams();
......@@ -93,6 +98,11 @@ public:
* set the plane of rendering for VR rendering
*/
void setEyePosition(const Geom::Vec3f& ep);
void setClippingPlane(const Geom::Vec4f& plane);
inline void setNoClippingPlane() { setClippingPlane(Geom::Vec4f(0.0f,0.0f,0.0f,0.0f)); }
};
} // namespace Utils
......
......@@ -6,8 +6,11 @@ ATTRIBUTE vec3 VertexPosition;
VARYING_VERT vec4 color;
#endif
VARYING_VERT vec3 posClip;
void main ()
{
posClip = VertexPosition;
gl_Position = vec4(VertexPosition, 1.0);
#ifdef WITH_COLOR_PER_VERTEX
color = VertexColor;
......
......@@ -79,6 +79,7 @@ void PointSprite::getLocations()
*m_uniform_lightPos = glGetUniformLocation(program_handler(),"lightPos");
if (plane)
*m_uniform_eyePos = glGetUniformLocation(program_handler(),"eyePos");
*m_unif_planeClip = glGetUniformLocation(this->program_handler(), "planeClip");
unbind();
}
......@@ -92,6 +93,8 @@ void PointSprite::sendParams()
glUniform3fv(*m_uniform_lightPos, 1, m_lightPos.data());
if (plane)
glUniform3fv(*m_uniform_eyePos, 1, m_eyePos.data());
if (*m_unif_planeClip > 0)
glUniform4fv(*m_unif_planeClip, 1, m_planeClip.data());
unbind();
}
......@@ -163,6 +166,15 @@ void PointSprite::setEyePosition(const Geom::Vec3f& ep)
}
}
void PointSprite::setClippingPlane(const Geom::Vec4f& plane)
{
m_planeClip = plane;
bind();
glUniform4fv(*m_unif_planeClip, 1, plane.data());
unbind();
}
void PointSprite::restoreUniformsAttribs()
{
getLocations();
......
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