Création d'un compte pour un collaborateur extérieur au laboratoire depuis l'intranet ICube : https://intranet.icube.unistra.fr/fr/labs/member/profile

Commit c46f1aac authored by Arash HABIBI's avatar Arash HABIBI
Browse files

comment

parents 895e18f6 c8122245
......@@ -5,6 +5,7 @@ project(SocialAgents)
#add_definitions(-DSPATIAL_HASHING)
SET(CGoGN_ROOT_DIR ${CMAKE_SOURCE_DIR}/../../CGoGN CACHE STRING "CGoGN root dir")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g")
include(${CGoGN_ROOT_DIR}/apps_cmake.txt)
add_subdirectory(${CMAKE_SOURCE_DIR}/Release Release)
......
......@@ -44,6 +44,7 @@ add_executable( socialAgentsD
../src/gl2ps.c
../src/ShapeMatching/rigidXfComputation.cpp
../src/shaderCustom.cpp
../src/shaderCustomTex.cpp
${socialAgents_moc}
${socialAgents_ui}
)
......
......@@ -10,6 +10,7 @@ ENDIF (WIN32)
include_directories(
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/Release
# ${CMAKE_CURRENT_SOURCE_DIR}
../include
......@@ -44,6 +45,7 @@ add_executable( socialAgents
../src/gl2ps.c
../src/ShapeMatching/rigidXfComputation.cpp
../src/shaderCustom.cpp
../src/shaderCustomTex.cpp
${socialAgents_moc}
${socialAgents_ui}
)
......
......@@ -7,7 +7,10 @@
#include "env_map.h"
#include "spatialHashing.h"
//#define SECURED
//#define EXPORTING_AGENT
//#define EXPORTING_OBJ
#ifdef SECURED
#include "Algo/MovingObjects/particle_cell_2D_secured.h"
......@@ -15,6 +18,19 @@
#include "Algo/MovingObjects/particle_cell_2D.h"
#endif
#ifdef EXPORTING_AGENT
#include "Utils/vbo.h"
#include "Utils/Shaders/shaderSimpleColor.h"
#endif
#ifdef EXPORTING_OBJ
#include "Algo/Render/GL2/mapRender.h"
#include "Utils/vbo.h"
#include "Algo/Import/importObjTex.h"
#include "shaderCustomTex.h"
#endif
class Simulator ;
class Agent
......@@ -24,6 +40,8 @@ public:
Agent(Simulator* sim, const VEC3& position, const VEC3& goals) ;
void init(const VEC3& start, const VEC3& goal);
void initGL();
void draw();
VEC3 getPosition() ;
......@@ -50,6 +68,33 @@ public:
std::vector<std::pair<float, Obstacle*> > obstacleNeighbors_ ;
std::vector<std::pair<float, Obstacle*> > movingObstacleNeighbors_;
#ifdef EXPORTING_AGENT
static const unsigned int m_ghost_nb = 500;
std::list<VEC3> m_ghost_previousPos;
Utils::VBO * m_ghost_VBO;
Utils::ShaderSimpleColor * m_ghost_shader;
#endif
#ifdef EXPORTING_OBJ
// PFP2::MAP map;
// VertexAttribute<VEC3> position;
// VertexAttribute<VEC3> normal;
VEC3 previousPos;
float previousRot;
Geom::Matrix44f m_transfo;
// Algo::Render::GL2::MapRender* m_render;
// Utils::VBO* m_positionVBO;
// Utils::VBO* m_normalVBO;
// Utils::Texture<2,Geom::Vec3uc>* m_texture;
// Utils::VBO* m_texcoordVBO;
// ShaderCustomTex* m_shaderTex;
// Algo::Surface::Import::OBJModel<PFP2> m_obj;
// unsigned int m_nbIndices;
#endif
#ifdef SPATIAL_HASHING
VEC3 pos ;
#else
......
......@@ -606,15 +606,16 @@ void generatePlanet(EnvMap& envMap)
{
unsigned int nx = envMap.geometry.size(0) / envMap.maxCellSize ;
unsigned int ny = envMap.geometry.size(1) / envMap.maxCellSize ;
if (nx < 1) nx = 1 ;
if (ny < 1) ny = 1 ;
if (nx < 1)
nx = 1 ;
if (ny < 1)
ny = 1 ;
Algo::Surface::Modelisation::Polyhedron<PFP> prim(envMap.map, envMap.position) ;
prim.cylinder_topo(nx, ny, true, true) ;
double pi = 3.14159265358979323846f ;
double xRadius = envMap.geometry.size(0) / 2 * pi ;
double yRadius = envMap.geometry.size(1) / 2 * pi ;
double xRadius = envMap.geometry.size(0) / 2 * M_PI;
double yRadius = envMap.geometry.size(1) / 2 * M_PI ;
prim.embedSphere((xRadius+yRadius)/2.0f) ;
}
......@@ -624,6 +625,7 @@ typename PFP::VEC3 parametrization(typename PFP::VEC3 p, float r,const Geom::Bou
{
p[0] = 2.0f*M_PI*(p[0]-bb.min()[0])/bb.size(0);
p[1] = ((2.0f*M_PI*(p[1]-bb.min()[1])/bb.size(1))-M_PI)/2.0f;
r += p[2];
return typename PFP::VEC3(2.0f*r*cos(p[0])*cos(p[1]),
2.0f*r*sin(p[0])*cos(p[1]),
......
......@@ -32,6 +32,15 @@ class ArticulatedObstacle;
#include "pfp.h"
//#define EXPORTING3
#ifdef EXPORTING3
#include "Utils/Shaders/shaderPhongTexture.h"
#include "Utils/Shaders/shaderSimpleTexture.h"
#include "shaderCustomTex.h"
#include "Algo/Import/importObjTex.h"
#endif
class EnvMap
{
public:
......@@ -52,6 +61,9 @@ public:
EnvMap() ;
void init(unsigned int config, REAL width, REAL height, REAL minSize, REAL maxSize) ;
void initGL();
void draw();
void scale(float val);
void markPedWay() ;
......@@ -96,6 +108,8 @@ public:
PFP::TVEC3 position ;
PFP::TVEC3 normal ;
Geom::BoundingBox<PFP::VEC3> bb;
PFP::MAP mapScenary ;
PFP::TVEC3 positionScenary ;
PFP::TVEC3 normalScenary ;
......@@ -112,6 +126,32 @@ public:
void popObstNeighborInCells(Obstacle* o, Dart d);
void find_next(Obstacle* o,Dart * d, CellMarkerMemo<FACE>& cms);
#ifdef EXPORTING3
std::vector<PFP::MAP *> m_map_Export;
std::vector<Algo::Surface::Import::OBJModel<PFP2> *> m_obj_Export;
std::vector<Utils::Texture<2,Geom::Vec3uc>*> m_texture_Export;
std::vector<Utils::VBO*> m_positionVBO_Export;
std::vector<Utils::VBO*> m_normalVBO_Export;
std::vector<Utils::VBO*> m_texcoordVBO_Export;
std::vector<ShaderCustomTex*> m_shaderTex_Export;
std::vector<unsigned int> m_nbIndice_Export;
// PFP2::MAP m_map_Export;
// VertexAttribute<VEC3> position_Export ;
// VertexAttribute<VEC3> normal_Export ;
// Algo::Surface::Import::OBJModel<PFP2> * m_obj_Export;
//
// Utils::Texture<2,Geom::Vec3uc>* m_texture_Export;
// Utils::VBO* m_positionVBO_Export;
// Utils::VBO* m_normalVBO_Export;
// Utils::VBO* m_texcoordVBO_Export;
// ShaderCustomTex* m_shaderTex_Export;
//
// unsigned int m_nbIndice_Export;
#endif
std::vector<Dart> newBuildings ;
......@@ -181,7 +221,7 @@ void update_registration(Obstacle * o);
void register_pop(Obstacle* o, int n);
void resetPartSubdiv(Obstacle* o);
void resetObstPartInFace(Obstacle* o, Dart d);// empeche de viser une dart ayant disparu
void resetPart(MovingObstacle * mo, Dart d); // empeche de viser une dart ayant disparu pour les voisins
void resetPart(Obstacle * mo, Dart d); // empeche de viser une dart ayant disparu pour les voisins
void displayMO(Obstacle * o);
/**************************************
......@@ -245,6 +285,17 @@ inline void EnvMap::pushAgentInCells(Agent* agent, Dart d)
{
assert(map.getCurrentLevel() == map.getMaxLevel()) ;
// assert(std::find(agentvect[d].begin(), agentvect[d].end(), agent) == agentvect[d].end());
// map.check();
// TraversorF<PFP::MAP> tF(map);
// for(Dart ddd = tF.begin() ; ddd != tF.end() ; ddd = tF.next())
// {
// if(std::find(agentvect[ddd].begin(), agentvect[ddd].end(), agent) != agentvect[ddd].end())
// std::cout <<agent << " SO WRONG ADD" <<ddd.index<< std::endl;
//
// if(std::find(neighborAgentvect[ddd].begin(), neighborAgentvect[ddd].end(), agent) != neighborAgentvect[ddd].end())
// std::cout <<agent<< " SO SO WRONG ADD" <<ddd.index<< std::endl;
// }
addElementToVector<Agent*>(agentvect[d],agent);
// agentvect[d].push_back(agent) ;
......@@ -256,7 +307,11 @@ inline void EnvMap::pushAgentInCells(Agent* agent, Dart d)
Dart ddd = map.alpha1(map.alpha1(dd)) ;
while (ddd != dd)
{
addElementToVector<Agent*>(neighborAgentvect[ddd],agent);
if (!map.isBoundaryMarked2(ddd))
{
addElementToVector<Agent*>(neighborAgentvect[ddd],agent);
}
// neighborAgentvect[ddd].push_back(agent) ;
// nbAgentsIncrease(ddd);
ddd = map.alpha1(ddd) ;
......@@ -279,12 +334,25 @@ inline void EnvMap::popAgentInCells(Agent* agent, Dart d)
Dart ddd = map.alpha1(map.alpha1(dd)) ;
while (ddd != dd)
{
removeElementFromVector<Agent*>(neighborAgentvect[ddd], agent) ;
if (!map.isBoundaryMarked2(ddd))
{
removeElementFromVector<Agent*>(neighborAgentvect[ddd], agent) ;
}
// nbAgentsDecrease(ddd) ;
ddd = map.alpha1(ddd) ;
}
dd = map.phi1(dd) ;
} while (dd != d) ;
// TraversorF<PFP::MAP> tF(map);
// for(Dart ddd = tF.begin() ; ddd != tF.end() ; ddd = tF.next())
// {
// if(std::find(agentvect[ddd].begin(), agentvect[ddd].end(), agent) != agentvect[ddd].end())
// std::cout <<agent << " SO WRONG" <<ddd.index<< std::endl;
//
// if(std::find(neighborAgentvect[ddd].begin(), neighborAgentvect[ddd].end(), agent) != neighborAgentvect[ddd].end())
// std::cout <<agent<< " SO SO WRONG " <<ddd.index<< std::endl;
// }
}
......@@ -298,7 +366,7 @@ inline void EnvMap::addObstAsNeighbor (Obstacle * o, const std::vector<Dart>& b
neighbor_cells->clear();
CellMarkerMemo<FACE> memo_mark(map);
CellMarkerMemo<FACE> OneRingMark(map);
memo_mark.unmarkAll();
for (std::vector<Dart>::const_iterator it =belonging_cells.begin();it<belonging_cells.end();++it)
memo_mark.mark(*it);
......@@ -307,8 +375,13 @@ inline void EnvMap::addObstAsNeighbor (Obstacle * o, const std::vector<Dart>& b
Dart first =NIL;
Dart d=NIL;
Dart dd=NIL;
// CGoGNout<<"beg : "<<(*it)<<CGoGNendl;
//boucle pour trouver une face du voisinage de l'obstacle ne contenant pas l'obstacle
/////////////////////////////////////////////boucle pour trouver une face du voisinage de l'obstacle ne contenant pas l'obstacle
// CGoGNout<<"debut neighbors cellules : ";
// for (std::vector<Dart>::const_iterator it =belonging_cells.begin();it<belonging_cells.end();++it)
// CGoGNout<<(*it).index<<" ; ";
// CGoGNout<<CGoGNendl;
do
{
beg = *it;
......@@ -342,16 +415,6 @@ inline void EnvMap::addObstAsNeighbor (Obstacle * o, const std::vector<Dart>& b
}
find_next(o,&d, memo_mark);
if(d==NIL)
{
CGoGNout<<"cellule de début : "<<first<<CGoGNendl;
CGoGNout<<"cellules markées OneRing : "<<CGoGNendl;
std::vector<Dart> v=OneRingMark.get_markedCells();
for(std::vector<Dart>::iterator it=v.begin();it<v.end();++it)
{
CGoGNout<<(*it).index<<CGoGNendl;
}
}
// CGoGNout<<"d : "<<d<<CGoGNendl;
}while(!map.sameFace(d,first));
}
......
......@@ -221,30 +221,30 @@ inline void renderAgent(EnvMap& m, Agent* agent, bool showNeighborDist = false,
//show goals
if (renderPath)
{
glLineWidth(3.0f) ;
glBegin(GL_LINE_STRIP) ;
for (std::vector<VEC3>::iterator it = (agent->goals_.begin()) ; it != agent->goals_.end() ;
++it)
{
glVertex3f((*it)[0], (*it)[1], agent->agentNo) ;
}
glVertex3f((*(agent->goals_.begin()))[0], (*(agent->goals_.begin()))[1], (*(agent->goals_.begin()))[2]) ;
glEnd() ;
glLineWidth(1.0f) ;
glPointSize(5.0f) ;
glBegin(GL_POINTS) ;
VEC3 g = agent->goals_[agent->curGoal_];
glVertex3fv(g.data()) ;
glEnd() ;
glPointSize(1.0f) ;
glBegin(GL_LINES);
VEC3 p = agent->getPosition();
glVertex3fv(p.data()) ;
glVertex3fv(g.data()) ;
glEnd();
// glLineWidth(3.0f) ;
// glBegin(GL_LINE_STRIP) ;
// for (std::vector<VEC3>::iterator it = (agent->goals_.begin()) ; it != agent->goals_.end() ;
// ++it)
// {
// glVertex3f((*it)[0], (*it)[1], agent->agentNo) ;
// }
//
// glVertex3f((*(agent->goals_.begin()))[0], (*(agent->goals_.begin()))[1], (*(agent->goals_.begin()))[2]) ;
// glEnd() ;
// glLineWidth(1.0f) ;
//
// glPointSize(5.0f) ;
// glBegin(GL_POINTS) ;
// VEC3 g = agent->goals_[agent->curGoal_];
// glVertex3fv(g.data()) ;
// glEnd() ;
// glPointSize(1.0f) ;
//
// glBegin(GL_LINES);
// VEC3 p = agent->getPosition();
// glVertex3fv(p.data()) ;
// glVertex3fv(g.data()) ;
// glEnd();
}
if (showNeighborDist)
......
......@@ -13,15 +13,20 @@
#include "Utils/Shaders/shaderSimpleColor.h"
#include "Utils/Qt/qtSimple.h"
using namespace std;
#include "shaderCustomTex.h"
#include "Algo/Import/importObjTex.h"
using namespace std;
//#define EXPORTING2
class MovingMesh
{
public:
MovingMesh(EnvMap& envMap, Dart d, std::string filename);
void initGL();
void linkWithObstacle(MovingObstacle * mo);
void transform(Geom::Matrix44f m);
......@@ -40,14 +45,26 @@ public:
PFP::MAP& motherMap;
VertexAttribute<VEC3>& motherPosition;
PFP::MAP map;
PFP2::MAP map;
VertexAttribute<VEC3> position;
VertexAttribute<VEC3> normal;
Algo::Render::GL2::MapRender* m_render;
Utils::VBO* m_positionVBO;
Utils::VBO* m_normalVBO;
#ifdef EXPORTING2
Utils::Texture<2,Geom::Vec3uc>* m_texture;
Utils::VBO* m_texcoordVBO;
ShaderCustomTex* m_shaderTex;
// Utils::ShaderPhongTexture* m_shaderTex;
// Utils::ShaderSimpleTexture* m_shaderTex;
Algo::Surface::Import::OBJModel<PFP2> m_obj;
unsigned int m_nbIndices;
#else
Utils::ShaderSimpleColor* m_simpleColorShader;
#endif
float scaleValue;
......
......@@ -8,6 +8,15 @@
#include <set>
#include "Algo/MovingObjects/particle_cell_2D_memo.h"
#define EXPORTING_BOXES
#ifdef EXPORTING_BOXES
#include "Algo/Render/GL2/mapRender.h"
#include "Utils/Shaders/shaderSimpleColor.h"
#include "Utils/Shaders/shaderFlat.h"
#include "Utils/vbo.h"
#endif
using namespace std;
PFP::VEC3 rotate (PFP::VEC3 pos1, PFP::VEC3 center, float angle);
float get_angle (PFP::VEC3 v1, PFP::VEC3 v2);
......@@ -18,7 +27,11 @@ class MovingMesh;
class MovingObstacle
{
public:
MovingObstacle(Simulator* sim, int index, std::vector<PFP::VEC3> pos, std::vector<VEC3> goals, bool rigid, bool spin, Dart d=NIL, ArticulatedObstacle * art=NULL, int indParent=-1);
MovingObstacle(Simulator* sim, int index, std::vector<PFP::VEC3> pos, std::vector<VEC3> goals, bool rigid, bool spin,int curGoal=0, Dart d=NIL, ArticulatedObstacle * art=NULL, int indParent=-1);
void initGL();
void draw();
bool test_opposition(VEC3 o, VEC3 p1, VEC3 p2);
// void contournerBatiment();
void updateAgentNeighbors() ;
......@@ -26,11 +39,10 @@ public:
bool is_inside (VEC3 p);
void computePrefVelocity();
void computeNewVelocity();
std::vector<Dart> getMemoCross(const VEC3& pos, const VEC3& dest, Dart& d1);
std::vector<Dart> getMemoCross(const VEC3& pos, const VEC3& dest, Dart& d1,Dart& d2);
VEC3 getDilatedPosition(unsigned int ind); //vertex position with velocity dilatation
VEC3 getPosition(unsigned int ind); // vertex position
void update();
PFP::REAL computeMVC(PFP::VEC3 p, Dart vertex);
......@@ -42,9 +54,7 @@ public:
unsigned int nbVertices;
CGoGN::Algo::Surface::MovingObjects::ParticleCell2DMemo<PFP> *registering_part;
// std::vector<PFP::VEC3> vertices;
CGoGN::Algo::Surface::MovingObjects::ParticleCell2D<PFP>* * parts_;
PFP::MAP map;
VertexAttribute<VEC3> position;
......@@ -57,6 +67,13 @@ public:
Dart groundFace;
#ifdef EXPORTING_BOXES
Algo::Render::GL2::MapRender* m_render;
Utils::VBO* m_positionVBO;
Utils::VBO* m_normalVBO;
Utils::ShaderSimpleColor* m_shader;
#endif
//vector de détails pour la deformation
// std::vector<PFP::VEC3> verticesDeformation;
......@@ -66,8 +83,6 @@ public:
// std::vector<float> verticesAngle;
// float rigidity;
// float gravity_dist;
VEC3 center;
int index;
int max_x_ind;
......@@ -98,7 +113,6 @@ public:
static float neighborDist_;
static float neighborDistSq_;
static float maxSpeed_;
// float obstacle_range;
static float timeHorizonObst_;
float velocity_factor;
float color1;
......@@ -112,11 +126,14 @@ public:
bool rigid_;
bool spinning;
ArticulatedObstacle * parent;
int index_parent;
MovingMesh* mm_;
Agent* ag_;
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_;
std::vector<std::pair<float, Obstacle*> > obstacleNeighbors_ ;
std::vector<std::pair<float, Obstacle*> > movingObstacleNeighbors_;
};
#endif
......@@ -24,6 +24,13 @@ struct PFP : public PFP_STANDARD
typedef NoMathIONameAttribute<std::pair<bool, bool> > BOOLATTRIB ;
} ;
struct PFP2 : public PFP_STANDARD
{
// definition de la carte
typedef EmbeddedMap2 MAP ;
// typedef Algo::Surface::IHM::ImplicitHierarchicalMap MAP ;
} ;
typedef PFP::VEC3 VEC3 ;
typedef PFP::REAL REAL ;
......
......@@ -9,6 +9,7 @@ uniform vec4 diffuse;
uniform vec4 ambient;
VARYING_OUT vec4 ColorFS;
VARYING_OUT vec3 N;
VARYING_OUT vec2 texCoord;
void main(void)
{
vec3 v1 = POSITION_IN(1).xyz - POSITION_IN(0).xyz;
......
// ShaderCustomTex::fragmentShaderText
PRECISON;
uniform sampler2D textureUnit;
in vec3 N;
in vec2 fragTexCoord;
uniform vec4 ambient;
FRAG_OUT_DEF;
void main()
{
gl_FragData[0] = ambient*texture2D(textureUnit,fragTexCoord);
gl_FragData[1] = vec4( 0.5*normalize(N)+vec3(0.5), 1.0 );
}
\ No newline at end of file
// ShaderCustomTex::geometryShaderText
VARYING_IN vec2 texCoord[];
VARYING_OUT vec2 fragTexCoord;
VARYING_OUT vec3 N;
void main(void)
{
vec3 v1 = POSITION_IN(1).xyz - POSITION_IN(0).xyz;
vec3 v2 = POSITION_IN(2).xyz - POSITION_IN(0).xyz;
N = cross(v1,v2);
N = normalize(N);
int i;
for(i=0; i< NBVERTS_IN; i++)
{
gl_Position = POSITION_IN(i);
fragTexCoord = texCoord[i];
EmitVertex();
}
EndPrimitive();
}
#ifndef __SHADER_CUSTOMTEX__
#define __SHADER_CUSTOMTEX__
#include "Utils/GLSLShader.h"
#include "Geometry/vector_gen.h"
#include "Utils/clippingShader.h"
#include "Utils/textures.h"
#include "Utils/gl_def.h"
#include "Geometry/matrix.h"
using namespace CGoGN;
class ShaderCustomTex : public Utils::ClippingShader
{
protected:
// shader sources
static std::string vertexShaderText;
static std::string fragmentShaderText;
static std::string geometryShaderText;
CGoGNGLuint m_unif_unit;
int m_unit;
Geom::Vec4f m_col;
Utils::GTexture* m_tex_ptr;
Utils::VBO* m_vboPos;
Utils::VBO* m_vboTexCoord;
void restoreUniformsAttribs();
public:
ShaderCustomTex();
/**
* choose the texture unit engine to use for this texture
*/
void setTextureUnit(GLenum texture_unit);
/**
* set the texture to use
*/
void setTexture(Utils::GTexture* tex);
/**
* activation of texture unit with set texture
*/
void activeTexture();
/**
* activation of texture unit with texture id
*/
void activeTexture(CGoGNGLuint texId);
unsigned