Coupure prévue mardi 3 Août au matin pour maintenance du serveur. Nous faisons au mieux pour que celle-ci soit la plus brève possible.

viewer.cpp 29.4 KB
Newer Older
Pierre Kraemer's avatar
Pierre Kraemer committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
/*******************************************************************************
* CGoGN: Combinatorial and Geometric modeling with Generic N-dimensional Maps  *
* version 0.1                                                                  *
* Copyright (C) 2009, IGG Team, LSIIT, University of Strasbourg                *
*                                                                              *
* This library is free software; you can redistribute it and/or modify it      *
* under the terms of the GNU Lesser General Public License as published by the *
* Free Software Foundation; either version 2.1 of the License, or (at your     *
* option) any later version.                                                   *
*                                                                              *
* This library is distributed in the hope that it will be useful, but WITHOUT  *
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or        *
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License  *
* for more details.                                                            *
*                                                                              *
* You should have received a copy of the GNU Lesser General Public License     *
* along with this library; if not, write to the Free Software Foundation,      *
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA.           *
*                                                                              *
* Web site: https://iggservis.u-strasbg.fr/CGoGN/                              *
* Contact information: cgogn@unistra.fr                                        *
*                                                                              *
*******************************************************************************/

#include "viewer.h"
#include <string>
Thomas's avatar
Thomas committed
27
#include <sys/time.h>
Pierre Kraemer's avatar
Pierre Kraemer committed
28

Pierre Kraemer's avatar
Pierre Kraemer committed
29
30
31
32
33
34
35
36
SocialAgents::SocialAgents() :
	drawEnvLines(true),
	drawEnvFaces(false),
	drawEnvTopo(false),
	drawAgents(true),
	drawAgentsNeighborDist(false),
	drawAgentsObstacleDist(false),
	drawAgentsPredictionTri(false)
Pierre Kraemer's avatar
Pierre Kraemer committed
37
38
39
40
{
	render_anim = false;
	nbGenerated = 0;

Pierre Kraemer's avatar
Pierre Kraemer committed
41
	displayFps = true;
Pierre Kraemer's avatar
Pierre Kraemer committed
42
43
44
45
46
	nextUpdate = clock() + 1 * CLOCKS_PER_SEC;
	fps = 0;
	
	glEnable( GL_POINT_SMOOTH );

Pierre Kraemer's avatar
Pierre Kraemer committed
47
48
	timer = new QTimer(this);
	connect(timer, SIGNAL(timeout()), this, SLOT(animate()));
Thomas's avatar
Thomas committed
49
50

	elapsedTime = 0;
Pierre Kraemer's avatar
Pierre Kraemer committed
51
52
}

Pierre Kraemer's avatar
Pierre Kraemer committed
53
void SocialAgents::initGUI()
Pierre Kraemer's avatar
Pierre Kraemer committed
54
{
Pierre Kraemer's avatar
Pierre Kraemer committed
55
    setDock(&dock) ;
Pierre Kraemer's avatar
Pierre Kraemer committed
56
57
58
59
60
61
62
63
64
65
66
67
68

	dock.check_drawEnvLines->setChecked(true) ;
	dock.check_drawAgents->setChecked(true) ;

	setCallBack( dock.check_timer, SIGNAL(toggled(bool)), SLOT(slot_timer(bool)) ) ;
	setCallBack( dock.check_drawEnvLines, SIGNAL(toggled(bool)), SLOT(slot_drawEnvLines(bool)) ) ;
	setCallBack( dock.check_drawEnvFaces, SIGNAL(toggled(bool)), SLOT(slot_drawEnvFaces(bool)) ) ;
	setCallBack( dock.check_drawEnvTopo, SIGNAL(toggled(bool)), SLOT(slot_drawEnvTopo(bool)) ) ;
	setCallBack( dock.check_drawObstacles, SIGNAL(toggled(bool)), SLOT(slot_drawObstacles(bool)) ) ;
	setCallBack( dock.check_drawAgents, SIGNAL(toggled(bool)), SLOT(slot_drawAgents(bool)) ) ;
	setCallBack( dock.check_drawAgentsPredictionTri, SIGNAL(toggled(bool)), SLOT(slot_drawAgentsPredictionTri(bool)) ) ;
	setCallBack( dock.check_drawAgentsNeighborDist, SIGNAL(toggled(bool)), SLOT(slot_drawAgentsNeighborDist(bool)) ) ;
	setCallBack( dock.check_drawAgentsObstacleDist, SIGNAL(toggled(bool)), SLOT(slot_drawAgentsObstacleDist(bool)) ) ;
Pierre Kraemer's avatar
Pierre Kraemer committed
69
}
Pierre Kraemer's avatar
Pierre Kraemer committed
70

Pierre Kraemer's avatar
Pierre Kraemer committed
71
72
73
74
75
76
77
78
79
80
81
82
83
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());
}
Pierre Kraemer's avatar
Pierre Kraemer committed
84

