Commit 4040a77e authored by Sylvain Thery's avatar Sylvain Thery

Merge branch 'master' of cgogn:/home/maire/CGoGN

Conflicts:
	src/Utils/Shaders/shaderPhong.cpp
parents 78e96120 13e149b1
SET(EXECUTABLE_OUTPUT_PATH ${CGoGN_ROOT_DIR}/bin)
SET (COMMON_LIBS ${GLUT_LIBRARY} ${OPENGL_LIBRARY} ${GLEW_LIBRARY} ${DEVIL_LIBRARIES} ${ZLIB_LIBRARIES} ${LIBXML2_LIBRARIES} gzstream AntTweakBar openctm assimp)
BOOST_LIBS(boost_regex_lib_lists "boost_regex-mt")
SET (COMMON_LIBS ${GLUT_LIBRARY} ${OPENGL_LIBRARY} ${GLEW_LIBRARY} ${DEVIL_LIBRARIES} ${ZLIB_LIBRARIES} ${LIBXML2_LIBRARIES} ${boost_regex_lib_lists} gzstream AntTweakBar openctm assimp)
SET(CGoGN_LIBS_R topology algo container utils)
......
......@@ -59,3 +59,9 @@ add_executable( viewerD ../viewer.cpp ${viewer_moc} ${viewer_ui})
target_link_libraries( viewerD
${CGoGN_LIBS_D} ${NUMERICAL_LIBS} ${COMMON_LIBS} ${QT_LIBRARIES} )
QT4_WRAP_UI( clipping_ui ../clipping.ui )
QT4_WRAP_CPP( clipping_moc ../clipping.h )
add_executable( clippingD ../clipping.cpp ${clipping_ui} ${clipping_moc})
target_link_libraries( clippingD
${CGoGN_LIBS_D} ${COMMON_LIBS} ${QT_LIBRARIES} )
......@@ -63,3 +63,9 @@ add_executable( viewer ../viewer.cpp ${viewer_moc} ${viewer_ui})
target_link_libraries( viewer
${CGoGN_LIBS_R} ${NUMERICAL_LIBS} ${COMMON_LIBS} ${QT_LIBRARIES} )
QT4_WRAP_UI( clipping_ui ../clipping.ui )
QT4_WRAP_CPP( clipping_moc ../clipping.h )
add_executable( clipping ../clipping.cpp ${clipping_ui} ${clipping_moc})
target_link_libraries( clipping
${CGoGN_LIBS_D} ${COMMON_LIBS} ${QT_LIBRARIES} )
This diff is collapsed.
......@@ -22,14 +22,15 @@
* *
*******************************************************************************/
#ifndef __STAGE_SHADER_H__
#define __STAGE_SHADER_H__
#ifndef __CLIPPING_H__
#define __CLIPPING_H__
#include <iostream>
#include "Utils/qtSimple.h"
#include "Utils/qtInputs.h"
#include "ui_stage_shader.h"
#include "ui_clipping.h"
// inclure qtui.h juste après le ui_xxx.h
#include "Utils/qtui.h"
......@@ -49,11 +50,16 @@
#include "Algo/Render/GL2/topo3Render.h"
#include "Utils/Shaders/shaderSimpleColor.h"
#include "Utils/frameManipulator.h"
#include "Utils/clippingPresets.h"
#include "Utils/cgognStream.h"
#include "Utils/drawer.h"
#include <string>
#include <sstream>
using namespace CGoGN ;
struct PFP: public PFP_STANDARD
......@@ -63,7 +69,7 @@ struct PFP: public PFP_STANDARD
};
class StageShader: public Utils::QT::SimpleQT
class Clipping: public Utils::QT::SimpleQT
{
Q_OBJECT
......@@ -80,12 +86,14 @@ public:
//Render
bool m_drawVertices;
bool m_drawLines;
bool m_drawFaces;
bool m_drawTopo;
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;
......@@ -94,13 +102,23 @@ public:
Utils::Drawer* chips_area;
Geom::Vec3f m_coeffTopoExplod;
Geom::Vec3f gPosObj ;
float gWidthObj ;
Geom::Vec3f gPosObj ;
float gWidthObj ;
//QT
Utils::QT::uiDockInterface dock;
//QT
Utils::QT::uiDockInterface dock;
// Picking
Utils::LineDrawable* m_planeDrawable;
Utils::LineDrawable* m_sphereDrawable;
Utils::FrameManipulator* m_frameManipulator;
unsigned int m_frameManipulatorPickedAxis;
std::vector<Utils::Pickable*> m_pickablePlanes;
std::vector<Utils::Pickable*> m_pickableSpheres;
Utils::Pickable* m_lastPickedObject;
int m_lastClickedX, m_lastClickedY;
StageShader();
Clipping();
void initGUI();
void cb_Open();
......@@ -108,6 +126,7 @@ public:
void cb_initGL();
void cb_redraw();
void cb_mousePress(int button, int x, int y);
void cb_mouseMove(int buttons, int x, int y);
void cb_keyPress(int code);
void importMesh(std::string& filename);
......@@ -121,7 +140,23 @@ public slots:
void slot_explodTopoPhi2(double c);
void slot_explodTopoPhi3(double c);
void dockWidget_topLevelChanged(bool isFloating);
void slot_pushButton_addPlane();
void slot_spinBox_GridResolution(int i);
void slot_pushButton_changePlanesColor();
void slot_pushButton_addSphere();
void slot_spinBox_SphereResolution(int i);
void slot_pushButton_changeSpheresColor();
void slot_doubleSpinBox_ColorAttenuationFactor(double c);
void slot_radioButton_ClippingMode(bool b);
void slot_radioButton_ColorAttenuationMode(bool b);
void slot_pushButton_deleteSelectedObject();
void slot_pushButton_applyClippingPreset();
void button_compile();
};
......
This diff is collapsed.
......@@ -47,7 +47,6 @@
#include "glm/gtc/type_precision.hpp"
#include "glm/gtc/type_ptr.hpp"
using namespace CGoGN;
struct PFP: public PFP_STANDARD
......
......@@ -66,13 +66,6 @@ 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} )
#add_executable( tuto_subdivision tuto_subdivision.cpp)
#target_link_libraries( tuto_subdivision
# ${CGoGN_LIBS_D} ${COMMON_LIBS} )
......
This diff is collapsed.
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>DockWidget</class>
<widget class="QDockWidget" name="DockWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>324</width>
<height>473</height>
</rect>
</property>
<property name="allowedAreas">
<set>Qt::LeftDockWidgetArea|Qt::RightDockWidgetArea</set>
</property>
<property name="windowTitle">
<string>Interface</string>
</property>
<widget class="QWidget" name="dockWidgetContents">
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QTabWidget" name="tabWidget">
<property name="tabPosition">
<enum>QTabWidget::East</enum>
</property>
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="tab">
<attribute name="title">
<string>Visualisation</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_6">
<item row="0" column="0">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QCheckBox" name="checkBox_vertices">
<property name="text">
<string>Vertices</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkBox_lines">
<property name="text">
<string>Lines</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkBox_faces">
<property name="text">
<string>Faces</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_topo">
<property name="enabled">
<bool>true</bool>
</property>
<property name="title">
<string>Topo</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>false</bool>
</property>
<layout class="QGridLayout" name="gridLayout_3">
<item row="1" column="0">
<layout class="QGridLayout" name="gridLayout_2">
<item row="3" column="2">
<widget class="QDoubleSpinBox" name="explod_phi2">
<property name="maximum">
<double>1.000000000000000</double>
</property>
<property name="singleStep">
<double>0.100000000000000</double>
</property>
<property name="value">
<double>0.900000000000000</double>
</property>
</widget>
</item>
<item row="5" column="2">
<widget class="QDoubleSpinBox" name="explod_phi3">
<property name="maximum">
<double>1.000000000000000</double>
</property>
<property name="singleStep">
<double>0.100000000000000</double>
</property>
<property name="value">
<double>0.900000000000000</double>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_faces">
<property name="text">
<string>Faces</string>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="label_volumes">
<property name="text">
<string>Volumes</string>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QDoubleSpinBox" name="explod_phi1">
<property name="prefix">
<string/>
</property>
<property name="maximum">
<double>1.000000000000000</double>
</property>
<property name="singleStep">
<double>0.100000000000000</double>
</property>
<property name="value">
<double>0.900000000000000</double>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_edges">
<property name="text">
<string>Edges</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_rotate">
<property name="title">
<string>Rotate</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>false</bool>
</property>
<layout class="QGridLayout" name="gridLayout_5">
<item row="0" column="0">
<layout class="QGridLayout" name="gridLayout_4">
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Speed</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QDoubleSpinBox" name="doubleSpinBox"/>
</item>
</layout>
</item>
<item row="1" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_2">
<attribute name="title">
<string>Shader</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_7">
<item row="0" column="0">
<layout class="QGridLayout" name="gridLayout_8">
<item row="0" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Shader Editor</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QPushButton" name="compileButton">
<property name="text">
<string>Recompile</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QTabWidget" name="tabWidget_2">
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="tab_3">
<attribute name="title">
<string>Vertex</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_9">
<item row="0" column="0">
<widget class="QTextEdit" name="vertexEdit"/>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_4">
<attribute name="title">
<string>Fragment</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_10">
<item row="0" column="0">
<widget class="QTextEdit" name="fragmentEdit"/>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_5">
<attribute name="title">
<string>Geometry</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_11">
<item row="0" column="0">
<widget class="QTextEdit" name="geometryEdit"/>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
</widget>
<resources/>
<connections/>
</ui>
......@@ -286,6 +286,9 @@ public:
*/
virtual void restoreUniformsAttribs() {CGoGNerr << "Warning restoreUniformsAttribs not implemented"<< CGoGNendl;}
virtual void updateClippingUniforms() {CGoGNerr << "Warning updateClippingUniforms not implemented"<< CGoGNendl;}
/**
*
*/
......
......@@ -26,6 +26,7 @@
#define __CGOGN_SHADER_CPV__
#include "Utils/GLSLShader.h"
#include "Utils/clippingShader.h"
#include "Geometry/vector_gen.h"
namespace CGoGN
......@@ -34,7 +35,7 @@ namespace CGoGN
namespace Utils
{
class ShaderColorPerVertex : public GLSLShader
class ShaderColorPerVertex : public ClippingShader
{
protected:
// shader sources
......
......@@ -17,8 +17,16 @@ void main()
float lambertTerm = dot(N,L);
vec4 finalColor = materialAmbient;
if(lambertTerm > 0.0)
#ifdef DOUBLE_SIDED
if (lambertTerm < 0.0)
{
N = -1.0*N;
lambertTerm = -1.0*lambertTerm;
#else
if (lambertTerm > 0.0)
{
#endif
#ifndef WITH_COLOR
finalColor += materialDiffuse * lambertTerm;
#else
......
......@@ -26,6 +26,7 @@
#define __CGOGN_SHADER_PHONG__
#include "Utils/GLSLShader.h"
#include "Utils/clippingShader.h"
#include "Geometry/vector_gen.h"
#include <string>
......@@ -36,7 +37,7 @@ namespace CGoGN
namespace Utils
{
class ShaderPhong : public GLSLShader
class ShaderPhong : public ClippingShader
{
protected:
// flag color per vertex or not
......@@ -71,7 +72,7 @@ protected:
void restoreUniformsAttribs();
public:
ShaderPhong();
ShaderPhong(bool doubleSided = false);
// inviduals parameter setting functions
void setAmbiant(const Geom::Vec4f& ambiant);
......
......@@ -26,6 +26,7 @@
#define __CGOGN_SHADER_SIMPLECOLOR__
#include "Utils/GLSLShader.h"
#include "Utils/clippingShader.h"
#include "Geometry/vector_gen.h"
namespace CGoGN
......@@ -34,14 +35,14 @@ namespace CGoGN
namespace Utils
{
class ShaderSimpleColor : public GLSLShader
class ShaderSimpleColor : public ClippingShader
{
protected:
// shader sources
static std::string vertexShaderText;
static std::string fragmentShaderText;
static std::string vertexShaderText;
static std::string fragmentShaderText;
// uniform locations
// uniform locations
GLuint m_unif_color;
Geom::Vec4f m_color;
......
......@@ -28,6 +28,7 @@
#include "Geometry/vector_gen.h"
#include "Utils/GLSLShader.h"
#include "Utils/clippingShader.h"
#include "Utils/textures.h"
namespace CGoGN
......@@ -36,7 +37,7 @@ namespace CGoGN
namespace Utils
{
class ShaderSimpleTexture : public GLSLShader
class ShaderSimpleTexture : public ClippingShader
{
protected:
// shader sources
......
......@@ -28,6 +28,7 @@
#include "Geometry/vector_gen.h"
#include "Utils/GLSLShader.h"
#include "Utils/clippingShader.h"
#include "Utils/textures.h"
namespace CGoGN
......@@ -36,7 +37,7 @@ namespace CGoGN
namespace Utils
{
class ShaderTextureMask : public GLSLShader
class ShaderTextureMask : public ClippingShader
{
protected:
// shader sources
......
/*******************************************************************************
* 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 _CGoGN_CLIPPINGPRESETS_H_
#define _CGoGN_CLIPPINGPRESETS_H_
#include "Utils/clippingShader.h"
#include "Geometry/vector_gen.h"
#include <vector>
#include <cmath>
namespace CGoGN
{
namespace Utils
{
class ClippingPreset
{
/***********************************************
*
* Constructors
*
***********************************************/
public :
/// public static constructor
static ClippingPreset* CreateEmptyPreset();
/**
* public static constructor
* @param center center between planes
* @param size distance between planes
* @param axis axis on which planes are aligned (0 for x, 1 for y, 2 for z)
* @param facing true means having facing planes
*/
static ClippingPreset* CreateDualPlanesPreset(Geom::Vec3f center, float size, int axis, bool facing);
/**
* public static constructor
* @param center center between planes
* @param size distance between planes
* @param facing true means having facing planes
*/
static ClippingPreset* CreateCubePreset(Geom::Vec3f center, float size, bool facing);
/**
* public static constructor
* @param center center of the tube
* @param size tube diameter
* @param axis axis of the tube (0 for x, 1 for y, 2 for z)
* @param precision planes count used to build tube
* @param facing true means an outer tube, false an inner tube
*/
static ClippingPreset* CreateTubePreset(Geom::Vec3f center, float size, int axis, int precision, bool facing);
/**
* public static constructor
* @param center center of molecule
* @param size molecule size
* @param atomsRadiuses radiuses of atoms
* @param orClipping set it to true for OR clipping mode
*/
static ClippingPreset* CreateMoleculePreset(Geom::Vec3f center, float size, float atomsRadiuses, bool orClipping);
private :
/// private constructor (used by public static constructors)
ClippingPreset();
/***********************************************
*
* Preset settings
*
***********************************************/
public :
/**
* adds a clip plane to the preset
* @param normal clip plane normal
* @param origin clip plane origin
*/
void addClipPlane(Geom::Vec3f normal, Geom::Vec3f origin);
/**
* adds a clip sphere to the preset
* @param center clip sphere center
* @param radius clip sphere radius