Coupure prévue mardi 3 Août au matin pour maintenance du serveur. Nous faisons au mieux pour que celle-ci soit la plus brève possible.

Commit 36742a28 authored by Thomas Jund's avatar Thomas Jund
Browse files

passage a qglviewer et code pr video

parent 51b490c1
......@@ -80,8 +80,8 @@ public:
// VertexAttribute<VEC3> position;
// VertexAttribute<VEC3> normal;
VEC3 previousPos;
float previousRot;
// VEC3 previousPos;
// float previousRot;
Geom::Matrix44f m_transfo;
// Algo::Render::GL2::MapRender* m_render;
......
......@@ -86,7 +86,8 @@ public:
float angle_X, float angle_Y, float angle_Z) ;
#endif
void cb_keyPress(int keycode) ;
// void cb_keyPress(int keycode) ;
void keyPressEvent(QKeyEvent *e);
//RENDERING
Geom::Vec4f colDif ;
......
......@@ -18,7 +18,8 @@ float Agent::averageMaxSpeed_ = 2.0f ;
float Agent::neighborDist_ = 20.0f ;
float Agent::neighborDistSq_ = neighborDist_ * neighborDist_ ;
//float Agent::radius_ = 8.0f ;
float Agent::radius_ = 1.5f ;
float Agent::radius_ = 3.0f ;
//float Agent::radius_ = 1.5f ;
//float Agent::timeHorizon_ = 10.0f ;
float Agent::timeHorizon_ = 100.0f ;
float Agent::timeHorizonObst_ = 10.0f ;
......@@ -511,8 +512,8 @@ void Agent::update()
Geom::rotateZ(myRot,m_transfo);
Geom::translate(displ[0],displ[1],displ[2],m_transfo);
m_transfo.transpose();
previousPos = getPosition();
previousRot = myRot;
// previousPos = getPosition();
// previousRot = myRot;
#endif
}
......
......@@ -256,7 +256,8 @@ void MovingObstacle::draw()
// m_render->initPrimitives<PFP>(map, Algo::Render::GL2::LINES,false) ;
// m_render->initPrimitives<PFP>(map, Algo::Render::GL2::TRIANGLES,false) ;
m_positionVBO->updateData(position);
m_shader->setColor(Geom::Vec4f(movingObstacleNeighbors_.size()>1 ? 1.0f : 0,0.,0.,0.));
// m_shader->setColor(Geom::Vec4f(movingObstacleNeighbors_.size()==0 ? 1.0f : 0,0.,0.,0.));
m_shader->setColor(Geom::Vec4f(1.0f,0.,0.,0.0));
m_render->draw(m_shader, Algo::Render::GL2::TRIANGLES);
m_shader->setColor(Geom::Vec4f(0.,0.,0.,0.));
m_render->draw(m_shader, Algo::Render::GL2::LINES);
......
......@@ -229,8 +229,8 @@ void SocialAgents::initRendering()
m_obst_render.push_back(new Algo::Render::GL2::MapRender());
Utils::ShaderFlat * shader = new Utils::ShaderFlat();
shader->setAmbiant(Geom::Vec4f(1.,0.,0.,0.)) ;
shader->setDiffuse(Geom::Vec4f(1.,0.,0.,0.));
shader->setAmbiant(Geom::Vec4f(1.,1.,0.,0.)) ;
shader->setDiffuse(Geom::Vec4f(1.,1.,0.,0.));
Utils::VBO * vbo = new Utils::VBO();
vbo->setDataSize(3);
......@@ -624,6 +624,9 @@ void SocialAgents::cb_redraw()
glDrawArrays(GL_TRIANGLES, 0, m_nbIndicesAgent);
m_shaderTexAgent->disableVertexAttribs();
}
// glDrawArraysInstanced(GL_TRIANGLES, 0, m_nbIndicesAgent, simulator.agents_.size());
#else
PFP::VEC3* data = static_cast<PFP::VEC3*>(m_agentsVBO->lockPtr());
for (unsigned int i=0; i< simulator.agents_.size(); ++i)
......@@ -685,14 +688,14 @@ void SocialAgents::cb_redraw()
if (drawMovingObstacles)
{
// updateObstacleVBO();
updateObstacleVBO();
for(unsigned int i = 0 ; i < simulator.movingObstacles_.size() ; ++i)
{
// Utils::ShaderFlat* moShader = m_obstShader[i];
// moShader->enableVertexAttribs();
// glDrawArrays(GL_POLYGON, 0, simulator.movingObstacles_[i]->nbVertices);
// moShader->disableVertexAttribs();
Utils::ShaderFlat* moShader = m_obstShader[i];
moShader->enableVertexAttribs();
glDrawArrays(GL_POLYGON, 0, simulator.movingObstacles_[i]->nbVertices);
moShader->disableVertexAttribs();
#ifdef EXPORTING_BOXES
simulator.movingObstacles_[i]->draw();
......@@ -825,9 +828,9 @@ void SocialAgents::cb_redraw()
if (drawEnvFaces)
{
glEnable(GL_LIGHTING) ;
// glEnable(GL_LIGHTING) ;
glEnable(GL_POLYGON_OFFSET_FILL) ;
glPolygonOffset(-0.1f, -0.1f) ;
glPolygonOffset(1.0f, -0.5f) ;
switch(m_renderStyle)
{
case SIMPLE:
......@@ -1043,108 +1046,138 @@ void SocialAgents::animate()
#ifndef SPATIAL_HASHING
if (render_anim)
{
std::ostringstream oss ;
std::ostringstream tmpNb ;
tmpNb << std::setfill('0') << std::setw(5) << nbGeneratedPov ;
// oss << "./DeCirkelMesh/meshCercle" << tmpNb.str() << ".pov" ;
oss << "./DeCorridorMesh/meshCorrida" << tmpNb.str() << ".pov" ;
std::string chaine = oss.str() ;
// VEC3 agPos = sim.agents_[0]->meanPos_ ;
// agPos[2] = agPos[1] ;
// agPos[1] = 0.0f ;
// VEC3 camPos(agPos) ;
// VEC3 camLook(agPos) ;
// camPos = camPos
// + VEC3(-10 - 0.05 * nbGenerated, 30 + 0.05 * nbGenerated,
// log(1.0f + nbGenerated / 700.0f)) ;
//travelling city nbMaxAgent 15000, nbSquare 40 (45?)
// VEC3 camPos(-800, 10, -800) ;
// camPos = camPos
// + VEC3(-10 - 0.3 * nbGenerated, 30 + 0.3 * nbGenerated,
// 400.0f * log(1.0f + nbGenerated / 700.0f)) ;
// VEC3 camLook(0, 0, 0) ;
// camLook = camLook
// + VEC3(-10 - 0.1 * nbGenerated, 30 + 0.1 * nbGenerated,
// 400.0f * log(1.0f + nbGenerated / 700.0f)) ;
//travelling horizontal
// VEC3 camPos(0, 5, -200) ;
// camPos = camPos + VEC3(-10 - 0.15 * nbGenerated, 0, 0) ;
// VEC3 camLook = camPos ;
// camLook[0] += 0.15 * nbGenerated ;
// camLook[2] += 100 ;
// camLook[1] = 0 ;
//vertical view
// VEC3 camPos(0, 300, 0) ;
// Geom::BoundingBox<VEC3> bb = simulator.getAgentsBB() ;
// VEC3 seeEveryone = bb.max() - bb.min() ;
// if (seeEveryone[0] > 200)
// camPos[1] += seeEveryone[0] ;
// else
// camPos[1] += 200 ;
// VEC3 camLook(0) ;
//video intro
// VEC3 camPos(-20, 10, 75) ;
// VEC3 camLook(-25, 0, 0) ;
//mall
// VEC3 camPos(-500, 500, -400) ;
// VEC3 camLook(100, 100, 0) ;
//openStreetMap
// VEC3 camPos(500, 75, 400) ;
// VEC3 camLook(-250, 0, 650) ;
//pathDyn
// VEC3 camPos(-700, 700, -1800) ;
// VEC3 camLook(200, 0, 0) ;
//corridor side
// VEC3 camPos(-700, 100, 0) ;
// VEC3 camLook(200, 0, 0) ;
//corridor top
// VEC3 camPos(0, 300, 0) ;
// VEC3 camLook(0, 0, 0) ;
//corridor take2
// VEC3 camPos(-350, 200, 0) ;
// VEC3 camLook(0, 0, 0) ;
//openStreetMap mapRoad & mapBuildings
// VEC3 camPos(-200, 100, 500) ;
// VEC3 camLook(1000, 0, 0) ;
if(nbIterations%2==1)
{
getQGLWidget()->resize(800,600);
updateGL() ;
// getQGLWidget()->setSnapshotQuality(100);
std::ostringstream tmpNb ;
unsigned int counter = getQGLWidget()->snapshotCounter();
tmpNb << std::setfill('0') << std::setw(5) << counter ;
getQGLWidget()->setSnapshotCounter(++counter);
QString filename("./export/meshCercleD" );
filename.append((tmpNb.str()).c_str());
filename.append(".png");
// getQGLWidget()->setSnapshotFileName(filename);
// getQGLWidget()->setSnapshotFormat(QString("PNG"));
QImage image = getQGLWidget()->grabFrameBuffer ();
if( !image.save( filename, "PNG" ) )
{
QMessageBox::warning( this, "Save Image", "Error saving image." );
}
//openStreetMap sphere
// VEC3 camPos(-200, 100, 500) ;
// VEC3 camLook(100, 0, 0) ;
if (nbIterations >= 7500)
{
std::cout << "enough .png generated" << std::endl ;
exit(0) ;
}
}
// //diligences / Cercle
// std::ostringstream oss ;
// std::ostringstream tmpNb ;
// tmpNb << std::setfill('0') << std::setw(5) << nbGeneratedPov ;
//// oss << "./DeCirkelMesh/meshCercle" << tmpNb.str() << ".pov" ;
// oss << "./DeCorridorMesh/meshCorrida" << tmpNb.str() << ".pov" ;
// std::string chaine = oss.str() ;
//// VEC3 agPos = sim.agents_[0]->meanPos_ ;
//// agPos[2] = agPos[1] ;
//// agPos[1] = 0.0f ;
//// VEC3 camPos(agPos) ;
//// VEC3 camLook(agPos) ;
//
//// camPos = camPos
//// + VEC3(-10 - 0.05 * nbGenerated, 30 + 0.05 * nbGenerated,
//// log(1.0f + nbGenerated / 700.0f)) ;
//
////travelling city nbMaxAgent 15000, nbSquare 40 (45?)
//// VEC3 camPos(-800, 10, -800) ;
//// camPos = camPos
//// + VEC3(-10 - 0.3 * nbGenerated, 30 + 0.3 * nbGenerated,
//// 400.0f * log(1.0f + nbGenerated / 700.0f)) ;
//// VEC3 camLook(0, 0, 0) ;
//// camLook = camLook
//// + VEC3(-10 - 0.1 * nbGenerated, 30 + 0.1 * nbGenerated,
//// 400.0f * log(1.0f + nbGenerated / 700.0f)) ;
//
////travelling horizontal
//// VEC3 camPos(0, 5, -200) ;
//// camPos = camPos + VEC3(-10 - 0.15 * nbGenerated, 0, 0) ;
//// VEC3 camLook = camPos ;
//// camLook[0] += 0.15 * nbGenerated ;
//// camLook[2] += 100 ;
//// camLook[1] = 0 ;
//
////vertical view
//// VEC3 camPos(0, 300, 0) ;
//// Geom::BoundingBox<VEC3> bb = simulator.getAgentsBB() ;
//// VEC3 seeEveryone = bb.max() - bb.min() ;
//// if (seeEveryone[0] > 200)
//// camPos[1] += seeEveryone[0] ;
//// else
//// camPos[1] += 200 ;
//// VEC3 camLook(0) ;
//
////video intro
//// VEC3 camPos(-20, 10, 75) ;
//// VEC3 camLook(-25, 0, 0) ;
//
////mall
//// VEC3 camPos(-500, 500, -400) ;
//// VEC3 camLook(100, 100, 0) ;
//
////openStreetMap
//// VEC3 camPos(500, 75, 400) ;
//// VEC3 camLook(-250, 0, 650) ;
//
////pathDyn
//// VEC3 camPos(-700, 700, -1800) ;
//// VEC3 camLook(200, 0, 0) ;
//
////corridor side
//// VEC3 camPos(-700, 100, 0) ;
//// VEC3 camLook(200, 0, 0) ;
//
////corridor top
//// VEC3 camPos(0, 300, 0) ;
//// VEC3 camLook(0, 0, 0) ;
//
////corridor take2
//// VEC3 camPos(-350, 200, 0) ;
//// VEC3 camLook(0, 0, 0) ;
//
////openStreetMap mapRoad & mapBuildings
//// VEC3 camPos(-200, 100, 500) ;
//// VEC3 camLook(1000, 0, 0) ;
//
////openStreetMap sphere
//// VEC3 camPos(-200, 100, 500) ;
//// VEC3 camLook(100, 0, 0) ;
//
//// //diligences / Cercle
//// VEC3 camPos(0, 300, 750) ;
//// VEC3 camLook(0, 0, 0) ;
//
// //corridor
// VEC3 camPos(0, 300, 750) ;
// VEC3 camLook(0, 0, 0) ;
//corridor
VEC3 camPos(0, 300, 750) ;
VEC3 camLook(0, 0, 0) ;
// if(nbIterations%2==0)
// {
// exportScenePov(simulator.envMap_.map,simulator.envMap_.position,chaine,camPos,camLook,VEC3(0.0f,0,0),0,0,0);
// // exportScenePov(sim.envMap_.map,sim.envMap_.position,chaine,VEC3(43,762,65),VEC3(0,762,0),VEC3(1.0f,0,0),0,0,0);
// // exportScenePov(sim.envMap_.map,sim.envMap_.position,chaine,VEC3(43,762,65+(1500.0f*float(nbGenerated)/400.0f)),VEC3(0,762,0),VEC3(1.0f,0,0),0,0,0);
// nbGeneratedPov++;
// }
//
// if (nbIterations >= 20000)
// {
// std::cout << "enough .pov generated" << std::endl ;
// exit(0) ;
// }
//
//// if(nbIterations%2==0)
//// {
//// exportScenePov(simulator.envMap_.map,simulator.envMap_.position,chaine,camPos,camLook,VEC3(0.0f,0,0),0,0,0);
//// // exportScenePov(sim.envMap_.map,sim.envMap_.position,chaine,VEC3(43,762,65),VEC3(0,762,0),VEC3(1.0f,0,0),0,0,0);
//// // exportScenePov(sim.envMap_.map,sim.envMap_.position,chaine,VEC3(43,762,65+(1500.0f*float(nbGenerated)/400.0f)),VEC3(0,762,0),VEC3(1.0f,0,0),0,0,0);
//// nbGeneratedPov++;
//// }
////
//// if (nbIterations >= 20000)
//// {
//// std::cout << "enough .pov generated" << std::endl ;
//// exit(0) ;
//// }
}
#endif
......@@ -1646,66 +1679,80 @@ bool SocialAgents::exportScenePov(PFP::MAP& map, PFP::TVEC3& position, const std
}
#endif
void SocialAgents::cb_keyPress(int keycode)
//void SocialAgents::cb_keyPress(int keycode)
void SocialAgents::keyPressEvent(QKeyEvent *e)
{
switch (keycode)
// switch (keycode)
switch(e->key())
{
case 'a' :
case Qt::Key_A :
{
if (timer->isActive())
timer->stop() ;
else
timer->start() ;
dock.check_timer->setChecked(timer->isActive()) ;
break ;
if (timer->isActive())
timer->stop() ;
else
timer->start() ;
dock.check_timer->setChecked(timer->isActive()) ;
break ;
}
case 'c' :
case Qt::Key_C :
{
simulator.envMap_.map.check() ;
break ;
simulator.envMap_.map.check() ;
break ;
}
case 'e' :
case Qt::Key_E :
{
std::cout << "exporting obstacle to file myScene.obst" << std::endl ;
std::string filename("myScene.obst") ;
CGoGN::ExportScene::exportSceneToFile<PFP>(simulator.envMap_.map, simulator.envMap_.position,
simulator.envMap_.obstacleMark,
simulator.envMap_.buildingMark, filename) ;
std::string filename2("myAgents.pos") ;
simulator.exportAgents(filename2) ;
std::cout << "exporting meshes" << std::endl ;
std::string filename3("pedway.ply") ;
std::string filename4("buildingMap.ply") ;
std::string filename5("road.ply") ;
std::cout << "exporting obstacle to file myScene.obst" << std::endl ;
std::string filename("myScene.obst") ;
CGoGN::ExportScene::exportSceneToFile<PFP>(simulator.envMap_.map, simulator.envMap_.position,
simulator.envMap_.obstacleMark,
simulator.envMap_.buildingMark, filename) ;
std::string filename2("myAgents.pos") ;
simulator.exportAgents(filename2) ;
std::cout << "exporting meshes" << std::endl ;
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);
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);
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);
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 ;
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 ;
}
case 'i' :
case Qt::Key_I:
{
QString filename("./export/test.jpg");
// QPixmap image = QPixmap::grabWidget( this );
// QImage image = m_glWidget->grabFrameBuffer ();
// if( !image.save( filename, "JPG" ) )
// {
// QMessageBox::warning( this, "Save Image", "Error saving image." );
// }
break;
getQGLWidget()->resize(800,600);
updateGL() ;
// getQGLWidget()->setSnapshotQuality(100);
std::ostringstream tmpNb ;
unsigned int counter = getQGLWidget()->snapshotCounter();
tmpNb << std::setfill('0') << std::setw(5) << counter ;
getQGLWidget()->setSnapshotCounter(++counter);
QString filename("./export/test" );
filename.append((tmpNb.str()).c_str());
filename.append(".png");
// getQGLWidget()->setSnapshotFileName(filename);
// getQGLWidget()->setSnapshotFormat(QString("PNG"));
QImage image = getQGLWidget()->grabFrameBuffer();
if( !image.save( filename, "PNG" ) )
{
QMessageBox::warning( this, "Save Image", "Error saving image." );
}
break;
}
case 'p' :
case Qt::Key_P :
{
std::cout << simulator.globalTime_ << std::endl ;
......@@ -1718,7 +1765,7 @@ void SocialAgents::cb_keyPress(int keycode)
break ;
}
#ifndef SPATIAL_HASHING
case 'r' :
case Qt::Key_R :
{
exportScenePov(simulator.envMap_.map, simulator.envMap_.position, "planSerre/exportSceneOle0000.pov",
VEC3(10, 3, 10), VEC3(0, 0, 0), VEC3(1.0f, 0, 0), 0, 0, 0) ;
......@@ -1729,12 +1776,32 @@ void SocialAgents::cb_keyPress(int keycode)
break ;
}
#endif
case 's' :
case Qt::Key_S :
{
animate() ;
break ;
}
case '5' :
case Qt::Key_V :
{
qglviewer::Camera* cam = getQGLWidget()->camera();
if(simulator.config==0)
{
cam->setPosition(qglviewer::Vec(0,-1200,700));
cam->setUpVector(qglviewer::Vec(0,0,0));
cam->lookAt(qglviewer::Vec(0,0,0));
cam->setSceneRadius(10000);
}
if(simulator.config==1)
{
cam->setPosition(qglviewer::Vec(0,-1200,700));
cam->setUpVector(qglviewer::Vec(0,0,0));
cam->lookAt(qglviewer::Vec(0,0,0));
cam->setSceneRadius(10000);
}
break;
}
case Qt::Key_5 :
{
FILE *fp ;
int state = GL2PS_OVERFLOW, buffsize = 0 ;
......@@ -1754,7 +1821,7 @@ void SocialAgents::cb_keyPress(int keycode)
printf("Done!\n") ;
break ;
}
case '9' :
case Qt::Key_9 :
{
render_anim = !render_anim ;
std::cout << "export anim " << render_anim << std::endl;
......
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