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

This commit is contained in:
2015-12-09 15:44:03 +00:00
parent 64f21dc682
commit 458a516317
31 changed files with 1486 additions and 870 deletions

View File

@@ -7,7 +7,7 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2 -Wall")
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g3")
set(CMAKE_C_FLAGS "${CMAKE_CXX_FLAGS}")
set(LIBS ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY} ${QT_QTOPENGL_LIBRARY} ${QT_QTXML_LIBRARY} qad_widgets)
set(LIBS ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY} ${QT_QTOPENGL_LIBRARY} ${QT_QTXML_LIBRARY} qad_widgets qad_utils)
find_package(OpenGL REQUIRED)
list(APPEND LIBS ${OPENGL_LIBRARIES})
@@ -41,5 +41,5 @@ endif ()
qt4_wrap_cpp(CMOCS_TEST "mainwindow.h" OPTIONS -nw)
qt4_wrap_ui(CUIS_TEST "mainwindow.ui")
add_executable(qglview_test "main.cpp" "mainwindow.cpp" ${CMOCS_TEST} ${CUIS_TEST})
target_link_libraries(qglview_test ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY} ${QT_QTOPENGL_LIBRARY} ${QT_QTXML_LIBRARY} qglview qad_widgets)
add_executable(qglview_test "main.cpp" "mainwindow.cpp" ${CMOCS_TEST} ${CUIS_TEST} ${CRES})
target_link_libraries(qglview_test ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY} ${QT_QTOPENGL_LIBRARY} ${QT_QTXML_LIBRARY} qglview qad_widgets qad_utils)

View File

