git-svn-id: svn://db.shs.com.ru/libs@544 a8b55f48-bf90-11e4-a774-851b48703e85

This commit is contained in:
2019-06-05 08:22:01 +00:00
parent e5e1cf2c24
commit 3044caff92
10 changed files with 112 additions and 84 deletions

View File

@@ -173,7 +173,7 @@ void GLTextureManagerBase::convertToNormal(QImage & im) {
sum[1] /= wh; sum[1] /= wh;
sum[2] /= wh; sum[2] /= wh;
qDebug() << sum[0] << sum[1] << sum[2]; qDebug() << sum[0] << sum[1] << sum[2];
if ((qAbs(sum[0]) <= 0.05f) && (qAbs(sum[1]) <= 0.05f) && (sum[2] >= 0.4f)) /// already normal if ((qAbs(sum[0]) <= 0.05f) && (qAbs(sum[1]) <= 0.05f) && (sum[2] >= 0.25f)) /// already normal
return; return;
qDebug() << "convert to bump"; qDebug() << "convert to bump";
QImage dim = QImage(sim.width(), sim.height(), QImage::Format_ARGB32); QImage dim = QImage(sim.width(), sim.height(), QImage::Format_ARGB32);

View File

@@ -22,7 +22,7 @@
#include <QPainter> #include <QPainter>
//__GLWidget__ * currentQGLView; //__GLWidget__ * currentQGLView;
QMutex globMutex; //QMutex globMutex;
QString readCharsUntilNull(QDataStream & s) { QString readCharsUntilNull(QDataStream & s) {

View File

@@ -141,8 +141,8 @@ inline float urand(const float & scale = 1.) {return ((float)rand() / RAND_MAX -
inline float uprand(const float & scale = 1.) {return ((float)rand() / RAND_MAX) * scale;} inline float uprand(const float & scale = 1.) {return ((float)rand() / RAND_MAX) * scale;}
QString readCharsUntilNull(QDataStream & s); QString readCharsUntilNull(QDataStream & s);
QString findFile(const QString & file, const QStringList & pathes); QString findFile(const QString & file, const QStringList & pathes);
inline QColor operator *(const QColor & c, float v) {return QColor(c.red() * v, c.green() * v, c.blue() * v, c.alpha() * v);} inline QColor operator *(const QColor & c, float v) {return QColor(piClamp<int>(c.red() * v, 0, 255), piClamp<int>(c.green() * v, 0, 255), piClamp<int>(c.blue() * v, 0, 255), piClamp<int>(c.alpha() * v, 0, 255));}
inline QColor operator /(const QColor & c, float v) {return QColor(c.red() / v, c.green() / v, c.blue() / v, c.alpha() / v);} inline QColor operator /(const QColor & c, float v) {return QColor(piClamp<int>(c.red() / v, 0, 255), piClamp<int>(c.green() / v, 0, 255), piClamp<int>(c.blue() / v, 0, 255), piClamp<int>(c.alpha() / v, 0, 255));}
//extern __GLWidget__ * currentQGLView; //extern __GLWidget__ * currentQGLView;

View File

@@ -153,15 +153,11 @@ QVector<Material> LoaderDAE::readMaterials(QDomElement le, QDomElement li, bool
if (!text.isEmpty()) mat.map_normal.bitmap_path = text; if (!text.isEmpty()) mat.map_normal.bitmap_path = text;
ret << mat; ret << mat;
/*
qDebug() << "** Material" << mat.name; qDebug() << "** Material" << mat.name;
qDebug() << " emission" << mat.color_self_illumination; qDebug() << " emission" << mat.color_self_illumination;
qDebug() << " diffuse" << mat.color_diffuse; qDebug() << " diffuse" << mat.color_diffuse;
qDebug() << " diffuse" << mat.diffuse.bitmap_path;
qDebug() << " specular" << mat.color_specular; qDebug() << " specular" << mat.color_specular;
qDebug() << " bump" << mat.bump.bitmap_path;
qDebug() << " transparency" << mat.transparency; qDebug() << " transparency" << mat.transparency;
*/
} }
return ret; return ret;
} }
@@ -318,7 +314,7 @@ GLObjectBase * loadFromDAEFile(const QString & filepath, float scale) {
co->setName(name + "_" + QString::number(j)); co->setName(name + "_" + QString::number(j));
//co->setTransform(m); //co->setTransform(m);
co->material() = LoaderDAE::materialByName(materials, matname); co->material() = LoaderDAE::materialByName(materials, matname);
//qDebug() << " tri" << co->material().color_diffuse << matname; qDebug() << " tri" << co->material().name << matname;
QVector<GLfloat> & vertices(co->VBO().vertices()), & normals(co->VBO().normals()), & uvs(co->VBO().texcoords()); QVector<GLfloat> & vertices(co->VBO().vertices()), & normals(co->VBO().normals()), & uvs(co->VBO().texcoords());
for (int k = 0; k < einp.count(); ++k) { for (int k = 0; k < einp.count(); ++k) {
QDomElement di = einp.at(k).toElement(); QDomElement di = einp.at(k).toElement();
@@ -366,6 +362,7 @@ GLObjectBase * loadFromDAEFile(const QString & filepath, float scale) {
if (!ml.isEmpty()) lo->intensity = ml.at(0).firstChild().nodeValue().toFloat(); if (!ml.isEmpty()) lo->intensity = ml.at(0).firstChild().nodeValue().toFloat();
ml = dn.elementsByTagName("intensity"); ml = dn.elementsByTagName("intensity");
if (!ml.isEmpty()) lo->intensity = ml.at(0).firstChild().nodeValue().toFloat(); if (!ml.isEmpty()) lo->intensity = ml.at(0).firstChild().nodeValue().toFloat();
lo->setColor(lo->color() / lo->intensity);
QString sv; QString sv;
sv = dl.firstChildElement("constant_attenuation").firstChild().nodeValue(); if (!sv.isEmpty()) lo->decay_const = sv.toFloat(); sv = dl.firstChildElement("constant_attenuation").firstChild().nodeValue(); if (!sv.isEmpty()) lo->decay_const = sv.toFloat();
sv = dl.firstChildElement("linear_attenuation").firstChild().nodeValue(); if (!sv.isEmpty()) lo->decay_linear = sv.toFloat(); sv = dl.firstChildElement("linear_attenuation").firstChild().nodeValue(); if (!sv.isEmpty()) lo->decay_linear = sv.toFloat();

View File

@@ -23,7 +23,7 @@ OpenGLWindow::OpenGLWindow(QWindow *parent)
} }
#endif #endif
format.setDepthBufferSize(24); format.setDepthBufferSize(24);
// format.setSamples(4); format.setSamples(8);
// format.setStencilBufferSize(8); // format.setStencilBufferSize(8);
setFormat(format); setFormat(format);
QSurfaceFormat::setDefaultFormat(format); QSurfaceFormat::setDefaultFormat(format);

View File

@@ -121,6 +121,7 @@ GLRendererBase * QGLView::renderer() {
return renderer_; return renderer_;
} }
void QGLView::setRenderer(GLRendererBase * r, GLRendererBase ** prev) { void QGLView::setRenderer(GLRendererBase * r, GLRendererBase ** prev) {
if (prev != nullptr) *prev = renderer_; if (prev != nullptr) *prev = renderer_;
renderer_ = r; renderer_ = r;
@@ -235,9 +236,7 @@ void QGLView::selectObject(GLObjectBase * o) {
void QGLView::resizeEvent(QResizeEvent * e) { void QGLView::resizeEvent(QResizeEvent * e) {
// if (isExposed()) renderLater();
// resizeGL(width(), height());
/* QWindow::resizeEvent(e);*/
} }
void QGLView::timerEvent(QTimerEvent *) { void QGLView::timerEvent(QTimerEvent *) {
@@ -509,6 +508,8 @@ void QGLView::renderSingleSelection(GLObjectBase & o) {
QMatrix4x4 curview = start_rp.view_matrix * start_rp.cam_offset_matrix * o.itransform_; QMatrix4x4 curview = start_rp.view_matrix * start_rp.cam_offset_matrix * o.itransform_;
uint id = qHash((quint64)&o); uint id = qHash((quint64)&o);
ids.insert(id, &o); ids.insert(id, &o);
glLineWidth(o.line_width > 0.f ? o.line_width : lineWidth_);
glPointSize(o.line_width > 0.f ? o.line_width : lineWidth_);
if (shaders_supported){ if (shaders_supported){
if (shader_select) { if (shader_select) {
if (shader_select->isLinked()) { if (shader_select->isLinked()) {
@@ -620,11 +621,13 @@ void QGLView::applyFog() {
void QGLView::resizeGL(int width, int height) { void QGLView::resizeGL(int width, int height) {
if (!is_init) return; if (!is_init) return;
if (width <= 0 || height <= 0) return; if (width <= 0 || height <= 0) return;
if (prev_size == QSize(width, height)) return;
prev_size = QSize(width, height);
aspect = float(width) / float(height); aspect = float(width) / float(height);
if (renderer_) renderer_->resize(width, height); if (renderer_) renderer_->resize(width, height);
mouse_first = true;
//qDebug() << "resize" << width << height; //qDebug() << "resize" << width << height;
fbo_selection.resize(width, height); fbo_selection.resize(width, height);
mouse_first = true;
iaspect = (aspect == 0.f) ? 0. : 1 / aspect; iaspect = (aspect == 0.f) ? 0. : 1 / aspect;
glViewport(0, 0, width, height); glViewport(0, 0, width, height);
emit glResize(width, height); emit glResize(width, height);
@@ -632,6 +635,7 @@ void QGLView::resizeGL(int width, int height) {
void QGLView::mouseReleaseEvent(QMouseEvent * e) { void QGLView::mouseReleaseEvent(QMouseEvent * e) {
// qDebug() << "mouseReleaseEvent" << e << isActive();
// QGraphicsView::mouseReleaseEvent(e); // QGraphicsView::mouseReleaseEvent(e);
//setCursor(QCursor(Qt::ArrowCursor)); //setCursor(QCursor(Qt::ArrowCursor));
selecting_ = false; selecting_ = false;
@@ -646,6 +650,7 @@ void QGLView::mouseReleaseEvent(QMouseEvent * e) {
void QGLView::mousePressEvent(QMouseEvent * e) { void QGLView::mousePressEvent(QMouseEvent * e) {
// qDebug() << "mousePressEvent" << e << isActive();
// QGraphicsView::mousePressEvent(e); // QGraphicsView::mousePressEvent(e);
// mouseThis_ = (scene()->itemAt(mapToScene(e->pos()) , QTransform() ) == 0); // mouseThis_ = (scene()->itemAt(mapToScene(e->pos()) , QTransform() ) == 0);
selecting_ = false; selecting_ = false;
@@ -661,13 +666,13 @@ void QGLView::mousePressEvent(QMouseEvent * e) {
void QGLView::mouseMoveEvent(QMouseEvent * e) { void QGLView::mouseMoveEvent(QMouseEvent * e) {
// qDebug() << e->pos(); // qDebug() << "mouseMoveEvent" << e << isActive();
// QGraphicsView::mouseMoveEvent(e); // QGraphicsView::mouseMoveEvent(e);
//lastPos = e->pos(); //lastPos = e->pos();
if (selecting_) { if (selecting_) {
return; return;
} }
// if (!QRect(QPoint(), size()).contains(e->pos())) return;
//if (scene()->itemAt(mapToScene(e->pos())) != 0) return; //if (scene()->itemAt(mapToScene(e->pos())) != 0) return;
///qDebug() << e->x() << e->y(); ///qDebug() << e->x() << e->y();
QRect g_rect(QPoint(), size()); QRect g_rect(QPoint(), size());

View File

@@ -99,7 +99,7 @@ public:
Q_ENUMS (SelectionMode) Q_ENUMS (SelectionMode)
void stop(); void stop();
void start(float freq = 40.); void start(float freq = 60.);
GLRendererBase * renderer(); GLRendererBase * renderer();
void setRenderer(GLRendererBase * r, GLRendererBase ** prev = nullptr); void setRenderer(GLRendererBase * r, GLRendererBase ** prev = nullptr);
@@ -232,6 +232,7 @@ private:
Qt::KeyboardModifier sel_mod; Qt::KeyboardModifier sel_mod;
GLRendererBase::RenderingParameters start_rp; GLRendererBase::RenderingParameters start_rp;
QHash<int, QVariant> features_; QHash<int, QVariant> features_;
QSize prev_size;
float lineWidth_; float lineWidth_;
float fogDensity_, fogStart_, fogEnd_, fps_, fps_tm, hoverHaloFill_, selectionHaloFill_, m_motionBlurFactor; float fogDensity_, fogStart_, fogEnd_, fps_, fps_tm, hoverHaloFill_, selectionHaloFill_, m_motionBlurFactor;
int timer, fps_cnt, sh_id_loc; int timer, fps_cnt, sh_id_loc;

View File

@@ -335,3 +335,4 @@ void QGLViewWindow::on_pushButton_3_clicked() {
} }
} }

View File

@@ -88,6 +88,7 @@ private slots:
void on_colorBack_colorChanged(QColor color) {view->view()->setBackColor(color);} void on_colorBack_colorChanged(QColor color) {view->view()->setBackColor(color);}
void on_colorAmbient_colorChanged(QColor color) {view->view()->setAmbientColor(color);} void on_colorAmbient_colorChanged(QColor color) {view->view()->setAmbientColor(color);}
void on_checkCameraOrbit_clicked(bool val) {view->view()->setCameraOrbit(val);} void on_checkCameraOrbit_clicked(bool val) {view->view()->setCameraOrbit(val);}
void on_spinViewLineWidth_valueChanged(double val) {view->view()->setLineWidth(val);}
void on_groupShadows_clicked(bool val) {view->view()->setFeature(QGLView::qglShadowsEnabled, val);} void on_groupShadows_clicked(bool val) {view->view()->setFeature(QGLView::qglShadowsEnabled, val);}
void on_groupEyeAccomodation_clicked(bool val) {view->view()->setFeature(QGLView::qglEyeAccomodationEnabled, val);} void on_groupEyeAccomodation_clicked(bool val) {view->view()->setFeature(QGLView::qglEyeAccomodationEnabled, val);}

View File

@@ -53,7 +53,7 @@
<item> <item>
<widget class="QTabWidget" name="tabWidget"> <widget class="QTabWidget" name="tabWidget">
<property name="currentIndex"> <property name="currentIndex">
<number>1</number> <number>0</number>
</property> </property>
<widget class="QWidget" name="tab"> <widget class="QWidget" name="tab">
<attribute name="title"> <attribute name="title">
@@ -96,6 +96,56 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Depth</string>
</property>
</widget>
</item>
<item row="1" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="spacing">
<number>0</number>
</property>
<item>
<widget class="QDoubleSpinBox" name="spinDepthStart">
<property name="decimals">
<number>3</number>
</property>
<property name="maximum">
<double>999999999.000000000000000</double>
</property>
<property name="value">
<double>1.000000000000000</double>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_6">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string> - </string>
</property>
</widget>
</item>
<item>
<widget class="QDoubleSpinBox" name="spinDepthEnd">
<property name="decimals">
<number>3</number>
</property>
<property name="maximum">
<double>999999999.000000000000000</double>
</property>
</widget>
</item>
</layout>
</item>
<item row="2" column="0"> <item row="2" column="0">
<widget class="QLabel" name="label_2"> <widget class="QLabel" name="label_2">
<property name="text"> <property name="text">
@@ -154,6 +204,24 @@
</item> </item>
</widget> </widget>
</item> </item>
<item row="4" column="0">
<widget class="QLabel" name="label_8">
<property name="text">
<string>Back color</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="ColorButton" name="colorBack">
<property name="color">
<color>
<red>10</red>
<green>10</green>
<blue>10</blue>
</color>
</property>
</widget>
</item>
<item row="5" column="0"> <item row="5" column="0">
<widget class="QLabel" name="label_7"> <widget class="QLabel" name="label_7">
<property name="text"> <property name="text">
@@ -172,21 +240,21 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="6" column="0" colspan="2"> <item row="7" column="0" colspan="2">
<widget class="QCheckBox" name="checkMSAA"> <widget class="QCheckBox" name="checkMSAA">
<property name="text"> <property name="text">
<string>MSAA</string> <string>MSAA</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="7" column="0" colspan="2"> <item row="8" column="0" colspan="2">
<widget class="QCheckBox" name="checkFXAA"> <widget class="QCheckBox" name="checkFXAA">
<property name="text"> <property name="text">
<string>FXAA</string> <string>FXAA</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="8" column="0" colspan="2"> <item row="9" column="0" colspan="2">
<widget class="QGroupBox" name="groupHoverHalo"> <widget class="QGroupBox" name="groupHoverHalo">
<property name="title"> <property name="title">
<string>Hover halo</string> <string>Hover halo</string>
@@ -241,7 +309,7 @@
</layout> </layout>
</widget> </widget>
</item> </item>
<item row="9" column="0" colspan="2"> <item row="10" column="0" colspan="2">
<widget class="QGroupBox" name="groupSelectionHalo"> <widget class="QGroupBox" name="groupSelectionHalo">
<property name="title"> <property name="title">
<string>Selection halo</string> <string>Selection halo</string>
@@ -296,7 +364,7 @@
</layout> </layout>
</widget> </widget>
</item> </item>
<item row="10" column="0" colspan="2"> <item row="11" column="0" colspan="2">
<widget class="QGroupBox" name="groupCamera"> <widget class="QGroupBox" name="groupCamera">
<property name="title"> <property name="title">
<string>Camera</string> <string>Camera</string>
@@ -322,71 +390,26 @@
</layout> </layout>
</widget> </widget>
</item> </item>
<item row="1" column="0"> <item row="6" column="1">
<widget class="QLabel" name="label_5"> <widget class="QDoubleSpinBox" name="spinViewLineWidth">
<property name="text"> <property name="minimum">
<string>Depth</string> <double>0.000000000000000</double>
</property>
<property name="maximum">
<double>99999.000000000000000</double>
</property>
<property name="singleStep">
<double>0.100000000000000</double>
</property>
<property name="value">
<double>1.000000000000000</double>
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="1"> <item row="6" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_2"> <widget class="QLabel" name="label_22">
<property name="spacing">
<number>0</number>
</property>
<item>
<widget class="QDoubleSpinBox" name="spinDepthStart">
<property name="decimals">
<number>3</number>
</property>
<property name="maximum">
<double>999999999.000000000000000</double>
</property>
<property name="value">
<double>1.000000000000000</double>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_6">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string> - </string>
</property>
</widget>
</item>
<item>
<widget class="QDoubleSpinBox" name="spinDepthEnd">
<property name="decimals">
<number>3</number>
</property>
<property name="maximum">
<double>999999999.000000000000000</double>
</property>
</widget>
</item>
</layout>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_8">
<property name="text"> <property name="text">
<string>Back color</string> <string>Line width</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="ColorButton" name="colorBack">
<property name="color">
<color>
<red>10</red>
<green>10</green>
<blue>10</blue>
</color>
</property> </property>
</widget> </widget>
</item> </item>