surface_radiance.h 3.5 KB
Newer Older
1
2
3
4
5
6
7
8
9
#ifndef _SURFACE_RADIANCE_PLUGIN_H_
#define _SURFACE_RADIANCE_PLUGIN_H_

#include "plugin_interaction.h"
#include "surface_radiance_dockTab.h"

#include "Utils/sphericalHarmonics.h"
#include "Utils/Shaders/shaderRadiancePerVertex.h"

10
#include "Algo/Decimation/decimation.h"
11
12
13
14
15
16
17
18
19
20
21
22
23

namespace CGoGN
{

namespace SCHNApps
{

struct MapParameters
{
	MapParameters() :
		positionVBO(NULL),
		normalVBO(NULL),
		radianceTexture(NULL),
24
25
26
27
28
		paramVBO(NULL),
		positionApproximator(NULL),
		normalApproximator(NULL),
		radianceApproximator(NULL),
		selector(NULL)
29
30
	{}

31
32
	unsigned int nbVertices;

33
34
35
36
37
	Utils::VBO* positionVBO;
	Utils::VBO* normalVBO;

	CGoGN::Utils::ShaderRadiancePerVertex* radiancePerVertexShader;

38
	VertexAttribute<Utils::SphericalHarmonics<PFP2::REAL, PFP2::VEC3>, PFP2::MAP> radiance;
39
40
41
	Utils::Texture<2, Geom::Vec3f>* radianceTexture;
	VertexAttribute<Geom::Vec2i, PFP2::MAP> param;
	Utils::VBO* paramVBO;
42
43
44

	DartAttribute<PFP2::REAL, PFP2::MAP> halfedgeError;

45
46
47
	Algo::Surface::Decimation::ApproximatorGen<PFP2>* positionApproximator;
	Algo::Surface::Decimation::ApproximatorGen<PFP2>* normalApproximator;
	Algo::Surface::Decimation::ApproximatorGen<PFP2>* radianceApproximator;
48
49

	Algo::Surface::Decimation::Selector<PFP2>* selector;
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
};

class Surface_Radiance_Plugin : public PluginInteraction
{
	Q_OBJECT
	Q_INTERFACES(CGoGN::SCHNApps::Plugin)

	friend class Surface_Radiance_DockTab;

public:
	Surface_Radiance_Plugin()
	{}

	~Surface_Radiance_Plugin()
	{}

	virtual bool enable();
	virtual void disable();

	virtual void draw(View *view) {}
	virtual void drawMap(View* view, MapHandlerGen* map);

	virtual void keyPress(View* view, QKeyEvent* event) {}
	virtual void keyRelease(View* view, QKeyEvent* event) {}
	virtual void mousePress(View* view, QMouseEvent* event) {}
	virtual void mouseRelease(View* view, QMouseEvent* event) {}
	virtual void mouseMove(View* view, QMouseEvent* event) {}
	virtual void wheelEvent(View* view, QWheelEvent* event) {}

	virtual void viewLinked(View *view) {}
	virtual void viewUnlinked(View *view) {}

private slots:
	// slots called from SCHNApps signals
	void selectedViewChanged(View* prev, View* cur);
	void selectedMapChanged(MapHandlerGen* prev, MapHandlerGen* cur);
	void mapAdded(MapHandlerGen* map);
	void mapRemoved(MapHandlerGen* map);

	// slots called from MapHandler signals
	void vboAdded(Utils::VBO* vbo);
	void vboRemoved(Utils::VBO* vbo);
	void attributeModified(unsigned int orbit, QString nameAttr);

	void importFromFileDialog();

public slots:
	// slots for Python calls
	void changePositionVBO(const QString& map, const QString& vbo);
	void changeNormalVBO(const QString& map, const QString& vbo);
	MapHandlerGen* importFromFile(const QString& fileName);
101
102
103
104
105
	void decimate(
		const QString& mapName,
		const QString& positionAttributeName,
		const QString& normalAttributeName,
		float decimationGoal,
106
107
108
109
110
111
112
113
		bool halfCollapse = false,
		bool exportMeshes = false
	);
	void exportPLY(
		const QString& mapName,
		const QString& positionAttributeName,
		const QString& normalAttributeName,
		const QString& filename
114
	);
115
116

protected:
117
118
119
	MapHandlerGen* currentlyDecimatedMap() { return m_currentlyDecimatedMap; }
	static void checkNbVerticesAndExport(Surface_Radiance_Plugin* p, const unsigned int* nbVertices);

120
121
122
	Surface_Radiance_DockTab* m_dockTab;
	QHash<MapHandlerGen*, MapParameters> h_mapParameterSet;

123
124
125
126
	MapHandlerGen* m_currentlyDecimatedMap;
	std::vector<unsigned int> exportNbVert;
	unsigned int nextExportIndex;

127
128
129
130
131
132
133
	QAction* m_importAction;
};

} // namespace SCHNApps

} // namespace CGoGN

134
#endif // _SURFACE_RADIANCE_PLUGIN_H_