@@ -24,6 +24,7 @@ QMatrix4x4 globCameraMatrix;
Camera::Camera() {
type_ = glCamera;
fov_ = 60.;
angle_limit_lower_xy = 0.;
angle_limit_upper_xy = 360.;

View File

@@ -30,6 +30,8 @@ class Camera: public GLObjectBase
{
friend class QGLView;
friend class GLParticlesSystem;
friend QDataStream & operator <<(QDataStream & s, const GLObjectBase * p);
friend QDataStream & operator >>(QDataStream & s, GLObjectBase *& p);
public:
Camera();

View File

@@ -20,6 +20,7 @@
#define GLMATERIAL_H
#include "gltypes.h"
#include "chunkstream.h"
class GLTexture {
public:
@@ -126,9 +127,53 @@ struct Material {
GLCubeTexture map_reflection;
};
inline QDataStream & operator <<(QDataStream & s, const Map & m) {s << m.bitmap_path << m.color_amount << m.color_offset << m.animation << m.animation_frame_rate; return s;}
inline QDataStream & operator >>(QDataStream & s, Map & m) {s >> m.bitmap_path >> m.color_amount >> m.color_offset >> m.animation >> m.animation_frame_rate; return s;}
inline QDataStream & operator <<(QDataStream & s, const Material & m) {s << m.name << m.color_diffuse << m.color_specular << m.color_self_illumination << m.transparency << m.reflectivity << m.glass << m.map_diffuse << m.map_normal << m.map_relief << m.map_specular << m.map_specularity << m.map_self_illumination; return s;}
inline QDataStream & operator >>(QDataStream & s, Material & m) {s >> m.name >> m.color_diffuse >> m.color_specular >> m.color_self_illumination >> m.transparency >> m.reflectivity >> m.glass >> m.map_diffuse >> m.map_normal >> m.map_relief >> m.map_specular >> m.map_specularity >> m.map_self_illumination; return s;}
inline QDataStream & operator <<(QDataStream & s, const Map & m) {
ChunkStream cs;
cs << cs.chunk(1, m.bitmap_path) << cs.chunk(2, m.color_amount) << cs.chunk(3, m.color_offset) << cs.chunk(4, m.animation) << cs.chunk(5, m.animation_frame_rate);
s << cs.data(); return s;
}
inline QDataStream & operator >>(QDataStream & s, Map & m) {
ChunkStream cs(s);
while (!cs.atEnd()) {
switch (cs.read()) {
case 1: m.bitmap_path = cs.getData<QString>(); break;
case 2: m.color_amount = cs.getData<float>(); break;
case 3: m.color_offset = cs.getData<float>(); break;
case 4: m.animation = cs.getData<QString>(); break;
case 5: m.animation_frame_rate = cs.getData<float>(); break;
}
}
return s;
}
inline QDataStream & operator <<(QDataStream & s, const Material & m) {
ChunkStream cs;
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(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;
}
inline QDataStream & operator >>(QDataStream & s, Material & m) {
ChunkStream cs(s);
while (!cs.atEnd()) {
switch (cs.read()) {
case 1: m.name = cs.getData<QString>(); break;
case 2: m.color_diffuse = cs.getData<QColor>(); break;
case 3: m.color_specular = cs.getData<QColor>(); break;
case 4: m.color_self_illumination = cs.getData<QColor>(); break;
case 5: m.transparency = cs.getData<float>(); break;
case 6: m.reflectivity = cs.getData<float>(); break;
case 7: m.glass = cs.getData<bool>(); break;
case 8: m.map_diffuse = cs.getData<Map>(); break;
case 9: m.map_normal = cs.getData<Map>(); break;
case 10: m.map_relief = cs.getData<Map>(); break;
case 11: m.map_specular = cs.getData<Map>(); break;
case 12: m.map_specularity = cs.getData<Map>(); break;
case 13: m.map_self_illumination = cs.getData<Map>(); break;
}
}
return s;
}
#endif // GLMATERIAL_H

View File

@@ -18,10 +18,11 @@
#include "globject.h"
#include "glcamera.h"
#include "qglview.h"
GLObjectBase::GLObjectBase() {
type_ = Mesh;
type_ = glMesh;
render_mode = View;
pass_ = Solid;
geom_prim = Triangles;
@@ -32,7 +33,7 @@ GLObjectBase::GLObjectBase() {
line_width = -1.;
blend_src = GL_SRC_ALPHA;
blend_dest = GL_ONE_MINUS_SRC_ALPHA;
type_ = Mesh;
type_ = glMesh;
raw_matrix = false;
mat_.setToIdentity();
view_ = 0;
@@ -96,6 +97,13 @@ void GLObjectBase::draw(QGLShaderProgram * prog, bool simplest) {
}
void GLObjectBase::setView(QGLView * v) {
view_ = v;
foreach (GLObjectBase * c, children_)
c->setView(v);
}
QList<GLObjectBase * > GLObjectBase::children(bool all_) {
if (!all_) return children_;
QList<GLObjectBase * > cl;
@@ -144,6 +152,14 @@ void GLObjectBase::setTransform(const QMatrix4x4 & t) {
}
void GLObjectBase::select() {
//qDebug() << "select" << name() << view_;
selected_ = true;
if (view_)
((QGLView*)view_)->selectObject(this);
}
void GLObjectBase::buildTransform() {
itransform_.setToIdentity();
GLObjectBase * p = parent_;
@@ -212,7 +228,7 @@ void GLObjectBase::render(int * id, QMap<int, GLObjectBase * > * ids, int sh_id_
Light::Light(): GLObjectBase(), shadow_map(0, true, GL_R16F) {
type_ = GLObjectBase::Light;
type_ = glLight;
light_type = Omni;
intensity = 1.;
angle_start = angle_end = 180.;
@@ -223,7 +239,7 @@ Light::Light(): GLObjectBase(), shadow_map(0, true, GL_R16F) {
Light::Light(const QVector3D & p, const QColor & c, GLdouble i): GLObjectBase(), shadow_map(0, true, GL_R16F) {
type_ = GLObjectBase::Light;
type_ = glLight;
light_type = Omni;
pos_ = p;
intensity = i;
@@ -279,3 +295,87 @@ void Light::draw(QGLShaderProgram * prog, bool simplest) {
if (l) glEnable(GL_LIGHTING);
}
QDataStream & operator <<(QDataStream & s, const GLObjectBase * p) {
ChunkStream cs;
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(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(17, p->name_);
if (p->type_ == GLObjectBase::glLight) {
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.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));
}
if (p->type_ == GLObjectBase::glCamera) {
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.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);
}
s << cs.data(); return s;
}
QDataStream & operator >>(QDataStream & s, GLObjectBase *& p) {
ChunkStream cs(s);
p = 0;
Light * l = 0;
Camera * c = 0;
while (!cs.atEnd()) {
switch (cs.read()) {
case 1:
{
GLObjectBase::Type type = (GLObjectBase::Type)cs.getData<int>();
switch (type) {
case GLObjectBase::glMesh: p = new GLObjectBase(); break;
case GLObjectBase::glLight: p = new Light(); l = (Light*)p; break;
case GLObjectBase::glCamera: p = new Camera(); c = (Camera*)p; break;
default : break;
}
if (p) p->type_ = type;
}
break;
case 2: if (p) p->accept_light = cs.getData<bool>(); break;
case 3: if (p) p->accept_fog = cs.getData<bool>(); break;
case 4: if (p) p->visible_ = cs.getData<bool>(); break;
case 5: if (p) p->cast_shadow = cs.getData<bool>(); break;
case 6: if (p) p->rec_shadow = cs.getData<bool>(); break;
case 7: if (p) p->raw_matrix = cs.getData<bool>(); break;
case 8: if (p) p->line_width = cs.getData<double>(); break;
case 9: if (p) p->render_mode = (GLObjectBase::RenderMode)cs.getData<int>(); break;
case 10: if (p) p->material_ = cs.getData<Material>(); break;
case 11: if (p) p->pos_ = cs.getData<QVector3D>(); break;
case 12: if (p) p->angles_ = 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 15: if (p) p->vbo = cs.getData<GLVBO>(); break;
case 16: if (p) {
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 100: if (l) l->direction = cs.getData<QVector3D>(); break;
case 101: if (l) l->angle_start = cs.getData<GLdouble>(); break;
case 102: if (l) l->angle_end = cs.getData<GLdouble>(); break;
case 103: if (l) l->intensity = cs.getData<GLdouble>(); break;
case 104: if (l) l->decay_const = cs.getData<GLdouble>(); break;
case 105: if (l) l->decay_linear = cs.getData<GLdouble>(); break;
case 106: if (l) l->decay_quadratic = cs.getData<GLdouble>(); break;
case 107: if (l) l->decay_start = cs.getData<GLdouble>(); break;
case 108: if (l) l->decay_end = cs.getData<GLdouble>(); break;
case 109: if (l) l->light_type = (Light::Type)cs.getData<int>(); break;
case 200: if (c) c->setAim(cs.getData<QVector3D>()); break;
case 201: if (c) c->setFOV(cs.getData<GLdouble>()); break;
case 202: if (c) c->setDepthStart(cs.getData<GLdouble>()); break;
case 203: if (c) c->setDepthEnd(cs.getData<GLdouble>()); break;
case 204: if (c) c->setAngleLowerLimitXY(cs.getData<GLdouble>()); break;
case 205: if (c) c->setAngleUpperLimitXY(cs.getData<GLdouble>()); break;
case 206: if (c) c->mirror_x = cs.getData<bool>(); break;
case 207: if (c) c->mirror_y = cs.getData<bool>(); break;
}
}
return s;
}

View File

@@ -24,13 +24,17 @@
#include "glmaterial.h"
class Camera;
class QGLView;
class GLObjectBase
{
friend class QGLView;
friend class GLRendererBase;
friend QDataStream & operator <<(QDataStream & s, const GLObjectBase * p);
friend QDataStream & operator >>(QDataStream & s, GLObjectBase *& p);
friend GLObjectBase * loadFromQGLFile(const QString & filepath);
public:
enum Type {Mesh, Light, ParticlesSystem};
enum Type {glMesh, glLight, glCamera, glParticlesSystem};
enum Pass {Solid, Transparent, Reflection, User};
enum GeomPrimitives {Triangles = GL_TRIANGLES, Quads = GL_QUADS};
enum RenderMode {View = 0, Point = GL_POINT, Line = GL_LINE, Fill = GL_FILL};
@@ -60,6 +64,7 @@ public:
void setParent(GLObjectBase * o) {parent_ = o;}
bool hasParent() const {return parent_ != 0;}
bool hasChildren() const {return children_.size() != 0;}
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 removeChild(GLObjectBase * o) {if (o == this) return; children_.removeAll(o); o->parent_ = 0; o->buildTransform(); if (view_ != 0) view_->collectLights();}
@@ -68,6 +73,8 @@ public:
int childCount() const {return children_.size();}
GLObjectBase * child(int index) {if (index < 0 || index >= children_.size()) return 0; return children_[index];}
GLObjectBase * child(const QString & name) {foreach (GLObjectBase * i, children_) if (i->name_ == name) return i; return 0;}
const GLObjectBase * child(int index) const {if (index < 0 || index >= children_.size()) return 0; return children_[index];}
const GLObjectBase * child(const QString & name) const {foreach (GLObjectBase * i, children_) if (i->name_ == name) return i; return 0;}
QList<GLObjectBase * > children(bool all_ = false);
bool isVisible() const {return visible_;}
@@ -145,7 +152,7 @@ public:
bool isSelected() const {return selected_;}
void setSelected(bool yes) {selected_ = yes;}
void select() {selected_ = true;}
void select();
void deselect() {selected_ = false;}
bool isSelectable() const {return select_;}
@@ -246,4 +253,8 @@ inline T globject_cast(GLObjectBase * object) {return reinterpret_cast<T>(object
template <class T>
inline T globject_cast(const GLObjectBase * object) {return reinterpret_cast<T>(object);}
QDataStream & operator <<(QDataStream & s, const GLObjectBase * p);
QDataStream & operator >>(QDataStream & s, GLObjectBase *& p);
#endif // GLOBJECT_H

View File

@@ -64,8 +64,8 @@ void GLObjectEditor::setObject(GLObjectBase * o) {
checkCastShadows->setChecked(object->isCastShadows());
checkReceiveShadows->setChecked(object->isReceiveShadows());
comboRenderMode->setCurrentIndex(rmodes.indexOf(object->renderMode()));
groupLight->setEnabled(object->type() == GLObjectBase::Light);
if (object->type() == GLObjectBase::Light) {
groupLight->setEnabled(object->type() == GLObjectBase::glLight);
if (object->type() == GLObjectBase::glLight) {
Light * l = globject_cast<Light * >(object);
//bool is_dir = l->light_type == Light::Directional, is_cone = l->light_type == Light::Cone;
buttonLightColor->setColor(l->color());
@@ -102,7 +102,7 @@ void GLObjectEditor::objectChanged() {
object->setCastShadows(checkCastShadows->isChecked());
object->setReceiveShadows(checkReceiveShadows->isChecked());
object->setRenderMode((GLObjectBase::RenderMode)rmodes[comboRenderMode->currentIndex()]);
if (object->type() == GLObjectBase::Light) {
if (object->type() == GLObjectBase::glLight) {
Light * l = globject_cast<Light * >(object);
//bool is_dir = l->light_type == Light::Directional, is_cone = l->light_type == Light::Cone;
l->setColor(buttonLightColor->color());

View File

@@ -151,6 +151,9 @@
</item>
<item row="6" column="1">
<widget class="QDoubleSpinBox" name="spinScaleX">
<property name="decimals">
<number>4</number>
</property>
<property name="minimum">
<double>-99999.000000000000000</double>
</property>
@@ -167,6 +170,9 @@
</item>
<item row="7" column="1">
<widget class="QDoubleSpinBox" name="spinScaleY">
<property name="decimals">
<number>4</number>
</property>
<property name="minimum">
<double>-99999.000000000000000</double>
</property>
@@ -183,6 +189,9 @@
</item>
<item row="8" column="1">
<widget class="QDoubleSpinBox" name="spinScaleZ">
<property name="decimals">
<number>4</number>
</property>
<property name="minimum">
<double>-99999.000000000000000</double>
</property>

View File

@@ -20,10 +20,13 @@
#define GLVBO_H
#include "gltypes.h"
#include "chunkstream.h"
class GLVBO
{
friend class GLObjectBase;
friend QDataStream & operator <<(QDataStream & s, const GLVBO & m);
friend QDataStream & operator >>(QDataStream & s, GLVBO & m);
public:
GLVBO(GLenum usage = GL_DYNAMIC_DRAW);
~GLVBO();
@@ -64,4 +67,25 @@ private:
};
inline QDataStream & operator <<(QDataStream & s, const GLVBO & m) {
ChunkStream cs;
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;
}
inline QDataStream & operator >>(QDataStream & s, GLVBO & m) {
ChunkStream cs(s);
while (!cs.atEnd()) {
switch (cs.read()) {
case 1: m.vertices_ = cs.getData<QVector<GLfloat> >(); break;
case 2: m.normals_ = cs.getData<QVector<GLfloat> >(); break;
case 3: m.texcoords_ = cs.getData<QVector<GLfloat> >(); break;
case 4: m.colors_ = cs.getData<QVector<GLfloat> >(); break;
case 5: m.usage = cs.getData<GLenum>(); break;
}
}
m.changed = true;
return s;
}
#endif // GLVBO_H

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

BIN
qglview/icons/type-geo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 971 B

View File

@@ -400,7 +400,7 @@ GLObjectBase * loadFromDAEFile(const QString & filepath, double scale) {
for (int i = 0; i < root->childCount(); ++i) {
GLObjectBase * o = root->child(i);
if (o->type() == GLObjectBase::Light) {
if (o->type() == GLObjectBase::glLight) {
Light * l = (Light*)o;
if (l->light_type == Light::Directional || l->light_type == Light::Cone) {
QString tn = l->name() + ".Target";
@@ -423,6 +423,7 @@ GLObjectBase * loadFromDAEFile(const QString & filepath, double scale) {
for (int j = 0; j < dol[i].size(); ++j)
delete dol[i][j];
root->setScale(0.001);
qDebug() << "[Loader DAE] Loaded" << root->childCount() << "objects from" << filepath;
return root;
}

64
qglview/loader_qgl.cpp Normal file
View File

@@ -0,0 +1,64 @@
/*
QGLView
Copyright (C) 2012 Ivan Pelipenko peri4ko@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "loader_qgl.h"
#include "chunkstream.h"
GLObjectBase * loadFromQGLFile(const QString & filepath) {
QFile f(filepath);
if (!f.exists()) {
qDebug() << "[Loader QGL] Error: can`t open \"" + filepath + "\"";
return 0;
}
f.open(QIODevice::ReadOnly);
QDataStream s(&f);
char sign[4];
s.readRawData(sign, 4);
if ((sign[0] != 'Q') || (sign[1] != 'G') || (sign[2] != 'L') || (sign[3] != 'F')) {
qDebug() << "[Loader QGL] Error: \"" + filepath + "\" is not valid QGL file!";
return 0;
}
QByteArray fc_; s >> fc_;
QByteArray fc = qUncompress(fc_);
if (fc.isEmpty()) return 0;
QDataStream os(fc);
GLObjectBase * root = 0;
os >> root;
root->buildTransform();
if (root->name().isEmpty())
root->setName(QFileInfo(f).baseName());
qDebug() << "[Loader QGL] Loaded" << root->childCount() << "objects from" << filepath;
return root;
}
bool saveToQGLFile(const QString & filepath, const GLObjectBase * o) {
QFile f(filepath);
if (!f.open(QIODevice::ReadWrite))
return false;
f.resize(0);
QDataStream s(&f);
char sign[4] = {'Q', 'G', 'L', 'F'};
s.writeRawData(sign, 4);
QByteArray fc;
QDataStream os(&fc, QIODevice::ReadWrite);
os << o;
s << qCompress(fc);
return true;
}

31
qglview/loader_qgl.h Normal file
View File

@@ -0,0 +1,31 @@
/*
QGLView
Copyright (C) 2012 Ivan Pelipenko peri4ko@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef LOADER_QGL_H
#define LOADER_QGL_H
#include "globject.h"
#include <QFileInfo>
namespace LoaderQGL {
}
GLObjectBase * loadFromQGLFile(const QString & filepath);
bool saveToQGLFile(const QString & filepath, const GLObjectBase * o);
#endif // LOADER_QGL_H

View File

@@ -17,23 +17,27 @@
*/
#include "mainwindow.h"
#include "loader_qgl.h"
#include "loader_ase.h"
#include "loader_3ds.h"
#include "loader_obj.h"
#include "loader_dae.h"
#include <QGraphicsRectItem>
#include <QImageReader>
#include <QMessageBox>
#define EARTH_H 6356863.019 // m
#define EARTH_WL 6378245.000 // m
MainWindow::MainWindow(QWidget * parent): QMainWindow(parent), Ui::MainWindow() {
setupUi(this);
colorHalo->setColor(view->selectionHaloColor());
icon_geo = QIcon(":/icons/type-geo.png");
icon_camera = QIcon(":/icons/type-camera.png");
icon_light = QIcon(":/icons/type-light.png");
sel_obj = 0;
//spinSliderShine->setDecimals(2);
view->camera().setAim(QVector3D());
view->camera().setPos(QVector3D(2, 2, 2));
view->setFrameShape(QFrame::NoFrame);
view->setRenderer(new RendererDeferredShading(view));
//view->setRenderer(new RendererSimple(view));
view->setMouseRotateEnabled(true);
view->setMouseSelectionEnabled(true);
view->setSelectionHaloEnabled(true);
@@ -43,130 +47,61 @@ MainWindow::MainWindow(QWidget * parent): QMainWindow(parent), Ui::MainWindow()
view->setBackColor(Qt::lightGray);
view->setDepthStart(1.);
view->setDepthEnd(10000.);
//view->setLightingMode(QGLView::PerPixel);
/*MaterialEditor * o = new MaterialEditor();
o->setWindowOpacity(.666);
view->addObject(o, Qt::Window);*/
/**obj = loadFrom3DSFile("data/test.3DS", 0.15);
m.reflectivity = 1;
m.reflection.loadPathesFromDirectory("data/e");
obj->child("sphere001")->setMaterial(m);*/
spinFOV->setValue(view->FOV());
spinDepthStart->setValue(view->depthStart());
spinDepthEnd->setValue(view->depthEnd());
groupHoverHalo->setChecked(view->isHoverHaloEnabled());
groupSelectionHalo->setChecked(view->isSelectionHaloEnabled());
spinHoverHaloFill->setValue(view->hoverHaloFillAlpha());
spinSelectionHaloFill->setValue(view->selectionHaloFillAlpha());
colorHoverHalo->setColor(view->hoverHaloColor());
colorSelectionHalo->setColor(view->selectionHaloColor());
checkFXAA->setChecked(view->isFeatureEnabled(QGLView::qglFXAA));
checkMSAA->setChecked(view->isFeatureEnabled(QGLView::qglMSAA));
colorBack->setColor(view->backColor());
colorAmbient->setColor(view->ambientColor());
checkCameraOrbit->setChecked(view->isCameraOrbit());
//m.shine = 40;
//m.shine_strength = 1;
//m.diffuse.bitmap_path = "celtic_010.jpg";
//m.bump.bitmap_path = "celtic_010n.jpg";
/*obj->child("cone")->setMaterial(m);
m.diffuse.bitmap_path = "proj_plane_d.tga";
m.bump.bitmap_path = "proj_plane_n.tga";
obj->child("tor")->setMaterial(m);
m.reflectivity = 1.;
obj->child("sphere")->setMaterial(m);*/
//obj->child("teapot")->setRenderMode(GLObjectBase::Point);
//obj->child("teapot")->setLineWidth(2.);
//obj->child("cone")->setRenderMode(GLObjectBase::Line);
//view->camera().setAim(obj->child("sphere001")->pos());
GLTextureManager::addSearchPath("data");
GLTextureManager::addSearchPath("data/images");
GLTextureManager::addSearchPath("data/SU-33_maps");
obj = loadFromDAEFile("data/shadows.dae");//new GLPrimitiveEllipsoid(EARTH_WL / 1E+6, EARTH_WL / 1E+6, EARTH_H / 1E+6, 500, 500);//GLPrimitiveCube();
//obj->setScale(0.1);
//obj->child("Plane001")->material().map_specularity.color_amount = 0.95;
//obj = new GLPrimitiveEllipsoid(100, 100, 100, 100, 100);//GLPrimitiveCube();
for (int i = 0; i < obj->childCount(); ++i)
if (obj->child(i)->type() == GLObjectBase::Light) {
//((Light*)obj->child(i))->intensity = 1.5;
//((Light*)obj->child(i))->decay_linear = .5;
}
view->addObject(obj);
groupShadows->setChecked(view->isFeatureEnabled(QGLView::qglShadowsEnabled));
groupEyeAccomodation->setChecked(view->isFeatureEnabled(QGLView::qglEyeAccomodationEnabled));
groupBloom->setChecked(view->isFeatureEnabled(QGLView::qglBloomEnabled));
groupMotionBlur->setChecked(view->isFeatureEnabled(QGLView::qglMotionBlurEnabled));
groupReflections->setChecked(view->isFeatureEnabled(QGLView::qglDynamicReflectionsEnabled));
checkSoftShadows->setChecked(view->isFeatureEnabled(QGLView::qglShadowsSoftEnabled));
spinAccom->setValue(view->isFeatureEnabled(QGLView::qglEyeAccomodationTime));
spinAccomMS->setValue(view->isFeatureEnabled(QGLView::qglEyeAccomodationMaxSpeed));
spinCubemapSize->setValue(view->isFeatureEnabled(QGLView::qglDynamicReflectionsMapSize));
spinShadowmapSize->setValue(view->isFeatureEnabled(QGLView::qglShadowsMapSize));
spinMotionBlurFactor->setValue(view->isFeatureEnabled(QGLView::qglMotionBlurFactor));
spinMotionBlurSteps->setValue(view->isFeatureEnabled(QGLView::qglMotionBlurSteps));
spinBloomFactor->setValue(view->isFeatureEnabled(QGLView::qglBloomFactor));
spinBloomRadius->setValue(view->isFeatureEnabled(QGLView::qglBloomRadius));
spinBloomThreshold->setValue(view->isFeatureEnabled(QGLView::qglBloomThreshold));
//obj->setPos(1000000, -1000000, -10000000);
//obj->child("Box001")->addChild(&(view->camera()));
//obj->child("Box001")->VBO().translatePoints(QVector3D(20,30,40));
view->camera().setPos(QVector3D(10, -20, 20));
view->camera().setAim(obj->pos());
view->camera().flyToDistance(500);
double al = 7.;
axis = new GLObjectBase();
GLObjectBase * obj;
double al = 1.;
obj = new GLPrimitiveLine(QVector3D(0, 0, -al), QVector3D(0, 0, al));
obj->material().color_diffuse = Qt::darkBlue; obj->setAcceptLight(false);
view->addObject(obj);
axis->addChild(obj);
obj = new GLPrimitiveLine(QVector3D(-al, 0, 0), QVector3D(al, 0, 0));
obj->material().color_diffuse = Qt::darkRed; obj->setAcceptLight(false);
view->addObject(obj);
axis->addChild(obj);
obj = new GLPrimitiveLine(QVector3D(0, -al, 0), QVector3D(0, al, 0));
obj->material().color_diffuse = Qt::darkGreen; obj->setAcceptLight(false);
view->addObject(obj);
double lat = deg2rad*(-85.), lng = deg2rad*(15.);
obj = new GLPrimitiveLine(QVector3D(), QVector3D(cos(lng)*cos(lat), sin(lng)*cos(lat), sin(lat)/*(EARTH_H/EARTH_WL)*/)*5);
view->addObject(obj);
//view->camera().setMode(Camera::AimMatrix);
Light * l = new Light(view->camera().pos());
/*l->light_type = Light::Cone;
l->direction = QVector3D(1., 0.2, -0.2);
l->angle_start = 0.;
l->angle_end = 120.;*/
l->intensity = 0.5;
//l->decay_linear = 0.2;
l->setName("camera");
view->addObject(l);
axis->addChild(obj);
view->addObject(axis);
cam_light = new Light(view->camera().pos());
cam_light->intensity = 0.5;
cam_light->setName("camera");
view->camera().addChild(cam_light);
view->start(-1);
//view->light(0)->light_type = Light::Omni;
//obj = loadFrom3DSFile("34.3DS", 0.03);
//view->addObject(obj);
//view->camera().moveUp(5, true);
/**ps = new GLParticlesSystem(QVector3D(0,0,5));
ps->setEmitterType(GLParticlesSystem::Box);
ps->setBirthRate(5);
ps->setSize(1.);
ps->setLifeDuration(5.);
ps->setInitialSpeed(.5);
ps->setFadeTime(1.);
ps->setSpeedDirectionJitter(1);
//ps->setTextureScale(2, 2);
ps->setAddVerticalFaceEnabled(true);
ps->addForce(QVector3D(0,0,-0.98/20));*/
//ps->material().diffuse.bitmap_path = "expl_07.png";
//view->addObject(ps);
/**box = new GLPrimitiveCube();
box->setSelectable(false);
box->setRenderMode(GLObjectBase::Line);
box->setLineWidth(2.);
view->addObject(box);
box->hide();*/
//while (view->lightsCount() >= 5) view->removeLight(view->lightsCount() - 1);
//view->addObject(box);
//obj = obj->clone(true);
//obj->move(QVector3D(10,10,0));
//view->addObject(obj);
//view->addObject(obj);
//obj = obj->clone(true);
//obj->move(QVector3D(10,10,0));
//view->addObject(obj);
/*int h = 0, dh = 360 / view->lights().size();
foreach (Light * i, view->lights()) {
i->setColor(QColor::fromHsv(h, 255, 255));
i->intensity *= 2;
h += dh;
}*/
startTimer(1000/60);
//connect(view, SIGNAL(hoverChanged(GLObjectBase*,GLObjectBase*)), this, SLOT(hoverChanged(GLObjectBase*,GLObjectBase*)));
treeProperties->assignObject(view);
connect(view, SIGNAL(selectionChanged(GLObjectBase*,GLObjectBase*)), this, SLOT(selectionChanged(GLObjectBase*,GLObjectBase*)));
connect(view, SIGNAL(glInitializeDone()), this, SLOT(glInit()));
connect(matEditor, SIGNAL(changed()), this, SLOT(materialChanged()));
//view->addObject(new Light(view->camera().pos()));
//show();
//comboBox->setCurrentIndex(2);
}
@@ -177,29 +112,18 @@ MainWindow::~MainWindow() {
void MainWindow::changeEvent(QEvent * e) {
QMainWindow::changeEvent(e);
/*if (e->type() == QEvent::LanguageChange) {
if (e->type() == QEvent::LanguageChange) {
retranslateUi(this);
return;
}*/
}
}
void MainWindow::timerEvent(QTimerEvent * ) {
static double t = 0.;
if (checkCameraLight->isChecked())
view->light(view->lightsCount() - 1)->setPos(view->camera().worldPos());
//static double t = 0.;
cam_light->setVisible(checkCameraLight->isChecked());
//((RendererSimple*)(view->renderer()))->mpos = view->mapFromGlobal(QCursor::pos());
//qDebug() << view->camera().angles();
//cam_mat.rotate(e->y(), 0., 1., 0.);
//view->camera().setTransform(cam_mat);
/*obj->child("tor")->rotateX(0.5);
obj->child("tor")->rotateZ(0.1);
obj->child("cone")->rotateZ(1);
obj->child("teapot")->rotateY(sin(t));
obj->child("sphere")->setPosZ(fabs(sin(t)*5)-0.75);*/
t += 0.1;
setWindowTitle(QString::number(view->currentFPS(), 'f', 2));
statusBar()->showMessage(QString("FPS: %1").arg(QString::number(view->currentFPS(), 'f', 2)));
}
@@ -214,34 +138,47 @@ void MainWindow::on_view_glKeyPressEvent(QKeyEvent * e) {
}
void MainWindow::on_view_glMouseMoveEvent(QMouseEvent * e) {
cam_mat.rotate(e->x(), 0., 0., 1.);
cam_mat.rotate(e->y(), 0., 1., 0.);
view->camera().setTransform(cam_mat);
}
void MainWindow::glInit() {
//view->bindTexture(QImage("e/bottom.jpg"));
}
void MainWindow::on_pushButton_clicked() {
//view->removeLight(view->lightsCount() - 1);
//setWindowTitle(QString::number(view->lightsCount()));
QVector3D wp = view->light(0)->worldPos();
view->camera().setPos(wp);
view->camera().setAim(wp + (view->light(0)->worldTransform() * QVector4D(view->light(0)->direction)).toVector3D()*100);
}
void MainWindow::loadFile(const QString & path) {
prev_path = path;
QCursor pcur = cursor();
setCursor(Qt::WaitCursor);
importFile(path);
}
setCursor(pcur);
void MainWindow::importFile(const QString & path) {
QApplication::setOverrideCursor(Qt::WaitCursor);
QFileInfo fi(path);
GLObjectBase * o = 0;
if (fi.completeSuffix().toLower() == "qgl") o = loadFromQGLFile(path);
if (fi.completeSuffix().toLower() == "ase") o = loadFromASEFile(path);
if (fi.completeSuffix().toLower() == "3ds") o = loadFrom3DSFile(path);
if (fi.completeSuffix().toLower() == "obj") o = loadFromOBJFile(path);
if (fi.completeSuffix().toLower() == "dae") o = loadFromDAEFile(path);
QApplication::restoreOverrideCursor();
if (!o) {
QMessageBox::critical(this, "Import", "Can`t load " + path + "!");
return;
}
o->setName(fi.baseName());
view->addObject(o);
objectsTreeChanged();
}
void MainWindow::makeObjetTree(const GLObjectBase * o, QTreeWidgetItem * ti) {
if (o == axis) return;
for (int i = 0; i < o->childCount(); ++i) {
const GLObjectBase * co = o->child(i);
QTreeWidgetItem * ci = new QTreeWidgetItem(ti);
ci->setText(0, co->name());
ci->setData(0, Qt::UserRole, quintptr(co));
switch (co->type()) {
case GLObjectBase::glMesh: ci->setIcon(0, icon_geo); break;
case GLObjectBase::glLight: ci->setIcon(0, icon_light); break;
case GLObjectBase::glCamera: ci->setIcon(0, icon_camera); break;
default: break;
}
makeObjetTree(co, ci);
}
}
@@ -271,25 +208,62 @@ void MainWindow::materialChanged() {
}
void MainWindow::on_pushButton_3_clicked() {
QList<GLObjectBase * > ol = view->objects(true);
qDebug() << ol.size();
foreach (GLObjectBase * i, ol) {
i->VBO().rebuffer();
}
}
void MainWindow::on_comboBox_currentIndexChanged(int val) {
void MainWindow::on_comboRenderer_currentIndexChanged(int val) {
GLRendererBase * pr = 0;
switch (val) {
case 0: view->setRenderer(new RendererSimple(view), &pr); break;
case 2: view->setRenderer(new RendererDeferredShading(view), &pr); break;
case 1: view->setRenderer(new RendererDeferredShading(view), &pr); break;
}
if (pr != 0) delete pr;
}
void MainWindow::on_actionReset_triggered() {
view->removeObject(axis, false);
view->clearObjects(true);
view->addObject(axis);
}
void MainWindow::on_actionImport_triggered() {
QStringList fl = QFileDialog::getOpenFileNames(this, "Select files", prev_path, "Supported types(*.qgl *.ase *.3ds *.obj *.dae);;"
"QGLView(*.qgl);;"
"Ascii Scene Export(*.ase);;"
"3D Studio(*.3ds);;"
"Wavefront OBJ(*.obj);;"
"Collada(*.dae)");
if (fl.isEmpty()) return;
prev_path = fl.back();
foreach (QString f, fl)
importFile(f);
}
void MainWindow::on_actionSave_triggered() {
QString f = QFileDialog::getSaveFileName(this, "Select file", prev_path, "QGLView(*.qgl)");
if (f.isEmpty()) return;
if (f.right(4).toLower() != ".qgl")
f += ".qgl";
prev_path = f;
view->removeObject(axis);
saveToQGLFile(f, &(view->rootObject()));
view->addObject(axis);
}
void MainWindow::on_actionOpen_triggered() {
QString f = QFileDialog::getOpenFileName(this, "Select file", prev_path, "Supported types(*.qgl *.ase *.3ds *.obj *.dae);;"
"QGLView(*.qgl);;"
"Ascii Scene Export(*.ase);;"
"3D Studio(*.3ds);;"
"Wavefront OBJ(*.obj);;"
"Collada(*.dae)");
if (f.isEmpty()) return;
prev_path = f;
importFile(f);
}
void MainWindow::on_view_keyEvent(Qt::Key k, Qt::KeyboardModifiers m) {
//qDebug() << k;
double spd = 0.2;
@@ -303,3 +277,33 @@ void MainWindow::on_view_keyEvent(Qt::Key k, Qt::KeyboardModifiers m) {
default: break;
}
}
void MainWindow::on_treeObjects_itemClicked(QTreeWidgetItem * ti, int col) {
((GLObjectBase*)(ti->data(0, Qt::UserRole).toULongLong()))->select();
}
void MainWindow::objectsTreeChanged() {
treeObjects->clear();
makeObjetTree(&(view->rootObject()), treeObjects->invisibleRootItem());
}
void MainWindow::on_pushButton_clicked() {
//view->removeLight(view->lightsCount() - 1);
//setWindowTitle(QString::number(view->lightsCount()));
QVector3D wp = view->light(0)->worldPos();
view->camera().setPos(wp);
view->camera().setAim(wp + (view->light(0)->worldTransform() * QVector4D(view->light(0)->direction)).toVector3D()*100);
}
void MainWindow::on_pushButton_3_clicked() {
QList<GLObjectBase * > ol = view->objects(true);
qDebug() << ol.size();
foreach (GLObjectBase * i, ol) {
i->VBO().rebuffer();
}
}

View File

@@ -52,61 +52,70 @@ private:
void timerEvent(QTimerEvent * );
void loadFile(const QString & path);
void importFile(const QString & path);
void makeObjetTree(const GLObjectBase * o, QTreeWidgetItem * ti);
QTranslator translator;
QString prev_path, dstyle;
QIcon icon_geo, icon_camera, icon_light;
QString prev_path;
GLObjectBase * sel_obj, * axis;
Light * cam_light;
GLPrimitiveCube * box;
Material m;
bool isChanged;
GLObjectBase * obj, * sel_obj;
GLPrimitiveCube * box;
GLParticlesSystem * ps;
WaterSystem * ws;
RopeSystem * rs;
Material m;
private slots:
void glInit();
void on_actionExit_triggered() {close();}
void on_spinFOV_valueChanged(double val) {view->setFOV(val);}
void on_spinDepthStart_valueChanged(double val) {view->setDepthStart(val);}
void on_spinDepthEnd_valueChanged(double val) {view->setDepthEnd(val);}
void on_comboRenderer_currentIndexChanged(int val);
void on_comboViewRenderMode_currentIndexChanged(int val) {static int modes[] = {GL_POINT, GL_LINE, GL_FILL}; view->setRenderMode((GLObjectBase::RenderMode)modes[val]);}
void on_groupHoverHalo_clicked(bool val) {view->setHoverHaloEnabled(val);}
void on_groupSelectionHalo_clicked(bool val) {view->setSelectionHaloEnabled(val);}
void on_spinHoverHaloFill_valueChanged(double val) {view->setHoverHaloFillAlpha(val);}
void on_spinSelectionHaloFill_valueChanged(double val) {view->setSelectionHaloFillAlpha(val);}
void on_colorHoverHalo_colorChanged(QColor color) {view->setHoverHaloColor(color);}
void on_colorSelectionHalo_colorChanged(QColor color) {view->setSelectionHaloColor(color);}
void on_checkFXAA_clicked(bool val) {view->setFeature(QGLView::qglFXAA, val);}
void on_checkMSAA_clicked(bool val) {view->setFeature(QGLView::qglMSAA, val);}
void on_colorBack_colorChanged(QColor color) {view->setBackColor(color);}
void on_colorAmbient_colorChanged(QColor color) {view->setAmbientColor(color);}
void on_checkCameraOrbit_clicked(bool val) {view->setCameraOrbit(val);}
void on_groupShadows_clicked(bool val) {view->setFeature(QGLView::qglShadowsEnabled, val);}
void on_groupEyeAccomodation_clicked(bool val) {view->setFeature(QGLView::qglEyeAccomodationEnabled, val);}
void on_groupBloom_clicked(bool val) {view->setFeature(QGLView::qglBloomEnabled, val);}
void on_groupMotionBlur_clicked(bool val) {view->setFeature(QGLView::qglMotionBlurEnabled, val);}
void on_groupReflections_clicked(bool val) {view->setFeature(QGLView::qglDynamicReflectionsEnabled, val);}
void on_checkSoftShadows_clicked(bool val) {view->setFeature(QGLView::qglShadowsSoftEnabled, 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_spinCubemapSize_valueChanged(double val) {view->setFeature(QGLView::qglDynamicReflectionsMapSize, val);}
void on_spinShadowmapSize_valueChanged(double val) {view->setFeature(QGLView::qglShadowsMapSize, val);}
void on_spinHaloFillAlpha_valueChanged(double val) {view->setSelectionHaloFillAlpha(val);}
void on_spinMotionBlurFactor_valueChanged(double val) {view->setFeature(QGLView::qglMotionBlurFactor, val);}
void on_spinMotionBlurSteps_valueChanged(int val) {view->setFeature(QGLView::qglMotionBlurSteps, val);}
void on_spinBloomFactor_valueChanged(double val) {view->setFeature(QGLView::qglBloomFactor, val);}
void on_spinBloomRadius_valueChanged(int val) {view->setFeature(QGLView::qglBloomRadius, val);}
void on_spinBloomThreshold_valueChanged(double val) {view->setFeature(QGLView::qglBloomThreshold, val);}
//void on_spinSliderShine_valueChanged(double val) {obj->material().shine_strength = val; obj->setMaterial(obj->material(), true);}
//void on_spinSliderRough_valueChanged(double val) {obj->material().shine = val; obj->setMaterial(obj->material(), true);}
void on_actionExit_triggered() {close();}
void on_actionReset_triggered();
void on_actionImport_triggered();
void on_actionSave_triggered();
void on_actionOpen_triggered();
void on_view_glKeyPressEvent(QKeyEvent * e);
void on_view_keyEvent(Qt::Key k, Qt::KeyboardModifiers m);
void on_treeObjects_itemClicked(QTreeWidgetItem * ti, int col);
void objectsTreeChanged();
void materialChanged();
void selectionChanged(GLObjectBase * cur, GLObjectBase * prev);
void on_pushButton_clicked();
void on_pushButton_2_clicked() {view->reloadShaders();}
void on_pushButton_3_clicked();
void on_comboBox_currentIndexChanged(int val);
void on_comboViewRenderMode_currentIndexChanged(int val) {static int modes[] = {GL_POINT, GL_LINE, GL_FILL}; view->setRenderMode((GLObjectBase::RenderMode)modes[val]);}
//void on_comboLight_currentIndexChanged(int val) {obj->material().light_model = (Material::LightModel)val; obj->setMaterial(obj->material(), true);}
void on_checkSelectionHalo_toggled(bool val) {view->setSelectionHaloEnabled(val);}
void on_checkDynamicReflections_toggled(bool val) {view->setFeature(QGLView::qglDynamicReflectionsEnabled, val);}
void on_checkHDR_toggled(bool val) {view->setFeature(QGLView::qglHDR, val);}
void on_checkAccomodation_toggled(bool val) {view->setFeature(QGLView::qglEyeAccomodationEnabled, val);}
void on_checkBloom_toggled(bool val) {view->setFeature(QGLView::qglBloomEnabled, val);}
void on_checkFXAA_toggled(bool val) {view->setFeature(QGLView::qglFXAA, val);}
void on_checkMSAA_toggled(bool val) {view->setFeature(QGLView::qglMSAA, val);}
void on_checkShadows_toggled(bool val) {view->setFeature(QGLView::qglShadowsEnabled, val);}
void on_checkSoftShadows_toggled(bool val) {view->setFeature(QGLView::qglShadowsSoftEnabled, val);}
void on_checkCameraOrbit_toggled(bool val) {view->setCameraOrbit(val);}
void on_checkMotionBlur_toggled(bool val) {view->setFeature(QGLView::qglMotionBlurEnabled, val);}
void on_colorAmbient_colorChanged(QColor color) {view->setAmbientColor(color);}
void on_colorHalo_colorChanged(QColor color) {view->setSelectionHaloColor(color);}
void on_view_glKeyPressEvent(QKeyEvent * e);
void on_view_glMouseMoveEvent(QMouseEvent * e);
void on_view_keyEvent(Qt::Key k, Qt::KeyboardModifiers m);
void hoverChanged(GLObjectBase * cur, GLObjectBase * prev) {/*qDebug() << "hovered" << (cur != 0 ? cur->name() : "0") << ", previous" << (prev != 0 ? prev->name() : "0");*/}
void selectionChanged(GLObjectBase * cur, GLObjectBase * prev); /*{qDebug() << "selected" << (cur != 0 ? cur->name() : "0") << ", previous" << (prev != 0 ? prev->name() : "0");}*/
void materialChanged();
public slots:

View File

@@ -6,25 +6,24 @@
<rect>
<x>0</x>
<y>0</y>
<width>1131</width>
<height>781</height>
<width>1125</width>
<height>808</height>
</rect>
</property>
<property name="windowTitle">
<string>Stanley designer</string>
</property>
<property name="windowIcon">
<iconset>
<normaloff>:/icons/stanley_128.png</normaloff>:/icons/stanley_128.png</iconset>
<string>QGLView converter</string>
</property>
<widget class="QWidget" name="centralwidget">
<layout class="QHBoxLayout" name="horizontalLayout" stretch="0,1">
<layout class="QHBoxLayout" name="horizontalLayout" stretch="0,1,0">
<item>
<widget class="QWidget" name="widget_2" native="true">
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<number>2</number>
</property>
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="labelName">
<property name="font">
@@ -53,313 +52,713 @@
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<layout class="QFormLayout" name="formLayout">
<property name="fieldGrowthPolicy">
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
<widget class="QTabWidget" name="tabWidget_2">
<property name="currentIndex">
<number>0</number>
</property>
<property name="labelAlignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>FOV</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="SpinSlider" name="spinFOV">
<property name="minimum">
<double>0.100000000000000</double>
</property>
<property name="maximum">
<double>179.900000000000006</double>
</property>
<property name="value">
<double>60.000000000000000</double>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>accomodation time</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_8">
<property name="text">
<string>accomodation max speed</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_9">
<property name="text">
<string>dynamic cubemap size</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_10">
<property name="text">
<string>shadowmap size</string>
</property>
</widget>
</item>
<item row="8" column="0">
<widget class="QLabel" name="label_12">
<property name="text">
<string>motion blur factor</string>
</property>
</widget>
</item>
<item row="9" column="0">
<widget class="QLabel" name="label_13">
<property name="text">
<string>motion blur steps</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="SpinSlider" name="spinAccom">
<property name="minimum">
<double>0.000000000000000</double>
</property>
<property name="maximum">
<double>256.000000000000000</double>
</property>
<property name="value">
<double>32.000000000000000</double>
</property>
<property name="squareScale">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="SpinSlider" name="spinAccomMS">
<property name="minimum">
<double>0.010000000000000</double>
</property>
<property name="maximum">
<double>1.000000000000000</double>
</property>
<property name="value">
<double>0.100000000000000</double>
</property>
<property name="decimals">
<number>3</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="3" column="1">
<widget class="SpinSlider" name="spinCubemapSize">
<property name="minimum">
<double>16.000000000000000</double>
</property>
<property name="maximum">
<double>2048.000000000000000</double>
</property>
<property name="value">
<double>512.000000000000000</double>
</property>
<property name="decimals">
<number>0</number>
</property>
<property name="singleStep">
<double>16.000000000000000</double>
</property>
<property name="pageStep">
<double>512.000000000000000</double>
</property>
<property name="squareScale">
<bool>false</bool>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="SpinSlider" name="spinShadowmapSize">
<property name="minimum">
<double>16.000000000000000</double>
</property>
<property name="maximum">
<double>2048.000000000000000</double>
</property>
<property name="value">
<double>512.000000000000000</double>
</property>
<property name="decimals">
<number>0</number>
</property>
<property name="singleStep">
<double>16.000000000000000</double>
</property>
<property name="pageStep">
<double>512.000000000000000</double>
</property>
<property name="squareScale">
<bool>true</bool>
</property>
</widget>
</item>
<item row="8" column="1">
<widget class="SpinSlider" name="spinMotionBlurFactor">
<property name="minimum">
<double>0.000000000000000</double>
</property>
<property name="maximum">
<double>10000.000000000000000</double>
</property>
<property name="value">
<double>1.000000000000000</double>
</property>
<property name="decimals">
<number>1</number>
</property>
<property name="singleStep">
<double>0.100000000000000</double>
</property>
<property name="pageStep">
<double>1.000000000000000</double>
</property>
<property name="squareScale">
<bool>false</bool>
</property>
</widget>
</item>
<item row="9" column="1">
<widget class="SpinSlider" name="spinMotionBlurSteps">
<property name="minimum">
<double>1.000000000000000</double>
</property>
<property name="maximum">
<double>128.000000000000000</double>
</property>
<property name="value">
<double>8.000000000000000</double>
</property>
<property name="decimals">
<number>0</number>
</property>
<property name="singleStep">
<double>1.000000000000000</double>
</property>
<property name="pageStep">
<double>4.000000000000000</double>
</property>
<property name="squareScale">
<bool>false</bool>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="label_14">
<property name="text">
<string>bloom factor</string>
</property>
</widget>
</item>
<item row="7" column="0">
<widget class="QLabel" name="label_15">
<property name="text">
<string>bloom radius</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="SpinSlider" name="spinBloomFactor">
<property name="minimum">
<double>0.000000000000000</double>
</property>
<property name="maximum">
<double>100.000000000000000</double>
</property>
<property name="value">
<double>1.000000000000000</double>
</property>
<property name="decimals">
<number>1</number>
</property>
<property name="singleStep">
<double>0.100000000000000</double>
</property>
<property name="pageStep">
<double>1.000000000000000</double>
</property>
<property name="squareScale">
<bool>false</bool>
</property>
</widget>
</item>
<item row="7" column="1">
<widget class="SpinSlider" name="spinBloomRadius">
<property name="minimum">
<double>1.000000000000000</double>
</property>
<property name="maximum">
<double>128.000000000000000</double>
</property>
<property name="value">
<double>8.000000000000000</double>
</property>
<property name="decimals">
<number>0</number>
</property>
<property name="singleStep">
<double>1.000000000000000</double>
</property>
<property name="pageStep">
<double>4.000000000000000</double>
</property>
<property name="squareScale">
<bool>false</bool>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QLabel" name="label_16">
<property name="text">
<string>bloom threshold</string>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="SpinSlider" name="spinBloomThreshold">
<property name="minimum">
<double>0.000000000000000</double>
</property>
<property name="maximum">
<double>1.000000000000000</double>
</property>
<property name="value">
<double>0.900000000000000</double>
</property>
<property name="decimals">
<number>1</number>
</property>
<property name="singleStep">
<double>0.100000000000000</double>
</property>
<property name="pageStep">
<double>1.000000000000000</double>
</property>
<property name="squareScale">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
<widget class="QWidget" name="tab_5">
<attribute name="title">
<string>Common</string>
</attribute>
<layout class="QFormLayout" name="formLayout_9">
<property name="fieldGrowthPolicy">
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
</property>
<property name="labelAlignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>FOV</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="SpinSlider" name="spinFOV">
<property name="minimum">
<double>0.100000000000000</double>
</property>
<property name="maximum">
<double>179.900000000000006</double>
</property>
<property name="value">
<double>60.000000000000000</double>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Renderer</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QComboBox" name="comboRenderer">
<property name="currentIndex">
<number>1</number>
</property>
<item>
<property name="text">
<string>Simple</string>
</property>
</item>
<item>
<property name="text">
<string>Deferred shading</string>
</property>
</item>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Draw mode</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QComboBox" name="comboViewRenderMode">
<property name="currentIndex">
<number>2</number>
</property>
<item>
<property name="text">
<string>Point</string>
</property>
</item>
<item>
<property name="text">
<string>Wireframe</string>
</property>
</item>
<item>
<property name="text">
<string>Solid</string>
</property>
</item>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="label_7">
<property name="text">
<string>Ambient</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="ColorButton" name="colorAmbient">
<property name="color">
<color>
<red>10</red>
<green>10</green>
<blue>10</blue>
</color>
</property>
</widget>
</item>
<item row="6" column="0" colspan="2">
<widget class="QCheckBox" name="checkMSAA">
<property name="text">
<string>MSAA</string>
</property>
</widget>
</item>
<item row="7" column="0" colspan="2">
<widget class="QCheckBox" name="checkFXAA">
<property name="text">
<string>FXAA</string>
</property>
</widget>
</item>
<item row="8" column="0" colspan="2">
<widget class="QGroupBox" name="groupHoverHalo">
<property name="title">
<string>Hover halo</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<layout class="QFormLayout" name="formLayout">
<item row="0" column="0" colspan="2">
<widget class="ColorButton" name="colorHoverHalo">
<property name="color">
<color>
<red>10</red>
<green>10</green>
<blue>10</blue>
</color>
</property>
<property name="useAlphaChannel">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_11">
<property name="text">
<string>Fill</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="SpinSlider" name="spinHoverHaloFill">
<property name="minimum">
<double>0.000000000000000</double>
</property>
<property name="maximum">
<double>1.000000000000000</double>
</property>
<property name="value">
<double>0.300000000000000</double>
</property>
<property name="decimals">
<number>2</number>
</property>
<property name="singleStep">
<double>0.050000000000000</double>
</property>
<property name="pageStep">
<double>0.100000000000000</double>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="9" column="0" colspan="2">
<widget class="QGroupBox" name="groupSelectionHalo">
<property name="title">
<string>Selection halo</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<layout class="QFormLayout" name="formLayout_8">
<item row="0" column="0" colspan="2">
<widget class="ColorButton" name="colorSelectionHalo">
<property name="color">
<color>
<red>10</red>
<green>10</green>
<blue>10</blue>
</color>
</property>
<property name="useAlphaChannel">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_20">
<property name="text">
<string>Fill</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="SpinSlider" name="spinSelectionHaloFill">
<property name="minimum">
<double>0.000000000000000</double>
</property>
<property name="maximum">
<double>1.000000000000000</double>
</property>
<property name="value">
<double>0.300000000000000</double>
</property>
<property name="decimals">
<number>2</number>
</property>
<property name="singleStep">
<double>0.050000000000000</double>
</property>
<property name="pageStep">
<double>0.100000000000000</double>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="10" column="0" colspan="2">
<widget class="QGroupBox" name="groupCamera">
<property name="title">
<string>Camera</string>
</property>
<layout class="QFormLayout" name="formLayout_10">
<item row="0" column="0" colspan="2">
<widget class="QCheckBox" name="checkCameraOrbit">
<property name="text">
<string>Orbit</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="0" colspan="2">
<widget class="QCheckBox" name="checkCameraLight">
<property name="text">
<string>Camera Light</string>
</property>
</widget>
</item>
</layout>
</widget>
</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="maximum">
<double>9999999.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="maximum">
<double>9999999.000000000000000</double>
</property>
</widget>
</item>
</layout>
</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>
</layout>
</widget>
<widget class="QWidget" name="tab_6">
<attribute name="title">
<string>Features</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_7">
<item>
<widget class="QGroupBox" name="groupShadows">
<property name="title">
<string>Shadows</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<layout class="QFormLayout" name="formLayout_3">
<property name="fieldGrowthPolicy">
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
</property>
<property name="labelAlignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<item row="1" column="0">
<widget class="QLabel" name="label_10">
<property name="text">
<string>Shadowmap size</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="SpinSlider" name="spinShadowmapSize">
<property name="minimum">
<double>16.000000000000000</double>
</property>
<property name="maximum">
<double>2048.000000000000000</double>
</property>
<property name="value">
<double>512.000000000000000</double>
</property>
<property name="decimals">
<number>0</number>
</property>
<property name="singleStep">
<double>16.000000000000000</double>
</property>
<property name="pageStep">
<double>512.000000000000000</double>
</property>
<property name="squareScale">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="0" colspan="2">
<widget class="QCheckBox" name="checkSoftShadows">
<property name="text">
<string>Soft</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBloom">
<property name="title">
<string>Bloom</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<layout class="QFormLayout" name="formLayout_5">
<property name="fieldGrowthPolicy">
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
</property>
<property name="labelAlignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<item row="0" column="0">
<widget class="QLabel" name="label_18">
<property name="text">
<string>Factror</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="SpinSlider" name="spinBloomFactor">
<property name="minimum">
<double>0.000000000000000</double>
</property>
<property name="maximum">
<double>100.000000000000000</double>
</property>
<property name="value">
<double>1.000000000000000</double>
</property>
<property name="decimals">
<number>1</number>
</property>
<property name="singleStep">
<double>0.100000000000000</double>
</property>
<property name="pageStep">
<double>1.000000000000000</double>
</property>
<property name="squareScale">
<bool>false</bool>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="SpinSlider" name="spinBloomRadius">
<property name="minimum">
<double>1.000000000000000</double>
</property>
<property name="maximum">
<double>128.000000000000000</double>
</property>
<property name="value">
<double>8.000000000000000</double>
</property>
<property name="decimals">
<number>0</number>
</property>
<property name="singleStep">
<double>1.000000000000000</double>
</property>
<property name="pageStep">
<double>4.000000000000000</double>
</property>
<property name="squareScale">
<bool>false</bool>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_17">
<property name="text">
<string>Radius</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_19">
<property name="text">
<string>Threshold</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="SpinSlider" name="spinBloomThreshold">
<property name="minimum">
<double>0.000000000000000</double>
</property>
<property name="maximum">
<double>1.000000000000000</double>
</property>
<property name="value">
<double>0.900000000000000</double>
</property>
<property name="decimals">
<number>2</number>
</property>
<property name="singleStep">
<double>0.050000000000000</double>
</property>
<property name="pageStep">
<double>0.100000000000000</double>
</property>
<property name="squareScale">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupMotionBlur">
<property name="title">
<string>Motion blur</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<layout class="QFormLayout" name="formLayout_2">
<property name="fieldGrowthPolicy">
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
</property>
<property name="labelAlignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<item row="0" column="0">
<widget class="QLabel" name="label_12">
<property name="text">
<string>Factror</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_13">
<property name="text">
<string>Steps</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="SpinSlider" name="spinMotionBlurFactor">
<property name="minimum">
<double>0.000000000000000</double>
</property>
<property name="maximum">
<double>10000.000000000000000</double>
</property>
<property name="value">
<double>1.000000000000000</double>
</property>
<property name="decimals">
<number>1</number>
</property>
<property name="singleStep">
<double>0.100000000000000</double>
</property>
<property name="pageStep">
<double>1.000000000000000</double>
</property>
<property name="squareScale">
<bool>false</bool>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="SpinSlider" name="spinMotionBlurSteps">
<property name="minimum">
<double>1.000000000000000</double>
</property>
<property name="maximum">
<double>128.000000000000000</double>
</property>
<property name="value">
<double>8.000000000000000</double>
</property>
<property name="decimals">
<number>0</number>
</property>
<property name="singleStep">
<double>1.000000000000000</double>
</property>
<property name="pageStep">
<double>4.000000000000000</double>
</property>
<property name="squareScale">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupEyeAccomodation">
<property name="title">
<string>Eye accomodation</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<layout class="QFormLayout" name="formLayout_4">
<property name="fieldGrowthPolicy">
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
</property>
<property name="labelAlignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<item row="0" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Time</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_14">
<property name="text">
<string>Max speed</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="SpinSlider" name="spinAccom">
<property name="minimum">
<double>0.000000000000000</double>
</property>
<property name="maximum">
<double>256.000000000000000</double>
</property>
<property name="value">
<double>32.000000000000000</double>
</property>
<property name="squareScale">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="SpinSlider" name="spinAccomMS">
<property name="minimum">
<double>0.010000000000000</double>
</property>
<property name="maximum">
<double>1.000000000000000</double>
</property>
<property name="value">
<double>0.100000000000000</double>
</property>
<property name="decimals">
<number>3</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>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupReflections">
<property name="title">
<string>Reflections</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<layout class="QFormLayout" name="formLayout_6">
<property name="fieldGrowthPolicy">
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
</property>
<property name="labelAlignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<item row="0" column="0">
<widget class="QLabel" name="label_15">
<property name="text">
<string>Cubemap size</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="SpinSlider" name="spinCubemapSize">
<property name="minimum">
<double>16.000000000000000</double>
</property>
<property name="maximum">
<double>2048.000000000000000</double>
</property>
<property name="value">
<double>512.000000000000000</double>
</property>
<property name="decimals">
<number>0</number>
</property>
<property name="singleStep">
<double>16.000000000000000</double>
</property>
<property name="pageStep">
<double>512.000000000000000</double>
</property>
<property name="squareScale">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton">
@@ -382,214 +781,6 @@
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="comboViewRenderMode">
<property name="currentIndex">
<number>2</number>
</property>
<item>
<property name="text">
<string>point</string>
</property>
</item>
<item>
<property name="text">
<string>wireframe</string>
</property>
</item>
<item>
<property name="text">
<string>solid</string>
</property>
</item>
</widget>
</item>
<item>
<widget class="QComboBox" name="comboBox">
<property name="currentIndex">
<number>0</number>
</property>
<item>
<property name="text">
<string>simple</string>
</property>
</item>
<item>
<property name="text">
<string>per-pixel</string>
</property>
</item>
<item>
<property name="text">
<string>deferred shading</string>
</property>
</item>
</widget>
</item>
<item>
<widget class="ColorButton" name="colorHalo">
<property name="color">
<color>
<red>10</red>
<green>10</green>
<blue>10</blue>
</color>
</property>
<property name="useAlphaChannel">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_11">
<property name="text">
<string>halo fill alpha</string>
</property>
</widget>
</item>
<item>
<widget class="SpinSlider" name="spinHaloFillAlpha">
<property name="minimum">
<double>0.000000000000000</double>
</property>
<property name="maximum">
<double>1.000000000000000</double>
</property>
<property name="value">
<double>0.300000000000000</double>
</property>
<property name="decimals">
<number>3</number>
</property>
<property name="singleStep">
<double>0.010000000000000</double>
</property>
<property name="pageStep">
<double>0.100000000000000</double>
</property>
</widget>
</item>
<item>
<layout class="QGridLayout" name="gridLayout">
<property name="bottomMargin">
<number>20</number>
</property>
<item row="3" column="0">
<widget class="QCheckBox" name="checkDynamicReflections">
<property name="text">
<string>dynamic reflections</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QCheckBox" name="checkBadAccum">
<property name="text">
<string>bad accumulation</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QCheckBox" name="checkSelectionHalo">
<property name="text">
<string>selection halo</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QCheckBox" name="checkShadows">
<property name="text">
<string>shadows</string>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QCheckBox" name="checkSoftShadows">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>soft shadows</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QCheckBox" name="checkCameraOrbit">
<property name="text">
<string>orbit camera</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QCheckBox" name="checkAccomodation">
<property name="text">
<string>accomodation</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QCheckBox" name="checkBloom">
<property name="text">
<string>bloom</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QCheckBox" name="checkMotionBlur">
<property name="text">
<string>motion blur</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QCheckBox" name="checkFXAA">
<property name="text">
<string>FXAA</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QCheckBox" name="checkMSAA">
<property name="text">
<string>MSAA</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QCheckBox" name="checkCameraLight">
<property name="text">
<string>Follow camera light</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QLabel" name="label_7">
<property name="text">
<string>ambient</string>
</property>
</widget>
</item>
<item>
<widget class="ColorButton" name="colorAmbient">
<property name="color">
<color>
<red>10</red>
<green>10</green>
<blue>10</blue>
</color>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
@@ -651,22 +842,6 @@
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_4">
<attribute name="title">
<string>Страница</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="PropertyEditor" name="treeProperties">
<column>
<property name="text">
<string notr="true">1</string>
</property>
</column>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
@@ -682,17 +857,115 @@
</property>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Objects</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QTreeWidget" name="treeObjects">
<property name="editTriggers">
<set>QAbstractItemView::NoEditTriggers</set>
</property>
<property name="verticalScrollMode">
<enum>QAbstractItemView::ScrollPerPixel</enum>
</property>
<property name="uniformRowHeights">
<bool>true</bool>
</property>
<column>
<property name="text">
<string>Name</string>
</property>
</column>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<widget class="QToolBar" name="toolBar">
<property name="windowTitle">
<string>toolBar</string>
</property>
<attribute name="toolBarArea">
<enum>TopToolBarArea</enum>
</attribute>
<attribute name="toolBarBreak">
<bool>false</bool>
</attribute>
</widget>
<widget class="QMenuBar" name="menuBar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>1125</width>
<height>26</height>
</rect>
</property>
<widget class="QMenu" name="menuFile">
<property name="title">
<string>File</string>
</property>
<addaction name="actionReset"/>
<addaction name="actionOpen"/>
<addaction name="actionSave"/>
<addaction name="separator"/>
<addaction name="actionImport"/>
<addaction name="separator"/>
<addaction name="actionExit"/>
</widget>
<addaction name="menuFile"/>
</widget>
<widget class="QStatusBar" name="statusBar_"/>
<action name="actionExit">
<property name="icon">
<iconset>
<iconset resource="qglview.qrc">
<normaloff>:/icons/application-exit.png</normaloff>:/icons/application-exit.png</iconset>
</property>
<property name="text">
<string>Exit</string>
</property>
</action>
<action name="actionImport">
<property name="icon">
<iconset resource="qglview.qrc">
<normaloff>:/icons/document-import.png</normaloff>:/icons/document-import.png</iconset>
</property>
<property name="text">
<string>Import ...</string>
</property>
</action>
<action name="actionOpen">
<property name="icon">
<iconset resource="qglview.qrc">
<normaloff>:/icons/document-open.png</normaloff>:/icons/document-open.png</iconset>
</property>
<property name="text">
<string>Open ...</string>
</property>
</action>
<action name="actionSave">
<property name="icon">
<iconset resource="qglview.qrc">
<normaloff>:/icons/document-save-.png</normaloff>:/icons/document-save-.png</iconset>
</property>
<property name="text">
<string>Save ...</string>
</property>
</action>
<action name="actionReset">
<property name="icon">
<iconset resource="qglview.qrc">
<normaloff>:/icons/document-new.png</normaloff>:/icons/document-new.png</iconset>
</property>
<property name="text">
<string>Reset</string>
</property>
</action>
</widget>
<customwidgets>
<customwidget>
@@ -723,29 +996,9 @@
<header>globject_editor.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>PropertyEditor</class>
<extends>QTreeWidget</extends>
<header>propertyeditor.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections>
<connection>
<sender>checkShadows</sender>
<signal>toggled(bool)</signal>
<receiver>checkSoftShadows</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>126</x>
<y>708</y>
</hint>
<hint type="destinationlabel">
<x>128</x>
<y>731</y>
</hint>
</hints>
</connection>
</connections>
<resources>
<include location="qglview.qrc"/>
</resources>
<connections/>
</ui>

View File

@@ -40,11 +40,23 @@ void MaterialMapEditor::changeEvent(QEvent * e) {
}
void MaterialMapEditor::resizeEvent(QResizeEvent * e) {
ui->iconedLabel->setFixedWidth(ui->iconedLabel->height());
ui->iconedLabel->setIconSize(ui->iconedLabel->size());
}
void MaterialMapEditor::updateIcon() {
ui->iconedLabel->setIcon(QIcon(ui->linePath->property("GLpath").toString()));
}
void MaterialMapEditor::setMap(const Map & m) {
active = false;
ui->sliderAmount->setValue(m.color_amount);
ui->sliderOffset->setValue(m.color_offset);
ui->linePath->setProperty("GLpath", m.bitmap_path); ui->linePath->setText(QFileInfo(m.bitmap_path).fileName());
updateIcon();
active = true;
}
@@ -63,6 +75,7 @@ void MaterialMapEditor::on_buttonSelect_clicked() {
if (str.isEmpty()) return;
ui->linePath->setProperty("GLpath", str);
ui->linePath->setText(QFileInfo(str).fileName());
updateIcon();
mapChanged();
}
@@ -70,5 +83,6 @@ void MaterialMapEditor::on_buttonSelect_clicked() {
void MaterialMapEditor::on_buttonClear_clicked() {
ui->linePath->setText("");
ui->linePath->setProperty("GLpath", "");
updateIcon();
mapChanged();
}

View File

@@ -37,6 +37,8 @@ public:
protected:
void changeEvent(QEvent * e);
void resizeEvent(QResizeEvent * e);
void updateIcon();
bool active;
Ui::MaterialMapEditor * ui;

View File

@@ -10,95 +10,103 @@
<height>74</height>
</rect>
</property>
<layout class="QFormLayout" name="formLayout">
<property name="fieldGrowthPolicy">
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
</property>
<property name="labelAlignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="spacing">
<number>0</number>
</property>
<property name="margin">
<number>0</number>
</property>
<item row="0" column="0" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="spacing">
<number>2</number>
<item>
<widget class="IconedLabel" name="iconedLabel">
<property name="direction">
<enum>IconedLabel::RightToLeft</enum>
</property>
<item>
<widget class="QLineEdit" name="linePath"/>
</widget>
</item>
<item>
<layout class="QFormLayout" name="formLayout">
<item row="0" column="0" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="spacing">
<number>2</number>
</property>
<item>
<widget class="QLineEdit" name="linePath"/>
</item>
<item>
<widget class="QToolButton" name="buttonClear">
<property name="text">
<string>X</string>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="buttonSelect">
<property name="text">
<string>^</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QToolButton" name="buttonClear">
<item row="1" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>X</string>
<string>Amount:</string>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="buttonSelect">
<item row="1" column="1">
<widget class="SpinSlider" name="sliderAmount">
<property name="minimum">
<double>-10.000000000000000</double>
</property>
<property name="maximum">
<double>10.000000000000000</double>
</property>
<property name="value">
<double>1.000000000000000</double>
</property>
<property name="decimals">
<number>2</number>
</property>
<property name="singleStep">
<double>0.050000000000000</double>
</property>
<property name="pageStep">
<double>0.200000000000000</double>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>^</string>
<string>Offset:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="SpinSlider" name="sliderOffset">
<property name="minimum">
<double>-10.000000000000000</double>
</property>
<property name="maximum">
<double>10.000000000000000</double>
</property>
<property name="decimals">
<number>2</number>
</property>
<property name="singleStep">
<double>0.050000000000000</double>
</property>
<property name="pageStep">
<double>0.200000000000000</double>
</property>
</widget>
</item>
</layout>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Amount:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="SpinSlider" name="sliderAmount">
<property name="minimum">
<double>-10.000000000000000</double>
</property>
<property name="maximum">
<double>10.000000000000000</double>
</property>
<property name="value">
<double>1.000000000000000</double>
</property>
<property name="decimals">
<number>2</number>
</property>
<property name="singleStep">
<double>0.050000000000000</double>
</property>
<property name="pageStep">
<double>0.200000000000000</double>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Offset:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="SpinSlider" name="sliderOffset">
<property name="minimum">
<double>-10.000000000000000</double>
</property>
<property name="maximum">
<double>10.000000000000000</double>
</property>
<property name="decimals">
<number>2</number>
</property>
<property name="singleStep">
<double>0.050000000000000</double>
</property>
<property name="pageStep">
<double>0.200000000000000</double>
</property>
</widget>
</item>
</layout>
</widget>
<customwidgets>
@@ -107,6 +115,11 @@
<extends>QWidget</extends>
<header>spinslider.h</header>
</customwidget>
<customwidget>
<class>IconedLabel</class>
<extends>QFrame</extends>
<header>iconedlabel.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections>

View File

@@ -108,7 +108,7 @@ void QGLView::addObject(QWidget * o, Qt::WindowFlags f) {
void QGLView::addObject(GLObjectBase * o) {
o->view_ = this;
o->setView(this);
objects_.addChild(o);
collectLights();
if (is_init) {
@@ -119,6 +119,12 @@ void QGLView::addObject(GLObjectBase * o) {
}
void QGLView::selectObject(GLObjectBase * o) {
emit selectionChanged(o, sel_obj);
sel_obj = o;
}
void QGLView::drawBackground(QPainter * painter, const QRectF & rect) {
static bool f = true;
painter_ = painter;
@@ -472,7 +478,7 @@ void QGLView::collectGraphicItems(QList<QGraphicsItem * > & list, QGraphicsItem
void QGLView::collectObjectLights(GLObjectBase * o) {
if (o->type_ == GLObjectBase::Light) lights_ << globject_cast<Light * >(o);
if (o->type_ == GLObjectBase::glLight) lights_ << globject_cast<Light * >(o);
foreach (GLObjectBase * i, o->children())
collectObjectLights(i);
}
@@ -530,10 +536,8 @@ void QGLView::mouseReleaseEvent(QMouseEvent * e) {
selecting_ = false;
if (mouseThis_ && mouseSelect_ && e->button() == Qt::LeftButton) {
if ((lastPos - downPos).manhattanLength() < 8) {
if (sel_obj != hov_obj) {
emit selectionChanged(hov_obj, sel_obj);
sel_obj = hov_obj;
}
if (sel_obj != hov_obj)
selectObject(hov_obj);
}
}
emit glMouseReleaseEvent(e);

View File

@@ -157,7 +157,7 @@ public:
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) {removeObject(&o, inChildren);}
void clearObjects(bool deleteAll = false) {objects_.clearChildren(deleteAll);}
void clearObjects(bool deleteAll = false) {objects_.clearChildren(deleteAll); sel_obj = hov_obj = 0;}
QList<GLObjectBase * > objects(bool all = false) {return objects_.children(all);}
int lightsCount() const {return lights_.size();}
@@ -187,6 +187,7 @@ public:
void setSelectionModifier(Qt::KeyboardModifier v) {sel_mod = v;}
void setSelectionRectPen(const QPen & v) {sel_pen = v;}
void setSelectionRectBrush(const QBrush & v) {sel_brush = v;}
void selectObject(GLObjectBase * o);
GLdouble aspect, iaspect;
//QGLShaderProgram * shader_rope;

28
qglview/qglview.qrc Normal file
View File

@@ -0,0 +1,28 @@
<RCC>
<qresource prefix="/">
<file>icons/document-new.png</file>
<file>icons/document-import.png</file>
<file>icons/dialog-close.png</file>
<file>icons/edit-clear.png</file>
<file>icons/edit-guides.png</file>
<file>icons/type-camera.png</file>
<file>icons/type-geo.png</file>
<file>icons/type-light.png</file>
<file>icons/view-grid.png</file>
<file>icons/zoom-fit-best.png</file>
<file>icons/configure.png</file>
<file>icons/document-save.png</file>
<file>icons/edit-clear-locationbar-rtl.png</file>
<file>icons/edit-find.png</file>
<file>icons/list-add.png</file>
<file>icons/edit-delete.png</file>
<file>icons/item.png</file>
<file>icons/node-add.png</file>
<file>icons/application-exit.png</file>
<file>icons/document-open.png</file>
<file>icons/document-save-.png</file>
<file>icons/node.png</file>
<file>icons/edit-copy.png</file>
<file>icons/edit-paste.png</file>
</qresource>
</RCC>

View File

@@ -5,7 +5,7 @@
in vec3 src_normal, normal, binormal;//, et;
in vec4 pos, ppos;
in float fogCoord, logz;
in float fogCoord, FC, C;
in mat3 TBN;
uniform bool acc_fog;
@@ -16,6 +16,7 @@ const vec3 luma = vec3(0.299, 0.587, 0.114);
void main(void) {
//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;
vec4 dc = qgl_FragColor;
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;

View File

@@ -2,7 +2,7 @@
out vec3 src_normal, normal, binormal;//, et;
out vec4 pos, ppos;
out float fogCoord, logz;
out float fogCoord, FC, C;
out mat3 TBN;
uniform bool acc_fog;
@@ -11,9 +11,6 @@ uniform vec3 eye;
uniform mat4 prev_ModelViewProjectioMatrix;
uniform float z_near, z_far;
const float C = 0.0001;
float FC = 1. / log(z_far * C + 1.);
void main(void) {
normal = qgl_Normal;//(qgl_NormalMatrix * qgl_Normal);
binormal = qgl_Bitangent;//(qgl_NormalMatrix * qgl_Normal);
@@ -39,7 +36,9 @@ void main(void) {
//pos *= pos.w;
//logz = gl_Position.w*C + 1; //version with fragment code
logz = log(pos.w * C + 1.) * FC;
C = 0.01;
FC = 1. / log(z_far * C + 1.);
//pos.z = (logz + logz - 1) * pos.w;
gl_Position = pos;