Pierre Kraemer's avatar
Pierre Kraemer committed
85
86
void SocialAgents::cb_redraw()
{
Pierre Kraemer's avatar
Pierre Kraemer committed
87
	glDisable(GL_LIGHTING);
88

Pierre Kraemer's avatar
Pierre Kraemer committed
89
90
91
92
93
94
95
96
97
98
99
	glColor3f(0.5f,0.5f,0.5f);
	glBegin(GL_LINES);
		glVertex3f(0.,0.,0.);
		glVertex3f(1.,0.,0.);

		glVertex3f(0.,0.,0.);
		glVertex3f(0.,1.,0.);

		glVertex3f(0.,0.,0.);
		glVertex3f(0.,0.,1.);
	glEnd();
100

Pierre Kraemer's avatar
Pierre Kraemer committed
101
102
103
104
105
106
	if(drawAgents)
	{
		for(std::vector<Agent*>::iterator it = sim.agents_.begin(); it != sim.agents_.end(); ++ it)
		{
			glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
			renderAgent(sim.envMap_, *it, drawAgentsNeighborDist, drawAgentsObstacleDist);
107

Pierre Kraemer's avatar
Pierre Kraemer committed
108
109
110
111
112
113
114
115
116
117
//			for(std::vector<std::pair<float, Dart> >::iterator obst = (*it)->obstacleNeighbors_.begin();
//				obst != (*it)->obstacleNeighbors_.end() && obst->first < (*it)->rangeSq_;
//				++obst)
//			{
//				glColor3f(0.0f, 1.0f, 1.0f);
//				glLineWidth(10.0f);
//				renderDart(sim.envMap_, obst->second);
//			}
		}
	}
118

Pierre Kraemer's avatar
Pierre Kraemer committed
119
120
121
	if(drawAgentsPredictionTri)
	{
		for(std::vector<Agent*>::iterator it = sim.agents_.begin(); it != sim.agents_.end(); ++ it)
Pierre Kraemer's avatar
Pierre Kraemer committed
122
		{
Pierre Kraemer's avatar
Pierre Kraemer committed
123
124
125
			glColor3f((*it)->part_.state / 3.0f, (*it)->part_.state % 2, 0.0f);
			glLineWidth(5.0f);
			renderPredictionTriangle(sim.envMap_, (*it)->part_.d, (*it)->part_.m_position);
Pierre Kraemer's avatar
Pierre Kraemer committed
126
127
128
129
		}
	}

	//draw the environment
Pierre Kraemer's avatar
Pierre Kraemer committed
130
	if(drawEnvLines)
Pierre Kraemer's avatar
Pierre Kraemer committed
131
132
	{
		glDisable(GL_LIGHTING);
133
 		glColor3f(1.0f, 1.0f, 1.0f);
Pierre Kraemer's avatar
Pierre Kraemer committed
134
135
136
137
		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);
	}
Pierre Kraemer's avatar
Pierre Kraemer committed
138
139

	if(drawEnvFaces)
Pierre Kraemer's avatar
Pierre Kraemer committed
140
	{
Pierre Kraemer's avatar
Pierre Kraemer committed
141
		glEnable(GL_LIGHTING);
Pierre Kraemer's avatar
Pierre Kraemer committed
142
		glColor3f(1.0f, 1.0f, 1.0f);
Pierre Kraemer's avatar
Pierre Kraemer committed
143
144
145
		glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
		glEnable(GL_POLYGON_OFFSET_FILL) ;
		glPolygonOffset(1.0f, 1.0f) ;
Pierre Kraemer's avatar
Pierre Kraemer committed
146
147
		Algo::Render::GL1::renderTriQuadPoly<PFP>(sim.envMap_.map, Algo::Render::GL1::LINE, 1.0, sim.envMap_.position, sim.envMap_.normal);
	}
Pierre Kraemer's avatar
Pierre Kraemer committed
148
149

	if(drawEnvTopo)
Pierre Kraemer's avatar
Pierre Kraemer committed
150
151
152
153
154
155
	{
		glDisable(GL_LIGHTING);
		glLineWidth(1.0f);
		Algo::Render::GL1::renderTopoMD2<PFP>(sim.envMap_.map, sim.envMap_.position, true, true, 0.9f, 0.9f);
	}
	
Pierre Kraemer's avatar
Pierre Kraemer committed
156
	if(drawObstacles)
Pierre Kraemer's avatar
Pierre Kraemer committed
157
	{
Pierre Kraemer's avatar
Pierre Kraemer committed
158
159
		glColor3f(1.0f, 0.0f, 0.0f);
		glLineWidth(5.0f);
Pierre Kraemer's avatar
Pierre Kraemer committed
160
		CellMarker dmo(sim.envMap_.map, EDGE);
Pierre Kraemer's avatar
Pierre Kraemer committed
161
		for(Dart d = sim.envMap_.map.begin(); d != sim.envMap_.map.end(); sim.envMap_.map.next(d))
Pierre Kraemer's avatar
Pierre Kraemer committed
162
		{
Pierre Kraemer's avatar
Pierre Kraemer committed
163
164
165
166
167
168
			if(!dmo.isMarked(d))
			{
				dmo.mark(d);
				if(sim.envMap_.obstacleMark.isMarked(d))
					renderDart(sim.envMap_, d);
			}
Pierre Kraemer's avatar
Pierre Kraemer committed
169
170
		}
	}
Pierre Kraemer's avatar
Pierre Kraemer committed
171

Thomas's avatar
Thomas committed
172
173
//	renderDart(sim.envMap_,264);

Pierre Kraemer's avatar
Pierre Kraemer committed
174
175
//	glPushMatrix();
//	glBegin(GL_LINES);
176
//	unsigned int iter = 100;
Pierre Kraemer's avatar
Pierre Kraemer committed
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
//	for(int i=0;i<700;i=i+iter)
//	{
//		VEC3 camPos(-800,-800,10);
//		camPos = camPos + VEC3(-10-0.3*i,400.0f*log(1.0f+i/700.0f),30+0.3*i);
//		glVertex3fv(&camPos[0]);
//		camPos = VEC3(-800,-800,10);
//		camPos = camPos + VEC3(-10-0.3*(i+iter),400.0f*log(1.0f+(i+iter)/700.0f),30+0.3*(i+iter));
//		glVertex3fv(&camPos[0]);
//	}
//	glEnd();
//	glPopMatrix();
//
//	glPushMatrix();
//	glBegin(GL_LINES);
//	for(int i=0;i<700;i=i+iter)
//	{
//		VEC3 camLook(0,0,0);
//		camLook = camLook + VEC3(-10-0.1*i,400.0f*log(1.0f+i/700.0f),30+0.1*i);
//		glVertex3fv(&camLook[0]);
//		camLook = VEC3(0,0,0);
//		camLook = camLook + VEC3(-10-0.1*(i+iter),400.0f*log(1.0f+(i+iter)/700.0f),30+0.1*(i+iter));
//		glVertex3fv(&camLook[0]);
//	}
//	glEnd();
//	glPopMatrix();
Thomas's avatar
Thomas committed
202

