Commit ff354286 authored by Pierre Kraemer's avatar Pierre Kraemer

update QT

parent 37ee91e4
......@@ -12,11 +12,19 @@ SET(CMAKE_MODULE_PATH " ${CMAKE_MODULE_PATH} ${CGoGN_ROOT_DIR}/cmake_modules/")
find_package(OpenGL)
find_package(GLUT)
# FOR Qt4
FIND_PACKAGE(Qt4 REQUIRED)
SET(QT_USE_QTOPENGL TRUE)
INCLUDE(${QT_USE_FILE})
ADD_DEFINITIONS(${QT_DEFINITIONS})
# qq definition specifiques pour mac
IF(APPLE)
# attention a changer pour chercher la bonne version automatiquement
SET(CMAKE_OSX_SYSROOT "/Developer/SDKs/MacOSX10.6.sdk")
SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-undefined -Wl,dynamic_lookup")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DMAC_OSX")
SET(CMAKE_OSX_ARCHITECTURES x86_64)
ENDIF(APPLE)
IF(WIN32)
......@@ -41,7 +49,10 @@ ENDIF(WIN32)
SET(EXECUTABLE_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/bin)
SET (COMMON_LIBS ${GLUT_LIBRARY} ${OPENGL_LIBRARY} ${GLEW_LIBRARY} ${DEVIL_LIBRARIES} ${ZLIB_LIBRARIES} ${LIBXML2_LIBRARIES} gzstream AntTweakBar )
SET(COMMON_LIBS ${GLUT_LIBRARY} ${OPENGL_LIBRARY} ${GLEW_LIBRARY} ${DEVIL_LIBRARIES} ${ZLIB_LIBRARIES} ${LIBXML2_LIBRARIES} gzstream openctm assimp)
SET(CGoGN_LIBS_D topologyD algoD containerD utilsD)
SET(CGoGN_LIBS_R topology algo container utils)
SET(NUMERICAL_LIBS numerical lapack blas f2c)
add_subdirectory(Release)
add_subdirectory(Debug)
......
cmake_minimum_required(VERSION 2.6)
project(SocialAgents)
SET(CMAKE_BUILD_TYPE Debug)
#SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pg")
......@@ -13,26 +11,31 @@ link_directories(
# define includes path
include_directories(
/usr/include/libxml2/
../include
/usr/include/libxml2/
${CGoGN_ROOT_DIR}/include
${CGoGN_ROOT_DIR}/ThirdParty/Numerical
${CGoGN_ROOT_DIR}/ThirdParty/Numerical/UFconfig
${CGoGN_ROOT_DIR}/ThirdParty/AntTweakBar/include
${CGoGN_ROOT_DIR}/ThirdParty/gzstream
${CGoGN_ROOT_DIR}/ThirdParty/Zinri
${CGoGN_ROOT_DIR}/ThirdParty/OpenCTM
${CGoGN_ROOT_DIR}/ThirdParty/Assimp/include
${CGoGN_ROOT_DIR}/ThirdParty/glm
${CMAKE_CURRENT_BINARY_DIR}
)
#define exec to compile
QT4_WRAP_UI( socialAgents_ui ../include/socialAgents.ui )
QT4_WRAP_CPP( socialAgents_moc ../include/viewer.h )
add_executable( socialAgentsD
../src/viewer.cpp
../src/env_map.cpp
../src/agent.cpp
../src/simulator.cpp
${socialAgents_moc}
${socialAgents_ui}
)
target_link_libraries( socialAgentsD
containerD topologyD utilsD algoD ${COMMON_LIBS} boost_thread-mt)
${CGoGN_LIBS_D} ${COMMON_LIBS} ${QT_LIBRARIES} boost_thread-mt)
cmake_minimum_required(VERSION 2.6)
project(SocialAgents)
SET(CMAKE_BUILD_TYPE Release)
link_directories(
......@@ -10,26 +8,31 @@ link_directories(
# define includes path
include_directories(
/usr/include/libxml2/
../include
/usr/include/libxml2/
${CGoGN_ROOT_DIR}/include
${CGoGN_ROOT_DIR}/ThirdParty/Numerical
${CGoGN_ROOT_DIR}/ThirdParty/Numerical/UFconfig
${CGoGN_ROOT_DIR}/ThirdParty/AntTweakBar/include
${CGoGN_ROOT_DIR}/ThirdParty/gzstream
${CGoGN_ROOT_DIR}/ThirdParty/Zinri
${CGoGN_ROOT_DIR}/ThirdParty/OpenCTM
${CGoGN_ROOT_DIR}/ThirdParty/Assimp/include
${CGoGN_ROOT_DIR}/ThirdParty/glm
${CMAKE_CURRENT_BINARY_DIR}
)
#define exec to compile
QT4_WRAP_UI( socialAgents_ui ../include/socialAgents.ui )
QT4_WRAP_CPP( socialAgents_moc ../include/viewer.h )
add_executable( socialAgents
../src/viewer.cpp
../src/env_map.cpp
../src/agent.cpp
../src/simulator.cpp
${socialAgents_moc}
${socialAgents_ui}
)
target_link_libraries( socialAgents
container topology utils algo ${COMMON_LIBS} boost_thread-mt)
${CGoGN_LIBS_R} ${COMMON_LIBS} ${QT_LIBRARIES} boost_thread-mt)
......@@ -4,9 +4,7 @@
#include "env_map.h"
#include "agent.h"
#include <GL/glut.h>
void renderDart(EnvMap& m, Dart d)
inline void renderDart(EnvMap& m, Dart d)
{
PFP::VEC3 p1 = m.position[d];
PFP::VEC3 p2 = m.position[m.map.phi1(d)];
......@@ -17,7 +15,7 @@ void renderDart(EnvMap& m, Dart d)
glEnd();
}
void renderFace(EnvMap& m, Dart& d)
inline void renderFace(EnvMap& m, Dart& d)
{
Dart dd=d;
do {
......@@ -26,7 +24,7 @@ void renderFace(EnvMap& m, Dart& d)
}while(dd!=d);
}
void renderPredictionTriangle(EnvMap& m, Dart d, PFP::VEC3 p)
inline void renderPredictionTriangle(EnvMap& m, Dart d, PFP::VEC3 p)
{
VEC3 pos1(m.position[d]);
VEC3 pos2(m.position[m.map.phi1(d)]);
......@@ -41,7 +39,7 @@ void renderPredictionTriangle(EnvMap& m, Dart d, PFP::VEC3 p)
static const float cosT[5] = { 1, 0.309017, -0.809017, -0.809017, 0.309017 };
static const float sinT[5] = { 0, 0.951057, 0.587785, -0.587785, -0.951057 };
void renderAgent(Agent* agent, bool showNeighborDist = false, bool showObstacleDist = false)
inline void renderAgent(Agent* agent, bool showNeighborDist = false, bool showObstacleDist = false)
{
VEC3& pos = agent->part_.m_position;
float radius = agent->radius_;
......@@ -76,4 +74,3 @@ void renderAgent(Agent* agent, bool showNeighborDist = false, bool showObstacleD
}
#endif
......@@ -24,16 +24,16 @@
#include <iostream>
#include "Utils/glutwin.h"
#include "Utils/os_spec.h"
#include "Utils/GLSLShader.h"
#include "Utils/qtSimple.h"
#include "ui_socialAgents.h"
#include "Utils/qtui.h"
#include "simulator.h"
#include "env_render.h"
#include "Algo/Geometry/boundingbox.h"
#include "Algo/Export/exportPov.h"
#include "Utils/GLSLShader.h"
#include "Algo/Render/GL1/map_glRender.h"
#include "Algo/Render/GL1/topo_render.h"
......@@ -41,20 +41,25 @@ using namespace CGoGN ;
typedef PFP::MAP MAP;
class MyGlutWin : public Utils::SimpleGlutWin
class SocialAgents : public Utils::QT::SimpleQT
{
Q_OBJECT
public:
MyGlutWin(int* argc, char** argv, int winX, int winY) ;
SocialAgents() ;
void init() ;
void myRedraw();
void animate();
void initGUI() ;
void cb_initGL() ;
void cb_redraw() ;
// bool exportScenePov(PFP::MAP& map, PFP::TVEC3& position, const std::string& filename, PFP::VEC3 cameraPos, PFP::VEC3 cameraLook, PFP::VEC3 translate, float angle_X, float angle_Y, float angle_Z,const FunctorSelect& good = SelectorTrue());
void myKeyboard(unsigned char keycode, int x, int y);
void cb_keyPress(int keycode) ;
Utils::QT::uiDockInterface dock ;
QTimer* timer;
// to count fps
int frames;
......@@ -65,10 +70,12 @@ public:
Simulator sim;
SelectorTrue allDarts;
bool b_animate;
bool render_anim;
int visu;
int nbGenerated;
float explode;
public slots:
void animate() ;
} ;
......@@ -5,8 +5,8 @@ Simulator::Simulator() : globalTime_(0.0f), timeStep_(0.25f)
srand(10);
envMap_.init();
std::cout << "setup scenario" << std::endl;
importAgents("myAgents.pos");
// setupScenario();
// importAgents("myAgents.pos");
setupScenario();
for(unsigned int i = 0; i < agents_.size(); ++i)
{
agents_[i]->updateObstacleNeighbors();
......
......@@ -25,19 +25,10 @@
#include "viewer.h"
#include <string>
/**********************************************************************************************
* MyGlutWin IMPLEMENTATION *
**********************************************************************************************/
MyGlutWin::MyGlutWin(int* argc, char **argv, int winX, int winY) :
SimpleGlutWin(argc, argv, winX, winY)
{}
void MyGlutWin::init()
SocialAgents::SocialAgents()
{
explode = 0.9f;
b_animate = false;
render_anim = false;
nbGenerated = 0;
......@@ -48,15 +39,32 @@ void MyGlutWin::init()
glEnable( GL_POINT_SMOOTH );
visu = 0;
timer = new QTimer(this);
connect(timer, SIGNAL(timeout()), this, SLOT(animate()));
}
void MyGlutWin::myRedraw()
void SocialAgents::initGUI()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
setDock(&dock) ;
}
if(b_animate)
animate();
void SocialAgents::cb_initGL()
{
Utils::GLSLShader::setCurrentOGLVersion(1) ;
setFocal(5.0f) ;
Geom::BoundingBox<PFP::VEC3> bb = Algo::Geometry::computeBoundingBox<PFP>(sim.envMap_.map, sim.envMap_.position) ;
VEC3 gPosObj = bb.center() ;
float tailleX = bb.size(0) ;
float tailleY = bb.size(1) ;
float tailleZ = bb.size(2) ;
float gWidthObj = std::max<float>(std::max<float>(tailleX, tailleY), tailleZ) ;
setParamObject(gWidthObj, gPosObj.data());
}
void SocialAgents::cb_redraw()
{
glDisable(GL_LIGHTING);
/*
glColor3f(0.5f,0.5f,0.5f);
......@@ -139,40 +147,39 @@ void MyGlutWin::myRedraw()
renderDart(sim.envMap_, d);
}
}
/*
glColor3f(0.0f, 1.0f, 0.0f);
glLineWidth(5.0f);
CellMarker dmb(sim.envMap_.map, FACE_CELL);
for(Dart d = sim.envMap_.map.begin(); d != sim.envMap_.map.end(); sim.envMap_.map.next(d))
{
if(!dmb.isMarked(d))
{
dmb.mark(d);
if(sim.envMap_.buildingMark.isMarked(d))
{
VEC3 c = Algo::Geometry::faceCentroid<PFP>(sim.envMap_.map, d, sim.envMap_.position);
glBegin(GL_LINES);
Dart dd = d;
do
{
VEC3 p1 = sim.envMap_.position[dd];
VEC3 p2 = sim.envMap_.position[sim.envMap_.map.phi1(dd)];
VEC3 vec = c - p1;
p1 = p1 + vec*0.25f;
vec = c - p2;
p2 = p2 + vec*0.25f;
glVertex3f(p1[0],p1[1],p1[2]);
glVertex3f(p2[0],p2[1],p2[2]);
dd = sim.envMap_.map.phi1(dd);
} while(dd != d);
glEnd();
}
}
}
*/
//count fps
// glColor3f(0.0f, 1.0f, 0.0f);
// glLineWidth(5.0f);
// CellMarker dmb(sim.envMap_.map, FACE_CELL);
// for(Dart d = sim.envMap_.map.begin(); d != sim.envMap_.map.end(); sim.envMap_.map.next(d))
// {
// if(!dmb.isMarked(d))
// {
// dmb.mark(d);
// if(sim.envMap_.buildingMark.isMarked(d))
// {
// VEC3 c = Algo::Geometry::faceCentroid<PFP>(sim.envMap_.map, d, sim.envMap_.position);
// glBegin(GL_LINES);
// Dart dd = d;
// do
// {
// VEC3 p1 = sim.envMap_.position[dd];
// VEC3 p2 = sim.envMap_.position[sim.envMap_.map.phi1(dd)];
// VEC3 vec = c - p1;
// p1 = p1 + vec*0.25f;
// vec = c - p2;
// p2 = p2 + vec*0.25f;
//
// glVertex3f(p1[0],p1[1],p1[2]);
// glVertex3f(p2[0],p2[1],p2[2]);
//
// dd = sim.envMap_.map.phi1(dd);
// } while(dd != d);
// glEnd();
// }
// }
// }
if(displayFps)
{
++frames;
......@@ -187,17 +194,16 @@ void MyGlutWin::myRedraw()
std::ostringstream oss;
oss << s << fps;
glColor3f(1.0f, 1.0f, 1.0f);
printString2D(10, 20, oss.str());
statusMsg(oss.str().c_str());
}
}
void MyGlutWin::animate()
void SocialAgents::animate()
{
if(sim.globalTime_ - int(sim.globalTime_) == 0.0f && int(sim.globalTime_) % 10 == 0)
std::cout << sim.globalTime_ << " " << sim.envMap_.mapMemoryCost() << std::endl;
sim.doStep();
glutPostRedisplay();
if(render_anim)
{
......@@ -216,9 +222,11 @@ void MyGlutWin::animate()
exit(0);
}
}
updateGL();
}
/*
bool MyGlutWin::exportScenePov(PFP::MAP& map, PFP::TVEC3& position, const std::string& filename, PFP::VEC3 cameraPos, PFP::VEC3 cameraLook, PFP::VEC3 translate, float angle_X, float angle_Y, float angle_Z,const FunctorSelect& good)
bool SocialAgents::exportScenePov(PFP::MAP& map, PFP::TVEC3& position, const std::string& filename, PFP::VEC3 cameraPos, PFP::VEC3 cameraLook, PFP::VEC3 translate, float angle_X, float angle_Y, float angle_Z,const FunctorSelect& good)
{
static const bool highlightAgent=false;
static const bool wireDisplay=false;
......@@ -367,13 +375,16 @@ bool MyGlutWin::exportScenePov(PFP::MAP& map, PFP::TVEC3& position, const std::s
return true;
}
*/
void MyGlutWin::myKeyboard(unsigned char keycode, int x, int y)
void SocialAgents::cb_keyPress(int keycode)
{
switch (keycode)
{
case 'a': {
sim.envMap_.map.check();
b_animate = !b_animate;
if(!timer->isActive())
timer->start();
else
timer->stop();
break;
}
case 'c': {
......@@ -389,7 +400,7 @@ void MyGlutWin::myKeyboard(unsigned char keycode, int x, int y)
break;
}
case 'f': {
displayFps = ! displayFps;
displayFps = !displayFps;
break;
}
case 'r' : {
......@@ -417,7 +428,7 @@ void MyGlutWin::myKeyboard(unsigned char keycode, int x, int y)
}
}
glutPostRedisplay();
updateGL() ;
}
/**********************************************************************************************
......@@ -426,22 +437,22 @@ void MyGlutWin::myKeyboard(unsigned char keycode, int x, int y)
int main(int argc, char** argv)
{
MyGlutWin* mgw = new MyGlutWin(&argc, argv, 1200, 800);
mgw->init();
if(argc == 2)
{
GLint t1 = glutGet(GLUT_ELAPSED_TIME);
for(unsigned int i = 0; i < 300; ++i)
mgw->animate();
GLint t2 = glutGet(GLUT_ELAPSED_TIME);
GLfloat seconds = (t2 - t1) / 1000.0f;
std::cout << "animation : "<< seconds << "sec" << std::endl;
}
else
mgw->mainLoop() ;
return 0 ;
QApplication app(argc, argv) ;
SocialAgents sa ;
sa.setGeometry(0, 0, 1200, 800) ;
sa.initGUI() ;
sa.show() ;
// if(argc == 2)
// {
// GLint t1 = glutGet(GLUT_ELAPSED_TIME);
// for(unsigned int i = 0; i < 300; ++i)
// sa->animate();
// GLint t2 = glutGet(GLUT_ELAPSED_TIME);
// GLfloat seconds = (t2 - t1) / 1000.0f;
// std::cout << "animation : "<< seconds << "sec" << std::endl;
// }
return app.exec() ;
}
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