Commit 0bf72574 authored by Thomas Jund's avatar Thomas Jund

passage a OGL2

parent ca274787
......@@ -5,27 +5,29 @@
#include "agent.h"
#include "Utils/colorMaps.h"
#include "Algo/Render/GL1/map_glRender.h"
inline void renderDart(EnvMap& m, Dart d)
{
PFP::VEC3 p1 = m.position[d] ;
PFP::VEC3 p2 = m.position[m.map.phi1(d)] ;
glBegin(GL_LINES) ;
glVertex3f(p1[0], p1[1], p1[2]) ;
glVertex3f(p2[0], p2[1], p2[2]) ;
glEnd() ;
std::cout << __FILE__ << " " << __LINE__ << " to update" << std::endl;
// glBegin(GL_LINES) ;
// glVertex3f(p1[0], p1[1], p1[2]) ;
// glVertex3f(p2[0], p2[1], p2[2]) ;
// glEnd() ;
}
inline void renderFace(EnvMap& m, Dart d)
{
Dart dd = d ;
do
{
renderDart(m, dd) ;
dd = m.map.phi1(dd) ;
} while (dd != d) ;
std::cout << __FILE__ << " " << __LINE__ << " to update" << std::endl;
// Dart dd = d ;
// do
// {
// renderDart(m, dd) ;
// dd = m.map.phi1(dd) ;
// } while (dd != d) ;
}
......@@ -38,26 +40,31 @@ inline void renderPredictionTriangle(EnvMap& m, Dart d, PFP::VEC3 p)
VEC3 pos1(m.position[d]) ;
VEC3 pos2(m.position[m.map.phi1(d)]) ;
pos2[2] += 2 ;
glBegin(GL_LINE_LOOP) ;
glVertex3fv(&p[0]) ;
glVertex3fv(&pos1[0]) ;
glVertex3fv(&pos2[0]) ;
glEnd() ;
// glBegin(GL_LINE_LOOP) ;
// glVertex3fv(&p[0]) ;
// glVertex3fv(&pos1[0]) ;
// glVertex3fv(&pos2[0]) ;
// glEnd() ;
std::cout << __FILE__ << " " << __LINE__ << " to update" << std::endl;
}
inline void renderObstacle(EnvMap& m, MovingObstacle * obst, bool showBelonging=false, bool renderPath = false, bool showVertices=false)
{
std::cout << __FILE__ << " " << __LINE__ << " to update" << std::endl;
// glPolygonMode(GL_FRONT_AND_BACK, GL_LINE) ;
glColor3f(1.0,1.0,1.0);
glBegin(GL_POLYGON) ;
for (unsigned int i = 0 ; i < (obst->nbVertices) ; ++i)
{
const VEC3& p = obst->getPosition(i) ;
glVertex3fv(p.data()) ;
}
glEnd() ;
// glColor3f(1.0,1.0,1.0);
// glBegin(GL_POLYGON) ;
// for (unsigned int i = 0 ; i < (obst->nbVertices) ; ++i)
// {
// const VEC3& p = obst->getPosition(i) ;
// glVertex3fv(p.data()) ;
// }
// glEnd() ;
// glColor3f(0,1,0);
......@@ -67,26 +74,26 @@ inline void renderObstacle(EnvMap& m, MovingObstacle * obst, bool showBelonging=
if(showVertices)
{
glPointSize(3.0f) ;
glColor3f(0.0,0.0,1.0);
glBegin(GL_POINTS) ;
for (unsigned int i = 0 ; i < (obst->nbVertices) ; ++i)
{
const VEC3& p = obst->getPosition(i) ;
glVertex3fv(p.data()) ;
}
glEnd() ;
glPointSize(1.0f) ;
// glPointSize(3.0f) ;
// glColor3f(0.0,0.0,1.0);
// glBegin(GL_POINTS) ;
// for (unsigned int i = 0 ; i < (obst->nbVertices) ; ++i)
// {
// const VEC3& p = obst->getPosition(i) ;
// glVertex3fv(p.data()) ;
// }
// glEnd() ;
// glPointSize(1.0f) ;
}
glColor3f(1.0,0.0,1.0);
glBegin(GL_LINE_LOOP) ;
for (unsigned int i = 0 ; i < (obst->nbVertices) ; ++i)
{
const VEC3& p = obst->getDilatedPosition(i) ;
glVertex3fv(p.data()) ;
}
glEnd() ;
// glColor3f(1.0,0.0,1.0);
// glBegin(GL_LINE_LOOP) ;
// for (unsigned int i = 0 ; i < (obst->nbVertices) ; ++i)
// {
// const VEC3& p = obst->getDilatedPosition(i) ;
// glVertex3fv(p.data()) ;
// }
// glEnd() ;
// glColor3f(0.0,1.0,1.0);
// glBegin(GL_LINES) ;
......@@ -99,35 +106,35 @@ inline void renderObstacle(EnvMap& m, MovingObstacle * obst, bool showBelonging=
// }
// glEnd() ;
glLineWidth(5.0f) ;
glColor3f(1.0,1.0,0.0);
glBegin(GL_LINES) ;
VEC3 p = obst->getPosition(0) ;
glVertex3fv(p.data()) ;
p += 20.0f*obst->velocity_;
glVertex3fv(p.data()) ;
glEnd() ;
// glLineWidth(5.0f) ;
// glColor3f(1.0,1.0,0.0);
// glBegin(GL_LINES) ;
// VEC3 p = obst->getPosition(0) ;
// glVertex3fv(p.data()) ;
// p += 20.0f*obst->velocity_;
// glVertex3fv(p.data()) ;
// glEnd() ;
if (renderPath)
{
glLineWidth(3.0f) ;
glBegin(GL_LINE_STRIP) ;
for (std::vector<VEC3>::iterator it = ++(obst->goals_.begin()) ; it != obst->goals_.end() ;
++it)
{
// glVertex3f((*it)[0], (*it)[1], (*it)[2]) ;
glVertex3f((*it)[0], (*it)[1], obst->index) ;
}
glEnd() ;
glLineWidth(1.0f) ;
glBegin(GL_LINES) ;
VEC3 p = obst->getPosition(0) ;
glVertex3fv(p.data()) ;
p = obst->goals_[obst->curGoal_];
glVertex3fv(p.data()) ;
glEnd() ;
// glLineWidth(3.0f) ;
// glBegin(GL_LINE_STRIP) ;
// for (std::vector<VEC3>::iterator it = ++(obst->goals_.begin()) ; it != obst->goals_.end() ;
// ++it)
// {
//// glVertex3f((*it)[0], (*it)[1], (*it)[2]) ;
// glVertex3f((*it)[0], (*it)[1], obst->index) ;
//
// }
// glEnd() ;
// glLineWidth(1.0f) ;
//
// glBegin(GL_LINES) ;
// VEC3 p = obst->getPosition(0) ;
// glVertex3fv(p.data()) ;
// p = obst->goals_[obst->curGoal_];
// glVertex3fv(p.data()) ;
// glEnd() ;
}
}
......@@ -137,6 +144,9 @@ static const float sinT[5] = { 0, 0.951057, 0.587785, -0.587785, -0.951057 } ;
inline void renderAgent(EnvMap& m, Agent* agent, bool showNeighborDist = false,
bool showObstacleDist = false, bool renderPath = false, float c1=1.0f,float c2=0, float c3=0 )
{
std::cout << __FILE__ << " " << __LINE__ << " to update" << std::endl;
#ifdef SPATIAL_HASHING
const VEC3& pos = agent->pos ;
#else
......@@ -152,7 +162,7 @@ inline void renderAgent(EnvMap& m, Agent* agent, bool showNeighborDist = false,
VEC3 col = Utils::color_map_BCGYR(float(agent->agentNo)/float(agent->sim_->agents_.size()));
glLineWidth(1.0f) ;
// glLineWidth(1.0f) ;
// glBegin(GL_LINES);
// glVertex3fv(pos.data());
......@@ -180,17 +190,17 @@ inline void renderAgent(EnvMap& m, Agent* agent, bool showNeighborDist = false,
// else
// col = VEC3(0,1,0);
glLineWidth(1.0f) ;
// glLineWidth(1.0f) ;
glColor3fv(col.data());
// glColor3f(c1,c2,c3) ;
glBegin(GL_POLYGON) ;
for(unsigned int i = 0 ; i < 5 ; ++i)
glVertex3f(pos[0] + (cosT[i] * radius), pos[1] + (sinT[i] * radius), pos[2]+0.01f) ;
glEnd() ;
VEC3 dir = agent->prefVelocity_ ;
dir.normalize() ;
// glColor3fv(col.data());
//// glColor3f(c1,c2,c3) ;
// glBegin(GL_POLYGON) ;
// for(unsigned int i = 0 ; i < 5 ; ++i)
// glVertex3f(pos[0] + (cosT[i] * radius), pos[1] + (sinT[i] * radius), pos[2]+0.01f) ;
// glEnd() ;
// VEC3 dir = agent->prefVelocity_ ;
// dir.normalize() ;
//draw the speed vector
// VEC3 base(0,0,1);
......@@ -213,50 +223,50 @@ 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)
{
radius = agent->neighborDist_ ;
glColor3f(0.0f, 1.0f, 0.0f) ;
glBegin(GL_LINE_LOOP) ;
for (unsigned int i = 0 ; i < 5 ; ++i)
glVertex3f(pos[0] + (cosT[i] * radius), pos[1] + (sinT[i] * radius), pos[2] + 0.01f) ;
glEnd() ;
// radius = agent->neighborDist_ ;
// glColor3f(0.0f, 1.0f, 0.0f) ;
// glBegin(GL_LINE_LOOP) ;
// for (unsigned int i = 0 ; i < 5 ; ++i)
// glVertex3f(pos[0] + (cosT[i] * radius), pos[1] + (sinT[i] * radius), pos[2] + 0.01f) ;
// glEnd() ;
}
if (showObstacleDist)
{
radius = (agent->range_);
glColor3f(0.0f, 0.0f, 1.0f) ;
glBegin(GL_LINE_LOOP) ;
for (unsigned int i = 0 ; i < 5 ; ++i)
glVertex3f(pos[0] + (cosT[i] * radius), pos[1] + (sinT[i] * radius), pos[2] + 0.01f) ;
glEnd() ;
// radius = (agent->range_);
// glColor3f(0.0f, 0.0f, 1.0f) ;
// glBegin(GL_LINE_LOOP) ;
// for (unsigned int i = 0 ; i < 5 ; ++i)
// glVertex3f(pos[0] + (cosT[i] * radius), pos[1] + (sinT[i] * radius), pos[2] + 0.01f) ;
// glEnd() ;
}
}
......
......@@ -39,8 +39,16 @@
#include "Algo/Export/exportPov.h"
#include "Utils/GLSLShader.h"
#include "Utils/colorMaps.h"
#include "Algo/Render/GL1/map_glRender.h"
#include "Algo/Render/GL1/topo_render.h"
#include "Algo/Render/GL2/mapRender.h"
#include "Algo/Render/GL2/topoRender.h"
#include "Utils/Shaders/shaderSimpleColor.h"
#include "Utils/Shaders/shaderFlat.h"
#include "Utils/Shaders/shaderPhong.h"
#include "Utils/colorMaps.h"
#include "Utils/vbo.h"
#include "Utils/drawer.h"
#include "Utils/pointSprite.h"
using namespace CGoGN ;
......@@ -55,7 +63,14 @@ public:
void initGUI() ;
void updateVBOprimitives(int upType);
void cb_initGL() ;
void initRendering();
void updateObstacleVBO();
void updateAgentPredTriVBO();
void updateObstaclePredTriVBO();
void cb_redraw() ;
#ifndef SPATIAL_HASHING
......@@ -68,6 +83,48 @@ public:
void cb_keyPress(int keycode) ;
//RENDERING
Geom::Vec4f colDif ;
Geom::Vec4f colSpec ;
Geom::Vec4f colClear ;
Geom::Vec4f colNormal ;
//navigation map
Algo::Render::GL2::MapRender* m_render;
Algo::Render::GL2::TopoRender* m_renderTopo;
Utils::VBO* m_positionVBO;
Utils::VBO* m_normalVBO;
Utils::VBO* m_colorVBO;
Utils::ShaderSimpleColor* m_simpleColorShader;
//building
Algo::Render::GL2::MapRender* m_render_scenary;
Utils::VBO* m_positionVBO_scenary;
Utils::VBO* m_normalVBO_scenary;
Utils::VBO* m_colorVBO_scenary;
Utils::ShaderFlat* m_flatShader_scenary;
//agents
Utils::VBO* m_agentsVBO;
Utils::PointSprite* m_sprite;
//obstacles ground
std::vector<Algo::Render::GL2::MapRender*> m_obst_render;
std::vector<Utils::VBO*> m_obst_VBO;
std::vector<Utils::ShaderFlat*> m_obstShader;
//prediction triangles
std::vector<Algo::Render::GL2::MapRender*> m_triObst_render;
std::vector<Utils::VBO*> m_triObst_VBO;
std::vector<Utils::ShaderSimpleColor*> m_triObst_Shader;
std::vector<Algo::Render::GL2::MapRender*> m_triAgent_render;
std::vector<Utils::VBO*> m_triAgent_VBO;
std::vector<Utils::ShaderSimpleColor*> m_triAgent_Shader;
enum renderMode {SIMPLE} ;
int m_renderStyle;
//////
Utils::QT::uiDockInterface dock ;
QTimer* timer ;
......@@ -146,11 +203,57 @@ public slots:
void slot_drawAgentsPredictionTri(bool b)
{
drawAgentsPredictionTri = b ;
if(drawAgentsPredictionTri && m_triAgent_render.size()==0)
{
for(unsigned int i=0 ; i < simulator.agents_.size() ; ++i)
{
m_triAgent_render.push_back(new Algo::Render::GL2::MapRender());
Utils::ShaderSimpleColor * shader = new Utils::ShaderSimpleColor();
shader->setColor(Geom::Vec4f(1.,0.,1.,0.)) ;
// shader->setAmbiant(Geom::Vec4f(1.,0.,1.,0.5)) ;
// shader->setDiffuse(Geom::Vec4f(1.,0.,1.,0.5));
Utils::VBO * vbo = new Utils::VBO();
vbo->setDataSize(3);
vbo->allocate(3);
shader->setAttributePosition(vbo);
m_triAgent_VBO.push_back(vbo);
m_triAgent_Shader.push_back(shader);
registerShader(shader);
}
}
updateGL() ;
}
void slot_drawObstPredictionTri(bool b)
{
drawObstPredictionTri = b ;
if(drawObstPredictionTri && m_triObst_render.size()==0)
{
for(unsigned int i=0 ; i < simulator.movingObstacles_.size() ; ++i)
{
m_triObst_render.push_back(new Algo::Render::GL2::MapRender());
Utils::ShaderSimpleColor * shader = new Utils::ShaderSimpleColor();
shader->setColor(Geom::Vec4f(1.,0.,1.,0.)) ;
// shader->setAmbiant(Geom::Vec4f(1.,0.,1.,0.5)) ;
// shader->setDiffuse(Geom::Vec4f(1.,0.,1.,0.5));
Utils::VBO * vbo = new Utils::VBO();
vbo->setDataSize(3);
vbo->allocate(3);
shader->setAttributePosition(vbo);
m_triObst_VBO.push_back(vbo);
m_triObst_Shader.push_back(shader);
registerShader(shader);
}
}
updateGL() ;
}
void slot_drawAgentsNeighborDist(bool b)
......
......@@ -99,13 +99,13 @@ void EnvMap::init(unsigned int config, REAL width, REAL height, REAL minSize, RE
Algo::Surface::Import::importSVG<PFP>(map, filename, position, obstacleMark, buildingMark) ;
std::string filename2 = "./svg/mapBuild.svg" ;
// Algo::Import::importSVG<PFP>(mapScenary, filename2, positionScenary, obstacleMarkS, buildingMarkS) ;
Algo::Surface::Import::importSVG<PFP>(mapScenary, filename2, positionScenary, obstacleMarkS, buildingMarkS) ;
Geom::BoundingBox<PFP::VEC3> bb1, bb2 ;
bb1 = Algo::Geometry::computeBoundingBox<PFP>(map, position) ;
// bb2 = Algo::Geometry::computeBoundingBox<PFP>(mapScenary, positionScenary) ;
// bb1.addPoint(bb2.min());
// bb1.addPoint(bb2.max());
bb2 = Algo::Geometry::computeBoundingBox<PFP>(mapScenary, positionScenary) ;
bb1.addPoint(bb2.min());
bb1.addPoint(bb2.max());
// CityGenerator::planetify<PFP>(map, position, 100.0f, bb1);
// CityGenerator::planetify<PFP>(mapScenary, positionScenary, 100.0f, bb1);
......@@ -204,6 +204,17 @@ void EnvMap::init(unsigned int config, REAL width, REAL height, REAL minSize, RE
subdivisableFace[i].first = false ;
#endif
if(!normal.isValid())
normal = map.addAttribute<PFP::VEC3, VERTEX>("normal") ;
Algo::Surface::Geometry::computeNormalVertices<PFP>(map, position, normal) ;
if(config==5 && !normalScenary.isValid())
{
normalScenary = mapScenary.addAttribute<PFP::VEC3, VERTEX>("normal") ;
Algo::Surface::Geometry::computeNormalVertices<PFP>(mapScenary, positionScenary, normalScenary) ;
}
}
void EnvMap::scale(float val)
......
This diff is collapsed.
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