1 /****************************************************************************
2 * MeshLab o o *
3 * A versatile mesh processing toolbox o o *
4 * _ O _ *
5 * Copyright(C) 2005 \/)\/ *
6 * Visual Computing Lab /\/| *
7 * ISTI - Italian National Research Council | *
8 * \ *
9 * All rights reserved. *
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 * This program is distributed in the hope that it will be useful, *
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
19 * GNU General Public License (http://www.gnu.org/licenses/gpl.txt) *
20 * for more details. *
21 * *
22 ****************************************************************************/
23
24 #include <math.h>
25 #include <stdlib.h>
26 #include <iostream>
27 #include "splatrenderer_plugin.h"
28
29 #include <QGLWidget>
30 #include <QTextStream>
31
32 #include <QGLFramebufferObject>
33
34
SplatRendererPlugin()35 SplatRendererPlugin::SplatRendererPlugin()
36 {
37 splat_renderer.Clear();
38
39 }
40
initActionList()41 void SplatRendererPlugin::initActionList()
42 {
43 actionList << new QAction("Splatting", this);
44 }
45
46
Init(QAction * a,MeshDocument & md,QMap<int,RenderMode> &,QGLWidget * gla)47 void SplatRendererPlugin::Init(QAction * a, MeshDocument & md, QMap<int,RenderMode>&, QGLWidget *gla)
48 {
49 if (!(md.mm()->hasDataMask(MeshModel::MM_VERTRADIUS)))
50 {
51 QMessageBox::warning(0, tr("Splat Render Failure"), QString("Warning the current mesh <font color=red>'" + md.mm()->fullName() + "'</font> cannot not be rendered.<br><i>Radius per vertex attribute</i> must be present."));
52 return;
53 }
54 splat_renderer.Init(gla);
55 }
56
Render(QAction *,MeshDocument & md,QMap<int,RenderMode> & rm,QGLWidget *)57 void SplatRendererPlugin::Render(QAction *, MeshDocument &md, QMap<int,RenderMode>& rm, QGLWidget * /* gla */)
58 {
59 GL_TEST_ERR
60
61 std::vector<CMeshO*> meshes_to_render;
62 foreach(MeshModel * mp, md.meshList)
63 {
64 meshes_to_render.push_back( &(*mp).cm );
65 }
66 //It's not possible to pass the per mesh rendering mode cause the splatting rendering function is inside the vcglib not inside MeshLab
67 RenderMode rmode;
68 if (rm.size() > 0)
69 rmode = rm.begin().value();
70 splat_renderer.Render(meshes_to_render,rmode.colorMode,rmode.textureMode);
71
72
73 }
74
Finalize(QAction *,MeshDocument *,GLArea *)75 void SplatRendererPlugin::Finalize(QAction * /*mode*/, MeshDocument */* &*//*m*/, GLArea * /*parent*/) {
76 splat_renderer.Destroy();
77 }
78
79 #if 0
80 void SplatRendererPlugin::Draw(QAction *a, MeshModel &m, RenderMode &rm, QGLWidget * gla)
81 {
82 if (m.cm.vert.RadiusEnabled)
83 {
84 if (mCurrentPass==2)
85 return;
86
87 enablePass(mCurrentPass);
88 /*if (mCurrentPass==1)*/ drawSplats(m, rm);
89 }
90 else if (mCurrentPass==2)
91 {
92 MeshRenderInterface::Draw(a, m, rm, gla);
93 }
94 }
95 #endif
96
97
98 MESHLAB_PLUGIN_NAME_EXPORTER(SplatRendererPlugin)
99