203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
//	glPushMatrix();
//	glBegin(GL_LINES);
//	for(int i=0;i<700;i=i+iter)
//	{
//		VEC3 camPos(0,-200,10);
//		camPos = camPos + VEC3(-10-0.15*i,0,0);
//		glVertex3fv(&camPos[0]);
//		camPos = camPos + VEC3(-10-0.15*(i+iter),0,0);
//		glVertex3fv(&camPos[0]);
//	}
//	glEnd();
//	glPopMatrix();
//
//	glPushMatrix();
//	glBegin(GL_LINES);
//	for(int i=0;i<700;i=i+iter)
//	{
//		VEC3 camLook(0,-200,10);
//		camLook[1] += 100;
//		camLook = camLook + VEC3(-10-0.15*i,0,0);
//		glVertex3fv(&camLook[0]);
//		camLook = camLook + VEC3(-10-0.15*(i+iter),0,0);
//		glVertex3fv(&camLook[0]);
//	}
//	glEnd();
//	glPopMatrix();
Thomas's avatar
Thomas committed
229

Pierre Kraemer's avatar
Pierre Kraemer committed
230
231
//	glColor3f(0.0f, 1.0f, 0.0f);
//	glLineWidth(5.0f);
Pierre Kraemer's avatar
Pierre Kraemer committed
232
//	CellMarker dmb(sim.envMap_.map, FACE);
Pierre Kraemer's avatar
Pierre Kraemer committed
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
//	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();
//			}
//		}
//	}

Pierre Kraemer's avatar
Pierre Kraemer committed
262
263
264
265
266
267
268
269
270
271
272
273
274
275
	if(displayFps)
	{
		++frames;
		clock_t overtime = clock() - nextUpdate;
		if (overtime > 0)
		{
			fps = frames / (float)(1+ (float)overtime/(float)CLOCKS_PER_SEC);
			frames = 0;
			nextUpdate = clock() + 1 * CLOCKS_PER_SEC;
		}
		std::string s("fps: ");
		std::ostringstream oss;
		oss << s << fps;
		glColor3f(1.0f, 1.0f, 1.0f);
Pierre Kraemer's avatar
Pierre Kraemer committed
276
		statusMsg(oss.str().c_str());
Pierre Kraemer's avatar
Pierre Kraemer committed
277
278
279
	}
}

Pierre Kraemer's avatar
Pierre Kraemer committed
280
void SocialAgents::animate()
Pierre Kraemer's avatar
Pierre Kraemer committed
281
282
283
{
	if(sim.globalTime_ - int(sim.globalTime_) == 0.0f && int(sim.globalTime_) % 10 == 0)
		std::cout << sim.globalTime_ << " " << sim.envMap_.mapMemoryCost() << std::endl;
Thomas's avatar
Thomas committed
284
285
286
287
288
289
290
291

	std::cout << "t : " << sim.globalTime_ <<  std::endl;

	timeval startTime;
	gettimeofday(&startTime, NULL);
	timeval endTime;
	long seconds, nseconds;

Pierre Kraemer's avatar
Pierre Kraemer committed
292
293
	sim.doStep();

Thomas's avatar
Thomas committed
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
    gettimeofday(&endTime, NULL);
    seconds  = endTime.tv_sec  - startTime.tv_sec;
	nseconds = endTime.tv_usec - startTime.tv_usec;

	elapsedTime += (seconds + nseconds/1000000.0) ;

//	if(sim.globalTime_ - int(sim.globalTime_) == 0.0f && int(sim.globalTime_) % 1500 == 0)
//	{
//		std::cout << "end " << elapsedTime << std::endl;
//		timer->stop();
//	}

//	if(sim.reachedGoal())
//	{
//		std::cout << "end " << elapsedTime << std::endl;
//		timer->stop();
310
//	}
Thomas's avatar
Thomas committed
311

Pierre Kraemer's avatar
Pierre Kraemer committed
312
313
314
315
316
317
	if(render_anim)
	{
		std::ostringstream oss;
		std::ostringstream tmpNb;
		tmpNb << std::setfill('0') << std::setw(4) << nbGenerated;
		nbGenerated++;
Thomas's avatar
Thomas committed
318
		oss << "./pourPeter/lightMyFire" << tmpNb.str() << ".pov";
Pierre Kraemer's avatar
Pierre Kraemer committed
319
		std::string chaine = oss.str();
Thomas's avatar
Thomas committed
320
321
322
323
324
325
326
//		VEC3 agPos = sim.agents_[0]->meanPos_;
//		agPos[2] = agPos[1];
//		agPos[1] = 0.0f;
//		VEC3 camPos(agPos);
//		VEC3 camLook(agPos);
//		camPos = camPos+VEC3(-10-0.05*nbGenerated,30+0.05*nbGenerated,log(1.0f+nbGenerated/700.0f));

327
328
329
330
331
		//travelling city nbMaxAgent 15000, nbSquare 40 (45?)
//		VEC3 camPos(-800,10,-800);
//		camPos = camPos + VEC3(-10-0.3*nbGenerated,30+0.3*nbGenerated,400.0f*log(1.0f+nbGenerated/700.0f));
//		VEC3 camLook(0,0,0);
//		camLook = camLook + VEC3(-10-0.1*nbGenerated,30+0.1*nbGenerated,400.0f*log(1.0f+nbGenerated/700.0f));
Thomas's avatar
Thomas committed
332

333
		//travelling horizontal
Thomas's avatar
Thomas committed
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
//		VEC3 camPos(0,5,-200);
//		camPos = camPos + VEC3(-10-0.15*nbGenerated,0,0);
//		VEC3 camLook = camPos;
//		camLook[0] += 0.15*nbGenerated;
//		camLook[2] += 100;
//		camLook[1] = 0;

		//vertical view
//		VEC3 camPos(0,300,0);
//		Geom::BoundingBox<VEC3> bb = sim.getAgentsBB();
//		VEC3 seeEveryone = bb.max()-bb.min();
//		if(seeEveryone[0]>200)
//			camPos[1] += seeEveryone[0];
//		else
//			camPos[1] += 200;
//		VEC3 camLook(0);

		VEC3 camPos(-60,65,-200);
		VEC3 camLook(0);

		//mall
//		VEC3 camPos(-500,500,-400);
//		VEC3 camLook(100,100,0);
357
358

		exportScenePov(sim.envMap_.map,sim.envMap_.position,chaine,camPos,camLook,VEC3(0.0f,0,0),0,0,0);
Pierre Kraemer's avatar
Pierre Kraemer committed
359
360
361
// 		exportScenePov(sim.envMap_.map,sim.envMap_.position,chaine,VEC3(43,762,65),VEC3(0,762,0),VEC3(1.0f,0,0),0,0,0);
//		exportScenePov(sim.envMap_.map,sim.envMap_.position,chaine,VEC3(43,762,65+(1500.0f*float(nbGenerated)/400.0f)),VEC3(0,762,0),VEC3(1.0f,0,0),0,0,0);

Thomas's avatar
Thomas committed
362
		if(nbGenerated == 3000)
Pierre Kraemer's avatar
Pierre Kraemer committed
363
364
365
366
367
		{
			std::cout << "enough .pov generated" << std::endl;
			exit(0);
		}
	}
Pierre Kraemer's avatar
Pierre Kraemer committed
368
369

	updateGL();
Pierre Kraemer's avatar
Pierre Kraemer committed
370
}
371

