Commit 10aeeaff authored by Sylvain Thery's avatar Sylvain Thery

Text3D: add clear function

Pickable: add constructor that generate LineDrawable for you
FrameManipulator: small bug in scale
shaderExplodeVolumes invert clipping plane direction
parent 53149cff
......@@ -12,7 +12,7 @@ void main(void)
{
float d = dot(plane,POSITION_IN(0));
if (d>=0.0)
if (d<=0.0)
{
vec3 v1 = POSITION_IN(2).xyz - POSITION_IN(1).xyz;
vec3 v2 = POSITION_IN(3).xyz - POSITION_IN(1).xyz;
......
......@@ -11,7 +11,7 @@ void main(void)
{
float d = dot(plane,POSITION_IN(0));
if (d>=0.0)
if (d<=0.0)
{
ColorFS = color;
......
......@@ -138,18 +138,41 @@ protected:
/// id of pickable
unsigned int m_id;
bool m_allocated;
/**
* comparison operator for depth ordered picking
*/
static bool distOrder(const std::pair<float, Pickable*>& e1, const std::pair<float, Pickable*>& e2);
public:
enum {GRID, SPHERE,CONE,CYLINDER,CUBE,ICOSPHERE};
/**
* constructor
* @param ld LineDrawable to use for drawing & picking
* @param id for picking
*/
Pickable(LineDrawable* ld, unsigned int id);
/**
* constructor with internal drawable allocation
* @param object GRID, SPHERE,CONE,CYLINDER,CUBE or ICOSPHERE
* @param id for picking
*/
Pickable(int object, unsigned int id);
/**
* destructor
*/
~Pickable();
/**
* get drawable pointer (usefull for modifying rendering parameters)
*/
LineDrawable* drawable() { return m_drawable;}
/**
* picking
* @param P camera point
......
......@@ -97,6 +97,11 @@ public:
*/
unsigned int addString(const std::string& str, const Geom::Vec3f& pos);
/**
* clear the string and position database
*/
void clear();
/**
* once all string are stored, we must send it to the gracphic card
*/
......
......@@ -122,8 +122,9 @@ std::string GLSLShader::defines_Geom(const std::string& primitivesIn, const std:
}
else
{
std::string str("#extension GL_EXT_geometry_shader4 : enable\n");
str.append("#define PRECISION\n");
std::string str("#version 110\n");
str.append("#extension GL_EXT_geometry_shader4 : enable\n");
str.append("#define PRECISON float pipo_PRECISION\n");
str.append("#define ATTRIBUTE attribute\n");
str.append("#define VARYING_IN varying in\n");
str.append("#define VARYING_OUT varying out\n");
......
......@@ -131,6 +131,8 @@ FrameManipulator::FrameManipulator():
m_vboPos->bind();
glBufferData(GL_ARRAY_BUFFER, points.size() * sizeof(Geom::Vec3f), &(points[0]), GL_STREAM_DRAW);
setLengthAxes();
}
void FrameManipulator::setSize(float radius)
......@@ -862,14 +864,19 @@ float FrameManipulator::distanceFromMouse(int dx, int dy)
float FrameManipulator::scaleFromMouse(int dx, int dy)
{
Geom::Vec3f dV(float(dx), float(dy), 0.0f);
float sc = dV*m_projectedSelectedAxis;
if (sc>0)
sc = dV.norm()/100.0f;
else
sc = dV.norm()/-100.0f;
return 1.0f + sc;
if (fabs(dx) > fabs(dy))
{
if (dx>0)
return 1.01;
return 0.99;
}
else
{
if (dy>0)
return 1.01;
return 0.99;
}
}
void FrameManipulator::translateInScreen(int dx, int dy)
......
......@@ -87,10 +87,45 @@ void LineDrawable::getPrecisionDrawing(unsigned int& sub, unsigned int& sub2)
Pickable::Pickable(LineDrawable* ld, unsigned int id):
m_drawable(ld),m_transfo(1.0f), m_id(id)
m_drawable(ld),m_transfo(1.0f), m_id(id), m_allocated(false)
{
}
Pickable::Pickable(int object, unsigned int id):
m_transfo(1.0f), m_id(id), m_allocated(true)
{
switch (object)
{
case GRID:
m_drawable = new Grid();
break;
case SPHERE:
m_drawable = new Sphere();
break;
case CONE:
m_drawable = new Sphere();
break;
case CYLINDER:
m_drawable = new Cylinder();
break;
case CUBE:
m_drawable = new Cube();
break;
case ICOSPHERE:
m_drawable = new IcoSphere();
break;
default:
break;
}
}
Pickable::~Pickable()
{
if (m_allocated)
delete m_drawable;
}
void Pickable::invertPV(const Geom::Vec3f& P, const Geom::Vec3f& V, const glm::mat4& transfo, Geom::Vec3f& PP, Geom::Vec3f& VV)
{
glm::mat4 invtr = glm::inverse(transfo);
......
......@@ -108,6 +108,14 @@ Strings3D::~Strings3D()
{
}
void Strings3D::clear()
{
m_nbChars=0;
m_strings.clear();
m_strTranslate.clear();
m_strpos.clear();
}
unsigned int Strings3D::addString(const std::string& str)
{
unsigned int id = m_strings.size();
......
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