Commit 8d93b635 authored by Thomas's avatar Thomas
Browse files

chgt setupScenario pr gestion nbAgentMax + glColor blanc + breakpoint pr rendu

parent f449faa5
......@@ -27,7 +27,7 @@ public:
void doStep();
void setupScenario();
void setupScenario(unsigned int nbMaxAgent);
void addPathsToAgents();
bool importAgents(std::string filename);
......
......@@ -18,7 +18,7 @@
<item>
<widget class="QPushButton" name="pushButton">
<property name="text">
<string>PushButton</string>
<string>Animate</string>
</property>
</widget>
</item>
......
......@@ -42,10 +42,10 @@ Dart EnvMap::getBelongingCell(const PFP::VEC3& pos)
void EnvMap::init()
{
float sideSize = 70.0f;
unsigned int nbSquares = 10;
unsigned int nbSquares = 40;
CityGenerator::generateCity<PFP>(map, position, obstacleMark, buildingMark, sideSize, nbSquares);
// CityGenerator::generateMall<PFP>(map, position, obstacleMark, buildingMark, sideSize);
// CityGenerator::simplifyFreeSpace<PFP>(map, position, obstacleMark, buildingMark);
CityGenerator::simplifyFreeSpace<PFP>(map, position, obstacleMark, buildingMark);
map.init();
registerObstaclesInFaces();
for(unsigned int i = subdivisableFace.begin(); i < subdivisableFace.end(); subdivisableFace.next(i))
......
#include "simulator.h"
<<<<<<< HEAD
Simulator::Simulator() : globalTime_(0.0f), timeStep_(0.1f)
=======
Simulator::Simulator() : globalTime_(0.0f), timeStep_(0.25f)
>>>>>>> e5aa38ee0dabd0a950a9aaa810f5f2fa6eb90d29
{
srand(10);
envMap_.init();
std::cout << "setup scenario" << std::endl;
importAgents("myAgents.pos");
// setupScenario();
// addPathsToAgents();
// setupScenario(15000);
addPathsToAgents();
for(unsigned int i = 0; i < agents_.size(); ++i)
{
agents_[i]->updateObstacleNeighbors();
......@@ -69,7 +65,7 @@ void Simulator::doStep()
globalTime_ += timeStep_;
}
void Simulator::setupScenario()
void Simulator::setupScenario(unsigned int nbMaxAgent)
{
/*
* Add agents, specifying their start position, and store their goals on the
......@@ -78,7 +74,12 @@ void Simulator::setupScenario()
Dart d = envMap_.map.begin();
DartMarkerStore filled(envMap_.map);
for (unsigned int i = 0; i < 2000 && d != envMap_.map.end(); ++i)
unsigned int nbx = 3;
unsigned int nby = 3;
unsigned int bMax = nbMaxAgent/(nbx*nby);
for (unsigned int i = 0; i < bMax && d != envMap_.map.end(); ++i)
{
bool found = false;
VEC3 pos;
......@@ -98,8 +99,6 @@ void Simulator::setupScenario()
if(found)
{
unsigned int nbx = 3;
unsigned int nby = 3;
float ecart = 3.0f;
VEC3 posinit = VEC3(pos[0] - (float(nbx)/2.0f * ecart), pos[1] - (float(nby)/2.0f * ecart), pos[2]);
for(unsigned int curx = 0; curx < nbx; ++curx)
......@@ -132,7 +131,7 @@ void Simulator::addPathsToAgents()
Dart dStart = agents_[i]->part_.d;
Dart dStop = dStart;
for(unsigned int j = 0; envMap_.buildingMark.isMarked(dStop) || j < dartDistForPath+rand()*10; ++j)
for(unsigned int j = 0; envMap_.buildingMark.isMarked(dStop) || j < dartDistForPath+rand()*20; ++j)
{
if(dStop == envMap_.map.end())
dStop = envMap_.map.begin();
......@@ -145,7 +144,7 @@ void Simulator::addPathsToAgents()
agents_[i]->goals_.push_back(Algo::Geometry::faceCentroid<PFP>(envMap_.map, *it, envMap_.position));
Dart dStop2 = dStop;
for(unsigned int j = 0; envMap_.buildingMark.isMarked(dStop2) || j < dartDistForPath+rand()*10; ++j)
for(unsigned int j = 0; envMap_.buildingMark.isMarked(dStop2) || j < dartDistForPath+rand()*20; ++j)
{
if(dStop2 == envMap_.map.end())
dStop2 = envMap_.map.begin();
......
......@@ -111,7 +111,7 @@ void SocialAgents::cb_redraw()
// glPolygonMode(GL_FRONT_AND_BACK,GL_FILL);
glDisable(GL_LIGHTING);
glColor3f(0.0f, 0.0f, 0.0f);
glColor3f(1.0f, 1.0f, 1.0f);
glLineWidth(1.0f);
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
Algo::Render::GL1::renderTriQuadPoly<PFP>(sim.envMap_.map, Algo::Render::GL1::LINE, 1.0, sim.envMap_.position, sim.envMap_.normal);
......@@ -236,8 +236,10 @@ void SocialAgents::animate()
sim.doStep();
if(sim.globalTime_<300+sim.timeStep_ && sim.globalTime_>=300)
b_animate=false;
if(sim.globalTime_<300+sim.timeStep_ && sim.globalTime_>=300) {
CGoGNout << " breakpoint for exporting pov" << CGoGNendl;
timer->stop();
}
if(render_anim)
{
......@@ -360,13 +362,6 @@ bool SocialAgents::exportScenePov(PFP::MAP& map, PFP::TVEC3& position, const std
out << "}" << std::endl;
}
out << "cylinder {" << std::endl;
out << "<100,100,100>, <100,200,100>,0.05" << std::endl;
out << "rotate <" << angleX << "," << angleY << "," << angleZ << "> " << std::endl;
out << "texture{ pigment{ color rgb<0.5,0.5,1.0>} finish { ambient rgb 0.1 brilliance 0.5 } }" << std::endl;
out << "}" << std::endl;
for(unsigned int i = 0; i< sim.agents_.size() ; ++i) {
int typeOfAgent=0;
if(draft) {
......@@ -412,10 +407,10 @@ bool SocialAgents::exportScenePov(PFP::MAP& map, PFP::TVEC3& position, const std
out << "rotate <0,0," << sign*myRot << ">"<< std::endl;
out << "rotate <" << angleX-90 << "," << angleY << "," << angleZ << "> " << std::endl;
// out << "translate <" << posR[0] << "," << posR[1] << "," << posR[2]+1+typeOfAgent*4*0.0638297872 << "> " << std::endl;
out << "translate <" << posR[0] << "," << posR[2] << "," << posR[1] << "> " << std::endl;
out << "rotate <" << angleX << "," << angleY << "," << angleZ << "> " << std::endl;
out << "translate <" << translate[0] << "," << translate[1] << "," << translate[2] << ">" << std::endl;
out << "}" << std::endl;
......
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