Commit 5de581be authored by pitiot's avatar pitiot

p3 obstacles + shapematching debut

parent bb48b7b5
......@@ -54,7 +54,7 @@ void ShapeMatchingLinear<PFP>::animate()
//initialize(nfe,frame_prec);
unsigned int n = m_darts.size();
unsigned int n = this->m_darts.size();
VEC3 xcm = this->computeBarycenterDarts();
......@@ -107,7 +107,7 @@ void ShapeMatchingLinear<PFP>::animate()
//once the transformation computed : move the vertices of the map
//compute barycenter
VEC3 b = this->computeBarycenterDarts();
// VEC3 b = this->computeBarycenterDarts();
//move the vertices
for(std::vector<Dart>::iterator it = this->m_darts.begin() ; it != this->m_darts.end() ; ++it)
......
......@@ -11,7 +11,7 @@
// #define SECURED
//#define EXPORTING_AGENT
#define EXPORTING_OBJ
//#define EXPORTING_OBJ
#define ARASH
......
......@@ -32,9 +32,9 @@ class ArticulatedObstacle;
#include "pfp.h"
#define EXPORTING3
//#define EXPORTING3
#define TWO_AND_HALF_DIM
//#define TWO_AND_HALF_DIM
#ifdef EXPORTING3
......@@ -371,11 +371,30 @@ inline void EnvMap::addObstAsNeighbor (Obstacle * o, const std::vector<Dart>& b
assert(map.getCurrentLevel() == map.getMaxLevel());
assert(!belonging_cells.empty());
neighbor_cells->clear();
CellMarkerMemo<FACE> memo_mark(map);
CellMarkerMemo<FACE> OneRingMark(map);
// CellMarkerMemo<FACE> memo_mark_speed(map);//marqueur additionnel (vitesse)
CellMarkerMemo<FACE> memo_mark(map); //marqueur des cellules "présentes"
CellMarkerMemo<FACE> OneRingMark(map); // marquer des cellules voisines
for (std::vector<Dart>::const_iterator it =belonging_cells.begin();it<belonging_cells.end();++it)
memo_mark.mark(*it);
memo_mark.mark(*it);
///////TENTATIVE D'AJOUT RATE
// MovingObstacle * mo = o->mo;
// int n = o->index;
// int m = (n+1)%mo->nbVertices;
//#ifdef TWO_AND_HALF_DIM
// CGoGN::Algo::Surface::MovingObjects::ParticleCell2DAndHalfMemo<PFP> * registering_part = new CGoGN::Algo::Surface::MovingObjects::ParticleCell2DAndHalfMemo<PFP>(mo->sim_->envMap_.map, mo->parts_[n]->d,o->p1,mo->sim_->envMap_.position);
//#else
// CGoGN::Algo::Surface::MovingObjects::ParticleCell2DMemo<PFP> * registering_part = new CGoGN::Algo::Surface::MovingObjects::ParticleCell2DMemo<PFP>(mo->sim_->envMap_.map, mo->position[n],o->p1,mo->sim_->envMap_.position);
//#endif
// registering_part->move(mo->velocity_[n]*mo->velocityAvoidanceFactor+mo->position[n],memo_mark_speed);
// registering_part->move(mo->velocity_[m]*mo->velocityAvoidanceFactor+mo->position[m],memo_mark_speed);
// std::vector<Dart> result =();
// d2=registering_part->d;
// CGoGNout<<"d1 : "<< *d1<<"|| d2 : "<< *d2<<"|| start : "<< pos<<"|| stop : "<< dest<<CGoGNendl;
std::vector<Dart>::const_iterator it=belonging_cells.begin();
Dart beg = NIL;
......
......@@ -18,7 +18,7 @@
using namespace std;
#define EXPORTING2
//#define EXPORTING2
float get_angle3D(VEC3 v1, VEC3 v2);
......
......@@ -2,7 +2,7 @@
#define M_MOVING_OBSTACLE_H
#include <iostream>
#include "ShapeMatching/shapeMatchingLinear.h"
#include "utils.h"
#include "env_map.h"
#include <set>
......@@ -19,7 +19,7 @@
#endif
#endif
// #define EXPORTING_BOXES
#define EXPORTING_BOXES
#ifdef EXPORTING_BOXES
#include "Algo/Render/GL2/mapRender.h"
......@@ -122,6 +122,7 @@ public:
Obstacle* * obstacles_;
std::vector<Dart> * belonging_cells;
std::vector<Dart> * neighbor_cells;
std::vector<std::pair<Dart, int> > general_belonging;
VEC3 front;
......@@ -163,6 +164,14 @@ public:
int index_parent;
float gravity_dist; /// distance entre le centre du MO et son sommet le plus éloigné
VertexAttribute<NoMathIONameAttribute<std::vector<PFP::REAL> > > mvc_;
/////// ShapeMatching
ShapeMatchingLinear<PFP> * shape_;
PFP::REAL beta;
float alpha;
};
#endif
......@@ -9,7 +9,7 @@ public:
Obstacle(const VEC3 point1, const VEC3 point2, const VEC3 prevPoint, const VEC3 nextPoint, Dart d_1, Dart d_2,
MovingObstacle * moving1=NULL, unsigned int ind=0) :
d1(d_1), d2(d_2), p1(point1), p2(point2), prevP(prevPoint), nextP(nextPoint),
mo(moving1), index(ind)
mo(moving1), index(ind),p3(0,0,0)
{
// p1[2] = 0 ;
// p2[2] = 0 ;
......@@ -23,8 +23,10 @@ public:
VEC3 p2 ;
VEC3 prevP ;
VEC3 nextP ;
MovingObstacle * mo ;
unsigned int index ;
VEC3 p3; //pour les ellipses
} ;
#endif
......@@ -100,7 +100,7 @@ public:
void setupPlanetScenario(unsigned int nbAgents, unsigned int nbObstacles, unsigned int nbx = 2,unsigned int nby= 2, float areaMin = 100.0f);
void addMovingObstacles(unsigned int nb, unsigned int type, float areaMin = 1400, int randLimace=12);
void addMovingObstacles(unsigned int nb, unsigned int type, float areaMin = 500, int randLimace=1);
void addMovingObstacle(Dart d, unsigned int obstType=0);
void addAgent(const VEC3& start,const VEC3& goals);
......
......@@ -56,8 +56,8 @@
#include "shaderCustom.h"
#include "shaderPhongTexCust.h"
#define AFFICHE_MESH
#define DRAW_REGISTRATION //montre l'enregistrement des obstacles mobiles
//#define AFFICHE_MESH
//#define EXPORTING
//#define ONERING
//#define SHADOWSHELL
......@@ -82,6 +82,7 @@ public:
void updateObstacleVBO();
void updateAgentPredTriVBO();
void updateObstaclePredTriVBO();
void drawCell(Dart d, float width, float r, float g, float b);
void moveCameraTo(VEC3 newPos);
void cb_redraw() ;
......
......@@ -169,7 +169,7 @@ void RigidComputation::jacrot(Geom::Matrix33f &a, Geom::Matrix33f &r)
q=0;
p=0;
float max = maxoffdiag(a,p,q);
if(max>0.0000001)
if(max>0.0000001) // eventuellement changer pour les perfs
{
rotate(a,r,p,q);
if((++iter)==10)
......@@ -212,8 +212,10 @@ int RigidComputation::jacobiDiagonalization( Geom::Matrix33f& A, Geom::Matrix33f
}
if( sm == 0.0f ) // The normal return, which relies on quadratic convergence to machine underflow.
return nrot;
{
// std::cout<<"OK"<<std::endl;
return nrot;
}
if( i < 3 )
thresh = 0.2f*sm/(n*n); // ... on the first three sweeps.
else
......@@ -293,6 +295,6 @@ int RigidComputation::jacobiDiagonalization( Geom::Matrix33f& A, Geom::Matrix33f
}
}
// std::cout<<"K O"<<std::endl;
return -1; // In case of error, returns minus one.
}
......@@ -93,7 +93,7 @@ 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,500.0f) ;
// CityGenerator::generateCity<PFP>(*this,10,500.0f) ;
break ;
case 4 :
CityGenerator::generatePlanet<PFP>(*this) ;
......
This diff is collapsed.
......@@ -17,11 +17,12 @@ 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) :
#ifdef TWO_AND_HALF_DIM
timeStep_(0.01f),
timeStep_(0.25f),
#else
timeStep_(config > 2 ? 0.01f : 0.25f),
// timeStep_(config > 2 ? 0.01f : 0.25f),
timeStep_(0.01f),
#endif
// timeStep_(0.2f),
globalTime_(0.0f),
nbSteps_(0),
nbUpdates(0),
......@@ -71,7 +72,7 @@ void Simulator::init( float dimension, unsigned int nbAgent, unsigned int nbObst
case 3 :
envMap_.init(config, 1000.0f, 1000.0f, minSize, 100.0f) ; //grosses cases
setupScenario(nbAgent, false) ;
addMovingObstacles(nbObst, 1, 10);
addMovingObstacles(nbObst, 1);
addPathToObstacles(envMap_.buildingMark, true);
//// setupCityScenario(-1.0f * (12 * (70.0f / 2.0f) - 10),
//// -1.0f * (12 * (70.0f / 2.0f) - 10), 20, 20);
......@@ -842,7 +843,7 @@ void Simulator::addMovingObstacles(unsigned int nb, unsigned int type, float are
)
{
float area = Algo::Surface::Geometry::convexFaceArea<PFP>(envMap_.map, d, envMap_.position);
if(area>areaMin && envMap_.movingObstacleNeighborFree(d) && (rand() % randLimace == 0))
if(area>areaMin && /*envMap_.movingObstacleNeighborFree(d) &&*/ (rand() % randLimace == 0))
{
dCell = d ;
found = true ;
......
......@@ -41,8 +41,8 @@ SocialAgents::SocialAgents(unsigned int config, unsigned int minSize, unsigned i
nextUpdate(0),
simulator(config, minSize, nbAgent, nbObst, resolution),
render_anim(false),
drawEnvLines(false),
drawEnvFaces(false),
drawEnvLines(true),
drawEnvFaces(true),
drawEnvTopo(false),
drawObstacles(false),
drawMovingObstacles(true),
......@@ -797,6 +797,28 @@ void SocialAgents::cb_redraw()
simulator.movingObstacles_[i]->draw(drawObstPath);
#ifdef DRAW_REGISTRATION
MovingObstacle * mo =simulator.movingObstacles_[i];
if (drawEnvTopo)
{
unsigned int n = 0;
if(n<mo->nbVertices)
{
for (std::vector<Dart>::iterator it = mo->belonging_cells[n].begin(); it != mo->belonging_cells[n].end(); ++it)
{
drawCell((*it),5.0f,0,1.0f,0.5f);
}
for (std::vector<Dart>::iterator it = mo->neighbor_cells[n].begin(); it != mo->neighbor_cells[n].end(); ++it)
{
drawCell((*it),5.0f,1.0f,0,0.5f);
}
}
}
#endif
}
......@@ -1031,6 +1053,18 @@ void SocialAgents::cb_redraw()
popTransfoMatrix();
}
void SocialAgents::drawCell(Dart d, float width, float r, float g, float b)
{
Dart dd = d;
do{
m_renderTopo->overdrawDart(dd,width,r,g,b);
dd=simulator.envMap_.map.phi1(dd);
}while(dd!=d);
}
void SocialAgents::animate()
{
// if(simulator.nbSteps_ % simulator.nbStepsPerUnit_ == 0 && (simulator.nbSteps_ / simulator.nbStepsPerUnit_) % 10 == 0)
......@@ -1044,7 +1078,7 @@ void SocialAgents::animate()
// simulator.addPathsToAgents() ;
//
//
std::cout << "t : " << nbIterations << std::endl ;
// std::cout << "t : " << nbIterations << std::endl ;
//
//
// timeval startTime ;
......@@ -1204,7 +1238,7 @@ void SocialAgents::animate()
#ifndef SPATIAL_HASHING
if (render_anim)
{
if(nbIterations%4==0)
// if(nbIterations%4==0)
{
// getQGLWidget()->resize(800,600);
getQGLWidget()->resize(1024,768);
......@@ -2118,20 +2152,20 @@ int main(int argc, char** argv)
glewInit();
sa.cam_output_file.open("cams/cam.out",std::ofstream::out);
char camfile[100];
sprintf(camfile,"cams/cam.scn%d.spline",config);
sa.readCameraInputFile(camfile);
if(sa.cif_exists)
{
unsigned int i;
for(i=0;i<sa.cif_begin;i++)
{
sa.nbIterations = sa.cif_begin;
// sa.cam_output_file.open("cams/cam.out",std::ofstream::out);
// char camfile[100];
// sprintf(camfile,"cams/cam.scn%d.spline",config);
// sa.readCameraInputFile(camfile);
// if(sa.cif_exists)
// {
// unsigned int i;
//
// for(i=0;i<sa.cif_begin;i++)
// {
// sa.nbIterations = sa.cif_begin;
sa.simulator.doStep();
}
}
// }
// }
sa.show() ;
// if (argc > 1)
......
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