Commit dc7ea6b5 authored by Thomas Jund's avatar Thomas Jund

chgmt taille route et qq modif rendus

parent c799a614
......@@ -32,7 +32,7 @@ class ArticulatedObstacle;
#include "pfp.h"
#define EXPORTING3
//#define EXPORTING3
#ifdef EXPORTING3
#include "Utils/Shaders/shaderPhongTexture.h"
......
......@@ -58,7 +58,8 @@ public:
Utils::VBO* m_texcoordVBO;
Utils::ShaderPhongTexture* m_shaderTex;
ShaderCustomTex* m_shaderTex;
// Utils::ShaderPhongTexture* m_shaderTex;
// Utils::ShaderSimpleTexture* m_shaderTex;
Algo::Surface::Import::OBJModel<PFP2> m_obj;
unsigned int m_nbIndices;
......
......@@ -89,6 +89,8 @@ public:
void cb_keyPress(int keycode) ;
//RENDERING
// Utils::Drawer * dCD;
Geom::Vec4f colDif ;
Geom::Vec4f colSpec ;
Geom::Vec4f colClear ;
......
This diff is collapsed.
......@@ -126,8 +126,8 @@ void main()
// else
// gl_FragColor = vec4( (0.5+0.5*edgeEnhancement) * texture2D(u_FrameBufferColor,gl_TexCoord[0]).xyz, 1.0 );
if( gl_TexCoord[0].x > 0.5 )
// if( gl_TexCoord[0].x > 0.5 )
gl_FragColor = vec4( (0.25+0.75*edgeEnhancement) * texture2D(u_FrameBufferColor,gl_TexCoord[0]).xyz, 1.0 );
else
gl_FragColor = vec4( (1.0+0.0*edgeEnhancement) * texture2D(u_FrameBufferColor,gl_TexCoord[0]).xyz, 1.0 );
// else
// gl_FragColor = vec4( (1.0+0.0*edgeEnhancement) * texture2D(u_FrameBufferColor,gl_TexCoord[0]).xyz, 1.0 );
}
......@@ -128,6 +128,6 @@ void main()
if( gl_TexCoord[0].x > 0.5 )
gl_FragColor = vec4( (0.25+0.75*edgeEnhancement) * texture2D(u_FrameBufferColor,gl_TexCoord[0]).xyz, 1.0 );
else
gl_FragColor = vec4( (0.5+0.5*edgeEnhancement) * texture2D(u_FrameBufferColor,gl_TexCoord[0]).xyz, 1.0 );
// else
// gl_FragColor = vec4( (1.0+0.0*edgeEnhancement) * texture2D(u_FrameBufferColor,gl_TexCoord[0]).xyz, 1.0 );
}
......@@ -210,7 +210,7 @@ void Agent::updateObstacleNeighbors()
if ((obstacleNeighbors_.size() < maxMovingObstacles_|| distSq < maxDistObst)
&& distSq < rangeSq_)
{
if (Geom::testOrientation2D(part_.getPosition(), (*it)->p1, (*it)->p2) == Geom::RIGHT)
// if (Geom::testOrientation2D(part_.getPosition(), (*it)->p1, (*it)->p2) == Geom::RIGHT)
{
if (distSq > maxDistObst)
......
......@@ -77,7 +77,7 @@ void EnvMap::init(unsigned int config, REAL width, REAL height, REAL minSize, RE
{
case 0 :
// CityGenerator::generateGrid<PFP>(*this) ;
CityGenerator::generateCity<PFP>(*this,10) ;
CityGenerator::generateCity<PFP>(*this,0) ;
break ;
case 1 :
// CityGenerator::generateGrid<PFP>(*this) ;
......@@ -187,7 +187,7 @@ void EnvMap::init(unsigned int config, REAL width, REAL height, REAL minSize, RE
//subdivision to create footpath
MapBrowserSelector mbs(map, SelectorDartNoBoundary<PFP::MAP>(map));
map.setBrowser(&mbs);
Algo::Surface::Modelisation::TwoNPlusOneSubdivision<PFP,PFP::TVEC3, VEC3>(map,position);
Algo::Surface::Modelisation::TwoNPlusOneSubdivision<PFP,PFP::TVEC3, VEC3>(map,position,1.0f/5.0f);
map.setBrowser(NULL);
markPedWay();
......
......@@ -61,16 +61,16 @@ void MovingMesh::initGL()
m_texture->setWrapping(GL_CLAMP_TO_EDGE);
m_shaderTex = new Utils::ShaderPhongTexture();
m_shaderTex = new ShaderCustomTex();
// m_shaderTex = new Utils::ShaderSimpleTexture();
m_shaderTex->setAttributePosition(m_positionVBO);
m_shaderTex->setAttributeTexCoord(m_texcoordVBO);
m_shaderTex->setAttributeNormal(m_normalVBO);
// m_shaderTex->setAttributeNormal(m_normalVBO);
m_shaderTex->setTextureUnit(GL_TEXTURE0);
m_shaderTex->setTexture(m_texture);
m_shaderTex->setShininess(10.0f);
m_shaderTex->setAmbient(0.1f);
m_shaderTex->setSpecular(Geom::Vec4f(0.5));
// m_shaderTex->setShininess(10.0f);
// m_shaderTex->setAmbient(0.1f);
// m_shaderTex->setSpecular(Geom::Vec4f(0.5));
glEnable(GL_TEXTURE_2D);
......@@ -197,8 +197,8 @@ void MovingMesh::draw()
m_simpleColorShader->setColor(Geom::Vec4f(1.0,0.627,0.0,0.));
m_render->draw(m_simpleColorShader, Algo::Render::GL2::TRIANGLES);
// m_simpleColorShader->setColor(Geom::Vec4f(0.0,0.0,0.0,0.));
// m_render->draw(m_simpleColorShader, Algo::Render::GL2::LINES);
m_simpleColorShader->setColor(Geom::Vec4f(0.0,0.0,0.0,0.));
m_render->draw(m_simpleColorShader, Algo::Render::GL2::LINES);
#endif
}
......@@ -210,7 +210,9 @@ std::vector<VEC3> MovingMesh::computeProjectedPointSet(float maxHeight)
for(Dart dd = tv.begin() ; dd != tv.end() ; dd = tv.next())
{
if(position[dd][2]<maxHeight)
{
points.push_back(position[dd]);
}
}
points = jarvisConvexHull(points);
......@@ -232,6 +234,7 @@ std::vector<VEC3> MovingMesh::computeProjectedPointSet(float maxHeight)
{
if(active[i])
res.push_back(points[i]);
// std::cout << "fin " << points[i] << std::endl;
}
std::cout << "nb vertices before simplification -> " << points.size() << std::endl;
......@@ -287,7 +290,7 @@ std::vector<VEC3> MovingMesh::jarvisConvexHull(const std::vector<VEC3>& pointSet
if(pointSet[i][1]>pointSet[minPoint][1])
minPoint=i;
// convHull.push_back(minPoint);
res.push_back(pointSet[minPoint]);
curr = minPoint;
do {
......@@ -315,7 +318,6 @@ std::vector<VEC3> MovingMesh::jarvisConvexHull(const std::vector<VEC3>& pointSet
if(trouve)
{
curr = i-1;
// convHull.push_back(curr);
res.push_back(pointSet[curr]);
}
else
......@@ -326,11 +328,6 @@ std::vector<VEC3> MovingMesh::jarvisConvexHull(const std::vector<VEC3>& pointSet
} while(curr != minPoint);
// res.reserve(convHull.size());
//
// for(std::vector<unsigned int>::iterator it = convHull.begin() ; it != convHull.end() ; ++it)
// res.push_back(pointSet[*it]);
return res;
}
......
......@@ -498,11 +498,14 @@ void MovingObstacle::update()
float rigidity = 70.0f;
float stretch = rigidity*(edgeLength[dd]-v1.norm());
VEC3 f = stretch*(v1/norm);
if(norm>0.0f)
{
VEC3 f = stretch*(v1/norm);
//apply force symmetrically
forces[dd] -= f;
forces[map.phi1(dd)] += f;
//apply force symmetrically
forces[dd] -= f;
forces[map.phi1(dd)] += f;
}
}
dd = map.phi1(dd);
......@@ -526,11 +529,16 @@ void MovingObstacle::update()
float angularRig = 70.0f;
float curAngle = Algo::Surface::Geometry::angle<PFP>(map, map.phi_1(dd),map.phi1(dd),position);
float angularStretch = angularRig*(restAngle-curAngle);
VEC3 f = angularStretch*(v1/norm);
forces[dd] += f;
forces[map.phi1(dd)] -= f;
if(norm>0.0f && curAngle==curAngle) //test to avoid NaN
{
VEC3 f = angularStretch*(v1/norm);
forces[dd] += f;
forces[map.phi1(dd)] -= f;
}
}
}
......@@ -714,7 +722,7 @@ void MovingObstacle::computePrefVelocity() //calcul du vecteur optimal pour atte
float goalDist2 = goalVector.norm2() ;
if (goalDist2 < 750.0f)
if (goalDist2 < 1000.0f)
{
curGoal_ = (curGoal_ + 1) % goals_.size() ;
goalVector = goals_[curGoal_] - center ;
......
......@@ -47,7 +47,7 @@ void Simulator::init( float dimension, unsigned int nbAgent, unsigned int nbObst
setupSnakeCorridorScenario(nbAgent,nbObst,10) ;
break ;
case 3 :
envMap_.init(config, 500.0f, 500.0f, minSize, 100.0f) ; //grosses cases
envMap_.init(config, 1000.0f, 1000.0f, minSize, 100.0f) ; //grosses cases
setupScenario(nbAgent, false) ;
addMovingObstacles(nbObst);
addPathToObstacles();
......@@ -116,7 +116,7 @@ void Simulator::doStep()
movingObstacles_[i]->update() ;
// commente par Arash
// movingObstacles_[i]->updateMesh() ;
movingObstacles_[i]->updateMesh() ;
}
for (unsigned int i = 0 ; i < agents_.size() ; ++i)
......@@ -686,7 +686,9 @@ void Simulator::addMovingObstacle(Dart d, unsigned int obstType)
break;
case 1 :
{
mm = new MovingMesh(envMap_, d, "./meshRessources/Limace_2.obj");
mm = new MovingMesh(envMap_, d, "./meshRessources/LimaceLvl1.obj");
// mm = new MovingMesh(envMap_, d, "./meshRessources/cylinder.obj");
// mm = new MovingMesh(envMap_, d, "./meshRessources/simpleCyl.obj");
movingMeshes_.push_back(mm);
vPos = mm->computeProjectedPointSet(maxHeight);
......
......@@ -115,7 +115,7 @@ void SocialAgents::cb_initGL()
float tailleX = bb.size(0) ;
float tailleY = bb.size(1) ;
float tailleZ = bb.size(2) ;
float gWidthObj = std::max<float>(std::max<float>(tailleX, tailleY), tailleZ);///10.0f ;
float gWidthObj = std::max<float>(std::max<float>(tailleX, tailleY), tailleZ);///50.0f ;
setParamObject(gWidthObj, gPosObj.data()) ;
// choose to use GL version 2
......@@ -188,16 +188,24 @@ void SocialAgents::cb_initGL()
void SocialAgents::initRendering()
{
// dCD = new Utils::Drawer();
// registerShader(dCD->getShader());
if(simulator.config==5)
{
m_render_scenary->initPrimitives<PFP>(simulator.envMap_.mapScenary, Algo::Render::GL2::LINES,false) ;
m_render_scenary->initPrimitives<PFP>(simulator.envMap_.mapScenary, Algo::Render::GL2::TRIANGLES,false) ;
m_render->initPrimitives<PFP>(simulator.envMap_.map, Algo::Render::GL2::LINES,false) ;
MapBrowserSelector mbs(simulator.envMap_.map,SelectorCellMarked<FACE>(simulator.envMap_.pedWayMark));
simulator.envMap_.map.setBrowser(&mbs);
m_render->initPrimitives<PFP>(simulator.envMap_.map, Algo::Render::GL2::TRIANGLES,false) ;
m_renderPedway->initPrimitives<PFP>(simulator.envMap_.map, Algo::Render::GL2::TRIANGLES,false) ;
simulator.envMap_.map.setBrowser(NULL);
m_render->initPrimitives<PFP>(simulator.envMap_.map, Algo::Render::GL2::LINES,false) ;
m_renderPedway->initPrimitives<PFP>(simulator.envMap_.map, Algo::Render::GL2::LINES,false) ;
m_renderPedway->initPrimitives<PFP>(simulator.envMap_.map, Algo::Render::GL2::TRIANGLES,false) ;
}
else
{
......@@ -495,8 +503,8 @@ void SocialAgents::cb_redraw()
glEnable(GL_POINT_SMOOTH);
glHint(GL_POINT_SMOOTH_HINT, GL_NICEST);
glEnable(GL_POLYGON_OFFSET_FILL) ;
glPolygonOffset( 2.0f,2.0f) ;
// glEnable(GL_POLYGON_OFFSET_FILL) ;
// glPolygonOffset( 2.0f,2.0f) ;
#ifdef EXPORTING
// m_Ground_Shader->enableVertexAttribs();
......@@ -507,7 +515,7 @@ void SocialAgents::cb_redraw()
#endif
glDisable(GL_POLYGON_OFFSET_FILL) ;
// glDisable(GL_POLYGON_OFFSET_FILL) ;
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL) ;
......@@ -569,13 +577,30 @@ void SocialAgents::cb_redraw()
moShader->enableVertexAttribs();
glDrawArrays(GL_POLYGON, 0, simulator.movingObstacles_[i]->nbVertices);
moShader->disableVertexAttribs();
// dCD->newList(GL_COMPILE_AND_EXECUTE);
// dCD->begin(GL_POINTS);
// dCD->lineWidth(1.0f);
// dCD->pointSize(10.0f);
// dCD->color3f(0,1,0);
// for(unsigned int j = 0 ; j < simulator.movingObstacles_[i]->nbVertices ; ++j)
// {
// VEC3 p = simulator.movingObstacles_[i]->getPosition(j);
// dCD->vertex3f(p[0], p[1], p[2]) ;
// }
//
// dCD->end();
// dCD->endList();
}
// Commente par Arash
/*for (std::vector<MovingMesh*>::iterator it = simulator.movingMeshes_.begin() ; it != simulator.movingMeshes_.end() ; ++it)
for (std::vector<MovingMesh*>::iterator it = simulator.movingMeshes_.begin() ; it != simulator.movingMeshes_.end() ; ++it)
{
(*it)->draw();
}*/
}
glColor3f(1.0f, 1.0f, 1.0f) ;
for (std::vector<MovingObstacle*>::iterator it = simulator.movingObstacles_.begin() ; it != simulator.movingObstacles_.end() ; ++it)
......@@ -674,7 +699,7 @@ void SocialAgents::cb_redraw()
{
glEnable(GL_LIGHTING) ;
glEnable(GL_POLYGON_OFFSET_FILL) ;
glPolygonOffset(1.0f, 1.0f) ;
glPolygonOffset(-3.0f, -3.0f) ;
switch(m_renderStyle)
{
case SIMPLE:
......@@ -1519,9 +1544,20 @@ void SocialAgents::cb_keyPress(int keycode)
std::string filename2("myAgents.pos") ;
simulator.exportAgents(filename2) ;
std::cout << "exporting meshes" << std::endl ;
std::string filename3("roadMap.ply") ;
std::string filename3("pedway.ply") ;
std::string filename4("buildingMap.ply") ;
std::string filename5("road.ply") ;
MapBrowserSelector mbs(simulator.envMap_.map,SelectorCellMarked<FACE>(simulator.envMap_.pedWayMark));
simulator.envMap_.map.setBrowser(&mbs);
Algo::Surface::Export::exportPLY<PFP>(simulator.envMap_.map, simulator.envMap_.position,filename3.c_str(), false);
MapBrowserSelector mbs2(simulator.envMap_.map,SelectorCellUnmarked<FACE>(simulator.envMap_.pedWayMark));
simulator.envMap_.map.setBrowser(&mbs2);
Algo::Surface::Export::exportPLY<PFP>(simulator.envMap_.map, simulator.envMap_.position,filename5.c_str(), false);
simulator.envMap_.map.setBrowser(NULL);
if(simulator.config==5)
Algo::Surface::Export::exportPLY<PFP>(simulator.envMap_.mapScenary, simulator.envMap_.positionScenary,filename4.c_str(), false);
break ;
......
......@@ -39,9 +39,9 @@
inkscape:window-height="991"
id="namedview20587"
showgrid="false"
inkscape:zoom="7.2407736"
inkscape:cx="340.96034"
inkscape:cy="899.38878"
inkscape:zoom="0.32000001"
inkscape:cx="1726.1139"
inkscape:cy="842.54778"
inkscape:window-x="1920"
inkscape:window-y="27"
inkscape:window-maximized="1"
......@@ -18927,9 +18927,10 @@
inkscape:connector-curvature="0" />
<path
style="fill:none;stroke:#bababa;stroke-width:16;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1"
d="m 465.15625,-83.187619 0.59766,14.1289 0.30468,7.0664 1.125,23.7774 0.87891,19.8593 1.42969,31.5664 0.82812,18.2461 1.4375,27.1368"
d="m 465.75391,-69.058719 0.30468,7.0664 1.125,23.7774 0.87891,19.8593 1.42969,31.5664 0.82812,18.2461 1.4375,27.1368"
id="path6395"
inkscape:connector-curvature="0" />
inkscape:connector-curvature="0"
sodipodi:nodetypes="ccccccc" />
<path
style="fill:none;stroke:#bababa;stroke-width:16;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1"
d="M 68.300781,970.19517 60.59375,958.57407 -7.335938,856.03118 c -21.353094,-33.1877 -42.729473,-66.3603 -64.078124,-99.5508"
......@@ -18969,10 +18970,10 @@
inkscape:connector-curvature="0" />
<path
style="fill:none;stroke:#bababa;stroke-width:16;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1"
d="M 465.15625,-83.187619 C 395.91458,-34.292706 323.73073,20.569222 264.35547,64.367081"
d="m 465.75391,-69.058719 -28.06047,5.45266 c 0,0 -121.77912,89.941012 -173.33797,127.97314"
id="path6411"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
sodipodi:nodetypes="ccc" />
<path
style="fill:none;stroke:#bababa;stroke-width:16;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1"
d="m 1029.9336,593.50377 c 22.593,-77.74253 58.8961,-154.43335 78.6992,-232.9844"
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