explodeVolumeRender.h 5.2 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
29
30
31
32
33
* Contact information: cgogn@unistra.fr                                        *
*                                                                              *
*******************************************************************************/

#ifndef _EXPLODE_VOLUME_VBO_RENDER
#define _EXPLODE_VOLUME_VBO_RENDER

#include <vector>
#include <list>

#include "Topology/generic/dart.h"
#include "Topology/generic/attributeHandler.h"
#include "Topology/generic/functor.h"
Thery Sylvain's avatar
Thery Sylvain committed
34
#include "Utils/vbo_base.h"
35
#include "Utils/Shaders/shaderExplodeSmoothVolumes.h"
36
37
#include "Utils/Shaders/shaderExplodeVolumes.h"
#include "Utils/Shaders/shaderExplodeVolumesLines.h"
Pierre Kraemer's avatar
Pierre Kraemer committed
38
39
40
41
42
43
44
45
46
47

namespace CGoGN
{

namespace Algo
{

namespace Render
{

Sylvain Thery's avatar
Sylvain Thery committed
48
namespace GL2
Pierre Kraemer's avatar
Pierre Kraemer committed
49
50
51
{


52
class ExplodeVolumeRender
Pierre Kraemer's avatar
Pierre Kraemer committed
53
54
55
{
protected:

56
	Utils::ShaderExplodeVolumes* m_shader;
Pierre Kraemer's avatar
Pierre Kraemer committed
57

58
59
	Utils::ShaderExplodeSmoothVolumes* m_shaderS;

60
61
	bool m_cpf;

62
63
	bool m_ef;

Sylvain Thery's avatar
Sylvain Thery committed
64
65
	bool m_smooth;

66
67
68
69
	Utils::ShaderExplodeVolumesLines* m_shaderL;

	Utils::VBO* m_vboPos;

70
71
	Utils::VBO* m_vboColors;

Sylvain Thery's avatar
Sylvain Thery committed
72
73
	Utils::VBO* m_vboNormals;

74
	Utils::VBO* m_vboPosLine;
Pierre Kraemer's avatar
Pierre Kraemer committed
75
76
77
78
79
80

	/**
	*number of triangles to draw
	*/
	GLuint m_nbTris;

81
82
	GLuint m_nbLines;

83
84
	Geom::Vec3f m_globalColor;

Sylvain Thery's avatar
Sylvain Thery committed
85
86
87
88
89
90
91
	template<typename PFP>
	void updateSmooth(typename PFP::MAP& map, const VertexAttribute<typename PFP::VEC3>& positions, const VolumeAttribute<typename PFP::VEC3>& colorPerFace, const FunctorSelect& good = allDarts) ;

	template<typename PFP>
	void updateSmooth(typename PFP::MAP& map, const VertexAttribute<typename PFP::VEC3>& positions, const FunctorSelect& good = allDarts) ;


Pierre Kraemer's avatar
Pierre Kraemer committed
92
93
94
public:
	/**
	* Constructor
95
96
	* @param withColorPerFace affect a color per face
	* @param withExplodeFace shrinj each face
Pierre Kraemer's avatar
Pierre Kraemer committed
97
	*/
98
	ExplodeVolumeRender(bool withColorPerFace = false, bool withExplodeFace = false, bool withSmoothFaces = false) ;
Pierre Kraemer's avatar
Pierre Kraemer committed
99
100
101
102

	/**
	* Destructor
	*/
Sylvain Thery's avatar
Sylvain Thery committed
103
	~ExplodeVolumeRender() ;
104
105
106
107

	/**
	 * return a ptr on used shader do not forgot to register
	 */
Sylvain Thery's avatar
Sylvain Thery committed
108
	Utils::GLSLShader* shaderFaces() ;
109
110
111
112

	/**
	 * return a ptr on used shader do not forgot to register
	 */
Sylvain Thery's avatar
Sylvain Thery committed
113
	Utils::GLSLShader* shaderLines() ;
114

Pierre Kraemer's avatar
Pierre Kraemer committed
115
116
117
118
	/**
	* update all drawing buffers
	* @param map the map
	* @param positions  attribute of position vertices
119
	* @param good selector
Pierre Kraemer's avatar
Pierre Kraemer committed
120
	*/
Sylvain Thery's avatar
Sylvain Thery committed
121
122
	template<typename PFP>
	void updateData(typename PFP::MAP& map, const VertexAttribute<typename PFP::VEC3>& positions, const FunctorSelect& good = allDarts) ;
Pierre Kraemer's avatar
Pierre Kraemer committed
123

124
125
126
	/**
	* update all drawing buffers
	* @param map the map
127
	* @param positions attribute of position vertices
128
129
130
131
	* @param colorPerFace attribute of color (per face)
	* @param good selector
	*/
	template<typename PFP>
132
	void updateData(typename PFP::MAP& map, const VertexAttribute<typename PFP::VEC3>& positions, const VolumeAttribute<typename PFP::VEC3>& colorPerFace, const FunctorSelect& good = allDarts) ;
133
134


Pierre Kraemer's avatar
Pierre Kraemer committed
135
	/**
136
	 * draw edges
Pierre Kraemer's avatar
Pierre Kraemer committed
137
	 */
Sylvain Thery's avatar
Sylvain Thery committed
138
	void drawEdges() ;
139

140
141
142
	/**
	 * draw edges
	 */
Sylvain Thery's avatar
Sylvain Thery committed
143
	void drawFaces() ;
144

Sylvain Thery's avatar
Sylvain Thery committed
145
146
147
148
	/**
	 * set exploding volume coefficient parameter
	 */
	void setExplodeVolumes(float explode) ;
149

150
151
152
153
154
	/**
	 * set exploding volume coefficient parameter
	 */
	void setExplodeFaces(float explode) ;

Sylvain Thery's avatar
Sylvain Thery committed
155
156
157
158
	/**
	 * set clipping plane
	 */
	void setClippingPlane(const Geom::Vec4f& p) ;
159

Sylvain Thery's avatar
Sylvain Thery committed
160
161
162
163
	/**
	 * unset clipping plane
	 */
	void setNoClippingPlane() ;
164

Sylvain Thery's avatar
Sylvain Thery committed
165
166
167
168
	/**
	 * set ambiant color parameter
	 */
	void setAmbiant(const Geom::Vec4f& ambiant) ;
169

Sylvain Thery's avatar
Sylvain Thery committed
170
	/**
171
	 * set back color parameter
Sylvain Thery's avatar
Sylvain Thery committed
172
	 */
173
	void setBackColor(const Geom::Vec4f& color) ;
174

Sylvain Thery's avatar
Sylvain Thery committed
175
176
177
178
179
180
181
182
183
	/**
	 * set light position parameter
	 */
	void setLightPosition(const Geom::Vec3f& lp) ;

	/**
	 * set color parameter for edge drawing
	 */
	void setColorLine(const Geom::Vec4f& col) ;
Pierre Kraemer's avatar
Pierre Kraemer committed
184
185
};

Sylvain Thery's avatar
Sylvain Thery committed
186
}//end namespace GL2
Pierre Kraemer's avatar
Pierre Kraemer committed
187
188
189
190
191
192
193

}//end namespace Algo

}//end namespace Render

}//end namespace CGoGN

Sylvain Thery's avatar
Sylvain Thery committed
194
#include "Algo/Render/GL2/explodeVolumeRender.hpp"
Pierre Kraemer's avatar
Pierre Kraemer committed
195
196

#endif