explodeVolumeRender.hpp 17.1 KB
Newer Older
Pierre Kraemer's avatar
Pierre Kraemer committed
1
2
3
/*******************************************************************************
* CGoGN: Combinatorial and Geometric modeling with Generic N-dimensional Maps  *
* version 0.1                                                                  *
4
* Copyright (C) 2009-2012, IGG Team, LSIIT, University of Strasbourg           *
Pierre Kraemer's avatar
Pierre Kraemer committed
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
*                                                                              *
* 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.           *
*                                                                              *
20
* Web site: http://cgogn.unistra.fr/                                           *
Pierre Kraemer's avatar
Pierre Kraemer committed
21
22
23
24
25
26
27
28
* Contact information: cgogn@unistra.fr                                        *
*                                                                              *
*******************************************************************************/
#include <cmath>

#include "Geometry/vector_gen.h"
#include "Topology/generic/dartmarker.h"
#include "Topology/generic/cellmarker.h"
29
#include "Algo/Geometry/centroid.h"
30
#include "Topology/generic/autoAttributeHandler.h"
Pierre Kraemer's avatar
Pierre Kraemer committed
31

Sylvain Thery's avatar
Sylvain Thery committed
32
33
#include "Algo/Geometry/basic.h"

Pierre Kraemer's avatar
Pierre Kraemer committed
34
35
36
37
38
39
40
41
42
namespace CGoGN
{

namespace Algo
{

namespace Render
{

Sylvain Thery's avatar
Sylvain Thery committed
43
namespace GL2
Pierre Kraemer's avatar
Pierre Kraemer committed
44
45
{

46
47
48
inline ExplodeVolumeRender::ExplodeVolumeRender(bool withColorPerFace, bool withExplodeFace, bool withSmoothFaces):
		m_cpf(withColorPerFace),m_ef(withExplodeFace),m_smooth(withSmoothFaces),
		m_nbTris(0), m_nbLines(0),m_globalColor(0.7f,0.7f,0.7f)
Pierre Kraemer's avatar
Pierre Kraemer committed
49
{
50
51
52
	m_vboPos = new Utils::VBO();
	m_vboPos->setDataSize(3);

53
54
55
	m_vboColors = new Utils::VBO();
	m_vboColors->setDataSize(3);

56
57
58
	m_vboPosLine = new Utils::VBO();
	m_vboPosLine->setDataSize(3);

59
60
61
62
	if (m_smooth)
	{
		m_shaderS = new Utils::ShaderExplodeSmoothVolumes(withColorPerFace,withExplodeFace);
		m_shader = NULL;
Sylvain Thery's avatar
Sylvain Thery committed
63
64
		m_vboNormals = new Utils::VBO();
		m_vboNormals->setDataSize(3);
65
66
67
68
69
	}
	else
	{
		m_shader = new Utils::ShaderExplodeVolumes(withColorPerFace,withExplodeFace);
		m_shaderS = NULL;
Sylvain Thery's avatar
Sylvain Thery committed
70
		m_vboNormals = NULL;
71
	}
72

73
	m_shaderL = new Utils::ShaderExplodeVolumesLines();
untereiner's avatar
untereiner committed
74
	m_shaderL->setColor(Geom::Vec4f(1.0f,1.0f,1.0f,0.0f));
75
76

}
Pierre Kraemer's avatar
Pierre Kraemer committed
77

78
inline ExplodeVolumeRender::~ExplodeVolumeRender()
Pierre Kraemer's avatar
Pierre Kraemer committed
79
{
80
	delete m_vboPos;
81
	delete m_vboColors;
82
	delete m_vboPosLine;
Sylvain Thery's avatar
Sylvain Thery committed
83
84
85

	if (m_vboNormals != NULL)
		delete m_vboNormals;
86
87
88
89
	if (m_shader != NULL)
		delete m_shader;
	if (m_shaderS != NULL)
		delete m_shaderS;
90
	delete m_shaderL;
Pierre Kraemer's avatar
Pierre Kraemer committed
91
92
}

93
94


95
template<typename PFP>
96
void ExplodeVolumeRender::updateSmooth(typename PFP::MAP& map, const VertexAttribute<typename PFP::VEC3>& positions, const VolumeAttribute<typename PFP::VEC3>& colorPerXXX, const FunctorSelect& good)
97
98
99
100
{
	typedef typename PFP::VEC3 VEC3;
	typedef typename PFP::REAL REAL;

101
	VolumeAutoAttribute<VEC3> centerVolumes(map, "centerVolumes");
102
	Algo::Volume::Geometry::Parallel::computeCentroidVolumes<PFP>(map, positions, centerVolumes, good);
103
104
105
106

	std::vector<VEC3> buffer;
	buffer.reserve(16384);

107
108
109
110
111
112
113
	std::vector<VEC3> bufferColors;
	bufferColors.reserve(16384);
	std::vector<VEC3> bufferNormals;
	bufferNormals.reserve(16384);
	std::vector<VEC3> normals;
	bufferNormals.reserve(20);

Pierre Kraemer's avatar
Pierre Kraemer committed
114
	TraversorCell<typename PFP::MAP, PFP::MAP::FACE_OF_PARENT> traFace(map, good);
115

116

Sylvain Thery's avatar
Sylvain Thery committed
117
	for (Dart d = traFace.begin(); d != traFace.end(); d = traFace.next())
118
	{
119

Sylvain Thery's avatar
Sylvain Thery committed
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
		// compute normals
		normals.clear();
		VEC3 centerFace(0);
		unsigned int nbs=0;
		Dart a = d;
		do
		{
			VEC3 v1 = Algo::Surface::Geometry::vectorOutOfDart<PFP>(map,a,positions);
			Dart e = map.phi1(a);
			VEC3 v2 = Algo::Surface::Geometry::vectorOutOfDart<PFP>(map,e,positions);
			VEC3 N = v1^v2;
			N.normalize();
			normals.push_back(N);
			a = e;
			centerFace += positions[d];
			nbs++;
		} while (a != d);

		centerFace /= float(nbs);

		typename std::vector<VEC3>::iterator in = normals.begin();
		a = d;
		Dart b = map.phi1(a);
		Dart c = map.phi1(b);
		// loop to cut a polygon in triangle on the fly (works only with convex faces)
		do
146
		{
Sylvain Thery's avatar
Sylvain Thery committed
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
			buffer.push_back(centerVolumes[d]);
			bufferColors.push_back(centerFace);
			bufferNormals.push_back(centerFace); // unsused just for fill
			buffer.push_back(positions[d]);
			bufferColors.push_back(colorPerXXX[d]);
			bufferNormals.push_back(normals.back());
			buffer.push_back(positions[b]);
			bufferColors.push_back(colorPerXXX[b]);
			bufferNormals.push_back(*in++);
			buffer.push_back(positions[c]);
			bufferColors.push_back(colorPerXXX[c]);
			bufferNormals.push_back(*in);
			b = c;
			c = map.phi1(b);
		} while (c != d);
162
	}
Sylvain Thery's avatar
Sylvain Thery committed
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188


	m_nbTris = buffer.size()/4;

	m_vboPos->allocate(buffer.size());
	VEC3* ptrPos = reinterpret_cast<VEC3*>(m_vboPos->lockPtr());
	memcpy(ptrPos,&buffer[0],buffer.size()*sizeof(VEC3));
	m_vboPos->releasePtr();
	m_shaderS->setAttributePosition(m_vboPos);

	m_vboColors->allocate(bufferColors.size());
	VEC3* ptrCol = reinterpret_cast<VEC3*>(m_vboColors->lockPtr());
	memcpy(ptrCol,&bufferColors[0],bufferColors.size()*sizeof(VEC3));
	m_vboColors->releasePtr();
	m_shaderS->setAttributeColor(m_vboColors);

	m_vboNormals->allocate(bufferNormals.size());
	VEC3* ptrNorm = reinterpret_cast<VEC3*>(m_vboNormals->lockPtr());
	memcpy(ptrNorm,&bufferNormals[0],bufferNormals.size()*sizeof(VEC3));
	m_vboNormals->releasePtr();
	m_shaderS->setAttributeNormal(m_vboNormals);

	buffer.clear();

	TraversorCell<typename PFP::MAP, PFP::MAP::EDGE_OF_PARENT> traEdge(map, good);
	for (Dart d = traEdge.begin(); d != traEdge.end(); d = traEdge.next())
189
	{
Sylvain Thery's avatar
Sylvain Thery committed
190
191
192
193
194
195
196
197
198
199
200
201
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
229
230
231
232
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
			buffer.push_back(centerVolumes[d]);
			buffer.push_back(positions[d]);
			buffer.push_back(positions[map.phi1(d)]);
	}

	m_nbLines = buffer.size()/3;

	m_vboPosLine->allocate(buffer.size());

	ptrPos = reinterpret_cast<VEC3*>(m_vboPosLine->lockPtr());
	memcpy(ptrPos,&buffer[0],buffer.size()*sizeof(VEC3));

	m_vboPosLine->releasePtr();
	m_shaderL->setAttributePosition(m_vboPosLine);
}


template<typename PFP>
void ExplodeVolumeRender::updateSmooth(typename PFP::MAP& map, const VertexAttribute<typename PFP::VEC3>& positions, const FunctorSelect& good)
{
	typedef typename PFP::VEC3 VEC3;
	typedef typename PFP::REAL REAL;

	VolumeAutoAttribute<VEC3> centerVolumes(map, "centerVolumes");
	Algo::Volume::Geometry::Parallel::computeCentroidVolumes<PFP>(map, positions, centerVolumes, good);

	std::vector<VEC3> buffer;
	buffer.reserve(16384);

	std::vector<VEC3> bufferColors;
	bufferColors.reserve(16384);
	std::vector<VEC3> bufferNormals;
	bufferNormals.reserve(16384);
	std::vector<VEC3> normals;
	bufferNormals.reserve(20);

	TraversorCell<typename PFP::MAP, PFP::MAP::FACE_OF_PARENT> traFace(map, good);

	for (Dart d = traFace.begin(); d != traFace.end(); d = traFace.next())
	{

		// compute normals

		normals.clear();
		VEC3 centerFace(0);
		unsigned int nbs=0;
		Dart a = d;
		do
		{
			VEC3 v1 = Algo::Surface::Geometry::vectorOutOfDart<PFP>(map,a,positions);
			Dart e = map.phi1(a);
			VEC3 v2 = Algo::Surface::Geometry::vectorOutOfDart<PFP>(map,e,positions);
			VEC3 N = v1^v2;
			N.normalize();
			normals.push_back(N);
			a = e;
			centerFace += positions[d];
			nbs++;
		} while (a != d);

		centerFace /= float(nbs);

		typename std::vector<VEC3>::iterator in = normals.begin();
		a = d;
		Dart b = map.phi1(a);
		Dart c = map.phi1(b);
		// loop to cut a polygon in triangle on the fly (works only with convex faces)
		do
258
		{
Sylvain Thery's avatar
Sylvain Thery committed
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
			buffer.push_back(centerVolumes[d]);
			bufferColors.push_back(centerFace);
			bufferNormals.push_back(centerFace); // unsused just for fill
			buffer.push_back(positions[d]);
			bufferColors.push_back(m_globalColor);
			bufferNormals.push_back(normals.back());
			buffer.push_back(positions[b]);
			bufferColors.push_back(m_globalColor);
			bufferNormals.push_back(*in++);
			buffer.push_back(positions[c]);
			bufferColors.push_back(m_globalColor);
			bufferNormals.push_back(*in);
			b = c;
			c = map.phi1(b);
		} while (c != d);
274
275
	}

Sylvain Thery's avatar
Sylvain Thery committed
276

277
278
279
280
281
282
	m_nbTris = buffer.size()/4;

	m_vboPos->allocate(buffer.size());
	VEC3* ptrPos = reinterpret_cast<VEC3*>(m_vboPos->lockPtr());
	memcpy(ptrPos,&buffer[0],buffer.size()*sizeof(VEC3));
	m_vboPos->releasePtr();
Sylvain Thery's avatar
Sylvain Thery committed
283
	m_shaderS->setAttributePosition(m_vboPos);
284

285
286
287
288
	m_vboColors->allocate(bufferColors.size());
	VEC3* ptrCol = reinterpret_cast<VEC3*>(m_vboColors->lockPtr());
	memcpy(ptrCol,&bufferColors[0],bufferColors.size()*sizeof(VEC3));
	m_vboColors->releasePtr();
Sylvain Thery's avatar
Sylvain Thery committed
289
290
291
292
293
294
295
	m_shaderS->setAttributeColor(m_vboColors);

	m_vboNormals->allocate(bufferNormals.size());
	VEC3* ptrNorm = reinterpret_cast<VEC3*>(m_vboNormals->lockPtr());
	memcpy(ptrNorm,&bufferNormals[0],bufferNormals.size()*sizeof(VEC3));
	m_vboNormals->releasePtr();
	m_shaderS->setAttributeNormal(m_vboNormals);
296

297
298
	buffer.clear();

Pierre Kraemer's avatar
Pierre Kraemer committed
299
	TraversorCell<typename PFP::MAP, PFP::MAP::EDGE_OF_PARENT> traEdge(map, good);
300
	for (Dart d = traEdge.begin(); d != traEdge.end(); d = traEdge.next())
301
	{
302
303
304
			buffer.push_back(centerVolumes[d]);
			buffer.push_back(positions[d]);
			buffer.push_back(positions[map.phi1(d)]);
305
306
307
308
309
310
311
312
313
314
315
316
	}

	m_nbLines = buffer.size()/3;

	m_vboPosLine->allocate(buffer.size());

	ptrPos = reinterpret_cast<VEC3*>(m_vboPosLine->lockPtr());
	memcpy(ptrPos,&buffer[0],buffer.size()*sizeof(VEC3));

	m_vboPosLine->releasePtr();
	m_shaderL->setAttributePosition(m_vboPosLine);
}
317

318

Sylvain Thery's avatar
Sylvain Thery committed
319

320
template<typename PFP>
321
void ExplodeVolumeRender::updateData(typename PFP::MAP& map, const VertexAttribute<typename PFP::VEC3>& positions, const VolumeAttribute<typename PFP::VEC3>& colorPerXXX, const FunctorSelect& good)
322
{
Sylvain Thery's avatar
Sylvain Thery committed
323
324
325
326
327
	if (!m_cpf)
	{
		CGoGNerr<< "ExplodeVolumeRender: problem wrong update fonction use the other (without VolumeAttribute parameter)" << CGoGNendl;
		return;
	}
328
329

	if (m_smooth)
330
	{
331

Sylvain Thery's avatar
Sylvain Thery committed
332
333
		updateSmooth<PFP>(map,positions,colorPerXXX,good);
		return;
334
335
	}

336

337
338
339
	typedef typename PFP::VEC3 VEC3;
	typedef typename PFP::REAL REAL;

340
	VolumeAutoAttribute<VEC3> centerVolumes(map, "centerVolumes");
341
	Algo::Volume::Geometry::Parallel::computeCentroidVolumes<PFP>(map, positions, centerVolumes, good);
342
343
344
345

	std::vector<VEC3> buffer;
	buffer.reserve(16384);

346
347
	std::vector<VEC3> bufferColors;

348
	bufferColors.reserve(16384);
349

Pierre Kraemer's avatar
Pierre Kraemer committed
350
	TraversorCell<typename PFP::MAP, PFP::MAP::FACE_OF_PARENT> traFace(map, good);
Sylvain Thery's avatar
Sylvain Thery committed
351
352

	for (Dart d = traFace.begin(); d != traFace.end(); d = traFace.next())
353
	{
Sylvain Thery's avatar
Sylvain Thery committed
354
355
356
357
358
359
360
		VEC3 centerFace = Algo::Surface::Geometry::faceCentroid<PFP>(map, d, positions);

		Dart a = d;
		Dart b = map.phi1(a);
		Dart c = map.phi1(b);
		// loop to cut a polygon in triangle on the fly (works only with convex faces)
		do
361
		{
Sylvain Thery's avatar
Sylvain Thery committed
362
363
364
365
366
367
368
369
370
371
372
			buffer.push_back(centerVolumes[d]);
			bufferColors.push_back(centerFace);
			buffer.push_back(positions[d]);
			bufferColors.push_back(colorPerXXX[d]);
			buffer.push_back(positions[b]);
			bufferColors.push_back(colorPerXXX[b]);
			buffer.push_back(positions[c]);
			bufferColors.push_back(colorPerXXX[c]);
			b = c;
			c = map.phi1(b);
		} while (c != d);
373
	}
Sylvain Thery's avatar
Sylvain Thery committed
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

	m_nbTris = buffer.size()/4;

	m_vboPos->allocate(buffer.size());
	VEC3* ptrPos = reinterpret_cast<VEC3*>(m_vboPos->lockPtr());
	memcpy(ptrPos,&buffer[0],buffer.size()*sizeof(VEC3));
	m_vboPos->releasePtr();
	m_shader->setAttributePosition(m_vboPos);

	m_vboColors->allocate(bufferColors.size());
	VEC3* ptrCol = reinterpret_cast<VEC3*>(m_vboColors->lockPtr());
	memcpy(ptrCol,&bufferColors[0],bufferColors.size()*sizeof(VEC3));
	m_vboColors->releasePtr();
	m_shader->setAttributeColor(m_vboColors);

	buffer.clear();

	TraversorCell<typename PFP::MAP, PFP::MAP::EDGE_OF_PARENT> traEdge(map, good);
	for (Dart d = traEdge.begin(); d != traEdge.end(); d = traEdge.next())
	{
			buffer.push_back(centerVolumes[d]);
			buffer.push_back(positions[d]);
			buffer.push_back(positions[map.phi1(d)]);
	}

	m_nbLines = buffer.size()/3;

	m_vboPosLine->allocate(buffer.size());

	ptrPos = reinterpret_cast<VEC3*>(m_vboPosLine->lockPtr());
	memcpy(ptrPos,&buffer[0],buffer.size()*sizeof(VEC3));

	m_vboPosLine->releasePtr();
	m_shaderL->setAttributePosition(m_vboPosLine);
}

template<typename PFP>
void ExplodeVolumeRender::updateData(typename PFP::MAP& map, const VertexAttribute<typename PFP::VEC3>& positions, const FunctorSelect& good)
{
	if (m_cpf)
	{
		CGoGNerr<< "ExplodeVolumeRender: problem wrong update fonction use the other (without VolumeAttribute parameter)" << CGoGNendl;
		return;
	}

	if (m_smooth)
	{
		updateSmooth<PFP>(map,positions,good);
		return;
	}


	typedef typename PFP::VEC3 VEC3;
	typedef typename PFP::REAL REAL;

	VolumeAutoAttribute<VEC3> centerVolumes(map, "centerVolumes");
	Algo::Volume::Geometry::Parallel::computeCentroidVolumes<PFP>(map, positions, centerVolumes, good);

	std::vector<VEC3> buffer;
	buffer.reserve(16384);

	std::vector<VEC3> bufferColors;

	bufferColors.reserve(16384);

	TraversorCell<typename PFP::MAP, PFP::MAP::FACE_OF_PARENT> traFace(map, good);

	for (Dart d = traFace.begin(); d != traFace.end(); d = traFace.next())
442
	{
Sylvain Thery's avatar
Sylvain Thery committed
443
444
445
446
447
448
449
		VEC3 centerFace = Algo::Surface::Geometry::faceCentroid<PFP>(map, d, positions);

		Dart a = d;
		Dart b = map.phi1(a);
		Dart c = map.phi1(b);
		// loop to cut a polygon in triangle on the fly (works only with convex faces)
		do
450
		{
Sylvain Thery's avatar
Sylvain Thery committed
451
452
453
454
455
456
457
458
459
460
461
			buffer.push_back(centerVolumes[d]);
			bufferColors.push_back(centerFace);
			buffer.push_back(positions[d]);
			bufferColors.push_back(m_globalColor);
			buffer.push_back(positions[b]);
			bufferColors.push_back(m_globalColor);
			buffer.push_back(positions[c]);
			bufferColors.push_back(m_globalColor);
			b = c;
			c = map.phi1(b);
		} while (c != d);
462
463
464
465
466
467
468
469
470
471
	}

	m_nbTris = buffer.size()/4;

	m_vboPos->allocate(buffer.size());
	VEC3* ptrPos = reinterpret_cast<VEC3*>(m_vboPos->lockPtr());
	memcpy(ptrPos,&buffer[0],buffer.size()*sizeof(VEC3));
	m_vboPos->releasePtr();
	m_shader->setAttributePosition(m_vboPos);

472
473
474
475
476
	m_vboColors->allocate(bufferColors.size());
	VEC3* ptrCol = reinterpret_cast<VEC3*>(m_vboColors->lockPtr());
	memcpy(ptrCol,&bufferColors[0],bufferColors.size()*sizeof(VEC3));
	m_vboColors->releasePtr();
	m_shader->setAttributeColor(m_vboColors);
477

478
	buffer.clear();
Sylvain Thery's avatar
Sylvain Thery committed
479

Pierre Kraemer's avatar
Pierre Kraemer committed
480
	TraversorCell<typename PFP::MAP, PFP::MAP::EDGE_OF_PARENT> traEdge(map, good);
481
	for (Dart d = traEdge.begin(); d != traEdge.end(); d = traEdge.next())
Pierre Kraemer's avatar
Pierre Kraemer committed
482
	{
483
484
			buffer.push_back(centerVolumes[d]);
			buffer.push_back(positions[d]);
485
			buffer.push_back(positions[map.phi1(d)]);
Pierre Kraemer's avatar
Pierre Kraemer committed
486
487
	}

488
489
490
491
492
493
494
495
496
	m_nbLines = buffer.size()/3;

	m_vboPosLine->allocate(buffer.size());

	ptrPos = reinterpret_cast<VEC3*>(m_vboPosLine->lockPtr());
	memcpy(ptrPos,&buffer[0],buffer.size()*sizeof(VEC3));

	m_vboPosLine->releasePtr();
	m_shaderL->setAttributePosition(m_vboPosLine);
Pierre Kraemer's avatar
Pierre Kraemer committed
497
498
}

Sylvain Thery's avatar
Sylvain Thery committed
499
500


501
inline void ExplodeVolumeRender::drawFaces()
Pierre Kraemer's avatar
Pierre Kraemer committed
502
{
Sylvain Thery's avatar
Sylvain Thery committed
503
504
505
506
507
508
509
510
511
512
513
514
	if (m_smooth)
	{
		m_shaderS->enableVertexAttribs();
		glDrawArrays(GL_LINES_ADJACENCY_EXT , 0 , m_nbTris*4 );
		m_shaderS->disableVertexAttribs();
	}
	else
	{
		m_shader->enableVertexAttribs();
		glDrawArrays(GL_LINES_ADJACENCY_EXT , 0 , m_nbTris*4 );
		m_shader->disableVertexAttribs();
	}
515
}
Pierre Kraemer's avatar
Pierre Kraemer committed
516

517
518
inline void ExplodeVolumeRender::drawEdges()
{
Pierre Kraemer's avatar
Pierre Kraemer committed
519

520
521
522
	m_shaderL->enableVertexAttribs();
	glDrawArrays(GL_TRIANGLES , 0 , m_nbLines*3 );
	m_shaderL->disableVertexAttribs();
Pierre Kraemer's avatar
Pierre Kraemer committed
523
524
}

Sylvain Thery's avatar
Sylvain Thery committed
525
526
inline void ExplodeVolumeRender::setExplodeVolumes(float explode)
{
Sylvain Thery's avatar
Sylvain Thery committed
527
528
529
530
	if (m_smooth)
		m_shaderS->setExplodeVolumes(explode);
	else
		m_shader->setExplodeVolumes(explode);
Sylvain Thery's avatar
Sylvain Thery committed
531
532
533
	m_shaderL->setExplodeVolumes(explode);
}

534
535
inline void ExplodeVolumeRender::setExplodeFaces(float explode)
{
Sylvain Thery's avatar
Sylvain Thery committed
536
537
538
539
	if (m_smooth)
		m_shaderS->setExplodeFaces(explode);
	else
		m_shader->setExplodeFaces(explode);
540
541
}

Sylvain Thery's avatar
Sylvain Thery committed
542
543
inline void ExplodeVolumeRender::setClippingPlane(const Geom::Vec4f& p)
{
Sylvain Thery's avatar
Sylvain Thery committed
544
545
546
547
	if (m_smooth)
		m_shaderS->setClippingPlane(p);
	else
		m_shader->setClippingPlane(p);
Sylvain Thery's avatar
Sylvain Thery committed
548
549
550
551
552
553
	m_shaderL->setClippingPlane(p);
}

inline void ExplodeVolumeRender::setNoClippingPlane()
{
	Geom::Vec4f p(1.0f,1.0f,1.0f,-99999999.9f);
Sylvain Thery's avatar
Sylvain Thery committed
554
555
556
557
	if (m_smooth)
		m_shaderS->setClippingPlane(p);
	else
		m_shader->setClippingPlane(p);
Sylvain Thery's avatar
Sylvain Thery committed
558
559
560
561
562
	m_shaderL->setClippingPlane(p);
}

inline void ExplodeVolumeRender::setAmbiant(const Geom::Vec4f& ambiant)
{
Sylvain Thery's avatar
Sylvain Thery committed
563
564
565
566
	if (m_smooth)
		m_shaderS->setAmbiant(ambiant);
	else
		m_shader->setAmbiant(ambiant);
Sylvain Thery's avatar
Sylvain Thery committed
567
568
}

569
inline void ExplodeVolumeRender::setBackColor(const Geom::Vec4f& color)
Sylvain Thery's avatar
Sylvain Thery committed
570
{
Sylvain Thery's avatar
Sylvain Thery committed
571
572
573
574
	if (m_smooth)
		m_shaderS->setBackColor(color);
	else
		m_shader->setBackColor(color);
Sylvain Thery's avatar
Sylvain Thery committed
575
576
577
578
}

inline void ExplodeVolumeRender::setLightPosition(const Geom::Vec3f& lp)
{
Sylvain Thery's avatar
Sylvain Thery committed
579
580
581
582
	if (m_smooth)
		m_shaderS->setLightPosition(lp);
	else
		m_shader->setLightPosition(lp);
Sylvain Thery's avatar
Sylvain Thery committed
583
584
585
586
587
588
589
590
591
}

inline void ExplodeVolumeRender::setColorLine(const Geom::Vec4f& col)
{
	m_shaderL->setColor(col);
}

inline Utils::GLSLShader* ExplodeVolumeRender::shaderFaces()
{
Sylvain Thery's avatar
Sylvain Thery committed
592
593
	if (m_smooth)
		return m_shaderS;
Sylvain Thery's avatar
Sylvain Thery committed
594
595
596
597
598
599
600
	return m_shader;
}

inline Utils::GLSLShader* ExplodeVolumeRender::shaderLines()
{
	return m_shaderL;
}
601

Pierre Kraemer's avatar
Pierre Kraemer committed
602
603
604
605
606
607
608
}//end namespace VBO

}//end namespace Algo

}//end namespace Render

}//end namespace CGoGN