Commit c20f9b48 authored by pitiot's avatar pitiot

merging

parent 88f271e5
......@@ -15,7 +15,7 @@ bool notDiagonalAdjacentToAnObstacle(typename PFP::MAP& map, Dart d, CellMarker<
template <typename PFP> Algo::Surface::Modelisation::Polyhedron<PFP> generateGrid(EnvMap& envMap) ;
template <typename PFP> void generateCity(EnvMap& envMap, unsigned int nbBuildings) ;
template <typename PFP> void generateCity(EnvMap& envMap, unsigned int nbBuildings, float minArea, float maxHeight = 10.0f) ;
template <typename PFP>
Algo::Surface::Modelisation::Polyhedron<PFP> generateTrianGrid(EnvMap& envMap,
......@@ -46,6 +46,9 @@ template <typename PFP>
void generatePathToUpperStair(typename PFP::MAP& map, typename PFP::TVEC3& position, Dart dLower,
Dart dUpper) ;
template <typename PFP>
void importObj(EnvMap& envMap,std::string filename) ;
/*******************************************************************************/
//template <typename PFP>
......
......@@ -8,6 +8,17 @@ namespace CGoGN
namespace CityGenerator
{
template <typename PFP>
void importObj(EnvMap& envMap,std::string filename)
{
std::vector<std::string> attrNames ;
if(!Algo::Surface::Import::importMesh<PFP2>(envMap.map, filename.c_str(), attrNames))
{
CGoGNerr << "could not import " << filename << CGoGNendl ;
return;
}
envMap.position = envMap.map.getAttribute<VEC3, VERTEX>(attrNames[0]) ;
}
template <typename PFP>
bool notAdjacentToAnObstacle(typename PFP::MAP& map, Dart d, CellMarker<FACE>& buildingMark)
......@@ -65,7 +76,7 @@ Algo::Surface::Modelisation::Polyhedron<PFP> generateGrid(EnvMap& envMap)
}
template <typename PFP>
void generateCity(EnvMap& envMap, unsigned int nbBuildings)
void generateCity(EnvMap& envMap, unsigned int nbBuildings, float minArea, float maxHeight)
{
unsigned int nbBuilding = nbBuildings ;
std::cout << " - Generate City : " << nbBuilding << " buildings" << std::endl ;
......@@ -76,12 +87,12 @@ void generateCity(EnvMap& envMap, unsigned int nbBuildings)
for (Dart d = envMap.map.begin(); d != dEnd && nbBuilding > 0; envMap.map.next(d))
{
if (!envMap.buildingMark.isMarked(d) && (rand() % 12 == 0)
&& notDiagonalAdjacentToAnObstacle<PFP>(envMap.map, d, envMap.buildingMark))
&& notDiagonalAdjacentToAnObstacle<PFP>(envMap.map, d, envMap.buildingMark) && (Algo::Surface::Geometry::convexFaceArea<PFP>(envMap.map, d, envMap.position)>minArea))
{
#ifndef TWO_AND_HALF_DIM
generateBuilding<PFP>(envMap, d, (1 + (rand() % 3)) * 50.0f, rand() % 4) ;
generateBuilding<PFP>(envMap, d, (1 + (rand() % 3)) * maxHeight, rand() % 4) ;
#else
generateBuilding<PFP>(envMap, d, (1 + (rand() % 3)) * 40.0f, rand() % 3) ;
generateBuilding<PFP>(envMap, d, (1 + (rand() % 3)) * maxHeight, rand() % 3) ;
#endif
--nbBuilding ;
......
......@@ -32,7 +32,7 @@ class ArticulatedObstacle;
#include "pfp.h"
//#define EXPORTING3
#define EXPORTING3
#define TWO_AND_HALF_DIM
#ifdef EXPORTING3
......
......@@ -18,7 +18,7 @@
using namespace std;
#define EXPORTING2
//#define EXPORTING2
float get_angle3D(VEC3 v1, VEC3 v2);
......
......@@ -100,7 +100,7 @@ public:
void setupPlanetScenario(unsigned int nbAgents, unsigned int nbObstacles);
void addMovingObstacles(unsigned int nb, unsigned int type);
void addMovingObstacles(unsigned int nb, unsigned int type, float areaMin = 1400);
void addMovingObstacle(Dart d, unsigned int obstType=0);
void addAgent(const VEC3& start,const VEC3& goals);
......
......@@ -24,6 +24,7 @@
#include <iostream>
#include <fstream>
#include <sstream>
#include <sys/time.h>
#include "Utils/Qt/qtQGLV.h"
......@@ -169,6 +170,18 @@ public:
int m_renderStyle;
//////
// ARASH : camera input file
std::ifstream cam_input_file;
bool cif_exists;
unsigned int cif_begin, cif_end;
VEC3 *cif_lookfrom;
VEC3 *cif_lookat;
VEC3 *cif_upvector;
void readCameraInputFile(char *filename);
std::ofstream cam_output_file;
Geom::BoundingBox<PFP::VEC3> bb ;
Utils::QT::uiDockInterface dock ;
......
......@@ -745,7 +745,11 @@ static int moAppend(MovingObstacle **moving_obstacles, int nb_mos, int max, Movi
void Agent::computeNewVelocity()
{
// The objective is to compute the sum of forces exerted on the agent.
#ifdef TWO_AND_HALF_DIM
VEC3 normFace = Algo::Surface::Geometry::faceNormal<PFP>(sim_->envMap_.map, part_.d, sim_->envMap_.position);
#else
VEC3 normFace = VEC3 (0,0,1);
#endif
double collision_softening_factor;
float ag_ambient_damping = 10.0;
......@@ -813,6 +817,7 @@ void Agent::computeNewVelocity()
Obstacle * obst = it->second;
if(obst->mo!=NULL)
{
VEC3 p1=obst->p1 ;
VEC3 p2=obst->p2 ;
double longueur2 = (p1-p2).norm2();
......@@ -910,13 +915,13 @@ void Agent::computeNewVelocity()
//----- forces dues à la répulsion des autres agents -------
double ag_stiffness = 200.0; // agent-agent interaction stiffness
double ag_stiffness = 400.0; // agent-agent interaction stiffness
double ag_damping = 1.0; // agent-agent interaction damping
// double ag_power = 1; // the power to which elevate the agent-agent distance
rand = 2.0*drand48()-1.0; // compris entre -1 et 1
double radius_var = 0.5;
double ag_phys_radius_coef = 4.0*(1 + rand*radius_var); // valeurs uniformement réparties entre min et max
double ag_phys_radius_coef = 2.0*(1 + rand*radius_var); // valeurs uniformement réparties entre min et max
unsigned int nbA = 0 ;
......
......@@ -78,7 +78,7 @@ void EnvMap::init(unsigned int config, REAL width, REAL height, REAL minSize, RE
case 0 :
// CityGenerator::generateGrid<PFP>(*this) ;
CityGenerator::generateGrid<PFP>(*this) ;
CityGenerator::generateCity<PFP>(*this,0) ;
CityGenerator::generateCity<PFP>(*this,0,500.0f) ;
break ;
case 1 :
CityGenerator::generateGrid<PFP>(*this) ;
......@@ -91,11 +91,11 @@ void EnvMap::init(unsigned int config, REAL width, REAL height, REAL minSize, RE
break ;
case 3 :
CityGenerator::generateGrid<PFP>(*this) ;
CityGenerator::generateCity<PFP>(*this,10) ;
CityGenerator::generateCity<PFP>(*this,10,500.0f) ;
break ;
case 4 :
CityGenerator::generatePlanet<PFP>(*this) ;
CityGenerator::generateCity<PFP>(*this,10) ;
CityGenerator::generateCity<PFP>(*this,10,500.0f) ;
break ;
case 5 :
{
......@@ -200,7 +200,30 @@ void EnvMap::init(unsigned int config, REAL width, REAL height, REAL minSize, RE
break;
case 6:
CityGenerator::generatePlanet<PFP>(*this);
CityGenerator::generateCity<PFP>(*this,200) ;
CityGenerator::generateCity<PFP>(*this,200, 1000.0f) ;
break;
case 7 :
// CityGenerator::importObj<PFP>(*this, "./meshRessources/simpleSlugSmoothTest.obj");
// CityGenerator::importObj<PFP>(*this, "./meshRessources/knot3Centered.obj");
CityGenerator::importObj<PFP>(*this, "./meshRessources/testTaches.obj");
scale(150.0f);
CityGenerator::generateCity<PFP>(*this,200, 150.0f, 10.0f) ;
break;
case 8 :
// CityGenerator::importObj<PFP>(*this, "./meshRessources/simpleSlugSmoothTest.obj");
CityGenerator::importObj<PFP>(*this, "./meshRessources/knot3Centered.obj");
scale(150.0f);
CityGenerator::generateCity<PFP>(*this,200, 150.0f,5.0f) ;
break;
case 9 :
CityGenerator::importObj<PFP>(*this, "./meshRessources/simpleSlugSmoothTest.obj");
scale(150.0f);
CityGenerator::generateCity<PFP>(*this,200, 150.0f,30.0f) ;
break;
}
......@@ -238,7 +261,7 @@ void EnvMap::initGL()
std::vector<std::string> filenames;
std::vector<std::string> texturenames;
std::string dir("./meshRessources/cityTex/");
std::string dir("./meshRessources/PlaneteRessource/");
DIR *dp;
struct dirent *dirp;
if((dp = opendir(dir.c_str())) == NULL)
......@@ -291,11 +314,11 @@ void EnvMap::initGL()
position_nmap.push_back(position_Export);
TraversorV<PFP2::MAP> tV(*nmap);
for(Dart d = tV.begin() ; d != tV.end() ; d = tV.next())
{
position_Export[d] *= 100.0f;
position_Export[d] += VEC3(2000,0,0);
}
// for(Dart d = tV.begin() ; d != tV.end() ; d = tV.next())
//// {
//// position_Export[d] *= 100.0f;
//// position_Export[d] += VEC3(2000,0,0);
//// }
Geom::BoundingBox<PFP::VEC3> bbTest2 = Algo::Geometry::computeBoundingBox<PFP>(*nmap, position_Export) ;
......
......@@ -230,7 +230,7 @@ std::vector<VEC3> MovingMesh::computeProjectedPointSet(float maxHeight, Dart d)
std::vector<bool> active;
active.assign(points.size(), true);
simplifyCurve(points, active, 0, points.size()-1, 0.3f);
simplifyCurve(points, active, 0, points.size()-1, 0.5f);
std::vector<VEC3> res;
VEC3 center =Algo::Surface::Geometry::faceCentroid<PFP>(motherMap, d, motherPosition);
......@@ -238,12 +238,14 @@ std::vector<VEC3> MovingMesh::computeProjectedPointSet(float maxHeight, Dart d)
VEC3 normale = Algo::Surface::Geometry::faceNormal<PFP>(motherMap, d, motherPosition);
Geom::Matrix44f rot ;
rot.identity() ;
Geom::translate(0.0f,0.0f,0.2f,rot);
float angle = Geom::angle(normale, VEC3 (0,0,1) ) ;
CGoGNout<<"angle : "<<angle<<CGoGNendl;
// CGoGNout<<"angle : "<<angle<<CGoGNendl;
VEC3 axis = VEC3(0,0,1) ^ normale ;
// Geom::translate(center[0],center[1],center[2],rot);
Geom::rotate(axis, angle, rot) ;
for(Dart dd = tv.begin() ; dd != tv.end() ; dd = tv.next())
{
......@@ -252,6 +254,16 @@ std::vector<VEC3> MovingMesh::computeProjectedPointSet(float maxHeight, Dart d)
}
translate(center);
rot.identity() ;
Geom::scale(1.5f,1.5f,1.0f,rot);
angle = Geom::angle(normale, VEC3 (0,0,1) ) ;
CGoGNout<<"angle : "<<angle<<CGoGNendl;
axis = VEC3(0,0,1) ^ normale ;
// Geom::translate(center[0],center[1],center[2],rot);
Geom::rotate(axis, angle, rot) ;
for(unsigned int i = 0; i < points.size() ; ++i)
{
points[i] =Geom::transform(points[i],rot);
......
This diff is collapsed.
......@@ -16,7 +16,11 @@ timespec timespec_delta(const timespec& t1, const timespec& t2) {
}
Simulator::Simulator(unsigned int config, unsigned int minS, unsigned int nbAgent, unsigned int nbObst, bool resolution) :
timeStep_(0.02f),
#ifdef TWO_AND_HALF_DIM
timeStep_(0.01f),
#else
timeStep_(0.25f),
#endif
// timeStep_(0.2f),
globalTime_(0.0f),
nbSteps_(0),
......@@ -83,17 +87,37 @@ void Simulator::init( float dimension, unsigned int nbAgent, unsigned int nbObst
// addPathToObstacles(envMap_.pedWayMark, false);
addPathsToAgents();
break;
case 6:
#ifdef TWO_AND_HALF_DIM
case 6:
envMap_.init(config,200.0,200.0, minSize, 400.0f);
setupPlanetScenario(nbAgent,nbObst);
addMovingObstacles(nbObst, 1);
addPathToObstacles(envMap_.buildingMark, true);
addPathsToAgents();
break;
case 7 : envMap_.init(config,200.0,200.0, minSize, 400.0f);
setupPlanetScenario(nbAgent,nbObst);
addMovingObstacles(nbObst, 1 , 100 );
addPathToObstacles(envMap_.buildingMark, true);
addPathsToAgents();
break;
case 8 : envMap_.init(config,200.0,200.0, minSize, 400.0f);
setupPlanetScenario(nbAgent,nbObst);
addMovingObstacles(nbObst, 1 , 100 );
addPathToObstacles(envMap_.buildingMark, true);
addPathsToAgents();
break;
case 9 : envMap_.init(config,200.0,200.0, minSize, 400.0f);
setupPlanetScenario(nbAgent,nbObst);
addMovingObstacles(nbObst, 1 , 100 );
addPathToObstacles(envMap_.buildingMark, true);
addPathsToAgents();
break;
#else
std::cout << "Agents not in 2.5D mode" << std::endl;
#endif
break;
default:
std::cout << "Unknown scenario !" << std::endl ;
exit(1) ;
......@@ -172,6 +196,11 @@ void Simulator::doStep()
// unsigned int i =12;
clock_gettime(CLOCK_MONOTONIC, &begTime) ;
movingObstacles_[i]->applyForces();
clock_gettime(CLOCK_MONOTONIC, &endTime) ;
time_behave+= timespec_delta(begTime,endTime).tv_nsec;
clock_gettime(CLOCK_MONOTONIC, &begTime) ;
movingObstacles_[i]->updateRegistration();
clock_gettime(CLOCK_MONOTONIC, &endTime) ;
time_obstacle+= timespec_delta(begTime,endTime).tv_nsec;
......@@ -352,11 +381,11 @@ void Simulator::setupCircleScenario(unsigned int nbAgents , unsigned int nbObsta
}
vPos.clear();
vPos.push_back(start+xSide-ySide);
vPos.push_back(start+xSide+ySide);
vPos.push_back(start-xSide+ySide);
vPos.push_back(start+xSide-ySide);
vPos.push_back(start-xSide-ySide);
vPos.push_back(start-xSide+ySide);
curGoal = ((int)(i*float(nbGoals)/float(nbObstacles/2.0f))+1)%nbGoals;
mo4= new MovingObstacle(this, i,vPos,goals, true, true,curGoal);
......@@ -384,10 +413,10 @@ void Simulator::setupCircleScenario(unsigned int nbAgents , unsigned int nbObsta
vPos.clear();
// Un obstacle sur deux va vers le haut
vPos.push_back(start+xSide-ySide);
vPos.push_back(start+xSide+ySide);
vPos.push_back(start-xSide+ySide);
vPos.push_back(start+xSide-ySide);
vPos.push_back(start-xSide-ySide);
vPos.push_back(start-xSide+ySide);
curGoal = ((int)(i*float(nbGoals)/float(nbObstacles/2.0f))+5)%nbGoals;
mo4= new MovingObstacle(this, i,vPos,goals, true, true,curGoal);
......@@ -417,8 +446,8 @@ void Simulator::setupCorridorScenario(unsigned int nbAgents, unsigned int nbObst
else
{
// envMap_.init(config, 1600.0f, 960.0f, minSize, 320.0f) ; //grosses cases
envMap_.init(config, 1600.0f, 960.0f, 40.0f, 40.0f) ; //cases fines
// envMap_.init(config, nbObstacles > 60 ? ((nbObstacles*20*xSide[0])/6) : 1000.0f, 960.0f, minSize, 320.0f) ; //grosses cases
envMap_.init(config,nbObstacles > 60 ? ((nbObstacles*20*xSide[0])/6) : 1000.0f, 960.0f, Agent::range_/5, Agent::range_/5) ; //cases fines
}
......@@ -483,18 +512,11 @@ void Simulator::setupCorridorScenario(unsigned int nbAgents, unsigned int nbObst
tmp = goal ;
goal = start ;
start = tmp ;
vPos.push_back(start-xSide+ySide);
vPos.push_back(start-xSide-ySide);
vPos.push_back(start+xSide-ySide);
vPos.push_back(start+xSide+ySide);
}
else
{
vPos.push_back(start+xSide-ySide);
vPos.push_back(start+xSide+ySide);
vPos.push_back(start-xSide+ySide);
vPos.push_back(start-xSide-ySide);
}
vPos.push_back(start+xSide+ySide);
vPos.push_back(start+xSide-ySide);
vPos.push_back(start-xSide-ySide);
vPos.push_back(start-xSide+ySide);
std::vector<VEC3> goals;
goals.push_back(start);
goals.push_back(goal);
......@@ -595,10 +617,10 @@ void Simulator::setupSnakeCorridorScenario(unsigned int nbAgents, unsigned int n
std::vector<VEC3> vPos;
vPos.push_back(start+xSide-ySide);
vPos.push_back(start+xSide+ySide);
vPos.push_back(start-xSide+ySide);
vPos.push_back(start+xSide-ySide);
vPos.push_back(start-xSide-ySide);
vPos.push_back(start-xSide+ySide);
std::vector<VEC3> goals;
goals.push_back(start);
......@@ -629,10 +651,10 @@ void Simulator::setupSnakeCorridorScenario(unsigned int nbAgents, unsigned int n
vPos.clear();
vPos.push_back(start+xSide-ySide);
vPos.push_back(start+xSide+ySide);
vPos.push_back(start-xSide+ySide);
vPos.push_back(start+xSide-ySide);
vPos.push_back(start-xSide-ySide);
vPos.push_back(start-xSide+ySide);
positions[i]=vPos;
}
// CGoGNout<<"positions : "<< positions[0][0]<<CGoGNendl;
......@@ -802,7 +824,7 @@ void Simulator::setupPlanetScenario(unsigned int nbAgents, unsigned int nbObstac
swapAgentsGoals();
}
void Simulator::addMovingObstacles(unsigned int nb, unsigned int type)
void Simulator::addMovingObstacles(unsigned int nb, unsigned int type, float areaMin)
{
TraversorF<PFP::MAP> tF(envMap_.map);
Dart d = tF.begin() ;
......@@ -817,7 +839,7 @@ void Simulator::addMovingObstacles(unsigned int nb, unsigned int type)
)
{
float area = Algo::Surface::Geometry::convexFaceArea<PFP>(envMap_.map, d, envMap_.position);
if(area>1400)
if(area>areaMin)
{
dCell = d ;
found = true ;
......@@ -971,6 +993,7 @@ void Simulator::addPathToObstacles(CellMarker<FACE>& markForbid, bool goalCenter
|| j < dartDistForPath + rand() * 20
|| envMap_.map.sameFace(dStop, dStart)
|| markForbid.isMarked(dStop)
|| !envMap_.map.sameVolume(dStop,dStart)
; ++j)
{
envMap_.map.next(dStop) ;
......@@ -1089,6 +1112,7 @@ void Simulator::addPathsToAgents()
|| j < dartDistForPath + rand() * 20
|| envMap_.map.sameFace(dStop, dStart)
|| envMap_.obstacleMark.isMarked(dStop)
|| !envMap_.map.sameVolume(dStop,dStart)
; ++j)
{
envMap_.map.next(dStop) ;
......@@ -1128,6 +1152,7 @@ void Simulator::addPathsToAgents()
|| envMap_.map.sameFace(dStop, dStop2)
|| envMap_.map.sameFace(dStop2, dStart)
|| envMap_.obstacleMark.isMarked(dStop)
|| !envMap_.map.sameVolume(dStop,dStart)
; ++j)
{
envMap_.map.next(dStop2) ;
......
......@@ -42,7 +42,7 @@ SocialAgents::SocialAgents(unsigned int config, unsigned int minSize, unsigned i
simulator(config, minSize, nbAgent, nbObst, resolution),
render_anim(false),
drawEnvLines(true),
drawEnvFaces(false),
drawEnvFaces(true),
drawEnvTopo(false),
drawObstacles(false),
drawMovingObstacles(true),
......@@ -216,6 +216,9 @@ void SocialAgents::cb_initGL()
registerShader(m_simpleColorShader);
registerShader(m_sprite);
qglviewer::Camera* cam = getQGLWidget()->camera();
cam->setSceneRadius(10000);
initRendering();
}
......@@ -771,7 +774,7 @@ void SocialAgents::cb_redraw()
for(unsigned int i = 0 ; i < simulator.movingObstacles_.size() ; ++i)
{
#ifdef SHADOWSHELL
if(simulator.movingObstacles_[i]->index==12){
if(false){
Utils::ShaderFlat* moShader = m_obstShader[i];
// moShader->setAmbiant(Geom::Vec4f(0.43137254902,0.76862745098,0.8862745098,0.));
......@@ -784,11 +787,11 @@ void SocialAgents::cb_redraw()
}
#endif
#ifdef EXPORTING_BOXES
simulator.movingObstacles_[i]->draw(drawObstPath);
#endif
}
// Commente par Arash
// Commente par Arash
// for (std::vector<MovingMesh*>::iterator it = simulator.movingMeshes_.begin() ; it != simulator.movingMeshes_.end() ; ++it)
// (*it)->draw();
......@@ -1038,6 +1041,36 @@ void SocialAgents::animate()
// long seconds, nseconds ;
nbIterations++ ;
if(cif_exists)
{
qglviewer::Vec lookfrom, lookat, upvector;
qglviewer::Camera* cam = getQGLWidget()->camera();
if(nbIterations<cif_begin)
{
lookfrom.setValue(cif_lookfrom[0][0],cif_lookfrom[0][1],cif_lookfrom[0][2]);
lookat. setValue(cif_lookat [0][0],cif_lookat [0][1],cif_lookat [0][2]);
upvector.setValue(cif_upvector[0][0],cif_upvector[0][1],cif_upvector[0][2]);
}
else if((nbIterations>=cif_begin)&&(nbIterations<cif_end))
{
lookfrom.setValue(cif_lookfrom[nbIterations-cif_begin][0],cif_lookfrom[nbIterations-cif_begin][1],cif_lookfrom[nbIterations-cif_begin][2]);
lookat. setValue(cif_lookat [nbIterations-cif_begin][0],cif_lookat [nbIterations-cif_begin][1],cif_lookat [nbIterations-cif_begin][2]);
upvector.setValue(cif_upvector[nbIterations-cif_begin][0],cif_upvector[nbIterations-cif_begin][1],cif_upvector[nbIterations-cif_begin][2]);
}
else
{
lookfrom.setValue(cif_lookfrom[cif_end-cif_begin][0],cif_lookfrom[cif_end-cif_begin][1],cif_lookfrom[cif_end-cif_begin][2]);
lookat. setValue(cif_lookat [cif_end-cif_begin][0],cif_lookat [cif_end-cif_begin][1],cif_lookat [cif_end-cif_begin][2]);
upvector.setValue(cif_upvector[cif_end-cif_begin][0],cif_upvector[cif_end-cif_begin][1],cif_upvector[cif_end-cif_begin][2]);
exit(0);
}
cam->setPosition(lookfrom);
cam->lookAt(lookat);
cam->setUpVector(upvector,true);
}
if (maxIterations > 0 && nbIterations > maxIterations)
{
// std::cout << "t : " << simulator.globalTime_ << std::endl ;
......@@ -1166,7 +1199,8 @@ void SocialAgents::animate()
if(nbIterations%4==0)
{
getQGLWidget()->resize(800,600);
// getQGLWidget()->resize(800,600);
getQGLWidget()->resize(1024,768);
updateGL() ;
// getQGLWidget()->setSnapshotQuality(100);
......@@ -1178,7 +1212,7 @@ void SocialAgents::animate()
// QString filename("./export/meshCercleBA" );
// QString filename("./export/meshCorridorBA" );
// QString filename("./export/oneRing" );
QString filename("./export/oneRingCercle" );
QString filename("./export/scenario3." );
filename.append((tmpNb.str()).c_str());
filename.append(".png");
// getQGLWidget()->setSnapshotFileName(filename);
......@@ -1835,6 +1869,7 @@ void SocialAgents::keyPressEvent(QKeyEvent *e)
std::string filename3("pedway.ply") ;
std::string filename4("buildingMap.ply") ;
std::string filename5("road.ply") ;
std::string filename6("road.obj") ;
MapBrowserSelector mbs(simulator.envMap_.map,SelectorCellMarked<FACE>(simulator.envMap_.pedWayMark));
simulator.envMap_.map.setBrowser(&mbs);
......@@ -1845,6 +1880,8 @@ void SocialAgents::keyPressEvent(QKeyEvent *e)
simulator.envMap_.map.setBrowser(&mbs2);
Algo::Surface::Export::exportPLY<PFP>(simulator.envMap_.map, simulator.envMap_.position,filename5.c_str(), false);
// Algo::Surface::Export::exportOBJ<PFP>(simulator.envMap_.map, simulator.envMap_.position,filename6.c_str());
// L'export OBJ ne semble pas marcher
simulator.envMap_.map.setBrowser(NULL);
......@@ -1852,6 +1889,19 @@ void SocialAgents::keyPressEvent(QKeyEvent *e)
Algo::Surface::Export::exportPLY<PFP>(simulator.envMap_.mapScenary, simulator.envMap_.positionScenary,filename4.c_str(), false);
break ;
}
case Qt::Key_G:
{
qglviewer::Camera* cam = getQGLWidget()->camera();
qglviewer::Vec lookat = cam->position() + 100*cam->viewDirection();
cam_output_file << nbIterations << " ";
cam_output_file << cam->position()[0] << " "<< cam->position()[1] << " "<< cam->position()[2] << " "
<< lookat[0] << " "<< lookat[1] << " "<< lookat[2] << " "
<< cam->upVector()[0] << " "<< cam->upVector()[1] << " "<< cam->upVector()[2] << endl;
break;
}
case Qt::Key_I:
{
getQGLWidget()->resize(800,600);
......@@ -1864,7 +1914,7 @@ void SocialAgents::keyPressEvent(QKeyEvent *e)
getQGLWidget()->setSnapshotCounter(++counter);
QString filename("./export/test" );
filename.append((tmpNb.str()).c_str());
filename.append((tmpNb.str()).c_str());
filename.append(".png");
// getQGLWidget()->setSnapshotFileName(filename);
// getQGLWidget()->setSnapshotFormat(QString("PNG"));
......@@ -1929,8 +1979,16 @@ void SocialAgents::keyPressEvent(QKeyEvent *e)
cam->lookAt(qglviewer::Vec(0,0,0));
cam->setSceneRadius(10000);
}
if(simulator.config==3)
{
cam->setPosition(qglviewer::Vec(0,-900,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 ;
......@@ -1962,6 +2020,53 @@ void SocialAgents::keyPressEvent(QKeyEvent *e)
updateGL() ;
}
//---------------------------------------------------------
void SocialAgents::readCameraInputFile(char *filename)
{
std::string line, word;
// const char *c_line;
cif_exists=false;
cam_input_file.open(filename,std::ifstream::in);
if(cam_input_file.is_open())