git-svn-id: svn://db.shs.com.ru/libs@75 a8b55f48-bf90-11e4-a774-851b48703e85
This commit is contained in:
@@ -754,11 +754,11 @@ void KX_Pult::progress(int val, int max) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void KX_Pult::renew() {
|
void KX_Pult::renew(bool write) {
|
||||||
addToList(trUtf8("Update settings from \"%1\"").arg(PI2QString(config_)), Qt::darkMagenta);
|
addToList(trUtf8("Update settings from \"%1\"").arg(PI2QString(config_)), Qt::darkMagenta);
|
||||||
dir.setPath(config.getValue("x.output_dir", "./Experiments/").stringValue());
|
dir.setPath(config.getValue("x.output_dir", "./Experiments/").stringValue());
|
||||||
setWindowTitle(config.getValue("title", "Noname").stringValue() + trUtf8(" - KX Pult"));
|
setWindowTitle(config.getValue("title", "Noname").stringValue() + trUtf8(" - KX Pult"));
|
||||||
ui->configWidget->write();
|
//if (write) ui->configWidget->write();
|
||||||
if (prot_x != 0) {
|
if (prot_x != 0) {
|
||||||
prot_x->stop();
|
prot_x->stop();
|
||||||
delete prot_x;
|
delete prot_x;
|
||||||
|
|||||||
@@ -122,7 +122,7 @@ private slots:
|
|||||||
void updateTree(bool move = false);
|
void updateTree(bool move = false);
|
||||||
void filterTree();
|
void filterTree();
|
||||||
void calculate();
|
void calculate();
|
||||||
void renew();
|
void renew(bool write = true);
|
||||||
void toggledX(int index, bool on);
|
void toggledX(int index, bool on);
|
||||||
void changedX(int index, int num);
|
void changedX(int index, int num);
|
||||||
void k_sendFailed();
|
void k_sendFailed();
|
||||||
|
|||||||
@@ -1244,13 +1244,13 @@ void Graphic::tick(int index, bool slide, bool update_) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!update_) {
|
if (!update_) {
|
||||||
findGraphicsRect();
|
if (isFit) findGraphicsRect();
|
||||||
mutex.unlock();
|
mutex.unlock();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//polyline.push_back(QPointF(brick->time_, brick->output(port)));
|
//polyline.push_back(QPointF(brick->time_, brick->output(port)));
|
||||||
//cout << polyline.size() << endl;
|
//cout << polyline.size() << endl;
|
||||||
findGraphicsRect();
|
if (isFit) findGraphicsRect();
|
||||||
if (!slide) {
|
if (!slide) {
|
||||||
if (aupdate) update();
|
if (aupdate) update();
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
#include "qpiconfig.h"
|
#include "qpiconfig.h"
|
||||||
|
#include <QFileInfo>
|
||||||
|
#include <QDir>
|
||||||
|
|
||||||
|
|
||||||
int QString2int(const QString & string) {
|
int QString2int(const QString & string) {
|
||||||
@@ -272,8 +274,50 @@ QPIConfig::QPIConfig(QString * str, QPIConfig::FileType type_) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QPIConfig::QPIConfig(const QString & path, QStringList dirs) {
|
||||||
|
init();
|
||||||
|
type = Config;
|
||||||
|
internal = true;
|
||||||
|
dev = new QFile(path);
|
||||||
|
dev->open(QIODevice::ReadOnly);
|
||||||
|
incdirs = dirs;
|
||||||
|
incdirs << QFileInfo(path).absoluteDir().path();
|
||||||
|
QString cp = path;
|
||||||
|
while (!dev->isOpen()) {
|
||||||
|
if (dirs.isEmpty()) break;
|
||||||
|
cp = dirs.back();
|
||||||
|
if (cp.endsWith("/") || cp.endsWith("\\")) cp.chop(1);
|
||||||
|
cp += "/" + path;
|
||||||
|
dev->setFileName(cp);
|
||||||
|
dev->open(QIODevice::ReadOnly);
|
||||||
|
dirs.pop_back();
|
||||||
|
}
|
||||||
|
if (!dev->isOpen()) {
|
||||||
|
delete dev;
|
||||||
|
dev = 0;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
dev->close();
|
||||||
|
setFileName(cp);
|
||||||
|
open(QIODevice::ReadOnly);
|
||||||
|
parse();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QPIConfig::~QPIConfig() {
|
||||||
|
stream.setDevice(0);
|
||||||
|
root.deleteBranch();
|
||||||
|
foreach (QPIConfig * c, inc_devs)
|
||||||
|
delete c;
|
||||||
|
inc_devs.clear();
|
||||||
|
includes.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void QPIConfig::init() {
|
void QPIConfig::init() {
|
||||||
|
internal = false;
|
||||||
buffer = 0;
|
buffer = 0;
|
||||||
|
dev = 0;
|
||||||
delim = ".";
|
delim = ".";
|
||||||
root._name = "root";
|
root._name = "root";
|
||||||
root.delim = delim;
|
root.delim = delim;
|
||||||
@@ -544,6 +588,22 @@ void QPIConfig::writeAll() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QString QPIConfig::getPrefixFromLine(QString line, bool * exists) {
|
||||||
|
line = line.trimmed();
|
||||||
|
if (line.left(1) == "#") {if (exists) *exists = false; return QString();}
|
||||||
|
int ci = line.indexOf("#");
|
||||||
|
if (ci >= 0) line = line.left(ci).trimmed();
|
||||||
|
if (line.indexOf("=") >= 0) {if (exists) *exists = false; return QString();}
|
||||||
|
if (line.indexOf("[") >= 0 && line.indexOf("]") >= 0) {
|
||||||
|
if (exists) *exists = true;
|
||||||
|
line.remove(0, 1);
|
||||||
|
return line.left(line.lastIndexOf("]")).trimmed();
|
||||||
|
}
|
||||||
|
if (exists) *exists = false;
|
||||||
|
return QString();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
QString QPIConfig::writeAllToString() {
|
QString QPIConfig::writeAllToString() {
|
||||||
QString str;
|
QString str;
|
||||||
QTextStream s(&str);
|
QTextStream s(&str);
|
||||||
@@ -606,14 +666,47 @@ bool QPIConfig::entryExists(const Entry * e, const QString & name) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void QPIConfig::updateIncludes() {
|
||||||
|
if (internal) return;
|
||||||
|
all_includes.clear();
|
||||||
|
foreach (QPIConfig * c, includes)
|
||||||
|
all_includes << c->allLeaves();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QString QPIConfig::entryValue(QString v) {
|
||||||
|
int i = -1, l = 0;
|
||||||
|
while (1) {
|
||||||
|
i = v.indexOf("${");
|
||||||
|
if (i < 0) break;
|
||||||
|
l = v.indexOf("}", i + 1);
|
||||||
|
QString w = v.mid(i + 2, l - i - 2), r;
|
||||||
|
l = w.length() + 3;
|
||||||
|
w = w.trimmed();
|
||||||
|
foreach (QPIConfig::Entry * e, all_includes) {
|
||||||
|
if (e->_full_name == w) {
|
||||||
|
r = e->_value;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
v.replace(i, l, r);
|
||||||
|
}
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void QPIConfig::parse(QString content) {
|
void QPIConfig::parse(QString content) {
|
||||||
root.deleteBranch();
|
root.deleteBranch();
|
||||||
root.clear();
|
root.clear();
|
||||||
QString src, str, tab, comm, all, name, type;
|
QString src, str, tab, comm, all, name, type, prefix, tprefix;
|
||||||
QStringList tree;
|
QStringList tree;
|
||||||
Entry * entry, * te, * ce;
|
Entry * entry, * te, * ce;
|
||||||
int ind, sind;
|
int ind, sind;
|
||||||
bool isNew;
|
bool isNew, isPrefix;
|
||||||
|
foreach (QPIConfig * c, inc_devs)
|
||||||
|
delete c;
|
||||||
|
inc_devs.clear();
|
||||||
|
includes.clear();
|
||||||
if (content.isEmpty()) {
|
if (content.isEmpty()) {
|
||||||
if (buffer == 0) {
|
if (buffer == 0) {
|
||||||
if (!isOpen()) return;
|
if (!isOpen()) return;
|
||||||
@@ -629,6 +722,12 @@ void QPIConfig::parse(QString content) {
|
|||||||
while (!stream.atEnd()) {
|
while (!stream.atEnd()) {
|
||||||
other.push_back(QString());
|
other.push_back(QString());
|
||||||
src = str = stream.readLine();
|
src = str = stream.readLine();
|
||||||
|
tprefix = getPrefixFromLine(src, &isPrefix);
|
||||||
|
if (isPrefix) {
|
||||||
|
prefix = tprefix;
|
||||||
|
if (!prefix.isEmpty())
|
||||||
|
prefix += delim;
|
||||||
|
}
|
||||||
//cout << str << endl;
|
//cout << str << endl;
|
||||||
tab = str.left(str.indexOf(str.trimmed().left(1)));
|
tab = str.left(str.indexOf(str.trimmed().left(1)));
|
||||||
str = str.trimmed();
|
str = str.trimmed();
|
||||||
@@ -647,44 +746,59 @@ void QPIConfig::parse(QString content) {
|
|||||||
comm = "";
|
comm = "";
|
||||||
}
|
}
|
||||||
//name = str.left(ind).trimmed();
|
//name = str.left(ind).trimmed();
|
||||||
tree = str.left(ind).trimmed().split(delim);
|
tree = (prefix + str.left(ind).trimmed()).split(delim);
|
||||||
name = tree.back();
|
if (tree.front() == "include") {
|
||||||
tree.pop_back();
|
name = str.right(str.length() - ind - 1).trimmed();
|
||||||
entry = &root;
|
QPIConfig * iconf = new QPIConfig(name, incdirs);
|
||||||
foreach (QString i, tree) {
|
if (!iconf->dev) {
|
||||||
te = entry->findChild(i);
|
delete iconf;
|
||||||
if (te == 0) {
|
} else {
|
||||||
|
inc_devs << iconf;
|
||||||
|
includes << iconf << iconf->includes;
|
||||||
|
updateIncludes();
|
||||||
|
}
|
||||||
|
//piCout << "includes" << includes;
|
||||||
|
other.back() = src;
|
||||||
|
} else {
|
||||||
|
name = tree.back();
|
||||||
|
tree.pop_back();
|
||||||
|
entry = &root;
|
||||||
|
foreach (QString i, tree) {
|
||||||
|
te = entry->findChild(i);
|
||||||
|
if (te == 0) {
|
||||||
|
ce = new Entry();
|
||||||
|
ce->delim = delim;
|
||||||
|
ce->_tab = tab;
|
||||||
|
ce->_line = lines;
|
||||||
|
ce->_name = i;
|
||||||
|
ce->_parent = entry;
|
||||||
|
entry->_children << ce;
|
||||||
|
entry = ce;
|
||||||
|
} else entry = te;
|
||||||
|
}
|
||||||
|
isNew = false;
|
||||||
|
ce = entry->findChild(name);
|
||||||
|
if (ce == 0) {
|
||||||
ce = new Entry();
|
ce = new Entry();
|
||||||
ce->delim = delim;
|
isNew = true;
|
||||||
ce->_tab = tab;
|
}
|
||||||
ce->_line = lines;
|
ce->delim = delim;
|
||||||
ce->_name = i;
|
ce->_tab = tab;
|
||||||
|
ce->_name = name;
|
||||||
|
ce->_value = entryValue(str.right(str.length() - ind - 1).trimmed());
|
||||||
|
ce->_type = type;
|
||||||
|
ce->_comment = comm;
|
||||||
|
ce->_line = lines;
|
||||||
|
ce->_all = all;
|
||||||
|
if (isNew) {
|
||||||
ce->_parent = entry;
|
ce->_parent = entry;
|
||||||
entry->_children << ce;
|
entry->_children << ce;
|
||||||
entry = ce;
|
}
|
||||||
} else entry = te;
|
|
||||||
}
|
|
||||||
isNew = false;
|
|
||||||
ce = entry->findChild(name);
|
|
||||||
if (ce == 0) {
|
|
||||||
ce = new Entry();
|
|
||||||
isNew = true;
|
|
||||||
}
|
|
||||||
ce->delim = delim;
|
|
||||||
ce->_tab = tab;
|
|
||||||
ce->_name = name;
|
|
||||||
ce->_value = str.right(str.length() - ind - 1).trimmed();
|
|
||||||
ce->_type = type;
|
|
||||||
ce->_comment = comm;
|
|
||||||
ce->_line = lines;
|
|
||||||
ce->_all = all;
|
|
||||||
if (isNew) {
|
|
||||||
ce->_parent = entry;
|
|
||||||
entry->_children << ce;
|
|
||||||
}
|
}
|
||||||
} else other.back() = src;
|
} else other.back() = src;
|
||||||
lines++;
|
lines++;
|
||||||
}
|
}
|
||||||
setEntryDelim(&root, delim);
|
setEntryDelim(&root, delim);
|
||||||
|
buildFullNames(&root);
|
||||||
//if (content.isEmpty()) stream.setDevice(this);
|
//if (content.isEmpty()) stream.setDevice(this);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ public:
|
|||||||
QPIConfig(const QString & path, QIODevice::OpenMode mode = QIODevice::ReadWrite);
|
QPIConfig(const QString & path, QIODevice::OpenMode mode = QIODevice::ReadWrite);
|
||||||
QPIConfig(const QString & path, QPIConfig::FileType type);
|
QPIConfig(const QString & path, QPIConfig::FileType type);
|
||||||
QPIConfig(QString * str, QPIConfig::FileType type = QPIConfig::Config);
|
QPIConfig(QString * str, QPIConfig::FileType type = QPIConfig::Config);
|
||||||
~QPIConfig() {stream.setDevice(0); root.deleteBranch();}
|
~QPIConfig();
|
||||||
|
|
||||||
void setFile(const QString & path, QIODevice::OpenMode mode = QIODevice::ReadWrite);
|
void setFile(const QString & path, QIODevice::OpenMode mode = QIODevice::ReadWrite);
|
||||||
void setString(QString * str);
|
void setString(QString * str);
|
||||||
@@ -248,6 +248,7 @@ public:
|
|||||||
void setDelimiter(const QString & d) {delim = d; setEntryDelim(&root, d); readAll();}
|
void setDelimiter(const QString & d) {delim = d; setEntryDelim(&root, d); readAll();}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
QPIConfig(const QString & path, QStringList dirs);
|
||||||
void init();
|
void init();
|
||||||
int childCount(const Entry * e) const {int c = 0; foreach (const Entry * i, e->_children) c += childCount(i); c += e->_children.size(); return c;}
|
int childCount(const Entry * e) const {int c = 0; foreach (const Entry * i, e->_children) c += childCount(i); c += e->_children.size(); return c;}
|
||||||
bool entryExists(const Entry * e, const QString & name) const;
|
bool entryExists(const Entry * e, const QString & name) const;
|
||||||
@@ -257,9 +258,17 @@ private:
|
|||||||
inline Entry & entryByIndex(const int index) {Branch b = allLeaves(); if (index < 0 || index >= b.size()) return empty; return *(b[index]);}
|
inline Entry & entryByIndex(const int index) {Branch b = allLeaves(); if (index < 0 || index >= b.size()) return empty; return *(b[index]);}
|
||||||
void removeEntry(Branch & b, Entry * e);
|
void removeEntry(Branch & b, Entry * e);
|
||||||
void deleteEntry(Entry * e) {foreach (Entry * i, e->_children) deleteEntry(i); delete e;}
|
void deleteEntry(Entry * e) {foreach (Entry * i, e->_children) deleteEntry(i); delete e;}
|
||||||
|
QString getPrefixFromLine(QString line, bool * exists);
|
||||||
|
void updateIncludes();
|
||||||
|
QString entryValue(QString v);
|
||||||
void parse(QString content = QString());
|
void parse(QString content = QString());
|
||||||
|
|
||||||
int centry;
|
int centry;
|
||||||
|
bool internal;
|
||||||
|
QVector<QPIConfig * > includes, inc_devs;
|
||||||
|
Branch all_includes;
|
||||||
|
QFile * dev;
|
||||||
|
QStringList incdirs;
|
||||||
QString delim, * buffer;
|
QString delim, * buffer;
|
||||||
Entry root, empty;
|
Entry root, empty;
|
||||||
uint lines;
|
uint lines;
|
||||||
|
|||||||
Binary file not shown.
@@ -47,13 +47,13 @@ void Camera::apply(const GLdouble & aspect) {
|
|||||||
glMatrixMode(GL_PROJECTION);
|
glMatrixMode(GL_PROJECTION);
|
||||||
if (aspect <= 1.)
|
if (aspect <= 1.)
|
||||||
glScaled(aspect, aspect, 1.);
|
glScaled(aspect, aspect, 1.);
|
||||||
QMatrix4x4 pm;// = glMatrixPerspective(fov_, aspect, depth_start, depth_end);
|
QMatrix4x4 pm = glMatrixPerspective(fov_, aspect, depth_start, depth_end);
|
||||||
pm.perspective(fov_, aspect, depth_start, depth_end);
|
//pm.perspective(fov_, aspect, depth_start, depth_end);
|
||||||
//qDebug() << pm;// << glMatrixPerspective(fov_, aspect, depth_start, depth_end);
|
//qDebug() << pm;// << glMatrixPerspective(fov_, aspect, depth_start, depth_end);
|
||||||
|
//qDebug() << pm;
|
||||||
setGLMatrix(pm);
|
setGLMatrix(pm);
|
||||||
glMatrixMode(GL_MODELVIEW);
|
glMatrixMode(GL_MODELVIEW);
|
||||||
pm.setToIdentity();
|
pm.setToIdentity();
|
||||||
//qDebug() << pm;
|
|
||||||
pm.translate(0., 0., -distance());
|
pm.translate(0., 0., -distance());
|
||||||
pm.rotate(angles_.y(), 1., 0., 0.);
|
pm.rotate(angles_.y(), 1., 0., 0.);
|
||||||
pm.rotate(angles_.x(), 0., 1., 0.);
|
pm.rotate(angles_.x(), 0., 1., 0.);
|
||||||
|
|||||||
@@ -152,10 +152,13 @@ inline QDataStream & operator <<(QDataStream & s, const Material & m) {
|
|||||||
cs << cs.chunk(1, m.name) << cs.chunk(2, m.color_diffuse) << cs.chunk(3, m.color_specular) << cs.chunk(4, m.color_self_illumination)
|
cs << cs.chunk(1, m.name) << cs.chunk(2, m.color_diffuse) << cs.chunk(3, m.color_specular) << cs.chunk(4, m.color_self_illumination)
|
||||||
<< cs.chunk(5, m.transparency) << cs.chunk(6, m.reflectivity) << cs.chunk(7, m.glass) << cs.chunk(8, m.map_diffuse) << cs.chunk(9, m.map_normal)
|
<< cs.chunk(5, m.transparency) << cs.chunk(6, m.reflectivity) << cs.chunk(7, m.glass) << cs.chunk(8, m.map_diffuse) << cs.chunk(9, m.map_normal)
|
||||||
<< cs.chunk(10, m.map_relief) << cs.chunk(11, m.map_specular) << cs.chunk(12, m.map_specularity) << cs.chunk(13, m.map_self_illumination);
|
<< cs.chunk(10, m.map_relief) << cs.chunk(11, m.map_specular) << cs.chunk(12, m.map_specularity) << cs.chunk(13, m.map_self_illumination);
|
||||||
s << cs.data(); return s;
|
s << qCompress(cs.data()); return s;
|
||||||
}
|
}
|
||||||
inline QDataStream & operator >>(QDataStream & s, Material & m) {
|
inline QDataStream & operator >>(QDataStream & s, Material & m) {
|
||||||
ChunkStream cs(s);
|
QByteArray ba;
|
||||||
|
s >> ba;
|
||||||
|
ba = qUncompress(ba);
|
||||||
|
ChunkStream cs(ba);
|
||||||
while (!cs.atEnd()) {
|
while (!cs.atEnd()) {
|
||||||
switch (cs.read()) {
|
switch (cs.read()) {
|
||||||
case 1: m.name = cs.getData<QString>(); break;
|
case 1: m.name = cs.getData<QString>(); break;
|
||||||
|
|||||||
@@ -296,30 +296,40 @@ void Light::draw(QGLShaderProgram * prog, bool simplest) {
|
|||||||
|
|
||||||
QDataStream & operator <<(QDataStream & s, const GLObjectBase * p) {
|
QDataStream & operator <<(QDataStream & s, const GLObjectBase * p) {
|
||||||
ChunkStream cs;
|
ChunkStream cs;
|
||||||
|
//qDebug() << "place" << p->name() << "...";
|
||||||
cs << cs.chunk(1, int(p->type_)) << cs.chunk(2, p->accept_light) << cs.chunk(3, p->accept_fog) << cs.chunk(4, p->visible_)
|
cs << cs.chunk(1, int(p->type_)) << cs.chunk(2, p->accept_light) << cs.chunk(3, p->accept_fog) << cs.chunk(4, p->visible_)
|
||||||
<< 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_)
|
<< 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_);
|
||||||
|
//qDebug() << "place self done";
|
||||||
if (p->type_ == GLObjectBase::glLight) {
|
if (p->type_ == GLObjectBase::glLight) {
|
||||||
|
//qDebug() << "place light ...";
|
||||||
Light * l = (Light*)p;
|
Light * l = (Light*)p;
|
||||||
cs << cs.chunk(100, l->direction) << cs.chunk(101, l->angle_start) << cs.chunk(102, l->angle_end) << cs.chunk(103, l->intensity)
|
cs << cs.chunk(100, l->direction) << cs.chunk(101, l->angle_start) << cs.chunk(102, l->angle_end) << cs.chunk(103, l->intensity)
|
||||||
<< cs.chunk(104, l->decay_const) << cs.chunk(105, l->decay_linear) << cs.chunk(106, l->decay_quadratic)
|
<< cs.chunk(104, l->decay_const) << cs.chunk(105, l->decay_linear) << cs.chunk(106, l->decay_quadratic)
|
||||||
<< cs.chunk(107, l->decay_start) << cs.chunk(108, l->decay_end) << cs.chunk(109, int(l->light_type));
|
<< cs.chunk(107, l->decay_start) << cs.chunk(108, l->decay_end) << cs.chunk(109, int(l->light_type));
|
||||||
}
|
}
|
||||||
if (p->type_ == GLObjectBase::glCamera) {
|
if (p->type_ == GLObjectBase::glCamera) {
|
||||||
|
//qDebug() << "place camera ...";
|
||||||
Camera * c = (Camera*)p;
|
Camera * c = (Camera*)p;
|
||||||
cs << cs.chunk(200, c->aim_) << cs.chunk(201, c->fov_) << cs.chunk(202, c->depth_start) << cs.chunk(203, c->depth_end)
|
cs << cs.chunk(200, c->aim_) << cs.chunk(201, c->fov_) << cs.chunk(202, c->depth_start) << cs.chunk(203, c->depth_end)
|
||||||
<< cs.chunk(204, c->angle_limit_lower_xy) << cs.chunk(205, c->angle_limit_upper_xy)
|
<< cs.chunk(204, c->angle_limit_lower_xy) << cs.chunk(205, c->angle_limit_upper_xy)
|
||||||
<< cs.chunk(206, c->mirror_x) << cs.chunk(207, c->mirror_y);
|
<< cs.chunk(206, c->mirror_x) << cs.chunk(207, c->mirror_y);
|
||||||
}
|
}
|
||||||
s << cs.data(); return s;
|
//qDebug() << "place" << p->name() << cs.data().size() << s.device()->size();
|
||||||
|
s << cs.data();
|
||||||
|
foreach (const GLObjectBase * c, p->children_)
|
||||||
|
s << c;
|
||||||
|
return s;
|
||||||
}
|
}
|
||||||
QDataStream & operator >>(QDataStream & s, GLObjectBase *& p) {
|
QDataStream & operator >>(QDataStream & s, GLObjectBase *& p) {
|
||||||
ChunkStream cs(s);
|
ChunkStream cs(s);
|
||||||
p = 0;
|
p = 0;
|
||||||
|
int ccnt = 0;
|
||||||
Light * l = 0;
|
Light * l = 0;
|
||||||
Camera * c = 0;
|
Camera * c = 0;
|
||||||
|
//qDebug() << "read obj ...";
|
||||||
while (!cs.atEnd()) {
|
while (!cs.atEnd()) {
|
||||||
switch (cs.read()) {
|
switch (cs.read()) {
|
||||||
case 1:
|
case 1:
|
||||||
@@ -348,12 +358,7 @@ QDataStream & operator >>(QDataStream & s, GLObjectBase *& p) {
|
|||||||
case 13: if (p) p->scale_ = cs.getData<QVector3D>(); break;
|
case 13: if (p) p->scale_ = cs.getData<QVector3D>(); break;
|
||||||
case 14: if (p) p->mat_ = cs.getData<QMatrix4x4>(); break;
|
case 14: if (p) p->mat_ = cs.getData<QMatrix4x4>(); break;
|
||||||
case 15: if (p) p->vbo = cs.getData<GLVBO>(); break;
|
case 15: if (p) p->vbo = cs.getData<GLVBO>(); break;
|
||||||
case 16: if (p) {
|
case 16: if (p) ccnt = cs.getData<int>(); break;
|
||||||
p->children_ = cs.getData<QList<GLObjectBase * > >();
|
|
||||||
foreach (GLObjectBase * c_, p->children_)
|
|
||||||
c_->parent_ = p;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 17: if (p) p->name_ = cs.getData<QString>(); break;
|
case 17: if (p) p->name_ = cs.getData<QString>(); 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;
|
||||||
@@ -375,5 +380,13 @@ QDataStream & operator >>(QDataStream & s, GLObjectBase *& p) {
|
|||||||
case 207: if (c) c->mirror_y = cs.getData<bool>(); break;
|
case 207: if (c) c->mirror_y = cs.getData<bool>(); break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//qDebug() << p->name() << ccnt;
|
||||||
|
for (int i = 0; i < ccnt; ++i) {
|
||||||
|
GLObjectBase * c = 0;
|
||||||
|
s >> c;
|
||||||
|
if (!c) continue;
|
||||||
|
c->parent_ = p;
|
||||||
|
p->children_ << c;
|
||||||
|
}
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,11 +45,12 @@ GLParticlesSystem::GLParticlesSystem(const QVector3D & pos): GLObjectBase() {
|
|||||||
|
|
||||||
|
|
||||||
void GLParticlesSystem::update() {
|
void GLParticlesSystem::update() {
|
||||||
|
//qDebug() << "update" << need_birth << tick_birth;
|
||||||
if (!active_) return;
|
if (!active_) return;
|
||||||
//QMutexLocker locker(&mutex);
|
//QMutexLocker locker(&mutex);
|
||||||
Particle cp(lifeDuration_);
|
Particle cp(lifeDuration_);
|
||||||
if (birthEnabled_) need_birth += tick_birth;
|
if (birthEnabled_) need_birth += tick_birth;
|
||||||
//qDebug() << "update" << particles.size();
|
qDebug() << "update" << particles.size();
|
||||||
if (need_birth >= 1.f) {
|
if (need_birth >= 1.f) {
|
||||||
cp.pos = emitterPosition_;
|
cp.pos = emitterPosition_;
|
||||||
//qDebug() << "speed" << cp.speed;
|
//qDebug() << "speed" << cp.speed;
|
||||||
@@ -134,8 +135,10 @@ void GLParticlesSystem::draw(QGLShaderProgram * prog, bool) {
|
|||||||
for (int i = 0; i < particles.size(); ++i)
|
for (int i = 0; i < particles.size(); ++i)
|
||||||
//particles[i].pos_h.setZ((particles[i].pos - apos).lengthSquared());
|
//particles[i].pos_h.setZ((particles[i].pos - apos).lengthSquared());
|
||||||
particles[i].pos_h.setZ(particles[i].pos.distanceToPlane(apos, dir));
|
particles[i].pos_h.setZ(particles[i].pos.distanceToPlane(apos, dir));
|
||||||
//qSort(particles.begin(), particles.end());
|
qSort(particles.begin(), particles.end());
|
||||||
|
glBegin(GL_POINTS);
|
||||||
foreach (const Particle & i, particles) {
|
foreach (const Particle & i, particles) {
|
||||||
|
//glVertex3f(i.pos.x(), i.pos.y(), i.pos.z());
|
||||||
a = (i.lifeDuration - i.lifeCurrent) / fade_time;
|
a = (i.lifeDuration - i.lifeCurrent) / fade_time;
|
||||||
if (a > 1.f) a = 1.f;
|
if (a > 1.f) a = 1.f;
|
||||||
a *= tr_a;
|
a *= tr_a;
|
||||||
@@ -178,7 +181,11 @@ void GLParticlesSystem::draw(QGLShaderProgram * prog, bool) {
|
|||||||
colors << tr_r << tr_g << tr_b << a;
|
colors << tr_r << tr_g << tr_b << a;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
bool cae = glIsEnabled(GL_COLOR_ARRAY), nae = glIsEnabled(GL_NORMAL_ARRAY);
|
glEnd();
|
||||||
|
//bool cae = glIsEnabled(GL_COLOR_ARRAY), nae = glIsEnabled(GL_NORMAL_ARRAY);
|
||||||
|
glEnableClientState(GL_VERTEX_ARRAY);
|
||||||
|
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||||
|
glEnableClientState(GL_COLOR_ARRAY);
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||||
//glNormal3f(vn.x(), vn.y(), vn.z());
|
//glNormal3f(vn.x(), vn.y(), vn.z());
|
||||||
glNormal3f(0., 0., 1.);
|
glNormal3f(0., 0., 1.);
|
||||||
@@ -193,6 +200,16 @@ void GLParticlesSystem::draw(QGLShaderProgram * prog, bool) {
|
|||||||
glDrawArrays(GL_QUADS, 0, vertices.size() / 3);
|
glDrawArrays(GL_QUADS, 0, vertices.size() / 3);
|
||||||
glDepthMask(true);
|
glDepthMask(true);
|
||||||
//glDisable(GL_ALPHA_TEST);
|
//glDisable(GL_ALPHA_TEST);
|
||||||
if (!cae) glDisable(GL_COLOR_ARRAY);
|
//if (!cae) glDisable(GL_COLOR_ARRAY);
|
||||||
if (nae) glEnable(GL_NORMAL_ARRAY);
|
//if (nae) glEnable(GL_NORMAL_ARRAY);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
GLParticlesSystem::Particle::Particle(float life_dur) {
|
||||||
|
size = 1.;
|
||||||
|
angle = lifeCurrent = 0.;
|
||||||
|
speedDecay = 0.;
|
||||||
|
lifeDuration = life_dur;
|
||||||
|
tex_rect = QRectF(0, 0, 1, 1);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,8 +24,29 @@
|
|||||||
#include "globject.h"
|
#include "globject.h"
|
||||||
#include "glcamera.h"
|
#include "glcamera.h"
|
||||||
|
|
||||||
class GLParticlesSystem: public GLObjectBase
|
class GLParticlesSystem: public QObject, public GLObjectBase
|
||||||
{
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
Q_PROPERTY(float birthRate READ birthRate WRITE setBirthRate)
|
||||||
|
Q_PROPERTY(float lifeDuration READ lifeDuration WRITE setLifeDuration)
|
||||||
|
Q_PROPERTY(float size READ size WRITE setSize)
|
||||||
|
Q_PROPERTY(float enlargeSpeed READ enlargeSpeed WRITE setEnlargeSpeed)
|
||||||
|
Q_PROPERTY(float initialAngle READ initialAngle WRITE setInitialAngle)
|
||||||
|
Q_PROPERTY(float initialSpeed READ initialSpeed WRITE setInitialSpeed)
|
||||||
|
Q_PROPERTY(float speedDecay READ speedDecay WRITE setSpeedDecay)
|
||||||
|
Q_PROPERTY(float baseAngle READ baseAngle WRITE setBaseAngle)
|
||||||
|
Q_PROPERTY(QVector3D speedDirection READ speedDirection WRITE setSpeedDirection)
|
||||||
|
Q_PROPERTY(QVector3D emitterPosition READ emitterPosition WRITE setEmitterPosition)
|
||||||
|
Q_PROPERTY(QVector3D emitterDirection READ emitterDirection WRITE setEmitterDirection)
|
||||||
|
Q_PROPERTY(float lifeDurationJitter READ lifeDurationJitter WRITE setLifeDurationJitter)
|
||||||
|
Q_PROPERTY(float speedJitter READ speedJitter WRITE setSpeedJitter)
|
||||||
|
Q_PROPERTY(float speedDirectionJitter READ speedDirectionJitter WRITE setSpeedDirectionJitter)
|
||||||
|
Q_PROPERTY(float sizeJitter READ sizeJitter WRITE setSizeJitter)
|
||||||
|
Q_PROPERTY(float enlargeSpeedJitter READ enlargeSpeedJitter WRITE setEnlargeSpeedJitter)
|
||||||
|
Q_PROPERTY(float angleJitter READ angleJitter WRITE setAngleJitter)
|
||||||
|
Q_PROPERTY(bool active READ isActive WRITE setActive)
|
||||||
|
Q_PROPERTY(bool birthEnabled READ isBirthEnabled WRITE setBirthEnabled)
|
||||||
|
Q_PROPERTY(float fadeTime READ fadeTime WRITE setFadeTime)
|
||||||
public:
|
public:
|
||||||
GLParticlesSystem(const QVector3D & pos = QVector3D());
|
GLParticlesSystem(const QVector3D & pos = QVector3D());
|
||||||
~GLParticlesSystem() {;}
|
~GLParticlesSystem() {;}
|
||||||
@@ -33,7 +54,7 @@ public:
|
|||||||
enum Type {Cone, Omni, Box};
|
enum Type {Cone, Omni, Box};
|
||||||
|
|
||||||
struct Particle {
|
struct Particle {
|
||||||
Particle(float life_dur = 40.) {size = 1.; angle = lifeCurrent = 0.; speedDecay = 0.; lifeDuration = life_dur;}
|
Particle(float life_dur = 40.);
|
||||||
QVector3D pos;
|
QVector3D pos;
|
||||||
QVector3D pos_h;
|
QVector3D pos_h;
|
||||||
QVector3D speed;
|
QVector3D speed;
|
||||||
|
|||||||
@@ -146,12 +146,12 @@ void createGLTexture(GLuint & tex, const QImage & image, const GLenum & format,
|
|||||||
|
|
||||||
QMatrix4x4 glMatrixPerspective(double angle, double aspect, double near_, double far_) {
|
QMatrix4x4 glMatrixPerspective(double angle, double aspect, double near_, double far_) {
|
||||||
QMatrix4x4 ret;
|
QMatrix4x4 ret;
|
||||||
double t = 1. / (tan(angle * deg2rad / 2.));
|
double t = 1. / (tan(angle * deg2rad / 2.)), e = 2.4e-7;
|
||||||
ret(0, 0) = t / aspect;
|
ret(0, 0) = t / aspect;
|
||||||
ret(1, 1) = t;
|
ret(1, 1) = t;
|
||||||
ret(2, 2) = far_ / (far_ - near_) - 1.;
|
ret(2, 2) = e - 1.;//far_ / (far_ - near_) - 1.;
|
||||||
ret(2, 3) = 2. * far_ * near_ / (far_ - near_);
|
ret(2, 3) = (e - 2.) * near_;//2. * far_ * near_ / (far_ - near_);
|
||||||
ret(3, 2) = -1;
|
ret(3, 2) = -1.;
|
||||||
ret(3, 3) = 0.;
|
ret(3, 3) = 0.;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -72,11 +72,16 @@ private:
|
|||||||
|
|
||||||
inline QDataStream & operator <<(QDataStream & s, const GLVBO & m) {
|
inline QDataStream & operator <<(QDataStream & s, const GLVBO & m) {
|
||||||
ChunkStream cs;
|
ChunkStream cs;
|
||||||
|
//qDebug() << "place VBO" << m.vertices_.size() << m.normals_.size() << m.texcoords_.size() << m.colors_.size() << "...";
|
||||||
cs << cs.chunk(1, m.vertices_) << cs.chunk(2, m.normals_) << cs.chunk(3, m.texcoords_) << cs.chunk(4, m.colors_) << cs.chunk(5, m.usage);
|
cs << cs.chunk(1, m.vertices_) << cs.chunk(2, m.normals_) << cs.chunk(3, m.texcoords_) << cs.chunk(4, m.colors_) << cs.chunk(5, m.usage);
|
||||||
s << cs.data(); return s;
|
//qDebug() << "place VBO done" << cs.data().size() << "...";
|
||||||
|
s << qCompress(cs.data()); return s;
|
||||||
}
|
}
|
||||||
inline QDataStream & operator >>(QDataStream & s, GLVBO & m) {
|
inline QDataStream & operator >>(QDataStream & s, GLVBO & m) {
|
||||||
ChunkStream cs(s);
|
QByteArray ba;
|
||||||
|
s >> ba;
|
||||||
|
ba = qUncompress(ba);
|
||||||
|
ChunkStream cs(ba);
|
||||||
while (!cs.atEnd()) {
|
while (!cs.atEnd()) {
|
||||||
switch (cs.read()) {
|
switch (cs.read()) {
|
||||||
case 1: m.vertices_ = cs.getData<QVector<GLfloat> >(); break;
|
case 1: m.vertices_ = cs.getData<QVector<GLfloat> >(); break;
|
||||||
|
|||||||
@@ -28,18 +28,23 @@ GLObjectBase * loadFromQGLFile(const QString & filepath) {
|
|||||||
}
|
}
|
||||||
f.open(QIODevice::ReadOnly);
|
f.open(QIODevice::ReadOnly);
|
||||||
QDataStream s(&f);
|
QDataStream s(&f);
|
||||||
|
s.setVersion(QDataStream::Qt_4_8);
|
||||||
char sign[4];
|
char sign[4];
|
||||||
s.readRawData(sign, 4);
|
s.readRawData(sign, 4);
|
||||||
if ((sign[0] != 'Q') || (sign[1] != 'G') || (sign[2] != 'L') || (sign[3] != 'F')) {
|
if ((sign[0] != 'Q') || (sign[1] != 'G') || (sign[2] != 'L') || (sign[3] != 'F')) {
|
||||||
qDebug() << "[Loader QGL] Error: \"" + filepath + "\" is not valid QGL file!";
|
qDebug() << "[Loader QGL] Error: \"" + filepath + "\" is not valid QGL file!";
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
QByteArray fc_; s >> fc_;
|
|
||||||
QByteArray fc = qUncompress(fc_);
|
|
||||||
if (fc.isEmpty()) return 0;
|
|
||||||
QDataStream os(fc);
|
|
||||||
GLObjectBase * root = 0;
|
GLObjectBase * root = 0;
|
||||||
os >> root;
|
ushort version = 0xFFFF;
|
||||||
|
f.peek((char*)&version, 2);
|
||||||
|
if (version == 1) {
|
||||||
|
s.skipRawData(2);
|
||||||
|
s >> root;
|
||||||
|
} else {
|
||||||
|
qDebug() << "[Loader QGL] Error: \"" + filepath + "\" unsupported version!";
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
root->buildTransform();
|
root->buildTransform();
|
||||||
if (root->name().isEmpty())
|
if (root->name().isEmpty())
|
||||||
root->setName(QFileInfo(f).baseName());
|
root->setName(QFileInfo(f).baseName());
|
||||||
@@ -54,11 +59,11 @@ bool saveToQGLFile(const QString & filepath, const GLObjectBase * o) {
|
|||||||
return false;
|
return false;
|
||||||
f.resize(0);
|
f.resize(0);
|
||||||
QDataStream s(&f);
|
QDataStream s(&f);
|
||||||
|
s.setVersion(QDataStream::Qt_4_8);
|
||||||
char sign[4] = {'Q', 'G', 'L', 'F'};
|
char sign[4] = {'Q', 'G', 'L', 'F'};
|
||||||
|
ushort version = 1;
|
||||||
s.writeRawData(sign, 4);
|
s.writeRawData(sign, 4);
|
||||||
QByteArray fc;
|
s.writeRawData((char*)&version, 2);
|
||||||
QDataStream os(&fc, QIODevice::ReadWrite);
|
s << o;
|
||||||
os << o;
|
|
||||||
s << qCompress(fc);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,8 +45,8 @@ MainWindow::MainWindow(QWidget * parent): QMainWindow(parent), Ui::MainWindow()
|
|||||||
view->setHoverHaloFillAlpha(0.);
|
view->setHoverHaloFillAlpha(0.);
|
||||||
view->setSelectionHaloFillAlpha(0.);
|
view->setSelectionHaloFillAlpha(0.);
|
||||||
view->setBackColor(Qt::lightGray);
|
view->setBackColor(Qt::lightGray);
|
||||||
view->setDepthStart(1.);
|
view->setDepthStart(0.001);
|
||||||
view->setDepthEnd(10000.);
|
view->setDepthEnd(100000.);
|
||||||
|
|
||||||
spinFOV->setValue(view->FOV());
|
spinFOV->setValue(view->FOV());
|
||||||
spinDepthStart->setValue(view->depthStart());
|
spinDepthStart->setValue(view->depthStart());
|
||||||
@@ -80,6 +80,11 @@ MainWindow::MainWindow(QWidget * parent): QMainWindow(parent), Ui::MainWindow()
|
|||||||
spinBloomRadius->setValue(view->feature(QGLView::qglBloomRadius).toInt());
|
spinBloomRadius->setValue(view->feature(QGLView::qglBloomRadius).toInt());
|
||||||
spinBloomThreshold->setValue(view->feature(QGLView::qglBloomThreshold).toDouble());
|
spinBloomThreshold->setValue(view->feature(QGLView::qglBloomThreshold).toDouble());
|
||||||
spinSSAORadius->setValue(view->feature(QGLView::qglSSAORadius).toInt());
|
spinSSAORadius->setValue(view->feature(QGLView::qglSSAORadius).toInt());
|
||||||
|
groupDOF->setChecked(view->isFeatureEnabled(QGLView::qglDepthOfFieldEnabled));
|
||||||
|
checkDOFAutoFocus->setChecked(view->isFeatureEnabled(QGLView::qglDepthOfFieldAutoFocusEnabled));
|
||||||
|
spinDOFFocus->setValue(view->feature(QGLView::qglDepthOfFieldFocus).toDouble());
|
||||||
|
spinDOFDiaphragm->setValue(view->feature(QGLView::qglDepthOfFieldDiaphragm).toDouble());
|
||||||
|
spinDOFSpeed->setValue(view->feature(QGLView::qglDepthOfFieldAutoFocusSpeed).toDouble());
|
||||||
|
|
||||||
axis = new GLObjectBase();
|
axis = new GLObjectBase();
|
||||||
GLObjectBase * obj;
|
GLObjectBase * obj;
|
||||||
@@ -104,6 +109,10 @@ MainWindow::MainWindow(QWidget * parent): QMainWindow(parent), Ui::MainWindow()
|
|||||||
|
|
||||||
connect(view, SIGNAL(selectionChanged(GLObjectBase*,GLObjectBase*)), this, SLOT(selectionChanged(GLObjectBase*,GLObjectBase*)));
|
connect(view, SIGNAL(selectionChanged(GLObjectBase*,GLObjectBase*)), this, SLOT(selectionChanged(GLObjectBase*,GLObjectBase*)));
|
||||||
connect(matEditor, SIGNAL(changed()), this, SLOT(materialChanged()));
|
connect(matEditor, SIGNAL(changed()), this, SLOT(materialChanged()));
|
||||||
|
|
||||||
|
//view->addObject(&partsys);
|
||||||
|
partsys.material().color_diffuse = Qt::red;
|
||||||
|
treeProps->assignObject(&partsys);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -140,6 +149,11 @@ void MainWindow::on_view_glKeyPressEvent(QKeyEvent * e) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void MainWindow::on_view_glInitializeDone() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void MainWindow::loadFile(const QString & path) {
|
void MainWindow::loadFile(const QString & path) {
|
||||||
prev_path = path;
|
prev_path = path;
|
||||||
importFile(path);
|
importFile(path);
|
||||||
@@ -216,6 +230,7 @@ void MainWindow::on_comboRenderer_currentIndexChanged(int val) {
|
|||||||
switch (val) {
|
switch (val) {
|
||||||
case 0: view->setRenderer(new RendererSimple(view), &pr); break;
|
case 0: view->setRenderer(new RendererSimple(view), &pr); break;
|
||||||
case 1: view->setRenderer(new RendererDeferredShading(view), &pr); break;
|
case 1: view->setRenderer(new RendererDeferredShading(view), &pr); break;
|
||||||
|
case 2: view->setRenderer(new RendererRT(view), &pr); break;
|
||||||
}
|
}
|
||||||
if (pr != 0) delete pr;
|
if (pr != 0) delete pr;
|
||||||
}
|
}
|
||||||
@@ -250,7 +265,9 @@ void MainWindow::on_actionSave_triggered() {
|
|||||||
f += ".qgl";
|
f += ".qgl";
|
||||||
prev_path = f;
|
prev_path = f;
|
||||||
view->removeObject(axis);
|
view->removeObject(axis);
|
||||||
|
QApplication::setOverrideCursor(Qt::WaitCursor);
|
||||||
saveToQGLFile(f, &(view->rootObject()));
|
saveToQGLFile(f, &(view->rootObject()));
|
||||||
|
QApplication::restoreOverrideCursor();
|
||||||
view->addObject(axis);
|
view->addObject(axis);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -262,7 +279,9 @@ void MainWindow::on_actionSaveSelected_triggered() {
|
|||||||
if (f.right(4).toLower() != ".qgl")
|
if (f.right(4).toLower() != ".qgl")
|
||||||
f += ".qgl";
|
f += ".qgl";
|
||||||
prev_path = f;
|
prev_path = f;
|
||||||
|
QApplication::setOverrideCursor(Qt::WaitCursor);
|
||||||
saveToQGLFile(f, sel_obj);
|
saveToQGLFile(f, sel_obj);
|
||||||
|
QApplication::restoreOverrideCursor();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -35,6 +35,8 @@
|
|||||||
#include "loader_ase.h"
|
#include "loader_ase.h"
|
||||||
#include "renderer_simple.h"
|
#include "renderer_simple.h"
|
||||||
#include "renderer_deferred_shading.h"
|
#include "renderer_deferred_shading.h"
|
||||||
|
#include "renderer_rt.h"
|
||||||
|
#include "glparticles_system.h"
|
||||||
#include "water_system.h"
|
#include "water_system.h"
|
||||||
#include "rope_system.h"
|
#include "rope_system.h"
|
||||||
|
|
||||||
@@ -65,6 +67,8 @@ private:
|
|||||||
Material m;
|
Material m;
|
||||||
bool isChanged;
|
bool isChanged;
|
||||||
|
|
||||||
|
GLParticlesSystem partsys;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void on_spinFOV_valueChanged(double val) {view->setFOV(val);}
|
void on_spinFOV_valueChanged(double val) {view->setFOV(val);}
|
||||||
void on_spinDepthStart_valueChanged(double val) {view->setDepthStart(val);}
|
void on_spinDepthStart_valueChanged(double val) {view->setDepthStart(val);}
|
||||||
@@ -90,6 +94,11 @@ private slots:
|
|||||||
void on_groupReflections_clicked(bool val) {view->setFeature(QGLView::qglReflectionsEnabled, val);}
|
void on_groupReflections_clicked(bool val) {view->setFeature(QGLView::qglReflectionsEnabled, val);}
|
||||||
void on_checkSoftShadows_clicked(bool val) {view->setFeature(QGLView::qglShadowsSoftEnabled, val);}
|
void on_checkSoftShadows_clicked(bool val) {view->setFeature(QGLView::qglShadowsSoftEnabled, val);}
|
||||||
void on_groupSSAO_clicked(bool val) {view->setFeature(QGLView::qglSSAOEnabled, val);}
|
void on_groupSSAO_clicked(bool val) {view->setFeature(QGLView::qglSSAOEnabled, val);}
|
||||||
|
void on_groupDOF_clicked(bool val) {view->setFeature(QGLView::qglDepthOfFieldEnabled, val);}
|
||||||
|
void on_checkDOFAutoFocus_clicked(bool val) {view->setFeature(QGLView::qglDepthOfFieldAutoFocusEnabled, val);}
|
||||||
|
void on_spinDOFFocus_valueChanged(double val) {view->setFeature(QGLView::qglDepthOfFieldFocus, val);}
|
||||||
|
void on_spinDOFDiaphragm_valueChanged(double val) {view->setFeature(QGLView::qglDepthOfFieldDiaphragm, val);}
|
||||||
|
void on_spinDOFSpeed_valueChanged(double val) {view->setFeature(QGLView::qglDepthOfFieldAutoFocusSpeed, val);}
|
||||||
void on_spinAccom_valueChanged(double val) {view->setFeature(QGLView::qglEyeAccomodationTime, val);}
|
void on_spinAccom_valueChanged(double val) {view->setFeature(QGLView::qglEyeAccomodationTime, val);}
|
||||||
void on_spinAccomMS_valueChanged(double val) {view->setFeature(QGLView::qglEyeAccomodationMaxSpeed, val);}
|
void on_spinAccomMS_valueChanged(double val) {view->setFeature(QGLView::qglEyeAccomodationMaxSpeed, val);}
|
||||||
void on_checkReflectionsBlur_clicked(bool val) {view->setFeature(QGLView::qglReflectionsBlur, val);}
|
void on_checkReflectionsBlur_clicked(bool val) {view->setFeature(QGLView::qglReflectionsBlur, val);}
|
||||||
@@ -109,6 +118,7 @@ private slots:
|
|||||||
void on_actionOpen_triggered();
|
void on_actionOpen_triggered();
|
||||||
|
|
||||||
void on_view_glKeyPressEvent(QKeyEvent * e);
|
void on_view_glKeyPressEvent(QKeyEvent * e);
|
||||||
|
void on_view_glInitializeDone();
|
||||||
void on_view_keyEvent(Qt::Key k, Qt::KeyboardModifiers m);
|
void on_view_keyEvent(Qt::Key k, Qt::KeyboardModifiers m);
|
||||||
|
|
||||||
void on_treeObjects_itemClicked(QTreeWidgetItem * ti, int col);
|
void on_treeObjects_itemClicked(QTreeWidgetItem * ti, int col);
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>1125</width>
|
<width>1125</width>
|
||||||
<height>808</height>
|
<height>905</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
@@ -54,7 +54,7 @@
|
|||||||
<item>
|
<item>
|
||||||
<widget class="QTabWidget" name="tabWidget_2">
|
<widget class="QTabWidget" name="tabWidget_2">
|
||||||
<property name="currentIndex">
|
<property name="currentIndex">
|
||||||
<number>1</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="tab_5">
|
<widget class="QWidget" name="tab_5">
|
||||||
<attribute name="title">
|
<attribute name="title">
|
||||||
@@ -97,7 +97,7 @@
|
|||||||
<item row="2" column="1">
|
<item row="2" column="1">
|
||||||
<widget class="QComboBox" name="comboRenderer">
|
<widget class="QComboBox" name="comboRenderer">
|
||||||
<property name="currentIndex">
|
<property name="currentIndex">
|
||||||
<number>1</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<item>
|
<item>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
@@ -109,6 +109,11 @@
|
|||||||
<string>Deferred shading</string>
|
<string>Deferred shading</string>
|
||||||
</property>
|
</property>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>RT</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="3" column="0">
|
<item row="3" column="0">
|
||||||
@@ -322,8 +327,11 @@
|
|||||||
</property>
|
</property>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QDoubleSpinBox" name="spinDepthStart">
|
<widget class="QDoubleSpinBox" name="spinDepthStart">
|
||||||
|
<property name="decimals">
|
||||||
|
<number>3</number>
|
||||||
|
</property>
|
||||||
<property name="maximum">
|
<property name="maximum">
|
||||||
<double>9999999.000000000000000</double>
|
<double>999999999.000000000000000</double>
|
||||||
</property>
|
</property>
|
||||||
<property name="value">
|
<property name="value">
|
||||||
<double>1.000000000000000</double>
|
<double>1.000000000000000</double>
|
||||||
@@ -345,8 +353,11 @@
|
|||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QDoubleSpinBox" name="spinDepthEnd">
|
<widget class="QDoubleSpinBox" name="spinDepthEnd">
|
||||||
|
<property name="decimals">
|
||||||
|
<number>3</number>
|
||||||
|
</property>
|
||||||
<property name="maximum">
|
<property name="maximum">
|
||||||
<double>9999999.000000000000000</double>
|
<double>999999999.000000000000000</double>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
@@ -706,6 +717,112 @@
|
|||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QGroupBox" name="groupDOF">
|
||||||
|
<property name="title">
|
||||||
|
<string>Depth of field</string>
|
||||||
|
</property>
|
||||||
|
<property name="checkable">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<layout class="QFormLayout" name="formLayout_11">
|
||||||
|
<property name="fieldGrowthPolicy">
|
||||||
|
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
|
||||||
|
</property>
|
||||||
|
<property name="labelAlignment">
|
||||||
|
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||||
|
</property>
|
||||||
|
<item row="2" column="0">
|
||||||
|
<widget class="QLabel" name="label_15">
|
||||||
|
<property name="text">
|
||||||
|
<string>Diaphragm</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="3" column="0">
|
||||||
|
<widget class="QLabel" name="label_16">
|
||||||
|
<property name="text">
|
||||||
|
<string>Max speed</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="1">
|
||||||
|
<widget class="SpinSlider" name="spinDOFDiaphragm">
|
||||||
|
<property name="minimum">
|
||||||
|
<double>0.100000000000000</double>
|
||||||
|
</property>
|
||||||
|
<property name="maximum">
|
||||||
|
<double>1024.000000000000000</double>
|
||||||
|
</property>
|
||||||
|
<property name="value">
|
||||||
|
<double>8.000000000000000</double>
|
||||||
|
</property>
|
||||||
|
<property name="squareScale">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="3" column="1">
|
||||||
|
<widget class="SpinSlider" name="spinDOFSpeed">
|
||||||
|
<property name="minimum">
|
||||||
|
<double>0.010000000000000</double>
|
||||||
|
</property>
|
||||||
|
<property name="maximum">
|
||||||
|
<double>10.000000000000000</double>
|
||||||
|
</property>
|
||||||
|
<property name="value">
|
||||||
|
<double>0.100000000000000</double>
|
||||||
|
</property>
|
||||||
|
<property name="decimals">
|
||||||
|
<number>2</number>
|
||||||
|
</property>
|
||||||
|
<property name="singleStep">
|
||||||
|
<double>0.100000000000000</double>
|
||||||
|
</property>
|
||||||
|
<property name="pageStep">
|
||||||
|
<double>1.000000000000000</double>
|
||||||
|
</property>
|
||||||
|
<property name="squareScale">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="0">
|
||||||
|
<widget class="QLabel" name="label_21">
|
||||||
|
<property name="text">
|
||||||
|
<string>Focus</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="1">
|
||||||
|
<widget class="SpinSlider" name="spinDOFFocus">
|
||||||
|
<property name="minimum">
|
||||||
|
<double>0.100000000000000</double>
|
||||||
|
</property>
|
||||||
|
<property name="maximum">
|
||||||
|
<double>1000.000000000000000</double>
|
||||||
|
</property>
|
||||||
|
<property name="value">
|
||||||
|
<double>1.000000000000000</double>
|
||||||
|
</property>
|
||||||
|
<property name="squareScale">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="spinMaximum">
|
||||||
|
<double>999999.000000000000000</double>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="0" colspan="2">
|
||||||
|
<widget class="QCheckBox" name="checkDOFAutoFocus">
|
||||||
|
<property name="text">
|
||||||
|
<string>Auto focus</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QGroupBox" name="groupReflections">
|
<widget class="QGroupBox" name="groupReflections">
|
||||||
<property name="title">
|
<property name="title">
|
||||||
@@ -867,6 +984,22 @@
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
|
<widget class="QWidget" name="tab_4">
|
||||||
|
<attribute name="title">
|
||||||
|
<string>Страница</string>
|
||||||
|
</attribute>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_6">
|
||||||
|
<item>
|
||||||
|
<widget class="PropertyEditor" name="treeProps">
|
||||||
|
<column>
|
||||||
|
<property name="text">
|
||||||
|
<string notr="true">1</string>
|
||||||
|
</property>
|
||||||
|
</column>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
@@ -1054,6 +1187,11 @@
|
|||||||
<header>globject_editor.h</header>
|
<header>globject_editor.h</header>
|
||||||
<container>1</container>
|
<container>1</container>
|
||||||
</customwidget>
|
</customwidget>
|
||||||
|
<customwidget>
|
||||||
|
<class>PropertyEditor</class>
|
||||||
|
<extends>QTreeWidget</extends>
|
||||||
|
<header>propertyeditor.h</header>
|
||||||
|
</customwidget>
|
||||||
</customwidgets>
|
</customwidgets>
|
||||||
<resources>
|
<resources>
|
||||||
<include location="qglview.qrc"/>
|
<include location="qglview.qrc"/>
|
||||||
|
|||||||
@@ -77,6 +77,11 @@ QGLView::QGLView(QWidget * parent): QGraphicsView(parent), fbo_selection(3) {
|
|||||||
setFeature(qglReflectionsBlur, true);
|
setFeature(qglReflectionsBlur, true);
|
||||||
setFeature(qglSSAOEnabled, false);
|
setFeature(qglSSAOEnabled, false);
|
||||||
setFeature(qglSSAORadius, 5);
|
setFeature(qglSSAORadius, 5);
|
||||||
|
setFeature(qglDepthOfFieldEnabled, false);
|
||||||
|
setFeature(qglDepthOfFieldAutoFocusEnabled, true);
|
||||||
|
setFeature(qglDepthOfFieldAutoFocusSpeed, 0.1);
|
||||||
|
setFeature(qglDepthOfFieldFocus, 1.);
|
||||||
|
setFeature(qglDepthOfFieldDiaphragm, 8.);
|
||||||
mouse_first = mouseSelect_ = hoverHalo_ = selectionHalo_ = true;
|
mouse_first = mouseSelect_ = hoverHalo_ = selectionHalo_ = true;
|
||||||
fogEnabled_ = is_init = grabMouse_ = mouseRotate_ = mouseThis_ = shaders_bind = changed_ = false;
|
fogEnabled_ = is_init = grabMouse_ = mouseRotate_ = mouseThis_ = shaders_bind = changed_ = false;
|
||||||
rmode = GLObjectBase::Fill;
|
rmode = GLObjectBase::Fill;
|
||||||
|
|||||||
@@ -100,7 +100,12 @@ public:
|
|||||||
qglReflectionsEnabled,
|
qglReflectionsEnabled,
|
||||||
qglReflectionsBlur,
|
qglReflectionsBlur,
|
||||||
qglSSAOEnabled,
|
qglSSAOEnabled,
|
||||||
qglSSAORadius
|
qglSSAORadius,
|
||||||
|
qglDepthOfFieldEnabled,
|
||||||
|
qglDepthOfFieldAutoFocusEnabled,
|
||||||
|
qglDepthOfFieldAutoFocusSpeed,
|
||||||
|
qglDepthOfFieldFocus,
|
||||||
|
qglDepthOfFieldDiaphragm
|
||||||
};
|
};
|
||||||
|
|
||||||
Q_ENUMS (FogMode)
|
Q_ENUMS (FogMode)
|
||||||
|
|||||||
@@ -36,7 +36,8 @@ fbo_g(5, true, GL_RGBA16F), fbo_out(3, false, GL_RGBA16F), fbo_hsmall(1, false,
|
|||||||
<< ShaderPair("ssr_blur", &shader_ssr_blur)
|
<< ShaderPair("ssr_blur", &shader_ssr_blur)
|
||||||
<< ShaderPair("ssr_merge", &shader_ssr_merge)
|
<< ShaderPair("ssr_merge", &shader_ssr_merge)
|
||||||
<< ShaderPair("ssao_blur", &shader_ssao_blur)
|
<< ShaderPair("ssao_blur", &shader_ssao_blur)
|
||||||
<< ShaderPair("ssao_merge", &shader_ssao_merge);
|
<< ShaderPair("ssao_merge", &shader_ssao_merge)
|
||||||
|
<< ShaderPair("dof", &shader_dof);
|
||||||
for (int i = 0; i < shaders.size(); ++i)
|
for (int i = 0; i < shaders.size(); ++i)
|
||||||
*(shaders[i].second) = 0;
|
*(shaders[i].second) = 0;
|
||||||
lights_per_pass = 8;
|
lights_per_pass = 8;
|
||||||
@@ -288,6 +289,7 @@ void RendererDeferredShading::renderScene() {
|
|||||||
glBindTexture(GL_TEXTURE_2D, fbo_g.colorTexture(0));
|
glBindTexture(GL_TEXTURE_2D, fbo_g.colorTexture(0));
|
||||||
glActiveTextureChannel(2);
|
glActiveTextureChannel(2);
|
||||||
glBindTexture(GL_TEXTURE_2D, fbo_g.colorTexture(1));
|
glBindTexture(GL_TEXTURE_2D, fbo_g.colorTexture(1));
|
||||||
|
fbo_g.bindDepthTexture(7);
|
||||||
shader_ssr->bind();
|
shader_ssr->bind();
|
||||||
shader_ssr->setUniformValue("qgl_ModelViewProjectionMatrix", QMatrix4x4());
|
shader_ssr->setUniformValue("qgl_ModelViewProjectionMatrix", QMatrix4x4());
|
||||||
shader_ssr->setUniformValue("z_far", GLfloat(view.depthEnd()));
|
shader_ssr->setUniformValue("z_far", GLfloat(view.depthEnd()));
|
||||||
@@ -296,6 +298,7 @@ void RendererDeferredShading::renderScene() {
|
|||||||
shader_ssr->setUniformValue("t0", 1);
|
shader_ssr->setUniformValue("t0", 1);
|
||||||
shader_ssr->setUniformValue("t1", 2);
|
shader_ssr->setUniformValue("t1", 2);
|
||||||
shader_ssr->setUniformValue("ts", 0);
|
shader_ssr->setUniformValue("ts", 0);
|
||||||
|
shader_ssr->setUniformValue("td", 7);
|
||||||
glDrawQuad(shader_ssr, corner_dirs);
|
glDrawQuad(shader_ssr, corner_dirs);
|
||||||
|
|
||||||
glActiveTextureChannel(0);
|
glActiveTextureChannel(0);
|
||||||
@@ -309,6 +312,8 @@ void RendererDeferredShading::renderScene() {
|
|||||||
int crad = 1;
|
int crad = 1;
|
||||||
for (int p = 0; p < passes; ++p) {
|
for (int p = 0; p < passes; ++p) {
|
||||||
glBindTexture(GL_TEXTURE_2D, fbo_out.colorTexture(lri));
|
glBindTexture(GL_TEXTURE_2D, fbo_out.colorTexture(lri));
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);//_MIPMAP_LINEAR);
|
||||||
fbo_out.setWriteBuffer(lwi);
|
fbo_out.setWriteBuffer(lwi);
|
||||||
shader_ssr_blur->setUniformValue("radius", GLfloat(crad));
|
shader_ssr_blur->setUniformValue("radius", GLfloat(crad));
|
||||||
glDrawQuad(shader_ssr_blur);
|
glDrawQuad(shader_ssr_blur);
|
||||||
@@ -341,6 +346,53 @@ void RendererDeferredShading::renderScene() {
|
|||||||
piSwap<int>(wi, ri);
|
piSwap<int>(wi, ri);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (view.isFeatureEnabled(QGLView::qglDepthOfFieldEnabled)) {
|
||||||
|
if (view.isFeatureEnabled(QGLView::qglDepthOfFieldAutoFocusEnabled)) {
|
||||||
|
GLfloat cw;
|
||||||
|
//glReadBuffer();
|
||||||
|
fbo_g.bind();
|
||||||
|
glReadPixels(fbo_out.width() / 2, fbo_out.height() / 2, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &cw);
|
||||||
|
fbo_out.bind();
|
||||||
|
const double _pe = 2.4e-7;
|
||||||
|
double cz = cw + cw - 1;
|
||||||
|
cz = ((_pe - 2.) * view.depthStart()) / (cz + _pe - 1.); // infinite depth
|
||||||
|
double z = view.feature(QGLView::qglDepthOfFieldFocus).toDouble(),
|
||||||
|
s = view.feature(QGLView::qglDepthOfFieldAutoFocusSpeed).toDouble();
|
||||||
|
z = z * (1. - s) + cz * s;
|
||||||
|
view.setFeature(QGLView::qglDepthOfFieldFocus, z);
|
||||||
|
}
|
||||||
|
shader_dof->bind();
|
||||||
|
shader_dof->setUniformValue("qgl_ModelViewProjectionMatrix", QMatrix4x4());
|
||||||
|
shader_dof->setUniformValue("z_far", GLfloat(view.depthEnd()));
|
||||||
|
shader_dof->setUniformValue("z_near", GLfloat(view.depthStart()));
|
||||||
|
shader_dof->setUniformValue("focus", GLfloat(view.feature(QGLView::qglDepthOfFieldFocus).toDouble()));
|
||||||
|
shader_dof->setUniformValue("diaphragm", GLfloat(view.feature(QGLView::qglDepthOfFieldDiaphragm).toDouble()));
|
||||||
|
shader_dof->setUniformValue("t0", 0);
|
||||||
|
shader_dof->setUniformValue("td", 7);
|
||||||
|
fbo_g.bindDepthTexture(7);
|
||||||
|
glActiveTextureChannel(0);
|
||||||
|
|
||||||
|
int passes = 3;
|
||||||
|
float crad = 1.;
|
||||||
|
for (int p = 0; p < passes; ++p) {
|
||||||
|
shader_dof->setUniformValue("radius", GLfloat(crad));
|
||||||
|
fbo_out.setWriteBuffer(wi);
|
||||||
|
glBindTexture(GL_TEXTURE_2D, fbo_out.colorTexture(ri));
|
||||||
|
shader_dof->setUniformValue("dt", QVector2D(1. / fbo_out.width(), 0.));
|
||||||
|
glDrawQuad(shader_dof);
|
||||||
|
piSwap<int>(wi, ri);
|
||||||
|
fbo_out.setWriteBuffer(wi);
|
||||||
|
glBindTexture(GL_TEXTURE_2D, fbo_out.colorTexture(ri));
|
||||||
|
shader_dof->setUniformValue("dt", QVector2D(0., 1. / fbo_out.height()));
|
||||||
|
glDrawQuad(shader_dof);
|
||||||
|
piSwap<int>(wi, ri);
|
||||||
|
crad *= 2.;
|
||||||
|
}
|
||||||
|
|
||||||
|
glActiveTextureChannel(0);
|
||||||
|
glBindTexture(GL_TEXTURE_2D, fbo_out.colorTexture(ri));
|
||||||
|
}
|
||||||
|
|
||||||
if (view.isFeatureEnabled(QGLView::qglEyeAccomodationEnabled)) {
|
if (view.isFeatureEnabled(QGLView::qglEyeAccomodationEnabled)) {
|
||||||
fbo_hsmall.bind();
|
fbo_hsmall.bind();
|
||||||
fbo_hsmall.setWriteBuffer(0);
|
fbo_hsmall.setWriteBuffer(0);
|
||||||
@@ -350,7 +402,7 @@ void RendererDeferredShading::renderScene() {
|
|||||||
glDrawQuad(shader_small);
|
glDrawQuad(shader_small);
|
||||||
hcontent.resize(fbo_hsmall.width() * fbo_hsmall.height());
|
hcontent.resize(fbo_hsmall.width() * fbo_hsmall.height());
|
||||||
glReadPixels(0, 0, fbo_hsmall.width(), fbo_hsmall.height(), GL_RGB, GL_FLOAT, hcontent.data());
|
glReadPixels(0, 0, fbo_hsmall.width(), fbo_hsmall.height(), GL_RGB, GL_FLOAT, hcontent.data());
|
||||||
GLfloat max[3] = {0.,0.,0.};//min[3] = {10000.,10000.,10000.}, ;
|
GLfloat max[3] = {0.,0.,0.};//min[3] = {10000.,10000.,10000.},;
|
||||||
for (int i = 0; i < hcontent.size(); ++i) {
|
for (int i = 0; i < hcontent.size(); ++i) {
|
||||||
//if (min[0] > hcontent[i].x) min[0] = hcontent[i].x;
|
//if (min[0] > hcontent[i].x) min[0] = hcontent[i].x;
|
||||||
if (max[0] < hcontent[i].x) max[0] = hcontent[i].x;
|
if (max[0] < hcontent[i].x) max[0] = hcontent[i].x;
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ private:
|
|||||||
QGLShaderProgram * shader_fxaa, * shader_ds_0, * shader_ds_1, * shader_hdr, * shader_small;
|
QGLShaderProgram * shader_fxaa, * shader_ds_0, * shader_ds_1, * shader_hdr, * shader_small;
|
||||||
QGLShaderProgram * shader_bloom_0, * shader_bloom_1, * shader_motion_blur, * shader_fbo_add;
|
QGLShaderProgram * shader_bloom_0, * shader_bloom_1, * shader_motion_blur, * shader_fbo_add;
|
||||||
QGLShaderProgram * shader_shadow, * shader_ssr, * shader_ssr_blur, * shader_ssr_merge;
|
QGLShaderProgram * shader_shadow, * shader_ssr, * shader_ssr_blur, * shader_ssr_merge;
|
||||||
QGLShaderProgram * shader_ssao_blur, * shader_ssao_merge;
|
QGLShaderProgram * shader_ssao_blur, * shader_ssao_merge, * shader_dof;
|
||||||
GLuint tnoise;
|
GLuint tnoise;
|
||||||
QVector<ShaderPair> shaders;
|
QVector<ShaderPair> shaders;
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ const vec3 luma = vec3(0.299, 0.587, 0.114);
|
|||||||
|
|
||||||
void main(void) {
|
void main(void) {
|
||||||
//float z = pos.w;//((z_near / (z_near-z_far)) * z_far) / (pos.w - (z_far / (z_far-z_near)));
|
//float z = pos.w;//((z_near / (z_near-z_far)) * z_far) / (pos.w - (z_far / (z_far-z_near)));
|
||||||
float logz = log(pos.w * C + 1.) * FC;
|
//float logz = log(pos.w * C + 1.) * FC;
|
||||||
vec4 dc = qgl_FragColor;
|
vec4 dc = qgl_FragColor;
|
||||||
vec2 tc = qgl_FragTexture.xy;
|
vec2 tc = qgl_FragTexture.xy;
|
||||||
float hei = dot(texture(qgl_Material.map_relief.map, tc).rgb, luma) * qgl_Material.map_relief.amount + qgl_Material.map_relief.offset;
|
float hei = dot(texture(qgl_Material.map_relief.map, tc).rgb, luma) * qgl_Material.map_relief.amount + qgl_Material.map_relief.offset;
|
||||||
@@ -44,7 +44,7 @@ void main(void) {
|
|||||||
//speed /= abs(pos.z);
|
//speed /= abs(pos.z);
|
||||||
|
|
||||||
//gl_FragDepth = logz;
|
//gl_FragDepth = logz;
|
||||||
qgl_FragData[0] = vec4(dc.rgb, pos.w);
|
qgl_FragData[0] = vec4(dc.rgb, 0.);
|
||||||
qgl_FragData[1] = vec4(n.xyz, specularity + round(reflectivity * 100));
|
qgl_FragData[1] = vec4(n.xyz, specularity + round(reflectivity * 100));
|
||||||
qgl_FragData[2] = vec4(spec.rgb, hei);
|
qgl_FragData[2] = vec4(spec.rgb, hei);
|
||||||
qgl_FragData[3] = vec4(self.rgb, bn.x);
|
qgl_FragData[3] = vec4(self.rgb, bn.x);
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ float sh_pow, sh_mul, dist, NdotL, NdotH, spot, ldist, diff, sdist, shadow;
|
|||||||
|
|
||||||
float getShadow(int light, vec3 view_pos, vec3 dpos) {
|
float getShadow(int light, vec3 view_pos, vec3 dpos) {
|
||||||
shp = qgl_Light[light].shadowMatrix * vec4(view_pos + dpos, 1);
|
shp = qgl_Light[light].shadowMatrix * vec4(view_pos + dpos, 1);
|
||||||
shp.z -= 0.05;
|
shp.z -= z_near / 20.;
|
||||||
return textureProj(qgl_Light[light].shadow, shp);
|
return textureProj(qgl_Light[light].shadow, shp);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -87,18 +87,26 @@ void calcLight(in int index, in vec3 n, in vec3 v, in vec4 v2) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const float _pe = 2.4e-7;
|
||||||
|
|
||||||
void main(void) {
|
void main(void) {
|
||||||
//if (d == 1.) discard;
|
//if (d == 1.) discard;
|
||||||
ivec2 tc = ivec2(gl_FragCoord.xy);
|
ivec2 tc = ivec2(gl_FragCoord.xy);
|
||||||
vec4 v0 = texelFetch(t0, tc, 0);
|
float z = texelFetch(td, tc, 0).r;
|
||||||
if (v0.w == 0.) {
|
if (z == 1.) {
|
||||||
qgl_FragData[0] = back_color;
|
qgl_FragData[0] = back_color;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
vec4 v1 = texelFetch(t1, tc, 0),
|
vec4 v0 = texelFetch(t0, tc, 0),
|
||||||
|
v1 = texelFetch(t1, tc, 0),
|
||||||
v2 = texelFetch(t2, tc, 0),
|
v2 = texelFetch(t2, tc, 0),
|
||||||
v3 = texelFetch(t3, tc, 0),
|
v3 = texelFetch(t3, tc, 0),
|
||||||
v4 = texelFetch(t4, tc, 0);
|
v4 = texelFetch(t4, tc, 0);
|
||||||
|
|
||||||
|
z = z + z - 1;
|
||||||
|
z = ((_pe - 2.) * z_near) / (z + _pe - 1.); // infinite depth
|
||||||
|
|
||||||
vec2 sp = gl_FragCoord.xy * dt * 2 - vec2(1, 1);
|
vec2 sp = gl_FragCoord.xy * dt * 2 - vec2(1, 1);
|
||||||
vec3 dc = v0.rgb, n = v1.xyz;
|
vec3 dc = v0.rgb, n = v1.xyz;
|
||||||
bn = normalize(vec3(v3.w, v4.zw));
|
bn = normalize(vec3(v3.w, v4.zw));
|
||||||
@@ -113,7 +121,7 @@ void main(void) {
|
|||||||
pos.z = posz;*/
|
pos.z = posz;*/
|
||||||
|
|
||||||
pos.w = 1;
|
pos.w = 1;
|
||||||
pos.xyz = view_dir * v0.w;
|
pos.xyz = view_dir * z;
|
||||||
pos.z = -pos.z;
|
pos.z = -pos.z;
|
||||||
|
|
||||||
//pos.z = posz;
|
//pos.z = posz;
|
||||||
@@ -133,10 +141,10 @@ void main(void) {
|
|||||||
sh_mul = max(1. - specularity, 0.0001);
|
sh_mul = max(1. - specularity, 0.0001);
|
||||||
for (int i = 0; i < 8; ++i)
|
for (int i = 0; i < 8; ++i)
|
||||||
calcLight(i, n, v, v2);
|
calcLight(i, n, v, v2);
|
||||||
calcLight(0, n, v, v2);
|
// calcLight(0, n, v, v2);
|
||||||
|
|
||||||
qgl_FragData[0] = vec4(max(vec3(0), li * dc + si * v2.rgb + v3.rgb + texelFetch(t_pp, tc, 0).rgb), v0.w);
|
qgl_FragData[0] = vec4(max(vec3(0), li * dc + si * v2.rgb + v3.rgb + texelFetch(t_pp, tc, 0).rgb), v0.w);
|
||||||
//qgl_FragData[0].rgb = vec3(abs((v0.w)/50));
|
//qgl_FragData[0].rgb = vec3(-z);
|
||||||
//qgl_FragData[0].rgb = li + vec3(texelFetch(t_pp, tc, 0).xyz);
|
//qgl_FragData[0].rgb = li + vec3(texelFetch(t_pp, tc, 0).xyz);
|
||||||
//shd = shd - shp.w;
|
//shd = shd - shp.w;
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,7 @@
|
|||||||
#version 150
|
#version 150
|
||||||
|
|
||||||
in float logz;
|
|
||||||
|
|
||||||
uniform vec4 id;
|
uniform vec4 id;
|
||||||
|
|
||||||
void main(void) {
|
void main(void) {
|
||||||
gl_FragDepth = logz;
|
|
||||||
qgl_FragData[0] = id;
|
qgl_FragData[0] = id;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,14 +1,8 @@
|
|||||||
#version 150
|
#version 150
|
||||||
|
|
||||||
out float logz;
|
|
||||||
|
|
||||||
uniform float z_near, z_far;
|
uniform float z_near, z_far;
|
||||||
|
|
||||||
const float C = 0.0001;
|
|
||||||
float FC = 1. / log(z_far * C + 1.);
|
|
||||||
|
|
||||||
void main(void) {
|
void main(void) {
|
||||||
vec4 pos = qgl_ftransform();
|
vec4 pos = qgl_ftransform();
|
||||||
logz = log(pos.w * C + 1.) * FC;
|
|
||||||
gl_Position = pos;
|
gl_Position = pos;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,20 +1,26 @@
|
|||||||
#version 150
|
#version 150
|
||||||
|
|
||||||
uniform sampler2D t0, t1, ts, tbs;
|
uniform sampler2D t0, t1, ts, td, tbs;
|
||||||
uniform float z_near, z_far;
|
uniform float z_near, z_far;
|
||||||
uniform mat4 mat_proj;
|
uniform mat4 mat_proj;
|
||||||
uniform vec3 cam_aim, cam_pos;
|
uniform vec3 cam_aim, cam_pos;
|
||||||
|
|
||||||
in vec3 view_dir;
|
in vec3 view_dir;
|
||||||
|
|
||||||
|
const float _pe = 2.4e-7;
|
||||||
|
|
||||||
void main(void) {
|
void main(void) {
|
||||||
ivec2 tc = ivec2(gl_FragCoord.xy);
|
ivec2 tc = ivec2(gl_FragCoord.xy);
|
||||||
vec4 v0 = texelFetch(t0, tc, 0), v1 = texelFetch(t1, tc, 0), vs = texelFetch(ts, tc, 0);
|
vec4 v0 = texelFetch(t0, tc, 0), v1 = texelFetch(t1, tc, 0), vs = texelFetch(ts, tc, 0);
|
||||||
vec3 sp = vec3(qgl_FragTexture.xy, v0.w);
|
vec3 sp = vec3(qgl_FragTexture.xy, v0.w);
|
||||||
vec2 tsp;
|
vec2 tsp;
|
||||||
vec4 pos;
|
vec4 pos;
|
||||||
|
float z = texelFetch(td, tc, 0).r;
|
||||||
|
z = z + z - 1;
|
||||||
|
z = ((_pe - 2.) * z_near) / (z + _pe - 1.); // infinite depth
|
||||||
pos.w = 1;
|
pos.w = 1;
|
||||||
pos.xyz = view_dir * v0.w;
|
pos.xyz = view_dir * z;
|
||||||
|
//pos.z = -pos.z;
|
||||||
vec4 spos = pos;
|
vec4 spos = pos;
|
||||||
vec4 tpos;
|
vec4 tpos;
|
||||||
|
|
||||||
@@ -22,9 +28,11 @@ void main(void) {
|
|||||||
vec3 vd = -normalize(vec3(-view_dir.xy, view_dir.z));
|
vec3 vd = -normalize(vec3(-view_dir.xy, view_dir.z));
|
||||||
vec3 rn = reflect(vd, n);
|
vec3 rn = reflect(vd, n);
|
||||||
//rn.z += 1.;
|
//rn.z += 1.;
|
||||||
float coeff = clamp(1. - (dot(vec3(0,0,1), n)), 0, 1), cz = v0.w;
|
float coeff = clamp(1. - (dot(vec3(0,0,1), n)), 0, 1);
|
||||||
coeff = coeff*coeff;
|
coeff = coeff*coeff;
|
||||||
|
/*coeff = coeff*coeff;
|
||||||
coeff = coeff*coeff;
|
coeff = coeff*coeff;
|
||||||
|
coeff = coeff*coeff;*/
|
||||||
float reflectivity = 0.;
|
float reflectivity = 0.;
|
||||||
float specularity = modf(v1.w, reflectivity);
|
float specularity = modf(v1.w, reflectivity);
|
||||||
|
|
||||||
@@ -33,12 +41,15 @@ void main(void) {
|
|||||||
vec4 tv0;
|
vec4 tv0;
|
||||||
float l = z_far * 0.5;
|
float l = z_far * 0.5;
|
||||||
pos.xyz += rn * l;
|
pos.xyz += rn * l;
|
||||||
for (i = 0; i < 20; ++i) {
|
float cz;
|
||||||
|
for (i = 0; i < 24; ++i) {
|
||||||
tpos = mat_proj * pos;
|
tpos = mat_proj * pos;
|
||||||
tsp = -(tpos.xy / tpos.w) / 2. + 0.5;
|
tsp = -(tpos.xy / tpos.w) / 2. + 0.5;
|
||||||
tv0 = texture(t0, tsp);
|
cz = texture(td, tsp).r;
|
||||||
|
cz = cz + cz - 1;
|
||||||
|
cz = ((_pe - 2.) * z_near) / (cz + _pe - 1.); // infinite depth
|
||||||
l *= 0.5;
|
l *= 0.5;
|
||||||
pos.xyz += rn * (step(pos.z, tv0.w) * 2. - 1.) * l;
|
pos.xyz += rn * (step(pos.z, cz) * 2. - 1.) * l;
|
||||||
}
|
}
|
||||||
|
|
||||||
vec2 ess = abs(tsp - vec2(0.5, 0.5)) - vec2(0.3, 0.3);
|
vec2 ess = abs(tsp - vec2(0.5, 0.5)) - vec2(0.3, 0.3);
|
||||||
@@ -52,4 +63,5 @@ void main(void) {
|
|||||||
vec3 rvs = texture(ts, tsp).rgb;
|
vec3 rvs = texture(ts, tsp).rgb;
|
||||||
|
|
||||||
qgl_FragData[0] = vec4(rvs.rgb, coeff / 1.1 + clamp(round(blur * 10), 0, 1000));
|
qgl_FragData[0] = vec4(rvs.rgb, coeff / 1.1 + clamp(round(blur * 10), 0, 1000));
|
||||||
|
//qgl_FragData[0] = vec4(rvs.rgb, cz/5);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ void main(void) {
|
|||||||
float r = float(radius);
|
float r = float(radius);
|
||||||
vec4 v0 = texture(t0, tc);
|
vec4 v0 = texture(t0, tc);
|
||||||
float rad;
|
float rad;
|
||||||
float coeff = modf(v0.a, rad) * 1.1;
|
float coeff = modf(v0.w, rad) * 1.1;
|
||||||
rad /= 10.;
|
rad /= 10.;
|
||||||
rad *= 2;
|
rad *= 2;
|
||||||
float o = radius * rad, o2 = radius * rad * 2;
|
float o = radius * rad, o2 = radius * rad * 2;
|
||||||
|
|||||||
@@ -6,10 +6,10 @@ void main(void) {
|
|||||||
ivec2 tc = ivec2(gl_FragCoord.xy);
|
ivec2 tc = ivec2(gl_FragCoord.xy);
|
||||||
vec4 v0 = texelFetch(t0, tc, 0), vg1 = texelFetch(tg1, tc, 0), vs = texelFetch(ts, tc, 0);
|
vec4 v0 = texelFetch(t0, tc, 0), vg1 = texelFetch(tg1, tc, 0), vs = texelFetch(ts, tc, 0);
|
||||||
float rad;
|
float rad;
|
||||||
float coeff = clamp(modf(v0.a, rad) * 1.1, 0., 1.);
|
float coeff = clamp(modf(v0.w, rad) * 1.1, 0., 1.);
|
||||||
float reflectivity = 0.;
|
float reflectivity = 0.;
|
||||||
float specularity = modf(vg1.w, reflectivity);
|
float specularity = modf(vg1.w, reflectivity);
|
||||||
reflectivity = clamp(reflectivity / 100., 0., 1.);
|
reflectivity = clamp(reflectivity / 100., 0., 1.);
|
||||||
qgl_FragData[0].rgb = mix(vs.rgb, v0.rgb, coeff * reflectivity);
|
qgl_FragData[0].rgb = mix(vs.rgb, v0.rgb, coeff * reflectivity);
|
||||||
//qgl_FragData[0].rgb = vec3(vs.rgb*coeff * reflectivity);
|
//qgl_FragData[0].rgb = vec3(v0.w);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user