explodeVolumeRender.h 4.65 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"
34 35 36
#include "Utils/vbo.h"
#include "Utils/Shaders/shaderExplodeVolumes.h"
#include "Utils/Shaders/shaderExplodeVolumesLines.h"
Pierre Kraemer's avatar
Pierre Kraemer committed
37 38 39 40 41 42 43 44 45 46

namespace CGoGN
{

namespace Algo
{

namespace Render
{

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


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

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

57 58
	bool m_cpf;

59 60
	bool m_ef;

61 62 63 64
	Utils::ShaderExplodeVolumesLines* m_shaderL;

	Utils::VBO* m_vboPos;

65 66
	Utils::VBO* m_vboColors;

67
	Utils::VBO* m_vboPosLine;
Pierre Kraemer's avatar
Pierre Kraemer committed
68 69 70 71 72 73

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

74 75
	GLuint m_nbLines;

76 77
	Geom::Vec3f m_globalColor;

Pierre Kraemer's avatar
Pierre Kraemer committed
78 79 80
public:
	/**
	* Constructor
81 82
	* @param withColorPerFace affect a color per face
	* @param withExplodeFace shrinj each face
Pierre Kraemer's avatar
Pierre Kraemer committed
83
	*/
84
	ExplodeVolumeRender(bool withColorPerFace = false, bool withExplodeFace = false) ;
Pierre Kraemer's avatar
Pierre Kraemer committed
85 86 87 88

	/**
	* Destructor
	*/
Sylvain Thery's avatar
Sylvain Thery committed
89
	~ExplodeVolumeRender() ;
90 91 92 93

	/**
	 * return a ptr on used shader do not forgot to register
	 */
Sylvain Thery's avatar
Sylvain Thery committed
94
	Utils::GLSLShader* shaderFaces() ;
95 96 97 98

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

Pierre Kraemer's avatar
Pierre Kraemer committed
101 102 103 104
	/**
	* update all drawing buffers
	* @param map the map
	* @param positions  attribute of position vertices
105
	* @param good selector
Pierre Kraemer's avatar
Pierre Kraemer committed
106
	*/
107
	template<typename PFP>
108
	void updateData(typename PFP::MAP& map, const VertexAttribute<typename PFP::VEC3>& positions, const FunctorSelect& good = allDarts) ;
Pierre Kraemer's avatar
Pierre Kraemer committed
109

110 111 112
	/**
	* update all drawing buffers
	* @param map the map
113
	* @param positions attribute of position vertices
114 115 116 117
	* @param colorPerFace attribute of color (per face)
	* @param good selector
	*/
	template<typename PFP>
118
	void updateData(typename PFP::MAP& map, const VertexAttribute<typename PFP::VEC3>& positions, const VolumeAttribute<typename PFP::VEC3>& colorPerFace, const FunctorSelect& good = allDarts) ;
119

Pierre Kraemer's avatar
Pierre Kraemer committed
120
	/**
121
	 * draw edges
Pierre Kraemer's avatar
Pierre Kraemer committed
122
	 */
Sylvain Thery's avatar
Sylvain Thery committed
123
	void drawEdges() ;
124

125 126 127
	/**
	 * draw edges
	 */
Sylvain Thery's avatar
Sylvain Thery committed
128
	void drawFaces() ;
129

Sylvain Thery's avatar
Sylvain Thery committed
130 131 132 133
	/**
	 * set exploding volume coefficient parameter
	 */
	void setExplodeVolumes(float explode) ;
134

135 136 137 138 139
	/**
	 * set exploding volume coefficient parameter
	 */
	void setExplodeFaces(float explode) ;

Sylvain Thery's avatar
Sylvain Thery committed
140 141 142 143
	/**
	 * set clipping plane
	 */
	void setClippingPlane(const Geom::Vec4f& p) ;
144

Sylvain Thery's avatar
Sylvain Thery committed
145 146 147 148
	/**
	 * unset clipping plane
	 */
	void setNoClippingPlane() ;
149

Sylvain Thery's avatar
Sylvain Thery committed
150 151 152 153
	/**
	 * set ambiant color parameter
	 */
	void setAmbiant(const Geom::Vec4f& ambiant) ;
154

Sylvain Thery's avatar
Sylvain Thery committed
155
	/**
156
	 * set back color parameter
Sylvain Thery's avatar
Sylvain Thery committed
157
	 */
158
	void setBackColor(const Geom::Vec4f& color) ;
159

Sylvain Thery's avatar
Sylvain Thery committed
160 161 162 163 164 165 166 167 168
	/**
	 * 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
169 170
};

Sylvain Thery's avatar
Sylvain Thery committed
171
}//end namespace GL2
Pierre Kraemer's avatar
Pierre Kraemer committed
172 173 174 175 176 177 178

}//end namespace Algo

}//end namespace Render

}//end namespace CGoGN

Sylvain Thery's avatar
Sylvain Thery committed
179
#include "Algo/Render/GL2/explodeVolumeRender.hpp"
Pierre Kraemer's avatar
Pierre Kraemer committed
180 181

#endif