Commit cf57535b authored by Maire Nicolas's avatar Maire Nicolas

Suppression des deux autres applis stage_shader, elles sont devenues obsolètes.

parent d6ae7f40
......@@ -65,25 +65,12 @@ add_executable( tuto5 tuto5.cpp ${tuto5_ui} ${tuto5_moc})
target_link_libraries( tuto5
${CGoGN_LIBS_D} ${COMMON_LIBS} ${QT_LIBRARIES} )
QT4_WRAP_UI( stage_shader_ui stage_shader.ui )
QT4_WRAP_CPP(stage_shader_moc stage_shader.h)
add_executable( stage_shader stage_shader.cpp ${stage_shader_ui} ${stage_shader_moc})
target_link_libraries( stage_shader
${CGoGN_LIBS_D} ${COMMON_LIBS} ${QT_LIBRARIES} )
QT4_WRAP_UI( stage_shader_reloaded_ui stage_shader_reloaded.ui )
QT4_WRAP_CPP(stage_shader_reloaded_moc stage_shader_reloaded.h)
add_executable( stage_shader_reloaded stage_shader_reloaded.cpp ${stage_shader_reloaded_ui} ${stage_shader_reloaded_moc})
target_link_libraries( stage_shader_reloaded
${CGoGN_LIBS_D} ${COMMON_LIBS} ${QT_LIBRARIES} )
QT4_WRAP_UI( stage_shader_number_two_ui stage_shader_number_two.ui )
QT4_WRAP_CPP( stage_shader_number_two_moc stage_shader_number_two.h )
add_executable( stage_shader_number_two stage_shader_number_two.cpp ${stage_shader_number_two_moc} ${stage_shader_number_two_ui})
target_link_libraries( stage_shader_number_two
${CGoGN_LIBS_D} ${NUMERICAL_LIBS} ${COMMON_LIBS} ${QT_LIBRARIES} )
#add_executable( tuto_subdivision tuto_subdivision.cpp)
#target_link_libraries( tuto_subdivision
......
This diff is collapsed.
/*******************************************************************************
* CGoGN: Combinatorial and Geometric modeling with Generic N-dimensional Maps *
* version 0.1 *
* Copyright (C) 2009-2011, IGG Team, LSIIT, University of Strasbourg *
* *
* 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. *
* *
* Web site: http://cgogn.u-strasbg.fr/ *
* Contact information: cgogn@unistra.fr *
* *
*******************************************************************************/
#ifndef __STAGE_SHADER_H__
#define __STAGE_SHADER_H__
#include <iostream>
#include "Utils/qtSimple.h"
#include "ui_stage_shader.h"
// inclure qtui.h juste après le ui_xxx.h
#include "Utils/qtui.h"
#include "Topology/generic/parameters.h"
#include "Topology/map/map3.h"
#include "Topology/generic/embeddedMap3.h"
#include "Geometry/vector_gen.h"
#include "Geometry/matrix.h"
#include "Geometry/bounding_box.h"
#include "Algo/Import/import.h"
//#include "Algo/Export/export.h"
#include "Algo/Geometry/boundingbox.h"
#include "Algo/Render/GL2/mapRender.h"
#include "Algo/Render/GL2/topo3Render.h"
#include "Utils/Shaders/shaderSimpleColor.h"
#include "Utils/cgognStream.h"
#include "Utils/drawer.h"
#include <string>
#include <sstream>
using namespace CGoGN ;
struct PFP: public PFP_STANDARD
{
// definition of the map
typedef EmbeddedMap3<Map3> MAP;
};
class StageShader: public Utils::QT::SimpleQT
{
Q_OBJECT
public:
typedef PFP::MAP MAP;
typedef PFP::TVEC3 TVEC3;
//Manip Carte
MAP myMap ;
SelectorTrue allDarts ;
TVEC3 position;
Dart dglobal;
//Render
bool m_drawVertices;
bool m_drawLines;
bool m_drawFaces;
bool m_drawTopo;
Algo::Render::GL2::MapRender* m_render;
Algo::Render::GL2::Topo3RenderMapD* m_render_topo;
Geom::BoundingBox<PFP::VEC3> m_bb;
Utils::VBO* m_positionVBO;
Utils::ShaderSimpleColor* m_shader;
Utils::Drawer* influence_area;
Utils::Drawer* chips_area;
Geom::Vec3f m_coeffTopoExplod;
Geom::Vec3f gPosObj ;
float gWidthObj ;
//QT
Utils::QT::uiDockInterface dock;
StageShader();
void initGUI();
void cb_Open();
void updateVBOprimitives(int upType);
void cb_initGL();
void cb_redraw();
void cb_mousePress(int button, int x, int y);
void cb_keyPress(int code);
void importMesh(std::string& filename);
public slots:
void slot_drawVertices(bool b);
void slot_drawLines(bool b);
void slot_drawFaces(bool b);
void slot_drawTopo(bool b);
void slot_explodTopoPhi1(double c);
void slot_explodTopoPhi2(double c);
void slot_explodTopoPhi3(double c);
void slot_pushButton_addPlane();
void slot_pushButton_deletePlane();
void slot_comboBox_PlaneIndexChanged(int newIndex);
void slot_doubleSpinBox_PlaneVec1(double c);
void slot_doubleSpinBox_PlaneVec2(double c);
void slot_doubleSpinBox_PlaneOrigin(double c);
void slot_doubleSpinBox_GridDisplaySize(double c);
void slot_spinBox_GridResolutionX(int i);
void slot_spinBox_GridResolutionY(int i);
void slot_doubleSpinBox_GridColor(double c);
void slot_pushButton_addSphere();
void slot_pushButton_deleteSphere();
void slot_comboBox_SphereIndexChanged(int newIndex);
void slot_doubleSpinBox_SphereCenter(double c);
void slot_doubleSpinBox_SphereRadius(double c);
void slot_spinBox_SphereGridResolutionX(int i);
void slot_spinBox_SphereGridResolutionY(int i);
void slot_doubleSpinBox_SphereGridColor(double c);
void slot_doubleSpinBox_ColorAttenuationFactor(double c);
void slot_horizontalSlider_ClippingMode(int i);
void button_compile();
};
#endif
This diff is collapsed.
/*******************************************************************************
* CGoGN: Combinatorial and Geometric modeling with Generic N-dimensional Maps *
* version 0.1 *
* Copyright (C) 2009, IGG Team, LSIIT, University of Strasbourg *
* *
* 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. *
* *
* Web site: https://iggservis.u-strasbg.fr/CGoGN/ *
* Contact information: cgogn@unistra.fr *
* *
*******************************************************************************/
#include "stage_shader_number_two.h"
Stage_shader_number_two::Stage_shader_number_two() :
m_renderStyle(FLAT),
m_drawVertices(false),
m_drawEdges(false),
m_drawFaces(true),
m_drawNormals(false),
m_render(NULL),
m_phongShader(NULL),
m_flatShader(NULL),
m_vectorShader(NULL),
m_simpleColorShader(NULL),
m_pointSprite(NULL)
{
normalScaleFactor = 1.0f ;
vertexScaleFactor = 1.0f ;
faceShrinkage = 1.0f ;
colClear = Geom::Vec4f(0.2f, 0.2f, 0.2f, 0.1f) ;
colDif = Geom::Vec4f(0.8f, 0.9f, 0.7f, 1.0f) ;
colSpec = Geom::Vec4f(0.9f, 0.9f, 0.9f, 1.0f) ;
colNormal = Geom::Vec4f(1.0f, 0.0f, 0.0f, 1.0f) ;
shininess = 80.0f ;
}
void Stage_shader_number_two::initGUI()
{
setDock(&dock) ;
dock.check_drawVertices->setChecked(false) ;
dock.check_drawEdges->setChecked(false) ;
dock.check_drawFaces->setChecked(true) ;
dock.check_drawNormals->setChecked(false) ;
dock.slider_verticesSize->setVisible(false) ;
dock.slider_normalsSize->setVisible(false) ;
dock.slider_verticesSize->setSliderPosition(50) ;
dock.slider_normalsSize->setSliderPosition(50) ;
setCallBack( dock.check_drawVertices, SIGNAL(toggled(bool)), SLOT(slot_drawVertices(bool)) ) ;
setCallBack( dock.slider_verticesSize, SIGNAL(valueChanged(int)), SLOT(slot_verticesSize(int)) ) ;
setCallBack( dock.check_drawEdges, SIGNAL(toggled(bool)), SLOT(slot_drawEdges(bool)) ) ;
setCallBack( dock.check_drawFaces, SIGNAL(toggled(bool)), SLOT(slot_drawFaces(bool)) ) ;
setCallBack( dock.combo_faceLighting, SIGNAL(currentIndexChanged(int)), SLOT(slot_faceLighting(int)) ) ;
setCallBack( dock.check_drawNormals, SIGNAL(toggled(bool)), SLOT(slot_drawNormals(bool)) ) ;
setCallBack( dock.slider_normalsSize, SIGNAL(valueChanged(int)), SLOT(slot_normalsSize(int)) ) ;
setCallBack(dock.doubleSpinBox_color_attenuation, SIGNAL(valueChanged(double)), SLOT(slot_doubleSpinBox_ColorAttenuationFactor(double)));
dock.doubleSpinBox_color_attenuation->setValue(m_phongShader->getClipColorAttenuationFactor());
}
void Stage_shader_number_two::cb_initGL()
{
Utils::GLSLShader::setCurrentOGLVersion(2) ;
setFocal(5.0f) ;
m_render = new Algo::Render::GL2::MapRender() ;
m_positionVBO = new Utils::VBO() ;
m_normalVBO = new Utils::VBO() ;
m_phongShader = new Utils::ShaderPhong(true) ; // true sets on double sided lighting
m_phongShader->setAttributePosition(m_positionVBO) ;
m_phongShader->setAttributeNormal(m_normalVBO) ;
m_phongShader->setAmbiant(colClear) ;
m_phongShader->setDiffuse(colDif) ;
m_phongShader->setSpecular(colSpec) ;
m_phongShader->setShininess(shininess) ;
m_flatShader = new Utils::ShaderFlat() ;
m_flatShader->setAttributePosition(m_positionVBO) ;
m_flatShader->setAmbiant(colClear) ;
m_flatShader->setDiffuse(colDif) ;
m_flatShader->setExplode(faceShrinkage) ;
m_vectorShader = new Utils::ShaderVectorPerVertex() ;
m_vectorShader->setAttributePosition(m_positionVBO) ;
m_vectorShader->setAttributeVector(m_normalVBO) ;
m_vectorShader->setColor(colNormal) ;
m_simpleColorShader = new Utils::ShaderSimpleColor() ;
m_simpleColorShader->setAttributePosition(m_positionVBO) ;
Geom::Vec4f c(0.1f, 0.1f, 0.1f, 1.0f) ;
m_simpleColorShader->setColor(c) ;
m_pointSprite = new Utils::PointSprite() ;
m_pointSprite->setAttributePosition(m_positionVBO) ;
registerShader(m_phongShader) ;
registerShader(m_flatShader) ;
registerShader(m_vectorShader) ;
registerShader(m_simpleColorShader) ;
registerShader(m_pointSprite) ;
m_phongShader->insertClippingCode();
m_phongShader->setClipPlanesCount(1);
}
void Stage_shader_number_two::cb_redraw()
{
if(m_drawVertices)
{
float size = vertexBaseSize * vertexScaleFactor ;
m_pointSprite->setSize(size) ;
m_pointSprite->predraw(Geom::Vec3f(0.0f, 0.0f, 1.0f)) ;
m_render->draw(m_pointSprite, Algo::Render::GL2::POINTS) ;
m_pointSprite->postdraw() ;
}
if(m_drawEdges)
{
glLineWidth(1.0f) ;
m_render->draw(m_simpleColorShader, Algo::Render::GL2::LINES) ;
}
if(m_drawNormals)
{
float size = normalBaseSize * normalScaleFactor ;
m_vectorShader->setScale(size) ;
glLineWidth(1.0f) ;
m_render->draw(m_vectorShader, Algo::Render::GL2::POINTS) ;
}
if(m_drawFaces)
{
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL) ;
glEnable(GL_LIGHTING) ;
glEnable(GL_POLYGON_OFFSET_FILL) ;
glPolygonOffset(1.0f, 1.0f) ;
switch(m_renderStyle)
{
case FLAT :
m_flatShader->setExplode(faceShrinkage) ;
m_render->draw(m_flatShader, Algo::Render::GL2::TRIANGLES) ;
break ;
case PHONG :
m_render->draw(m_phongShader, Algo::Render::GL2::TRIANGLES) ;
break ;
}
glDisable(GL_POLYGON_OFFSET_FILL) ;
}
m_phongShader->displayClipPlanes();
}
void Stage_shader_number_two::cb_Open()
{
std::string filters("all (*.*);; trian (*.trian);; ctm (*.ctm);; off (*.off);; ply (*.ply)") ;
std::string filename = selectFile("Open Mesh", "", filters) ;
importMesh(filename) ;
updateGL() ;
}
void Stage_shader_number_two::cb_keyPress(int code)
{
}
void Stage_shader_number_two::cb_mousePress(int button, int x, int y)
{
m_mouseLastX = x;
m_mouseLastY = y;
}
void Stage_shader_number_two::cb_mouseMove(int button, int x, int y)
{
if (Shift())
{
if (button == Qt::LeftButton)
{
Geom::Vec3f clipPlaneVec1 = m_phongShader->getClipPlaneParamsFirstVec(0);
Geom::Vec3f clipPlaneVec2 = m_phongShader->getClipPlaneParamsSecondVec(0);
clipPlaneVec1[0] += (m_mouseLastX - x)/40.0;
clipPlaneVec1[1] += (m_mouseLastY - y)/40.0;
clipPlaneVec2[1] += (m_mouseLastX - x)/40.0;
clipPlaneVec2[2] += (m_mouseLastY - y)/40.0;
m_phongShader->setClipPlaneParamsFirstVec(clipPlaneVec1, 0);
m_phongShader->setClipPlaneParamsSecondVec(clipPlaneVec2, 0);
updateGL();
}
}
m_mouseLastX = x;
m_mouseLastY = y;
}
void Stage_shader_number_two::importMesh(std::string& filename)
{
std::vector<std::string> attrNames ;
if(!Algo::Import::importMesh<PFP>(myMap, filename.c_str(), attrNames))
{
CGoGNerr << "could not import " << filename << CGoGNendl ;
return;
}
position = myMap.getAttribute<PFP::VEC3>(VERTEX, attrNames[0]) ;
m_render->initPrimitives<PFP>(myMap, allDarts, Algo::Render::GL2::POINTS) ;
m_render->initPrimitives<PFP>(myMap, allDarts, Algo::Render::GL2::LINES) ;
m_render->initPrimitives<PFP>(myMap, allDarts, Algo::Render::GL2::TRIANGLES) ;
bb = Algo::Geometry::computeBoundingBox<PFP>(myMap, position) ;
normalBaseSize = bb.diagSize() / 100.0f ;
vertexBaseSize = normalBaseSize * 2.0f ;
if(!normal.isValid())
normal = myMap.addAttribute<PFP::VEC3>(VERTEX, "normal") ;
Algo::Geometry::computeNormalVertices<PFP>(myMap, position, normal) ;
m_positionVBO->updateData(position) ;
m_normalVBO->updateData(normal) ;
setParamObject(bb.maxSize(), bb.center().data()) ;
updateGLMatrices() ;
m_phongShader->setClipPlanesDisplaySize(bb.maxSize()*1.2f);
m_phongShader->setClipPlaneParamsOrigin(bb.center(), 0);
}
void Stage_shader_number_two::slot_drawVertices(bool b)
{
m_drawVertices = b ;
updateGL() ;
}
void Stage_shader_number_two::slot_verticesSize(int i)
{
vertexScaleFactor = i / 50.0f ;
updateGL() ;
}
void Stage_shader_number_two::slot_drawEdges(bool b)
{
m_drawEdges = b ;
updateGL() ;
}
void Stage_shader_number_two::slot_drawFaces(bool b)
{
m_drawFaces = b ;
updateGL() ;
}
void Stage_shader_number_two::slot_faceLighting(int i)
{
m_renderStyle = i ;
updateGL() ;
}
void Stage_shader_number_two::slot_drawNormals(bool b)
{
m_drawNormals = b ;
updateGL() ;
}
void Stage_shader_number_two::slot_normalsSize(int i)
{
normalScaleFactor = i / 50.0f ;
updateGL() ;
}
void Stage_shader_number_two::slot_doubleSpinBox_ColorAttenuationFactor(double c)
{
m_phongShader->setClipColorAttenuationFactor((float)c);
updateGL();
}
/**********************************************************************************************
* MAIN FUNCTION *
**********************************************************************************************/
int main(int argc, char **argv)
{
// comment
QApplication app(argc, argv) ;
Stage_shader_number_two sqt ;
sqt.setGeometry(0, 0, 1000, 800) ;
sqt.show() ;
if(argc == 2)
{
std::string filename(argv[1]) ;
sqt.importMesh(filename) ;
}
sqt.initGUI() ;
return app.exec() ;
}
/*******************************************************************************
* CGoGN: Combinatorial and Geometric modeling with Generic N-dimensional Maps *
* version 0.1 *
* Copyright (C) 2009, IGG Team, LSIIT, University of Strasbourg *
* *
* 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. *
* *
* Web site: https://iggservis.u-strasbg.fr/CGoGN/ *
* Contact information: cgogn@unistra.fr *
* *
*******************************************************************************/
#include <iostream>
#include "Utils/qtSimple.h"
#include "ui_stage_shader_number_two.h"
#include "Utils/qtui.h"
#include "Topology/generic/parameters.h"
#include "Topology/map/map2.h"
#include "Topology/generic/embeddedMap2.h"
#include "Geometry/vector_gen.h"
#include "Geometry/matrix.h"
#include "Algo/Import/import.h"
#include "Algo/Render/GL2/mapRender.h"
#include "Utils/Shaders/shaderPhong.h"
#include "Utils/Shaders/shaderFlat.h"
#include "Utils/Shaders/shaderSimpleColor.h"
#include "Utils/Shaders/shaderVectorPerVertex.h"
#include "Utils/pointSprite.h"
#include "Algo/Geometry/boundingbox.h"
#include "Algo/Geometry/normal.h"
using namespace CGoGN ;
struct PFP: public PFP_STANDARD
{
// definition of the map
typedef EmbeddedMap2<Map2> MAP ;
};
typedef PFP::MAP MAP ;
class Stage_shader_number_two : public Utils::QT::SimpleQT
{
Q_OBJECT
public:
MAP myMap ;
SelectorTrue allDarts ;
Utils::QT::uiDockInterface dock ;
enum renderMode { FLAT, PHONG } ;
Geom::Vec4f colDif ;
Geom::Vec4f colSpec ;
Geom::Vec4f colClear ;
Geom::Vec4f colNormal ;
float shininess ;
Geom::BoundingBox<PFP::VEC3> bb ;
float normalBaseSize ;
float normalScaleFactor ;
float vertexBaseSize ;
float vertexScaleFactor ;
float faceShrinkage ;
int m_renderStyle ;
bool m_drawVertices ;
bool m_drawEdges ;
bool m_drawFaces ;
bool m_drawNormals ;
PFP::TVEC3 position ;
PFP::TVEC3 normal ;
Algo::Render::GL2::MapRender* m_render ;
Utils::VBO* m_positionVBO ;