Thomas's avatar
Thomas committed
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
inline Geom::Vec3f color_map_BCGYR (float x){
    Geom::Vec3f r (0.0f,0.0f,0.0f);
    if (x<0.0) {r[2]=1.0f;}
    else if (x<0.25) {r[0]=0.0f; r[1]=4*x; r[2]=1.0f;}
    else if (x<0.5) {r[0]=0.0f; r[1]=1.0f; r[2]=2.0f-4*x;}
    else if (x<0.75) {r[0]=4*x-2; r[1]=1.0f;r[2]=0.0f;}
    else if (x<1.0) {r[0]=1.0f; r[1]=4-4*x;r[2]=0.0f;}
    else {r[0]=1.0f;}
    return r;
}

void SocialAgents::exportInfoFace(std::ofstream& out, Dart d)
{
	//get corner
	Dart dd = d;
	VEC3 cornerLeftBottom = sim.envMap_.position[d];
	do
	{
		VEC3 p = sim.envMap_.position[dd];
		if(cornerLeftBottom[0]>p[0])
			cornerLeftBottom[0] = p[0];
		if(cornerLeftBottom[1]>p[1])
			cornerLeftBottom[1] = p[1];
		if(cornerLeftBottom[2]>p[2])
			cornerLeftBottom[2] = p[2];
		dd = sim.envMap_.map.phi1(dd);
	} while (dd!=d);


	//draw text
	if(!sim.envMap_.buildingMark.isMarked(d))
	{
		out << "object {" << std::endl;
		out << "polygon { 4 , <0,0,0>, <11,0,0>, <11,0,6>, <0,0,6> }" << std::endl;
		out << "texture { pigment{ color rgb<1,0,1> } finish { ambient 1 diffuse 0 } }" << std::endl;
		out << "translate < " << cornerLeftBottom[0]+5 << "," << cornerLeftBottom[2]+2 << "," << cornerLeftBottom[1]+7 << ">" << std::endl;
		out << "}" << std::endl;


		out << "object {" << std::endl;
		out << "polygon { 4 , <0,0,0>, <17,0,0>, <17,0,6>, <0,0,6> }" << std::endl;
		out << "texture { pigment{ color rgb<0.25,1,0> } finish { ambient 1 diffuse 0 } }" << std::endl;
		out << "translate < " << 12+cornerLeftBottom[0]+5 << "," << cornerLeftBottom[2]+2 << "," << cornerLeftBottom[1]+7 << ">" << std::endl;
		out << "}" << std::endl;

//		out << "text { ttf \"timrom.ttf\" \"Contains\" 1, 0 pigment { Black } rotate <90,0,0> scale <2,0,2> no_shadow" << std::endl;
//		out << "translate < " << cornerLeftBottom[0]+5 << "," << cornerLeftBottom[2]+2 << "," << cornerLeftBottom[1]+5 << ">" << std::endl;
//		out << "}" << std::endl;
//
//		out << "text { ttf \"timrom.ttf\" \"Neighbours\" 1, 0 pigment { Black } rotate <90,0,0> scale <2,0,2> no_shadow" << std::endl;
//		out << "translate < " << 12+cornerLeftBottom[0]+5 << "," << cornerLeftBottom[2]+2 << "," << cornerLeftBottom[1]+5 << ">" << std::endl;
//		out << "}" << std::endl;
	}

	//draw vectors
	//contains
	for(unsigned int i=0 ; i < sim.envMap_.agentvect[d].size() ; ++i)
	{
		Agent * ag = sim.envMap_.agentvect[d][i];

		int j = 0;
		for(unsigned int iA = 0; iA< sim.agents_.size() ; ++iA) {
			if(sim.agents_[iA]==ag)
			{
				j=iA;
				break;
			}
		}

//		if(j==0) {
//			out << "object {" << " Sheriff_animated_ " << std::endl;
//			out << "scale 0.165745856" << std::endl;
//		}
//		else if(j%7==0) {
//			out << "object {" << " Cowbow_animated_ " << std::endl;
//			out << "scale 0.170454545" << std::endl;
//		}
//		else if(j%7<5) {
//			out << "object {" << " sombrero2_highres_ " << std::endl;
//			out << "scale 0.127659574" << std::endl;
//		}
//		else {
//			out << "object {" << " sombrero3_highres_ " << std::endl;
//			out << "scale 0.132743363" << std::endl;
//		}

		out << "cylinder {" << " <0,0,0>, <0,6,0>, 1.5 " << std::endl;

		out << "scale 0.5" << std::endl;

		VEC3 col = color_map_BCGYR(float(j)/float(sim.agents_.size()));
		out << "pigment { color <" << col[0]  << "," << col[1] << "," << col[2]<< "> }" << std::endl;

//		float col = float(j)/float(sim.agents_.size());
//		col = col*16777215;
//		out << "pigment { color <" << (int(col/256/256)%256)/256.0f << "," << (int(col/256)%256)/256.0f << "," << (int(col)%256)/256.0f << "> }" << std::endl;

//		VEC3 pBase(ag->getPosition());
//					VEC3 posR(pBase);
//
//					Geom::Plane3D<float> pl = Algo::Geometry::facePlane<PFP>(sim.envMap_.map,ag->part_.d,sim.envMap_.position);
//					posR[2] -= 1000;
//					Geom::intersectionPlaneRay(pl,posR,VEC3(0,0,-1),posR);
//
		//			VEC3 dir = ag->velocity_;
//					VEC3 dir = ag->meanSpeed_;
//					dir.normalize();
//					VEC3 base(0,-1,0);
//					VEC3 axisRot = base^dir;
//					int sign = axisRot[2] > 0 ? 1 : -1;
//
					//57,2957795 : conversion from radian to degree
//					float myRot =  acos(-dir[1])*57.2957795f;
//
//
//					out << "rotate <0,0," << sign*myRot << ">"<< std::endl;
//					out << "rotate <" << -90 << "," << 0 << "," << 0 << "> " << std::endl;
					if(i<5)
						out << "translate < " << cornerLeftBottom[0]+5+1+i*2 << "," << cornerLeftBottom[2]+2 << "," << cornerLeftBottom[1]+7+1.5 << ">" << std::endl;
					else
						out << "translate < " << cornerLeftBottom[0]+5+1+(i-5)*2 << "," << cornerLeftBottom[2]+2 << "," << cornerLeftBottom[1]+7+1.5+3 << ">" << std::endl;


				out << "}" << std::endl;
	}

	//neighbours
	for(unsigned int i=0 ; i < sim.envMap_.neighborAgentvect[d].size() ; ++i)
	{
		Agent * ag = sim.envMap_.neighborAgentvect[d][i];

		int j = 0;
		for(unsigned int iA = 0; iA< sim.agents_.size() ; ++iA) {
			if(sim.agents_[iA]==ag)
			{
				j=iA;
				break;
			}
		}

//		if(j==0) {
//			out << "object {" << " Sheriff_animated_ " << std::endl;
//			out << "scale 0.165745856" << std::endl;
//		}
//		else if(j%7==0) {
//			out << "object {" << " Cowbow_animated_ " << std::endl;
//			out << "scale 0.170454545" << std::endl;
//		}
//		else if(j%7<5) {
//			out << "object {" << " sombrero2_highres_ " << std::endl;
//			out << "scale 0.127659574" << std::endl;
//		}
//		else {
//			out << "object {" << " sombrero3_highres_ " << std::endl;
//			out << "scale 0.132743363" << std::endl;
//
//		}

		out << "cylinder {" << " <0,0,0>, <0,6,0>, 1.5 " << std::endl;

		out << "scale 0.5" << std::endl;

		VEC3 col = color_map_BCGYR(float(j)/float(sim.agents_.size()));
		out << "pigment { color <" << col[0]  << "," << col[1] << "," << col[2]<< "> }" << std::endl;

//		float col = float(j)/float(sim.agents_.size());
//		col = col*16777215;
//		out << "pigment { color <" << (int(col/256/256)%256)/256.0f << "," << (int(col/256)%256)/256.0f << "," << (int(col)%256)/256.0f << "> }" << std::endl;

//		VEC3 pBase(ag->getPosition());
//					VEC3 posR(pBase);
//
//					Geom::Plane3D<float> pl = Algo::Geometry::facePlane<PFP>(sim.envMap_.map,ag->part_.d,sim.envMap_.position);
//					posR[2] -= 1000;
//					Geom::intersectionPlaneRay(pl,posR,VEC3(0,0,-1),posR);
//
//		//			VEC3 dir = ag->velocity_;
//					VEC3 dir = ag->meanSpeed_;
//					dir.normalize();
//					VEC3 base(0,-1,0);
//					VEC3 axisRot = base^dir;
//					int sign = axisRot[2] > 0 ? 1 : -1;
//
//					//57,2957795 : conversion from radian to degree
//					float myRot =  acos(-dir[1])*57.2957795f;
//
//
//					out << "rotate <0,0," << sign*myRot << ">"<< std::endl;
//					out << "rotate <" << -90 << "," << 0 << "," << 0 << "> " << std::endl;
					if(i<8)
						out << "translate < " << 12+cornerLeftBottom[0]+5+1+i*2 << "," << cornerLeftBottom[2]+2 << "," << cornerLeftBottom[1]+7+1.5 << ">" << std::endl;
					else
						out << "translate < " << 12+cornerLeftBottom[0]+5+1+(i-8)*2 << "," << cornerLeftBottom[2]+2 << "," << cornerLeftBottom[1]+7+1.5+3 << ">" << std::endl;

				out << "no_shadow }" << std::endl;
	}
}

