mirror of https://github.com/CGAL/cgal
Edit_sphere_item
This commit is contained in:
parent
99fbc5587f
commit
6d54163bbd
|
|
@ -991,7 +991,8 @@ public:
|
|||
public:
|
||||
virtual void setVisualHintsMask(int mask, int delay = 2000);
|
||||
virtual void drawVisualHints();
|
||||
QOpenGLFramebufferObject* getStoredFrameBuffer();
|
||||
QOpenGLFramebufferObject* getStoredFrameBuffer() const;
|
||||
void setStoredFrameBuffer(QOpenGLFramebufferObject*);
|
||||
|
||||
public Q_SLOTS:
|
||||
virtual void resetVisualHints();
|
||||
|
|
|
|||
|
|
@ -4097,11 +4097,17 @@ QImage* CGAL::QGLViewer::takeSnapshot( CGAL::qglviewer::SnapShotBackground back
|
|||
}
|
||||
|
||||
CGAL_INLINE_FUNCTION
|
||||
QOpenGLFramebufferObject* CGAL::QGLViewer::getStoredFrameBuffer()
|
||||
QOpenGLFramebufferObject* CGAL::QGLViewer::getStoredFrameBuffer() const
|
||||
{
|
||||
return stored_fbo;
|
||||
}
|
||||
|
||||
CGAL_INLINE_FUNCTION
|
||||
void CGAL::QGLViewer::setStoredFrameBuffer(QOpenGLFramebufferObject *fbo)
|
||||
{
|
||||
stored_fbo = fbo;
|
||||
}
|
||||
|
||||
CGAL_INLINE_FUNCTION
|
||||
void CGAL::QGLViewer::saveSnapshot()
|
||||
{
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -1,14 +1,14 @@
|
|||
#ifndef SCENE_EDIT_BOX_ITEM_H
|
||||
#define SCENE_EDIT_BOX_ITEM_H
|
||||
|
||||
#include <CGAL/Three/Scene_item.h>
|
||||
#include <CGAL/Three/Scene_item_rendering_helper.h>
|
||||
#include <CGAL/Three/Scene_transparent_interface.h>
|
||||
#include <CGAL/Simple_cartesian.h>
|
||||
#include "create_sphere.h"
|
||||
#include "Scene_edit_box_item_config.h"
|
||||
struct Scene_edit_box_item_priv;
|
||||
class SCENE_EDIT_BOX_ITEM_EXPORT Scene_edit_box_item:
|
||||
public CGAL::Three::Scene_item,
|
||||
public CGAL::Three::Scene_item_rendering_helper,
|
||||
public CGAL::Three::Scene_transparent_interface
|
||||
{
|
||||
Q_OBJECT
|
||||
|
|
@ -42,11 +42,8 @@ class SCENE_EDIT_BOX_ITEM_EXPORT Scene_edit_box_item:
|
|||
void drawHl(CGAL::Three::Viewer_interface *) const;
|
||||
void drawEdges(CGAL::Three::Viewer_interface* viewer) const;
|
||||
void drawSpheres(CGAL::Three::Viewer_interface* viewer, const QMatrix4x4 f_matrix) const;
|
||||
void invalidateOpenGLBuffers()
|
||||
{
|
||||
compute_bbox();
|
||||
are_buffers_filled = false;
|
||||
}
|
||||
void invalidateOpenGLBuffers();
|
||||
|
||||
// 5-----6
|
||||
// . | . |
|
||||
// 4------7 |
|
||||
|
|
@ -56,11 +53,12 @@ class SCENE_EDIT_BOX_ITEM_EXPORT Scene_edit_box_item:
|
|||
// 0------3
|
||||
|
||||
double point(short i, short j) const;
|
||||
void removeViewer(CGAL::Three::Viewer_interface *viewer){}
|
||||
void newViewer(CGAL::Three::Viewer_interface *viewer){}
|
||||
void initializeBuffers(CGAL::Three::Viewer_interface *) const;
|
||||
void computeElements() const;
|
||||
public Q_SLOTS:
|
||||
void highlight(CGAL::Three::Viewer_interface* viewer);
|
||||
void clearHL();
|
||||
void connectNewViewer(QObject* o);
|
||||
protected:
|
||||
friend struct Scene_edit_box_item_priv;
|
||||
Scene_edit_box_item_priv* d;
|
||||
|
|
|
|||
|
|
@ -96,6 +96,8 @@
|
|||
<file>resources/compatibility_shaders/shader_with_textured_edges.v</file>
|
||||
<file>resources/compatibility_shaders/shader_without_light.f</file>
|
||||
<file>resources/compatibility_shaders/shader_without_light.v</file>
|
||||
<file>resources/shader_dark_spheres.v</file>
|
||||
<file>resources/compatibility_shaders/shader_dark_spheres.v</file>
|
||||
</qresource>
|
||||
<qresource prefix="/cgal/cursors">
|
||||
<file>resources/rotate_around_cursor.png</file>
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ struct Tri_d{
|
|||
bool is_surface;
|
||||
float alpha;
|
||||
QMatrix4x4 f_matrix;
|
||||
QMatrix4x4 mv_matrix;
|
||||
};
|
||||
|
||||
Triangle_container::Triangle_container(int program, bool indexed)
|
||||
|
|
@ -145,6 +146,8 @@ void Triangle_container::draw(Viewer_interface* viewer,
|
|||
getVbo(Vertex_indices)->bind();
|
||||
if(getVao(viewer)->program->property("hasFMatrix").toBool())
|
||||
getVao(viewer)->program->setUniformValue("f_matrix", getFrameMatrix());
|
||||
if(d->mv_matrix != QMatrix4x4())
|
||||
getVao(viewer)->program->setUniformValue("mv_matrix", getMvMatrix());
|
||||
if(getVao(viewer)->program->property("hasTransparency").toBool())
|
||||
{
|
||||
getVao(viewer)->program->setUniformValue("comparing", viewer->currentPass() > 0);
|
||||
|
|
@ -232,10 +235,12 @@ float Triangle_container::getShrinkFactor() { return d->shrink_factor ; }
|
|||
QVector4D Triangle_container::getPlane() { return d->plane; }
|
||||
float Triangle_container::getAlpha() { return d->alpha; }
|
||||
QMatrix4x4 Triangle_container::getFrameMatrix() const { return d->f_matrix; }
|
||||
QMatrix4x4 Triangle_container::getMvMatrix() const { return d->mv_matrix; }
|
||||
|
||||
void Triangle_container::setShrinkFactor(const float& f) { d->shrink_factor = f; }
|
||||
void Triangle_container::setAlpha (const float& f) { d->alpha = f ; }
|
||||
void Triangle_container::setFrameMatrix(const QMatrix4x4& m) { d->f_matrix = m; }
|
||||
void Triangle_container::setMvMatrix(const QMatrix4x4& m) { d->mv_matrix = m; }
|
||||
void Triangle_container::setPlane(const QVector4D& p) { d->plane = p; }
|
||||
void Triangle_container::setIsSurface (const bool b) { d->is_surface = b; }
|
||||
Triangle_container::~Triangle_container()
|
||||
|
|
|
|||
|
|
@ -875,8 +875,16 @@ void Viewer::attribBuffers(int program_name) const {
|
|||
case PROGRAM_CUTPLANE_SPHERES:
|
||||
program->setUniformValue("alpha", 1.0f); //overriden in item draw() if necessary
|
||||
}
|
||||
if(program_name == PROGRAM_SPHERES)
|
||||
switch(program_name)
|
||||
{
|
||||
case PROGRAM_SPHERES:
|
||||
case PROGRAM_DARK_SPHERES:
|
||||
case PROGRAM_WITH_LIGHT:
|
||||
program->setUniformValue("f_matrix",f_mat);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
switch(program_name)
|
||||
{
|
||||
case PROGRAM_WITH_LIGHT:
|
||||
|
|
@ -1115,6 +1123,7 @@ QOpenGLShaderProgram* Viewer::getShaderProgram(int name) const
|
|||
program->setProperty("hasLight", true);
|
||||
program->setProperty("hasNormals", true);
|
||||
program->setProperty("hasTransparency", true);
|
||||
program->setProperty("hasFMatrix", true);
|
||||
return program;
|
||||
}
|
||||
case PROGRAM_WITHOUT_LIGHT:
|
||||
|
|
@ -1220,6 +1229,18 @@ QOpenGLShaderProgram* Viewer::getShaderProgram(int name) const
|
|||
program->setProperty("hasFMatrix", true);
|
||||
return program;
|
||||
}
|
||||
case PROGRAM_DARK_SPHERES:
|
||||
{
|
||||
QOpenGLShaderProgram* program = isOpenGL_4_3()
|
||||
?declare_program(name, ":/cgal/Polyhedron_3/resources/shader_dark_spheres.v" , ":/cgal/Polyhedron_3/resources/shader_no_light_no_selection.f")
|
||||
: declare_program(name, ":/cgal/Polyhedron_3/resources/compatibility_shaders/shader_dark_spheres.v" ,
|
||||
":/cgal/Polyhedron_3/resources/compatibility_shaders/shader_no_light_no_selection.f");
|
||||
program->setProperty("hasCenter", true);
|
||||
program->setProperty("hasRadius", true);
|
||||
program->setProperty("isInstanced", true);
|
||||
program->setProperty("hasFMatrix", true);
|
||||
return program;
|
||||
}
|
||||
case PROGRAM_FLAT:
|
||||
{
|
||||
if(!isOpenGL_4_3())
|
||||
|
|
|
|||
|
|
@ -0,0 +1,17 @@
|
|||
attribute highp vec4 vertex;
|
||||
attribute highp vec3 colors;
|
||||
attribute highp vec3 center;
|
||||
attribute highp float radius;
|
||||
uniform highp mat4 mvp_matrix;
|
||||
uniform highp mat4 f_matrix;
|
||||
varying highp vec4 color;
|
||||
varying highp float dist[6];
|
||||
|
||||
void main(void)
|
||||
{
|
||||
for(int i=0; i<6; ++i)
|
||||
dist[i] = 1.0;
|
||||
color = vec4(colors, 1.0);
|
||||
gl_Position = mvp_matrix * f_matrix *
|
||||
vec4(radius*vertex.x + center.x, radius* vertex.y + center.y, radius*vertex.z + center.z, 1.0) ;
|
||||
}
|
||||
|
|
@ -4,6 +4,7 @@ attribute highp vec3 normals;
|
|||
attribute highp vec4 colors;
|
||||
uniform highp mat4 mvp_matrix;
|
||||
uniform highp mat4 mv_matrix;
|
||||
uniform highp mat4 f_matrix;
|
||||
varying highp vec4 fP;
|
||||
varying highp vec3 fN;
|
||||
varying highp vec4 color;
|
||||
|
|
@ -44,5 +45,5 @@ void main(void)
|
|||
mv_matrix_3[1] = mv_matrix[1].xyz;
|
||||
mv_matrix_3[2] = mv_matrix[2].xyz;
|
||||
fN = mv_matrix_3* normals;
|
||||
gl_Position = mvp_matrix * vertex;
|
||||
gl_Position = mvp_matrix * f_matrix * vertex;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,19 @@
|
|||
#version 150
|
||||
in vec4 vertex;
|
||||
in vec3 colors;
|
||||
in vec3 center;
|
||||
in float radius;
|
||||
uniform mat4 mvp_matrix;
|
||||
uniform mat4 f_matrix;
|
||||
out vec4 color;
|
||||
out float dist[6];
|
||||
|
||||
void main(void)
|
||||
{
|
||||
for(int i=0; i<6; ++i)
|
||||
dist[i] = 1.0;
|
||||
color = vec4(colors, 1.0);
|
||||
gl_Position = mvp_matrix * f_matrix *
|
||||
vec4(radius*vertex.x + center.x, radius* vertex.y + center.y,
|
||||
radius*vertex.z + center.z, 1.0) ;
|
||||
}
|
||||
|
|
@ -4,6 +4,7 @@ in vec3 normals;
|
|||
in vec4 colors;
|
||||
uniform mat4 mvp_matrix;
|
||||
uniform mat4 mv_matrix;
|
||||
uniform mat4 f_matrix;
|
||||
out vec4 fP;
|
||||
out vec3 fN;
|
||||
out vec4 color;
|
||||
|
|
@ -44,5 +45,5 @@ void main(void)
|
|||
mv_matrix_3[1] = mv_matrix[1].xyz;
|
||||
mv_matrix_3[2] = mv_matrix[2].xyz;
|
||||
fN = mv_matrix_3* normals;
|
||||
gl_Position = mvp_matrix * vertex;
|
||||
gl_Position = mvp_matrix * f_matrix * vertex;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -71,26 +71,27 @@ public:
|
|||
* @see getShaderProgram
|
||||
* @see attribBuffers
|
||||
*/
|
||||
enum OpenGL_program_IDs
|
||||
{
|
||||
PROGRAM_WITH_LIGHT = 0, /** Used to render a surface or edge affected by the light. It uses a per fragment lighting model, and renders brighter the selected item.*/
|
||||
PROGRAM_WITHOUT_LIGHT, /** Used to render a polygon edge or points. It renders in a uniform color and is not affected by light. It renders the selected item in black.*/
|
||||
PROGRAM_NO_SELECTION, /** Used to render a polyline or a surface that is not affected by light, like a cutting plane. It renders in a uniform color that does not change with selection.*/
|
||||
PROGRAM_WITH_TEXTURE, /** Used to render a textured polyhedron. Affected by light.*/
|
||||
PROGRAM_PLANE_TWO_FACES, /** Used to render a two-faced plane. The two faces have a different color. Not affected by light.*/
|
||||
PROGRAM_WITH_TEXTURED_EDGES, /** Used to render the edges of a textured polyhedorn. Not affected by light.*/
|
||||
PROGRAM_INSTANCED, /** Used to display instanced rendered spheres.Affected by light.*/
|
||||
PROGRAM_INSTANCED_WIRE, /** Used to display instanced rendered wired spheres. Not affected by light.*/
|
||||
PROGRAM_C3T3, /** Used to render a c3t3_item. It discards any fragment on a side of a plane, meaning that nothing is displayed on this side of the plane. Affected by light.*/
|
||||
PROGRAM_C3T3_EDGES, /** Used to render the edges of a c3t3_item. It discards any fragment on a side of a plane, meaning that nothing is displayed on this side of the plane. Not affected by light.*/
|
||||
PROGRAM_CUTPLANE_SPHERES, /** Used to render the spheres of an item with a cut plane.*/
|
||||
PROGRAM_SPHERES, /** Used to render one or several spheres.*/
|
||||
PROGRAM_FLAT, /** Used to render flat shading without pre computing normals*/
|
||||
PROGRAM_OLD_FLAT, /** Used to render flat shading without pre computing normals without geometry shader*/
|
||||
PROGRAM_SOLID_WIREFRAME, //! Used to render edges with width superior to 1.
|
||||
PROGRAM_NO_INTERPOLATION, //! Used to render faces without interpolating their color.
|
||||
NB_OF_PROGRAMS /** Holds the number of different programs in this enum.*/
|
||||
};
|
||||
enum OpenGL_program_IDs
|
||||
{
|
||||
PROGRAM_WITH_LIGHT = 0, //! Used to render a surface or an edge affected by the light. It uses a per fragment lighting model, and renders the selected item brighter.
|
||||
PROGRAM_WITHOUT_LIGHT, //! Used to render a polyhedron edge or points. It renders in a uniform color and is not affected by light. \attention It renders the selected item in black.
|
||||
PROGRAM_NO_SELECTION, //! Used to render a polyline or a surface that is not affected by light, like a cutting plane. It renders in a uniform color that does not change with selection.
|
||||
PROGRAM_WITH_TEXTURE, //! Used to render a textured polyhedron. Affected by light.
|
||||
PROGRAM_PLANE_TWO_FACES, //! Used to render a two-faced plane. The two faces have a different color. Not affected by light.
|
||||
PROGRAM_WITH_TEXTURED_EDGES, //! Used to render the edges of a textured polyhedron. Not affected by light.
|
||||
PROGRAM_INSTANCED, //! Used to display instanced rendered spheres.Affected by light.
|
||||
PROGRAM_INSTANCED_WIRE, //! Used to display instanced rendered wired spheres. Not affected by light.
|
||||
PROGRAM_C3T3, //! Used to render a c3t3_item. It discards any fragment on a side of a plane, meaning that nothing is displayed on this side of the plane. Affected by light.
|
||||
PROGRAM_C3T3_EDGES, //! Used to render the edges of a c3t3_item. It discards any fragment on a side of a plane, meaning that nothing is displayed on this side of the plane. Not affected by light.
|
||||
PROGRAM_CUTPLANE_SPHERES, //! Used to render the spheres of an item with a cut plane.
|
||||
PROGRAM_SPHERES, //! Used to render one or several spheres.
|
||||
PROGRAM_DARK_SPHERES, //! Used to render one or several spheres without light (for picking for example).
|
||||
PROGRAM_FLAT, /** Used to render flat shading without pre computing normals*/
|
||||
PROGRAM_OLD_FLAT, /** Used to render flat shading without pre computing normals without geometry shader*/
|
||||
PROGRAM_SOLID_WIREFRAME, //! Used to render edges with width superior to 1.
|
||||
PROGRAM_NO_INTERPOLATION, //! Used to render faces without interpolating their color.
|
||||
NB_OF_PROGRAMS //! Holds the number of different programs in this enum.
|
||||
};
|
||||
typedef CGAL::Bbox_3 Bbox;
|
||||
typedef CGAL::qglviewer::ManipulatedFrame ManipulatedFrame;
|
||||
//! \brief The default color of a scene_item.
|
||||
|
|
|
|||
|
|
@ -99,6 +99,8 @@ struct DEMO_FRAMEWORK_EXPORT Triangle_container :public Primitive_container
|
|||
float getAlpha();
|
||||
//! getter for the "f_matrix" parameter
|
||||
QMatrix4x4 getFrameMatrix()const;
|
||||
//! getter for the "mv_matrix" parameter
|
||||
QMatrix4x4 getMvMatrix()const;
|
||||
//! setter for the "shrink_factor" parameter
|
||||
void setShrinkFactor(const float&);
|
||||
//! setter for the "plane" parameter
|
||||
|
|
@ -107,6 +109,8 @@ struct DEMO_FRAMEWORK_EXPORT Triangle_container :public Primitive_container
|
|||
void setAlpha (const float&);
|
||||
//! setter for the "f_matrix" parameter
|
||||
void setFrameMatrix(const QMatrix4x4&);
|
||||
//! setter for the "mv_matrix" parameter
|
||||
void setMvMatrix(const QMatrix4x4&);
|
||||
//! setter for the "is_surface" attribute. Used in PROGRAM_C3T3
|
||||
void setIsSurface (const bool);
|
||||
///@}
|
||||
|
|
|
|||
|
|
@ -74,6 +74,7 @@ public:
|
|||
PROGRAM_C3T3_EDGES, //! Used to render the edges of a c3t3_item. It discards any fragment on a side of a plane, meaning that nothing is displayed on this side of the plane. Not affected by light.
|
||||
PROGRAM_CUTPLANE_SPHERES, //! Used to render the spheres of an item with a cut plane.
|
||||
PROGRAM_SPHERES, //! Used to render one or several spheres.
|
||||
PROGRAM_DARK_SPHERES, //! Used to render one or several spheres without light (for picking for example).
|
||||
PROGRAM_FLAT, /** Used to render flat shading without pre computing normals*/
|
||||
PROGRAM_OLD_FLAT, /** Used to render flat shading without pre computing normals without geometry shader*/
|
||||
PROGRAM_SOLID_WIREFRAME, //! Used to render edges with width superior to 1.
|
||||
|
|
|
|||
Loading…
Reference in New Issue