Commit 2c736586 authored by Thomas Pitiot 's avatar Thomas Pitiot

affichage closest pour debugging

parent 65c76644
......@@ -7,7 +7,7 @@ class Triangle
{
public:
Triangle(VEC3 p1, VEC3 p2, VEC3 p3,Surface * surf =NULL,Dart d=NIL,float rouge=0,float green =0, float blue=1.0f) :
p1(p1),p2(p2),p3(p3),surf(surf),cell(d),r(rouge),g(green),b(blue)
p1(p1),p2(p2),p3(p3),surf(surf),cell(d),r(rouge),g(green),b(blue),closest_point(p1)
{
}
// colors
......@@ -17,6 +17,7 @@ public:
float r;
float g;
float b;
VEC3 closest_point;
} ;
......
......@@ -97,6 +97,8 @@ class Volusion: public Utils::QT::SimpleQGLV
unsigned int dartSlider;
//MovingObject
Utils::VBO* m_closestVBO;
Utils::PointSprite* m_spriteClosest;
Utils::VBO* m_MovingObjectVBO;
Utils::PointSprite* m_sprite;
Utils::Drawer* m_ds;
......
......@@ -60,6 +60,7 @@ void Needle::color_close()
for(Triangle * t : sim_->envMap_.RegisteredTriangles[volume])
{
VEC3 closest = closestPointInTriangle(t->p1,t->p2,t->p3,pos);
t->closest_point=closest;
// CGoGNout<<"pos :"<<pos<<" || closest :"<<closest<<CGoGNendl;
distSq = (pos-closest).norm2();
if(distSq < ((pos-closest_point).norm2()))
......
......@@ -236,13 +236,32 @@ void Volusion::cb_initGL()
// m_sh2->setClipPlaneParamsAll(clip_id2, Geom::Vec3f(0,0,1), m_PosObj);
m_explode_render->setClippingPlane(Geom::Vec4f(0,0,1,m_PosObj*Geom::Vec3f(0,0,-1)));
m_closestVBO = new Utils::VBO();
m_closestVBO->setDataSize(3);
m_closestVBO->allocate(10000);
PFP::VEC3* data = static_cast<PFP::VEC3*>(m_closestVBO->lockPtr());
int j =0;
for(Surface * surf : simul.surfaces)
{
surf->initGL();
registerShader(surf->m_shader);
for(Triangle * t : surf->triangles_)
{
data[j]=t->closest_point;
j++;
}
}
m_closestVBO->releasePtr();
m_spriteClosest = new Utils::PointSprite();
m_spriteClosest->setAttributePosition(m_closestVBO);
m_spriteClosest->setSize(simul.aiguille->width);
m_spriteClosest->setColor(Geom::Vec4f(0.0f,1.0f,0.5f,1.0f));
registerShader(m_spriteClosest);
m_MovingObjectVBO = new Utils::VBO();
m_MovingObjectVBO->setDataSize(3);
......@@ -250,18 +269,20 @@ void Volusion::cb_initGL()
//initialisation aiguille
PFP::VEC3* data = static_cast<PFP::VEC3*>(m_MovingObjectVBO->lockPtr());
data = static_cast<PFP::VEC3*>(m_MovingObjectVBO->lockPtr());
for (unsigned int i=0; i< simul.aiguille->nbVertices; ++i)
{
VEC3 p = simul.aiguille->parts_[i]->getPosition();
data[i] = p;
}
data[simul.aiguille->nbVertices]=simul.aiguille->closest_point;
m_MovingObjectVBO->releasePtr();
m_sprite = new Utils::PointSprite();
m_sprite->setAttributePosition(m_MovingObjectVBO);
m_sprite->setSize(simul.aiguille->width/2.0);
m_sprite->setSize(simul.aiguille->width);
registerShader(m_sprite);
m_frame_MovingObject = new Utils::FrameManipulator();
......@@ -342,11 +363,26 @@ void Volusion::cb_redraw()
}
if(true) // affichage objets fixes
{
PFP::VEC3* data2 = static_cast<PFP::VEC3*>(m_closestVBO->lockPtr());
int j =0;
for(Surface * surf : simul.surfaces)
{
surf->draw();
for(Triangle * t : surf->triangles_)
{
data2[j]=t->closest_point;
j++;
}
}
m_closestVBO->releasePtr();
m_spriteClosest->enableVertexAttribs();
glDrawArrays(GL_POINTS, 0, j+1);
m_spriteClosest->disableVertexAttribs();
for (ArticulatedObject * art : simul.objects)
{
......
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