Pierre Kraemer's avatar
Pierre Kraemer committed
570
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)
Pierre Kraemer's avatar
Pierre Kraemer committed
571
{
Thomas's avatar
Thomas committed
572
	static const bool draft=true;
Pierre Kraemer's avatar
Pierre Kraemer committed
573
	static const bool highlightAgent=false;
Thomas's avatar
Thomas committed
574
575
	static const bool wireDisplay=true;
	static const bool infoFaces=true;
Pierre Kraemer's avatar
Pierre Kraemer committed
576
	
577
	unsigned int highlightAgentNo=0;
Pierre Kraemer's avatar
Pierre Kraemer committed
578
579
580
581
582
583
584
585
586
587
588
  
	std::ofstream out(filename.c_str(), std::ios::out);
	if (!out.good()) {
		std::cerr << "(export) Unable to open file " << filename << std::endl;
		return false;
	}

	float angleX = angle_X;
	float angleY = angle_Y;
	float angleZ = angle_Z;
	
589
	//view the agent from an upper position
Pierre Kraemer's avatar
Pierre Kraemer committed
590
	if(highlightAgent) {
591
592
593
594
	  Agent * agent = sim.agents_[highlightAgentNo];
	  cameraLook = agent->getPosition();
	  VEC3 goalV = (agent->goals_[agent->curGoal_] - agent->getPosition());
	  goalV.normalize();
Pierre Kraemer's avatar
Pierre Kraemer committed
595
596
597
598
599
600
601
602
603
604
	  cameraPos = cameraLook - goalV*50.0f;
	  float tmp = cameraPos[1];
	  cameraPos[1] = cameraPos[2]+400.0f;
	  cameraPos[2] = tmp;
	  tmp = cameraLook[1];
	  cameraLook[2] = cameraLook[1];
	  cameraLook[1] = tmp;
	}

	//define the camera position
Thomas's avatar
Thomas committed
605
606
607
608
//	if(draft)
//		out << "#include \"sombrero2_lowres_POV_geom.inc\"" << std::endl;
	if(!draft)
	{
Thomas's avatar
Thomas committed
609
610
611
612
613
		out << "#include \"Sheriff_animated_POV_geom.inc\"" << std::endl;
		out << "#include \"Cowbow_animated_POV_geom.inc\"" << std::endl;
		out << "#include \"sombrero2_highres_POV_geom.inc\"" << std::endl;
		out << "#include \"sombrero3_highres_POV_geom.inc\"" << std::endl;
	}
614
615
616
617
618
619
620
621

	out << "#include \"transforms.inc\"" << std::endl;

	out << "camera { location <" << cameraPos[0] << "," << cameraPos[1] << "," << cameraPos[2] << "> look_at <" << cameraLook[0] << "," << cameraLook[1] << "," << cameraLook[2] <<"> ";
 	if(highlightAgent) {
 	  out << "translate <" << translate[0] << "," << translate[1] << "," << translate[2] << "> " << std::endl;
 	  out << "rotate <" << angleX << "," << angleY << "," << angleZ << "> }" << std::endl;
 	}
Pierre Kraemer's avatar
Pierre Kraemer committed
622
623
624
625
626
	out << "}" << std::endl;
	
	//set a sky sphere
	out << "sphere { <0, 0, 0>, 5000";
	out << "texture{ pigment { color rgb <1, 1, 1>}	finish { ambient 1 diffuse 0 } } }" << std::endl;
627

Pierre Kraemer's avatar
Pierre Kraemer committed
628
629
	//put some lights
// 	out << "light_source { <-800, 800, -800> color rgb 0.25 }"<< std::endl;
630

Pierre Kraemer's avatar
Pierre Kraemer committed
631
632
633
634
	//set a high quality rendering
	out << "global_settings {" << std::endl;
	out << "radiosity {" << std::endl;
	out << "pretrace_start 0.08 pretrace_end 0.04" << std::endl;
Thomas's avatar
Thomas committed
635
636
637
//	if(draft)
//		out << "count 10 nearest_count 10 error_bound 0.25 recursion_limit 1 low_error_factor 0.2 gray_threshold 0.0 minimum_reuse 0.015 brightness 1.4 adc_bailout 0.01/2 normal off media off} max_trace_level 5}" << std::endl;
//	else
638
639
		out << "count 300 nearest_count 10 error_bound 0.10 recursion_limit 1 low_error_factor 0.2 gray_threshold 0.0 minimum_reuse 0.015 brightness 1.4 adc_bailout 0.01/2 normal off media off} max_trace_level 60}" << std::endl;

Thomas's avatar
Thomas committed
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
//	if(draft)
//		for(unsigned int i = 0; i< sim.agents_.size() ; ++i) {
//			VEC3 pBase(sim.agents_[i]->getPosition());
//			VEC3 posR(pBase);
//
//			Geom::Plane3D<float> pl = Algo::Geometry::facePlane<PFP>(map,sim.agents_[i]->part_.d,position);
//			posR[2] -= 1000;
//			Geom::intersectionPlaneRay(pl,posR,VEC3(0,0,-1),posR);
//
//			VEC3 dir = sim.agents_[i]->velocity_;
//			dir.normalize();
//			dir *= 5.0f;
//			out << "cylinder {" << std::endl;
//			out << "<0,0,0>, <" << dir[0] << "," << dir[1] << "," << dir[2] << ">,0.05" << std::endl;
//			out << "translate <" << posR[0] << "," << posR[1] << "," << posR[2]+1+4*0.0638297872 << "> " << std::endl;
//			out << "rotate <" << angleX-90 << "," << 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;
//		}
Pierre Kraemer's avatar
Pierre Kraemer committed
660
661

	for(unsigned int i = 0; i< sim.agents_.size() ; ++i) {
662
663
			int typeOfAgent=0;
			if(draft) {
Thomas's avatar
Thomas committed
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
//				typeOfAgent=2;
//				out << "object {" << " sombrero2_lowres_ " << std::endl;
//				out << "scale 0.0638297872" << std::endl;
				out << "cylinder {" << " <0,0,0>, <0,6,0>, 1.5 " << std::endl;

				out << "scale 0.5" << std::endl;

				VEC3 col = color_map_BCGYR(float(i)/float(sim.agents_.size()));
				out << "pigment { color <" << col[0]  << "," << col[1] << "," << col[2]<< "> }" << std::endl;

//				unsigned int col = (unsigned int)(float(i)/float(sim.agents_.size())*0xfffffe);

//				std::cout << "i" << i << " truc " << xfloat(i)/float(sim.agents_.size()) << std::endl;

//				std::cout << "col " << (col/256/256)%256  << "," << (col/256)%256 << "," << col%256 << std::endl;

//				out << "pigment { color <" << (col > 16)/256.0f  << "," << ((col > 8) & 0xff)/256.0f << "," << (col & 0xff)/256.0f << "> }" << std::endl;
//				out << "pigment { color <" << (col/256/256)%256  << "," << (col/256)%256 << "," << col%256 << "> }" << std::endl;
Pierre Kraemer's avatar
Pierre Kraemer committed
682
683
			}
			else {
Thomas's avatar
Thomas committed
684
685
686
687
688
689
				if(i==0) {
					typeOfAgent=3;
					out << "object {" << " Sheriff_animated_ " << std::endl;
					out << "scale 0.165745856" << std::endl;
				}
				else if(i%7==0) {
690
					typeOfAgent=2;
Thomas's avatar
Thomas committed
691
692
					out << "object {" << " Cowbow_animated_ " << std::endl;
					out << "scale 0.170454545" << std::endl;
693
				}
Thomas's avatar
Thomas committed
694
				else if(i%7<5) {
695
696
					typeOfAgent=1;
					out << "object {" << " sombrero2_highres_ " << std::endl;
Thomas's avatar
Thomas committed
697
					out << "scale 0.127659574" << std::endl;
698
699
700
701
				}
				else {
					typeOfAgent=0;
					out << "object {" << " sombrero3_highres_ " << std::endl;
Thomas's avatar
Thomas committed
702
					out << "scale 0.132743363" << std::endl;
703
				}
Pierre Kraemer's avatar
Pierre Kraemer committed
704
			}
705
706
707
708

			VEC3 pBase(sim.agents_[i]->getPosition());
			VEC3 posR(pBase);

Thomas's avatar
Thomas committed
709
710
711
			Geom::Plane3D<float> pl = Algo::Geometry::facePlane<PFP>(map,sim.agents_[i]->part_.d,position);
			posR[2] -= 1000;
			Geom::intersectionPlaneRay(pl,posR,VEC3(0,0,-1),posR);
712

Thomas's avatar
Thomas committed
713
714
715
716
717
718
719
720
721
722
723
724
725
////			VEC3 dir = sim.agents_[i]->velocity_;
//			VEC3 dir = sim.agents_[i]->meanSpeed_;
//			dir.normalize();
//			VEC3 base(0,-1,0);
//			VEC3 axisRot = base^dir;
//			int sign = axisRot[2] > 0 ? 1 : -1;
//
//			//57,2957795 : conversion from radian to degree
//			float myRot =  acos(-dir[1])*57.2957795f;
//
//
//			out << "rotate <0,0," << sign*myRot << ">"<< std::endl;
//			out << "rotate <" << angleX-90 << "," << angleY << "," << angleZ << "> " << std::endl;
726
//			out << "translate <" << posR[0] << "," << posR[1] << "," << posR[2]+1+typeOfAgent*4*0.0638297872 << "> " << std::endl;
Thomas's avatar
Thomas committed
727
			out << "translate <" << posR[0] << "," << posR[2] << "," << posR[1] << "> " << std::endl;
728

729

Pierre Kraemer's avatar
Pierre Kraemer committed
730
731
732
733
 			out << "translate <" << translate[0] << "," << translate[1] << "," << translate[2] << ">" << std::endl;
		out << "}" << std::endl;
	}

Thomas's avatar
Thomas committed
734
735
736
	if(infoFaces)
	{
		CellMarker m(sim.envMap_.map,FACE);
Thomas's avatar
Thomas committed
737
//		m.unmarkAll();
Thomas's avatar
Thomas committed
738
739
740
741
742
743
744
745
746
747
748
749
		for(Dart d = sim.envMap_.map.begin() ; d != sim.envMap_.map.end() ; sim.envMap_.map.next(d))
		{
			if(!m.isMarked(d))
			{
				m.mark(d);
				exportInfoFace(out,d);
			}
		}
	}

//	if(!draft)
	{
750
751
752
753
754
755
756
757
		if(highlightAgent) {
		  //find the cells to highlight
		  DartMarkerStore highlight(map);
		  Agent * ag = sim.agents_[highlightAgentNo];
		  for(Dart d=map.begin();d!=map.end();map.next(d)) {
			if(!highlight.isMarked(d)) {
			  PFP::AGENTS listAgentInCell  = sim.envMap_.agentvect[d];
			  if(std::find(listAgentInCell.begin(), listAgentInCell.end(), ag)!=listAgentInCell.end()) {
Pierre Kraemer's avatar
Pierre Kraemer committed
758
				  highlight.markOrbit(FACE,d);
759
760
761
762
763
764
765
766
			  }
			}
		  }

		  SelectorMarked sm(highlight);
		  SelectorUnmarked sum(highlight);
		  Algo::ExportPov::exportMeshPlain<PFP>(out,map,position,"facesHighlighted",sm);
		  Algo::ExportPov::exportMeshPlain<PFP>(out,map,position,"myMesh",sum);
Pierre Kraemer's avatar
Pierre Kraemer committed
767

768
769
		  out << "object {facesHighlighted" << std::endl;
		  out << "rotate <" << angleX << "," << angleY << "," << angleZ << "> " << std::endl;
770
		  out << "translate <" << translate[0] << "," << translate[1] << "," << translate[2] << ">" << std::endl;
771
772
773
774
775
		  out << "texture{ pigment{ color rgb<0.4667,0.709,0.996>} finish { ambient rgb 0.35 brilliance 0.5 } } }" << std::endl;
		}
		else {
		  Algo::ExportPov::exportMeshPlain<PFP>(out,map,position,"myMesh",good);
		}
Pierre Kraemer's avatar
Pierre Kraemer committed
776

777
		if(wireDisplay) {
Thomas's avatar
Thomas committed
778
			Algo::ExportPov::exportMeshWire<PFP>(out,map,position,"myMeshWire",SelectorTrue());
779
780
			out << "object {myMeshWire" << std::endl;
			out << "rotate <" << angleX << "," << angleY << "," << angleZ << "> " << std::endl;
Thomas's avatar
Thomas committed
781
			out << "translate <" << translate[0] << "," << translate[1] << "," << translate[2] << ">" << std::endl;
782
783
784
785
			out << "texture{ pigment{ color rgb<0,0,0>} } }" << std::endl;
		}

		out << "object {myMesh" << std::endl;
Pierre Kraemer's avatar
Pierre Kraemer committed
786
		out << "rotate <" << angleX << "," << angleY << "," << angleZ << "> " << std::endl;
Thomas's avatar
Thomas committed
787
788
		out << "translate <" << translate[0] << "," << translate[1] << "," << translate[2] << ">" << std::endl;
		out << "texture{ pigment{ color rgb 0.7} finish { ambient rgb 0.3 brilliance 0.5 } } }" << std::endl;
Pierre Kraemer's avatar
Pierre Kraemer committed
789
	}
790

Pierre Kraemer's avatar
Pierre Kraemer committed
791
792
793
//  	out << "texture{ pigment{ color rgb<1.0,1.0,1>} finish { ambient rgb 0.05 brilliance 0.5 } } }" << std::endl;

	out.close();
794

Pierre Kraemer's avatar
Pierre Kraemer committed
795
796
	return true;
}
797

