git-svn-id: svn://db.shs.com.ru/libs@421 a8b55f48-bf90-11e4-a774-851b48703e85
This commit is contained in:
@@ -40,6 +40,17 @@ GLObjectBase::GLObjectBase() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
GLObjectBase::~GLObjectBase() {
|
||||||
|
//qDebug() << "del" << name() << view_;
|
||||||
|
if (parent_) parent_->children_.removeAll(this);
|
||||||
|
if (view_) ((QGLView*)view_)->objectDeleted(this);
|
||||||
|
foreach (GLObjectBase * c, children_) {
|
||||||
|
c->parent_ = 0;
|
||||||
|
delete c;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
GLObjectBase * GLObjectBase::clone(bool withChildren) {
|
GLObjectBase * GLObjectBase::clone(bool withChildren) {
|
||||||
GLObjectBase * o = new GLObjectBase();
|
GLObjectBase * o = new GLObjectBase();
|
||||||
o->pass_ = pass_;
|
o->pass_ = pass_;
|
||||||
@@ -104,16 +115,34 @@ void GLObjectBase::setView(QGLView * v) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void GLObjectBase::addChild(GLObjectBase * o) {
|
||||||
|
if (o == this) return;
|
||||||
|
if (o->parent_)
|
||||||
|
o->parent_->children_.removeAll(o);
|
||||||
|
children_ << o;
|
||||||
|
o->parent_ = this;
|
||||||
|
o->setView((QGLView*)view_);
|
||||||
|
o->buildTransform();
|
||||||
|
if (view_) {
|
||||||
|
view_->collectLights();
|
||||||
|
QList<GLObjectBase*> cl = o->children(true);
|
||||||
|
cl << o;
|
||||||
|
foreach (GLObjectBase * i, cl) {
|
||||||
|
emit ((QGLView*)view_)->objectAdded(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void GLObjectBase::clearChildren(bool deleteAll) {
|
void GLObjectBase::clearChildren(bool deleteAll) {
|
||||||
foreach (GLObjectBase * i, children_) {
|
foreach (GLObjectBase * i, children_) {
|
||||||
i->setView(0);
|
i->view_ = 0;
|
||||||
i->parent_ = 0;
|
i->parent_ = 0;
|
||||||
|
i->clearChildren(deleteAll);
|
||||||
if (deleteAll) {
|
if (deleteAll) {
|
||||||
i->clearChildren(true);
|
|
||||||
delete i;
|
delete i;
|
||||||
} else {
|
|
||||||
i->buildTransform();
|
|
||||||
}
|
}
|
||||||
|
i->buildTransform();
|
||||||
}
|
}
|
||||||
children_.clear();
|
children_.clear();
|
||||||
if (view_) view_->collectLights();
|
if (view_) view_->collectLights();
|
||||||
@@ -151,6 +180,27 @@ void GLObjectBase::calculateBoundingBox() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void GLObjectBase::setProperty(const QString & pn, const QVariant & v) {
|
||||||
|
meta[pn] = v;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QVariant GLObjectBase::property(const QString & pn, bool * exists) const {
|
||||||
|
if (exists) *exists = meta.contains(pn);
|
||||||
|
return meta.value(pn);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool GLObjectBase::hasProperty(const QString & pn) const {
|
||||||
|
return meta.contains(pn);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void GLObjectBase::removeProperty(const QString & pn) {
|
||||||
|
meta.remove(pn);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void GLObjectBase::setTransform(const QMatrix4x4 & t) {
|
void GLObjectBase::setTransform(const QMatrix4x4 & t) {
|
||||||
raw_matrix = true;
|
raw_matrix = true;
|
||||||
mat_ = t;
|
mat_ = t;
|
||||||
@@ -171,7 +221,7 @@ void GLObjectBase::select() {
|
|||||||
void GLObjectBase::buildTransform() {
|
void GLObjectBase::buildTransform() {
|
||||||
itransform_.setToIdentity();
|
itransform_.setToIdentity();
|
||||||
GLObjectBase * p = parent_;
|
GLObjectBase * p = parent_;
|
||||||
if (p != 0)
|
if (p)
|
||||||
itransform_ = p->itransform_;
|
itransform_ = p->itransform_;
|
||||||
if (raw_matrix) {
|
if (raw_matrix) {
|
||||||
itransform_.translate(pos_);
|
itransform_.translate(pos_);
|
||||||
@@ -311,7 +361,7 @@ QDataStream & operator <<(QDataStream & s, const GLObjectBase * p) {
|
|||||||
<< cs.chunk(5, p->cast_shadow) << cs.chunk(6, p->rec_shadow) << cs.chunk(7, p->raw_matrix) << cs.chunk(8, p->line_width)
|
<< cs.chunk(5, p->cast_shadow) << cs.chunk(6, p->rec_shadow) << cs.chunk(7, p->raw_matrix) << cs.chunk(8, p->line_width)
|
||||||
<< cs.chunk(9, int(p->render_mode)) << cs.chunk(10, p->material_) << cs.chunk(11, p->pos_) << cs.chunk(12, p->angles_)
|
<< cs.chunk(9, int(p->render_mode)) << cs.chunk(10, p->material_) << cs.chunk(11, p->pos_) << cs.chunk(12, p->angles_)
|
||||||
<< cs.chunk(13, p->scale_) << cs.chunk(14, p->mat_) << cs.chunk(15, p->vbo) << cs.chunk(16, p->children_.size())
|
<< cs.chunk(13, p->scale_) << cs.chunk(14, p->mat_) << cs.chunk(15, p->vbo) << cs.chunk(16, p->children_.size())
|
||||||
<< cs.chunk(17, p->name_);
|
<< cs.chunk(17, p->name_) << cs.chunk(18, p->meta);
|
||||||
//qDebug() << "place self done";
|
//qDebug() << "place self done";
|
||||||
if (p->type_ == GLObjectBase::glLight) {
|
if (p->type_ == GLObjectBase::glLight) {
|
||||||
//qDebug() << "place light ...";
|
//qDebug() << "place light ...";
|
||||||
@@ -370,6 +420,7 @@ QDataStream & operator >>(QDataStream & s, GLObjectBase *& p) {
|
|||||||
case 15: if (p) p->vbo = cs.getData<GLVBO>(); break;
|
case 15: if (p) p->vbo = cs.getData<GLVBO>(); break;
|
||||||
case 16: if (p) ccnt = cs.getData<int>(); break;
|
case 16: if (p) ccnt = cs.getData<int>(); break;
|
||||||
case 17: if (p) p->name_ = cs.getData<QString>(); break;
|
case 17: if (p) p->name_ = cs.getData<QString>(); break;
|
||||||
|
case 18: if (p) p->meta = cs.getData<QVariantMap>(); break;
|
||||||
case 100: if (l) l->direction = cs.getData<QVector3D>(); break;
|
case 100: if (l) l->direction = cs.getData<QVector3D>(); break;
|
||||||
case 101: if (l) l->angle_start = cs.getData<GLdouble>(); break;
|
case 101: if (l) l->angle_start = cs.getData<GLdouble>(); break;
|
||||||
case 102: if (l) l->angle_end = cs.getData<GLdouble>(); break;
|
case 102: if (l) l->angle_end = cs.getData<GLdouble>(); break;
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ public:
|
|||||||
enum RenderMode {View = 0, Point = GL_POINT, Line = GL_LINE, Fill = GL_FILL};
|
enum RenderMode {View = 0, Point = GL_POINT, Line = GL_LINE, Fill = GL_FILL};
|
||||||
|
|
||||||
GLObjectBase();
|
GLObjectBase();
|
||||||
virtual ~GLObjectBase() {;}
|
virtual ~GLObjectBase();
|
||||||
|
|
||||||
virtual GLObjectBase * clone(bool withChildren = true);
|
virtual GLObjectBase * clone(bool withChildren = true);
|
||||||
|
|
||||||
@@ -66,7 +66,7 @@ public:
|
|||||||
bool hasChildren() const {return children_.size() != 0;}
|
bool hasChildren() const {return children_.size() != 0;}
|
||||||
void setView(QGLView * v);
|
void setView(QGLView * v);
|
||||||
|
|
||||||
void addChild(GLObjectBase * o) {if (o == this) return; if (o->parent_ != 0) o->parent_->children_.removeAll(o); children_ << o; o->parent_ = this; o->buildTransform(); if (view_ != 0) view_->collectLights();}
|
void addChild(GLObjectBase * o);
|
||||||
void removeChild(GLObjectBase * o) {if (o == this) return; children_.removeAll(o); o->parent_ = 0; o->buildTransform(); if (view_ != 0) view_->collectLights();}
|
void removeChild(GLObjectBase * o) {if (o == this) return; children_.removeAll(o); o->parent_ = 0; o->buildTransform(); if (view_ != 0) view_->collectLights();}
|
||||||
void removeChild(int index) {children_[index]->parent_ = 0; children_[index]->buildTransform(); children_.removeAt(index); if (view_ != 0) view_->collectLights();}
|
void removeChild(int index) {children_[index]->parent_ = 0; children_[index]->buildTransform(); children_.removeAt(index); if (view_ != 0) view_->collectLights();}
|
||||||
void clearChildren(bool deleteAll = false);
|
void clearChildren(bool deleteAll = false);
|
||||||
@@ -177,6 +177,11 @@ public:
|
|||||||
|
|
||||||
void calculateBoundingBox();
|
void calculateBoundingBox();
|
||||||
|
|
||||||
|
void setProperty(const QString & pn, const QVariant & v);
|
||||||
|
QVariant property(const QString & pn, bool * exists = 0) const;
|
||||||
|
bool hasProperty(const QString & pn) const;
|
||||||
|
void removeProperty(const QString & pn);
|
||||||
|
|
||||||
QVector3D pos_h;
|
QVector3D pos_h;
|
||||||
QVector<Vector3d> points, puvws;
|
QVector<Vector3d> points, puvws;
|
||||||
QVector<Vector3i> faces, uvws, norms;
|
QVector<Vector3i> faces, uvws, norms;
|
||||||
@@ -214,6 +219,7 @@ protected:
|
|||||||
GLObjectBase * parent_;
|
GLObjectBase * parent_;
|
||||||
QGLViewBase * view_;
|
QGLViewBase * view_;
|
||||||
GLVBO vbo;
|
GLVBO vbo;
|
||||||
|
QVariantMap meta;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -286,6 +286,12 @@ void GLRendererBase::renderSingleShadow(GLObjectBase & o, RenderingParameters &
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
GLRendererBase::RenderingParameters::RenderingParameters() {
|
||||||
|
shaders = 0;
|
||||||
|
cur_shader = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void GLRendererBase::RenderingParameters::prepare() {
|
void GLRendererBase::RenderingParameters::prepare() {
|
||||||
proj_matrix = getGLMatrix(GL_PROJECTION_MATRIX);
|
proj_matrix = getGLMatrix(GL_PROJECTION_MATRIX);
|
||||||
view_matrix = getGLMatrix(GL_MODELVIEW_MATRIX);
|
view_matrix = getGLMatrix(GL_MODELVIEW_MATRIX);
|
||||||
|
|||||||
@@ -34,8 +34,8 @@ public:
|
|||||||
virtual void prepareScene() {;}
|
virtual void prepareScene() {;}
|
||||||
virtual void renderScene() = 0;
|
virtual void renderScene() = 0;
|
||||||
|
|
||||||
protected:
|
|
||||||
struct RenderingParameters {
|
struct RenderingParameters {
|
||||||
|
RenderingParameters();
|
||||||
void prepare();
|
void prepare();
|
||||||
void setUniform(__GLShaderProgram__ * prog);
|
void setUniform(__GLShaderProgram__ * prog);
|
||||||
int pass;
|
int pass;
|
||||||
@@ -55,6 +55,9 @@ protected:
|
|||||||
__GLShaderProgram__ * cur_shader;
|
__GLShaderProgram__ * cur_shader;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
RenderingParameters rp;
|
||||||
|
|
||||||
|
protected:
|
||||||
virtual void setupLight(const Light & l, int inpass_index, int gl_index);
|
virtual void setupLight(const Light & l, int inpass_index, int gl_index);
|
||||||
virtual void setupAmbientLight(const QColor & a, bool first_pass);
|
virtual void setupAmbientLight(const QColor & a, bool first_pass);
|
||||||
virtual void setupShadersLights(int lights_count);
|
virtual void setupShadersLights(int lights_count);
|
||||||
@@ -71,7 +74,6 @@ protected:
|
|||||||
void renderShadow(Light * l, __GLShaderProgram__ * prog = 0, QMatrix4x4 mat = QMatrix4x4());
|
void renderShadow(Light * l, __GLShaderProgram__ * prog = 0, QMatrix4x4 mat = QMatrix4x4());
|
||||||
void renderSingleShadow(GLObjectBase & o, RenderingParameters & rpl);
|
void renderSingleShadow(GLObjectBase & o, RenderingParameters & rpl);
|
||||||
|
|
||||||
RenderingParameters rp;
|
|
||||||
QGLView & view;
|
QGLView & view;
|
||||||
QImage white_image, violent_image;
|
QImage white_image, violent_image;
|
||||||
GLuint white_image_id, violent_image_id;
|
GLuint white_image_id, violent_image_id;
|
||||||
|
|||||||
@@ -158,6 +158,7 @@ void setUniformMatrices(__GLShaderProgram__ * prog, QMatrix4x4 proj, QMatrix4x4
|
|||||||
prog->setUniformValue("qgl_ModelViewMatrix", view);
|
prog->setUniformValue("qgl_ModelViewMatrix", view);
|
||||||
prog->setUniformValue("qgl_ProjectionMatrix", proj);
|
prog->setUniformValue("qgl_ProjectionMatrix", proj);
|
||||||
prog->setUniformValue("prev_ModelViewProjectioMatrix", pmvpm);
|
prog->setUniformValue("prev_ModelViewProjectioMatrix", pmvpm);
|
||||||
|
prog->setUniformValue("prev_ModelViewMatrix", prevview);
|
||||||
prog->setUniformValue("qgl_ModelViewProjectionMatrix", mvpm);
|
prog->setUniformValue("qgl_ModelViewProjectionMatrix", mvpm);
|
||||||
prog->setUniformValue("qgl_NormalMatrix", nm);
|
prog->setUniformValue("qgl_NormalMatrix", nm);
|
||||||
//prog->setUniformValue("qgl_BumpMatrix", nm.);
|
//prog->setUniformValue("qgl_BumpMatrix", nm.);
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>470</width>
|
<width>470</width>
|
||||||
<height>737</height>
|
<height>791</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QFormLayout" name="formLayout">
|
<layout class="QFormLayout" name="formLayout">
|
||||||
@@ -44,6 +44,9 @@
|
|||||||
</item>
|
</item>
|
||||||
<item row="0" column="1">
|
<item row="0" column="1">
|
||||||
<widget class="ColorButton" name="colorDiffuse">
|
<widget class="ColorButton" name="colorDiffuse">
|
||||||
|
<property name="focusPolicy">
|
||||||
|
<enum>Qt::NoFocus</enum>
|
||||||
|
</property>
|
||||||
<property name="styleSheet">
|
<property name="styleSheet">
|
||||||
<string notr="true">font:normal;</string>
|
<string notr="true">font:normal;</string>
|
||||||
</property>
|
</property>
|
||||||
@@ -83,6 +86,9 @@
|
|||||||
</item>
|
</item>
|
||||||
<item row="0" column="1">
|
<item row="0" column="1">
|
||||||
<widget class="ColorButton" name="colorSpecular">
|
<widget class="ColorButton" name="colorSpecular">
|
||||||
|
<property name="focusPolicy">
|
||||||
|
<enum>Qt::NoFocus</enum>
|
||||||
|
</property>
|
||||||
<property name="styleSheet">
|
<property name="styleSheet">
|
||||||
<string notr="true">font:normal;</string>
|
<string notr="true">font:normal;</string>
|
||||||
</property>
|
</property>
|
||||||
@@ -122,6 +128,9 @@
|
|||||||
</item>
|
</item>
|
||||||
<item row="0" column="1">
|
<item row="0" column="1">
|
||||||
<widget class="ColorButton" name="colorSelfIllum">
|
<widget class="ColorButton" name="colorSelfIllum">
|
||||||
|
<property name="focusPolicy">
|
||||||
|
<enum>Qt::NoFocus</enum>
|
||||||
|
</property>
|
||||||
<property name="styleSheet">
|
<property name="styleSheet">
|
||||||
<string notr="true">font:normal;</string>
|
<string notr="true">font:normal;</string>
|
||||||
</property>
|
</property>
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ QGLView::QGLView(QWidget * parent): QGraphicsView(parent), fbo_selection(3) {
|
|||||||
_w = 0;
|
_w = 0;
|
||||||
need_init_ = is_first_draw = true;
|
need_init_ = is_first_draw = true;
|
||||||
objects_.is_root = true;
|
objects_.is_root = true;
|
||||||
|
objects_.view_ = this;
|
||||||
painter_ = 0;
|
painter_ = 0;
|
||||||
backColor_ = Qt::black;
|
backColor_ = Qt::black;
|
||||||
hoverHaloColor_ = QColor(195, 140, 255, 96);
|
hoverHaloColor_ = QColor(195, 140, 255, 96);
|
||||||
@@ -119,9 +120,14 @@ void QGLView::addObject(QWidget * o, Qt::WindowFlags f) {
|
|||||||
|
|
||||||
|
|
||||||
void QGLView::addObject(GLObjectBase * o) {
|
void QGLView::addObject(GLObjectBase * o) {
|
||||||
o->setView(this);
|
|
||||||
objects_.addChild(o);
|
objects_.addChild(o);
|
||||||
|
o->setView(this);
|
||||||
collectLights();
|
collectLights();
|
||||||
|
QList<GLObjectBase*> cl = o->children(true);
|
||||||
|
cl << o;
|
||||||
|
foreach (GLObjectBase * i, cl) {
|
||||||
|
emit objectAdded(i);
|
||||||
|
}
|
||||||
if (is_init) {
|
if (is_init) {
|
||||||
globMutex.lock();
|
globMutex.lock();
|
||||||
o->init();
|
o->init();
|
||||||
@@ -130,9 +136,30 @@ void QGLView::addObject(GLObjectBase * o) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void QGLView::removeObject(GLObjectBase * o, bool inChildren) {
|
||||||
|
o->setView(0);
|
||||||
|
if (inChildren)
|
||||||
|
removeObjectInternal(o, &objects_);
|
||||||
|
else
|
||||||
|
objects_.removeChild(o);
|
||||||
|
objectDeleted(o);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void QGLView::clearObjects(bool deleteAll) {
|
||||||
|
removeObject(camera_);
|
||||||
|
objects_.clearChildren(deleteAll);
|
||||||
|
addObject(camera());
|
||||||
|
selectObject(0);
|
||||||
|
hov_obj = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void QGLView::selectObject(GLObjectBase * o) {
|
void QGLView::selectObject(GLObjectBase * o) {
|
||||||
emit selectionChanged(o, sel_obj);
|
if (o == sel_obj) return;
|
||||||
|
GLObjectBase * pso = sel_obj;
|
||||||
sel_obj = o;
|
sel_obj = o;
|
||||||
|
emit selectionChanged(sel_obj, pso);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -224,6 +251,7 @@ void QGLView::paintGL() {
|
|||||||
if (need_init_)
|
if (need_init_)
|
||||||
initializeGL();
|
initializeGL();
|
||||||
#endif
|
#endif
|
||||||
|
emit glBeforePaint();
|
||||||
//qDebug() << "paintGL";
|
//qDebug() << "paintGL";
|
||||||
//QMutexLocker ml_v(&v_mutex);
|
//QMutexLocker ml_v(&v_mutex);
|
||||||
glEnable(GL_CULL_FACE);
|
glEnable(GL_CULL_FACE);
|
||||||
@@ -473,6 +501,13 @@ void QGLView::collectLights() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void QGLView::objectDeleted(GLObjectBase * o) {
|
||||||
|
//qDebug() << "del" << o;
|
||||||
|
if (sel_obj == o) selectObject(0);
|
||||||
|
if (hov_obj == o) hov_obj = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
QList<QGraphicsItem * > QGLView::collectGraphicItems() {
|
QList<QGraphicsItem * > QGLView::collectGraphicItems() {
|
||||||
QList<QGraphicsItem * > list = scene()->items();
|
QList<QGraphicsItem * > list = scene()->items();
|
||||||
foreach (QGraphicsItem * i, list)
|
foreach (QGraphicsItem * i, list)
|
||||||
@@ -500,6 +535,17 @@ void QGLView::collectObjectLights(GLObjectBase * o) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void QGLView::removeObjectInternal(GLObjectBase * o, GLObjectBase * where) {
|
||||||
|
foreach (GLObjectBase * i, where->children_) {
|
||||||
|
if (o == i)
|
||||||
|
where->removeChild(i);
|
||||||
|
else
|
||||||
|
removeObjectInternal(o, i);
|
||||||
|
objectDeleted(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void QGLView::checkCaps() {
|
void QGLView::checkCaps() {
|
||||||
glGetIntegerv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &max_anisotropic);
|
glGetIntegerv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &max_anisotropic);
|
||||||
//glGetIntegerv(GL_MAX_TEXTURE_UNITS, &max_texture_chanels);
|
//glGetIntegerv(GL_MAX_TEXTURE_UNITS, &max_texture_chanels);
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ class QGLView: public QGraphicsView, public QGLViewBase
|
|||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
friend class GLRendererBase;
|
friend class GLRendererBase;
|
||||||
|
friend class GLObjectBase;
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PROPERTY (QColor backColor READ backColor WRITE setBackColor)
|
Q_PROPERTY (QColor backColor READ backColor WRITE setBackColor)
|
||||||
Q_PROPERTY (double lineWidth READ lineWidth WRITE setLineWidth)
|
Q_PROPERTY (double lineWidth READ lineWidth WRITE setLineWidth)
|
||||||
@@ -167,9 +168,9 @@ public:
|
|||||||
void addObject(GLObjectBase * o);
|
void addObject(GLObjectBase * o);
|
||||||
void addObject(GLObjectBase & o) {addObject(&o);}
|
void addObject(GLObjectBase & o) {addObject(&o);}
|
||||||
int objectsCount(bool all = false) {if (!all) return objects_.childCount(); int cnt = 0; objectsCountInternal(&cnt, &objects_); return cnt;}
|
int objectsCount(bool all = false) {if (!all) return objects_.childCount(); int cnt = 0; objectsCountInternal(&cnt, &objects_); return cnt;}
|
||||||
void removeObject(GLObjectBase * o, bool inChildren = true) {if (inChildren) removeObjectInternal(o, &objects_); else objects_.removeChild(o);}
|
void removeObject(GLObjectBase * o, bool inChildren = true);
|
||||||
void removeObject(GLObjectBase & o, bool inChildren = true) {removeObject(&o, inChildren);}
|
void removeObject(GLObjectBase & o, bool inChildren = true) {removeObject(&o, inChildren);}
|
||||||
void clearObjects(bool deleteAll = false) {removeObject(camera_); objects_.clearChildren(deleteAll); addObject(camera()); sel_obj = hov_obj = 0;}
|
void clearObjects(bool deleteAll = false);
|
||||||
QList<GLObjectBase * > objects(bool all = false) {return objects_.children(all);}
|
QList<GLObjectBase * > objects(bool all = false) {return objects_.children(all);}
|
||||||
|
|
||||||
int lightsCount() const {return lights_.size();}
|
int lightsCount() const {return lights_.size();}
|
||||||
@@ -200,6 +201,7 @@ public:
|
|||||||
void setSelectionRectPen(const QPen & v) {sel_pen = v;}
|
void setSelectionRectPen(const QPen & v) {sel_pen = v;}
|
||||||
void setSelectionRectBrush(const QBrush & v) {sel_brush = v;}
|
void setSelectionRectBrush(const QBrush & v) {sel_brush = v;}
|
||||||
void selectObject(GLObjectBase * o);
|
void selectObject(GLObjectBase * o);
|
||||||
|
GLObjectBase * selectedObject() const {return sel_obj;}
|
||||||
|
|
||||||
GLdouble aspect, iaspect;
|
GLdouble aspect, iaspect;
|
||||||
QMatrix4x4 cur_mvpm;
|
QMatrix4x4 cur_mvpm;
|
||||||
@@ -229,9 +231,10 @@ protected:
|
|||||||
void collectLights();
|
void collectLights();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void objectDeleted(GLObjectBase * o);
|
||||||
void collectObjectLights(GLObjectBase * o);
|
void collectObjectLights(GLObjectBase * o);
|
||||||
void objectsCountInternal(int * cnt, GLObjectBase * where) {++(*cnt); foreach (GLObjectBase * i, where->children_) objectsCountInternal(cnt, i);}
|
void objectsCountInternal(int * cnt, GLObjectBase * where) {++(*cnt); foreach (GLObjectBase * i, where->children_) objectsCountInternal(cnt, i);}
|
||||||
void removeObjectInternal(GLObjectBase * o, GLObjectBase * where) {foreach (GLObjectBase * i, where->children_) {if (o == i) where->removeChild(i); else removeObjectInternal(o, i);}}
|
void removeObjectInternal(GLObjectBase * o, GLObjectBase * where);
|
||||||
void renderSingleSelection(GLObjectBase & o);
|
void renderSingleSelection(GLObjectBase & o);
|
||||||
//void renderSingleShadow(GLObjectBase & o);
|
//void renderSingleShadow(GLObjectBase & o);
|
||||||
void renderHalo(const GLObjectBase * obj, const int iid, const QColor & color, const double & fill);
|
void renderHalo(const GLObjectBase * obj, const int iid, const QColor & color, const double & fill);
|
||||||
@@ -306,6 +309,7 @@ public slots:
|
|||||||
void deselect() {sel_obj = 0;}
|
void deselect() {sel_obj = 0;}
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
void glBeforePaint();
|
||||||
void glBeginPaint();
|
void glBeginPaint();
|
||||||
void glPainting();
|
void glPainting();
|
||||||
void glEndPaint();
|
void glEndPaint();
|
||||||
@@ -323,6 +327,7 @@ signals:
|
|||||||
|
|
||||||
void hoverChanged(GLObjectBase * cur, GLObjectBase * prev);
|
void hoverChanged(GLObjectBase * cur, GLObjectBase * prev);
|
||||||
void selectionChanged(GLObjectBase * cur, GLObjectBase * prev);
|
void selectionChanged(GLObjectBase * cur, GLObjectBase * prev);
|
||||||
|
void objectAdded(GLObjectBase * );
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>1125</width>
|
<width>1125</width>
|
||||||
<height>905</height>
|
<height>1056</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
@@ -21,7 +21,16 @@
|
|||||||
<property name="spacing">
|
<property name="spacing">
|
||||||
<number>2</number>
|
<number>2</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="margin">
|
<property name="leftMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="topMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="rightMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="bottomMargin">
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<item>
|
<item>
|
||||||
@@ -44,7 +53,7 @@
|
|||||||
<item>
|
<item>
|
||||||
<widget class="QTabWidget" name="tabWidget">
|
<widget class="QTabWidget" name="tabWidget">
|
||||||
<property name="currentIndex">
|
<property name="currentIndex">
|
||||||
<number>0</number>
|
<number>1</number>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="tab">
|
<widget class="QWidget" name="tab">
|
||||||
<attribute name="title">
|
<attribute name="title">
|
||||||
@@ -1066,7 +1075,7 @@
|
|||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>1125</width>
|
<width>1125</width>
|
||||||
<height>26</height>
|
<height>24</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QMenu" name="menuFile">
|
<widget class="QMenu" name="menuFile">
|
||||||
@@ -1087,7 +1096,7 @@
|
|||||||
<widget class="QStatusBar" name="statusBar_"/>
|
<widget class="QStatusBar" name="statusBar_"/>
|
||||||
<action name="actionExit">
|
<action name="actionExit">
|
||||||
<property name="icon">
|
<property name="icon">
|
||||||
<iconset resource="qglview.qrc">
|
<iconset>
|
||||||
<normaloff>:/icons/application-exit.png</normaloff>:/icons/application-exit.png</iconset>
|
<normaloff>:/icons/application-exit.png</normaloff>:/icons/application-exit.png</iconset>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
@@ -1096,7 +1105,7 @@
|
|||||||
</action>
|
</action>
|
||||||
<action name="actionImport">
|
<action name="actionImport">
|
||||||
<property name="icon">
|
<property name="icon">
|
||||||
<iconset resource="qglview.qrc">
|
<iconset>
|
||||||
<normaloff>:/icons/document-import.png</normaloff>:/icons/document-import.png</iconset>
|
<normaloff>:/icons/document-import.png</normaloff>:/icons/document-import.png</iconset>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
@@ -1108,7 +1117,7 @@
|
|||||||
</action>
|
</action>
|
||||||
<action name="actionOpen">
|
<action name="actionOpen">
|
||||||
<property name="icon">
|
<property name="icon">
|
||||||
<iconset resource="qglview.qrc">
|
<iconset resource="../../../SM/src/SignalModelling/signalmodelling.qrc">
|
||||||
<normaloff>:/icons/document-open.png</normaloff>:/icons/document-open.png</iconset>
|
<normaloff>:/icons/document-open.png</normaloff>:/icons/document-open.png</iconset>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
@@ -1120,7 +1129,7 @@
|
|||||||
</action>
|
</action>
|
||||||
<action name="actionSave">
|
<action name="actionSave">
|
||||||
<property name="icon">
|
<property name="icon">
|
||||||
<iconset resource="qglview.qrc">
|
<iconset resource="../../../SM/src/SignalModelling/signalmodelling.qrc">
|
||||||
<normaloff>:/icons/document-save-all.png</normaloff>:/icons/document-save-all.png</iconset>
|
<normaloff>:/icons/document-save-all.png</normaloff>:/icons/document-save-all.png</iconset>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
@@ -1132,7 +1141,7 @@
|
|||||||
</action>
|
</action>
|
||||||
<action name="actionReset">
|
<action name="actionReset">
|
||||||
<property name="icon">
|
<property name="icon">
|
||||||
<iconset resource="qglview.qrc">
|
<iconset resource="../../../SM/src/SMBricks/SM_plugins/signal_process/icons.qrc">
|
||||||
<normaloff>:/icons/document-new.png</normaloff>:/icons/document-new.png</iconset>
|
<normaloff>:/icons/document-new.png</normaloff>:/icons/document-new.png</iconset>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
@@ -1144,7 +1153,7 @@
|
|||||||
</action>
|
</action>
|
||||||
<action name="actionSaveSelected">
|
<action name="actionSaveSelected">
|
||||||
<property name="icon">
|
<property name="icon">
|
||||||
<iconset resource="qglview.qrc">
|
<iconset resource="../../../SM/src/SMBricks/SM_plugins/signal_process/icons.qrc">
|
||||||
<normaloff>:/icons/document-save-.png</normaloff>:/icons/document-save-.png</iconset>
|
<normaloff>:/icons/document-save-.png</normaloff>:/icons/document-save-.png</iconset>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
@@ -1172,13 +1181,13 @@
|
|||||||
<customwidget>
|
<customwidget>
|
||||||
<class>QGLView</class>
|
<class>QGLView</class>
|
||||||
<extends>QWidget</extends>
|
<extends>QWidget</extends>
|
||||||
<header>qglview.h</header>
|
<header location="global">qglview.h</header>
|
||||||
<container>1</container>
|
<container>1</container>
|
||||||
</customwidget>
|
</customwidget>
|
||||||
<customwidget>
|
<customwidget>
|
||||||
<class>MaterialEditor</class>
|
<class>MaterialEditor</class>
|
||||||
<extends>QWidget</extends>
|
<extends>QWidget</extends>
|
||||||
<header>material_editor.h</header>
|
<header location="global">material_editor.h</header>
|
||||||
<container>1</container>
|
<container>1</container>
|
||||||
</customwidget>
|
</customwidget>
|
||||||
<customwidget>
|
<customwidget>
|
||||||
@@ -1193,8 +1202,6 @@
|
|||||||
<header>propertyeditor.h</header>
|
<header>propertyeditor.h</header>
|
||||||
</customwidget>
|
</customwidget>
|
||||||
</customwidgets>
|
</customwidgets>
|
||||||
<resources>
|
<resources/>
|
||||||
<include location="qglview.qrc"/>
|
|
||||||
</resources>
|
|
||||||
<connections/>
|
<connections/>
|
||||||
</ui>
|
</ui>
|
||||||
|
|||||||
@@ -29,11 +29,11 @@ public:
|
|||||||
virtual ~RendererDeferredShading();
|
virtual ~RendererDeferredShading();
|
||||||
|
|
||||||
virtual void renderScene();
|
virtual void renderScene();
|
||||||
|
|
||||||
protected:
|
|
||||||
void init(int width, int height);
|
void init(int width, int height);
|
||||||
void resize(int width, int height);
|
void resize(int width, int height);
|
||||||
void reloadShaders();
|
void reloadShaders();
|
||||||
|
|
||||||
|
protected:
|
||||||
void setupShadersTextures(GLObjectBase & object, RenderingParameters & rp);
|
void setupShadersTextures(GLObjectBase & object, RenderingParameters & rp);
|
||||||
void setupShadersLights(int lights_count) {cplc = lights_count;}
|
void setupShadersLights(int lights_count) {cplc = lights_count;}
|
||||||
void setupDSLights(int pass, const QMatrix4x4 & view_matrix);
|
void setupDSLights(int pass, const QMatrix4x4 & view_matrix);
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ void RendererSimple::renderScene() {
|
|||||||
glDepthMask(GL_FALSE);
|
glDepthMask(GL_FALSE);
|
||||||
glDepthFunc(GL_EQUAL);
|
glDepthFunc(GL_EQUAL);
|
||||||
}
|
}
|
||||||
view.camera().apply(view.aspect);
|
//view.camera().apply(view.aspect);
|
||||||
rp.cam_offset_matrix = view.camera().offsetMatrix();
|
rp.cam_offset_matrix = view.camera().offsetMatrix();
|
||||||
rp.prepare();
|
rp.prepare();
|
||||||
setupLights(l, 8);
|
setupLights(l, 8);
|
||||||
|
|||||||
@@ -28,19 +28,19 @@ public:
|
|||||||
virtual ~RendererSimple() {if (shader_fxaa != 0) delete shader_fxaa;}
|
virtual ~RendererSimple() {if (shader_fxaa != 0) delete shader_fxaa;}
|
||||||
|
|
||||||
virtual void renderScene();
|
virtual void renderScene();
|
||||||
|
virtual void reloadShaders();
|
||||||
QPoint mpos;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
virtual void init(int width, int height) {resizeFBO(width, height);}
|
virtual void init(int width, int height) {resizeFBO(width, height);}
|
||||||
virtual void resize(int width, int height) {resizeFBO(width, height);}
|
virtual void resize(int width, int height) {resizeFBO(width, height);}
|
||||||
virtual void reloadShaders();
|
|
||||||
|
QPoint mpos;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void resizeFBO(int w, int h);
|
void resizeFBO(int w, int h);
|
||||||
|
|
||||||
GLFramebuffer fbo , fbo_c;
|
GLFramebuffer fbo, fbo_c;
|
||||||
__GLShaderProgram__ * shader_fxaa , * shader;
|
__GLShaderProgram__ * shader_fxaa, * shader;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user