Pierre Kraemer's avatar
Pierre Kraemer committed
798
void SocialAgents::cb_keyPress(int keycode)
Pierre Kraemer's avatar
Pierre Kraemer committed
799
800
801
{
	switch (keycode)
	{
802
803
804
805
806
807
808
809
		case 'a': {
			if(timer->isActive())
				timer->stop();
			else
				timer->start();
			dock.check_timer->setChecked(timer->isActive());
			break;
		}
Pierre Kraemer's avatar
Pierre Kraemer committed
810
811
812
813
		case 'c': {
			sim.envMap_.map.check();
			break;
		}
Pierre Kraemer's avatar
Pierre Kraemer committed
814
		case 'e' : {
Thomas's avatar
Thomas committed
815
816
817
			std::cout << "exporting obstacle to file myScene.obst" << std::endl;
			std::string filename("myScene.obst");
			CGoGN::ExportScene::exportSceneToFile<PFP>(sim.envMap_.map,sim.envMap_.position,sim.envMap_.obstacleMark,filename);
Pierre Kraemer's avatar
Pierre Kraemer committed
818
819
			std::string filename2("myAgents.pos");
			sim.exportAgents(filename2);
Pierre Kraemer's avatar
Pierre Kraemer committed
820
			break;
Pierre Kraemer's avatar
Pierre Kraemer committed
821
822
		}
		case 'f': {
Pierre Kraemer's avatar
Pierre Kraemer committed
823
			displayFps = !displayFps;
Pierre Kraemer's avatar
Pierre Kraemer committed
824
825
			break;
		}
Thomas's avatar
Thomas committed
826
827
828
829
		case 'p': {
			std::cout << sim.globalTime_ << std::endl;
			break;
		}
Pierre Kraemer's avatar
Pierre Kraemer committed
830
		case 'r' : {
831
 			exportScenePov(sim.envMap_.map,sim.envMap_.position,"planSerre/exportSceneOle0000.pov",VEC3(10,3,10),VEC3(0,0,0),VEC3(1.0f,0,0),0,0,0);
Pierre Kraemer's avatar
Pierre Kraemer committed
832
833
834
835
836
837
838
839
//			exportScenePov(sim.envMap_.map,sim.envMap_.position,"exportScene0002.pov",VEC3(43,762,1565),VEC3(0,762,0),VEC3(1.0f,0,0),0,0,0);
// 			exportScenePov(sim.envMap_.map,sim.envMap_.position,"exportScene0002.pov",VEC3(43,762,65),VEC3(0,762,0),VEC3(1.0f,0,0),0,0,0);
			break;
		}
		case 's': {
			animate();
			break;
		}
840
841
842
843
844
845
846
847
848
849
850
		case '5': {
			FILE *fp;
			int state = GL2PS_OVERFLOW, buffsize = 0;

		    fp = fopen("out.svg", "wb");
		    printf("Writing 'out.eps'... ");
		    while(state == GL2PS_OVERFLOW){
		      buffsize += 1024*1024;
		      gl2psBeginPage("test", "gl2psTestSimple", NULL, GL2PS_SVG, GL2PS_SIMPLE_SORT,
		                     GL2PS_USE_CURRENT_VIEWPORT,
		                     GL_RGBA, 0, NULL, 0, 0, 0, buffsize, fp, "out.svg");
Pierre Kraemer's avatar
Pierre Kraemer committed
851
		      updateGL();
852
853
854
855
856
857
		      state = gl2psEndPage();
		    }
		    fclose(fp);
		    printf("Done!\n");
		    break;
		}
Pierre Kraemer's avatar
Pierre Kraemer committed
858
859
860
861
862
863
		case '9': {
			render_anim = !render_anim;
			break;
		}
	}

Pierre Kraemer's avatar
Pierre Kraemer committed
864
	updateGL() ;
Pierre Kraemer's avatar
Pierre Kraemer committed
865
866
867
868
869
870
871
872
}

/**********************************************************************************************
 *                                      MAIN FUNCTION                                         *
 **********************************************************************************************/

int main(int argc, char** argv)
{
Pierre Kraemer's avatar
Pierre Kraemer committed
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
	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() ;
Pierre Kraemer's avatar
Pierre Kraemer committed
891
}