add textureTransform to ObjectBase
before textures load refactoring
This commit is contained in:
@@ -10,6 +10,7 @@ project(QGLEngine)
|
||||
if (NOT DEFINED SHSTKPROJECT)
|
||||
include(SHSTKQtMacros)
|
||||
endif()
|
||||
find_package(PIP REQUIRED)
|
||||
find_package(QAD REQUIRED)
|
||||
shstk_qt_founded(QtVersions)
|
||||
set(_qgl_ok 0)
|
||||
@@ -23,7 +24,6 @@ if (NOT _qgl_ok)
|
||||
message(WARNING "Building ${PROJECT_NAME} available only on Qt5/6!")
|
||||
else()
|
||||
include(SHSTKQtMacros)
|
||||
include_directories("c:/sdk/MinGW/x32/lib/gcc/i686-w64-mingw32/8.1.0/include")
|
||||
|
||||
set(QGLEngine_MAJOR 1)
|
||||
set(QGLEngine_MINOR 0)
|
||||
|
||||
@@ -6,7 +6,7 @@ out vec4 object_color;
|
||||
|
||||
void main(void) {
|
||||
qgl_MaterialIndex = qgl_Material;
|
||||
qgl_FragTexture = qgl_Texture;
|
||||
qgl_FragTexture = qgl_getFragTexture();
|
||||
gl_Position = qgl_ftransform();
|
||||
|
||||
geom_normal = normalize(qgl_Normal * qgl_getNormalMatrix());
|
||||
|
||||
@@ -20,6 +20,6 @@ void main(void) {
|
||||
float g = gamma / frame_max;
|
||||
res /= l;
|
||||
l = 1 - exp(-l*g);
|
||||
res *= l;
|
||||
res = max(vec3(0.f), res * l);
|
||||
qgl_FragColor = vec4(res, dot(res, luma));
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ qad_add_library(${PROJECT_NAME} ${QGLEngine_LIB_TYPE} out_CPP ${_RC})
|
||||
qad_generate_export_header(${PROJECT_NAME})
|
||||
list(APPEND out_HDR "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}_export.h")
|
||||
qad_target_include_directories(${PROJECT_NAME} PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}" ${_includes})
|
||||
qad_target_link_libraries(${PROJECT_NAME} QAD::Widgets assimp ${OPENGL_LIBRARIES})
|
||||
qad_target_link_libraries(${PROJECT_NAME} QAD::Widgets QAD::PIQtUtils assimp ${OPENGL_LIBRARIES})
|
||||
message(STATUS "Building QGLEngine version ${QGLEngine_VERSION} (${QGLEngine_LIB_TYPE_MSG}) for ${QtVersions}")
|
||||
|
||||
list(APPEND QT_MULTILIB_LIST ${PROJECT_NAME})
|
||||
|
||||
@@ -32,6 +32,11 @@ FramebufferMipmap::FramebufferMipmap(const Framebuffer & fb, int index_from_, in
|
||||
FramebufferMipmap::~FramebufferMipmap() {}
|
||||
|
||||
|
||||
void FramebufferMipmap::setIndexFrom(int index) {
|
||||
index_from = index;
|
||||
}
|
||||
|
||||
|
||||
void FramebufferMipmap::resize() {
|
||||
QSize sz = src_fb.size();
|
||||
for (int i = 0; i < fbo.size(); ++i) {
|
||||
|
||||
@@ -35,6 +35,7 @@ public:
|
||||
int height(int level) const { return fbo[level]->hei; }
|
||||
QSize size(int level) const { return fbo[level]->size(); }
|
||||
QRect rect(int level) const { return fbo[level]->rect(); }
|
||||
void setIndexFrom(int index);
|
||||
|
||||
void resize();
|
||||
void create();
|
||||
|
||||
@@ -21,6 +21,8 @@
|
||||
|
||||
#include "glframebuffer.h"
|
||||
|
||||
#include <QElapsedTimer>
|
||||
|
||||
|
||||
class QGLENGINE_CORE_EXPORT FramebufferEffectBase {
|
||||
friend class FramebufferMipmap;
|
||||
@@ -31,6 +33,10 @@ public:
|
||||
virtual ~FramebufferEffectBase();
|
||||
|
||||
virtual void draw() = 0;
|
||||
void setEnabled(bool on) { enabled_ = on; }
|
||||
bool isEnabled() const { return enabled_; }
|
||||
void setParameter(const QString & name, const QVariant & val) { parameters[name] = val; }
|
||||
virtual QString name() const = 0;
|
||||
|
||||
protected:
|
||||
void resize(int width, int height, bool force = false);
|
||||
@@ -51,8 +57,9 @@ protected:
|
||||
static void deleteShader(QOpenGLShaderProgram *& s);
|
||||
|
||||
private:
|
||||
bool is_loaded = false;
|
||||
Renderer * r = nullptr;
|
||||
bool is_loaded = false, enabled_ = true;
|
||||
Renderer * r = nullptr;
|
||||
QHash<QString, QVariant> parameters;
|
||||
GLint wid, hei;
|
||||
};
|
||||
|
||||
|
||||
@@ -29,6 +29,9 @@ Map::Map() {
|
||||
color_offset = 0.f;
|
||||
bitmap_scale = QPointF(1., 1.);
|
||||
use_bitmap = false;
|
||||
invert_R = false;
|
||||
invert_G = false;
|
||||
invert_B = false;
|
||||
_changed = true;
|
||||
_layer = 0;
|
||||
}
|
||||
|
||||
@@ -38,6 +38,7 @@ public:
|
||||
float color_amount;
|
||||
float color_offset;
|
||||
bool use_bitmap;
|
||||
bool invert_R, invert_G, invert_B;
|
||||
|
||||
bool _changed;
|
||||
int _type, _layer;
|
||||
@@ -75,14 +76,28 @@ public:
|
||||
|
||||
inline QDataStream & operator<<(QDataStream & s, const Map & m) {
|
||||
ChunkStream cs;
|
||||
cs.add(1, m.bitmap_path).add(2, m.color_amount).add(3, m.color_offset).add(6, m.bitmap_scale).add(7, m.use_bitmap);
|
||||
cs.add(1, m.bitmap_path)
|
||||
.add(2, m.color_amount)
|
||||
.add(3, m.color_offset)
|
||||
.add(6, m.bitmap_scale)
|
||||
.add(7, m.use_bitmap)
|
||||
.add(8, m.invert_R)
|
||||
.add(9, m.invert_G)
|
||||
.add(10, m.invert_B);
|
||||
s << cs.data();
|
||||
return s;
|
||||
}
|
||||
inline QDataStream & operator>>(QDataStream & s, Map & m) {
|
||||
ChunkStream cs(s);
|
||||
cs.readAll();
|
||||
cs.get(1, m.bitmap_path).get(2, m.color_amount).get(3, m.color_offset).get(6, m.bitmap_scale).get(7, m.use_bitmap);
|
||||
cs.get(1, m.bitmap_path)
|
||||
.get(2, m.color_amount)
|
||||
.get(3, m.color_offset)
|
||||
.get(6, m.bitmap_scale)
|
||||
.get(7, m.use_bitmap)
|
||||
.get(8, m.invert_R)
|
||||
.get(9, m.invert_G)
|
||||
.get(10, m.invert_B);
|
||||
return s;
|
||||
}
|
||||
|
||||
|
||||
@@ -312,7 +312,7 @@ void Mesh::transformPoints(const QMatrix4x4 & mat) {
|
||||
void Mesh::flipNormals() {
|
||||
if (vertices_.isEmpty()) return;
|
||||
for (int i = 0; i < triangles_.size(); ++i)
|
||||
piSwap(triangles_[i].p1, triangles_[i].p2);
|
||||
piSwap(triangles_[i].p0, triangles_[i].p1);
|
||||
for (int i = 0; i < lines_.size(); ++i)
|
||||
piSwap(lines_[i].p0, lines_[i].p1);
|
||||
int ncnt = normals_.size();
|
||||
|
||||
@@ -50,7 +50,7 @@ bool addShader(QOpenGLShaderProgram * prog,
|
||||
content.prepend(defs);
|
||||
content.prepend(qgl_common_head);
|
||||
bool ret = prog->addShaderFromSourceCode(type, content.toLatin1());
|
||||
if (!ret) qDebug() << "[QGLEngine] Shader" << file << "Compile error:\n" << prog->log();
|
||||
if (!ret) qDebug() << "[QGLEngine] Shader" << file << "Compile error:\n" << prog->log().toLocal8Bit().constData();
|
||||
content.clear();
|
||||
return ret;
|
||||
}
|
||||
@@ -110,7 +110,7 @@ bool QGLEngineShaders::loadShadersMulti(QOpenGLShaderProgram *& prog, const QStr
|
||||
}
|
||||
if (!addShader(prog, type, cur_shader, file, add_qgl, defs)) return false;
|
||||
if (!prog->link()) {
|
||||
qDebug() << "[QGLEngine] Shader" << file << "Link error:\n" << prog->log();
|
||||
qDebug() << "[QGLEngine] Shader" << file << "Link error:\n" << prog->log().toLocal8Bit().constData();
|
||||
return false;
|
||||
}
|
||||
qDebug() << "[QGLEngine] Shader" << file << "ok";
|
||||
@@ -138,7 +138,7 @@ bool QGLEngineShaders::loadShaders(QOpenGLShaderProgram *& prog, const QStringLi
|
||||
if (!addShader(prog, type, cur_shader, f, add_qgl, defs)) return false;
|
||||
}
|
||||
if (!prog->link()) {
|
||||
qDebug() << "[QGLEngine] Shader" << files << "Link error:\n" << prog->log();
|
||||
qDebug() << "[QGLEngine] Shader" << files << "Link error:\n" << prog->log().toLocal8Bit().constData();
|
||||
return false;
|
||||
}
|
||||
qDebug() << "[QGLEngine] Shader" << files << "ok";
|
||||
|
||||
@@ -37,13 +37,15 @@ const char qgl_vertex_head[] = "layout(location = 1 ) in vec3 qgl_Vertex
|
||||
"layout(location = 8 ) in uint qgl_ObjectID ;\n"
|
||||
"layout(location = 9 ) in vec4 qgl_ObjectColor ;\n"
|
||||
"layout(location = 10) in mat4 qgl_ModelMatrix ;\n"
|
||||
"layout(location = 14) in mat2x3 qgl_TextureMatrix ;\n"
|
||||
"out vec2 qgl_FragTexture;\n"
|
||||
"flat out uint qgl_MaterialIndex;\n"
|
||||
"uniform mat4 qgl_ViewMatrix;\n"
|
||||
"uniform mat4 qgl_ViewProjMatrix;\n"
|
||||
"mat3 qgl_getNormalMatrix() {return inverse(mat3(qgl_ViewMatrix * qgl_ModelMatrix));}\n"
|
||||
"mat3 qgl_getTangentMatrix() {return mat3(qgl_ViewMatrix * qgl_ModelMatrix);}\n"
|
||||
"vec4 qgl_ftransform() {return qgl_ViewProjMatrix * (qgl_ModelMatrix * vec4(qgl_Vertex, 1));}\n"
|
||||
"vec2 qgl_getFragTexture() {return (vec3(qgl_Texture, 1.f) * qgl_TextureMatrix).xy;}\n"
|
||||
"vec4 qgl_ftransform() {return qgl_ViewProjMatrix * (qgl_ModelMatrix * vec4(qgl_Vertex, 1.f));}\n"
|
||||
"";
|
||||
|
||||
const char qgl_fragment_head[] =
|
||||
|
||||
@@ -64,9 +64,10 @@ void QGLEngineShaders::prepareDrawObj(QOpenGLExtraFunctions * f) {
|
||||
f->glEnableVertexAttribArray(material_loc);
|
||||
f->glEnableVertexAttribArray(object_id_loc);
|
||||
f->glEnableVertexAttribArray(color_loc);
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
for (int i = 0; i < 4; ++i)
|
||||
f->glEnableVertexAttribArray(modelmatrix_loc + i);
|
||||
}
|
||||
for (int i = 0; i < 2; ++i)
|
||||
f->glEnableVertexAttribArray(texturematrix_loc + i);
|
||||
|
||||
GLsizei size = sizeof(Object);
|
||||
f->glVertexAttribIPointer(material_loc, 1, GL_UNSIGNED_INT, size, (const void *)material_offset);
|
||||
@@ -80,13 +81,22 @@ void QGLEngineShaders::prepareDrawObj(QOpenGLExtraFunctions * f) {
|
||||
size,
|
||||
(const void *)(modelmatrix_offset + sizeof(QVector4D) * i));
|
||||
}
|
||||
for (int i = 0; i < 2; ++i) {
|
||||
f->glVertexAttribPointer(texturematrix_loc + i,
|
||||
3,
|
||||
GL_FLOAT,
|
||||
GL_FALSE,
|
||||
size,
|
||||
(const void *)(texturematrix_offset + sizeof(QVector3D) * i));
|
||||
}
|
||||
|
||||
f->glVertexAttribDivisor(material_loc, 1);
|
||||
f->glVertexAttribDivisor(object_id_loc, 1);
|
||||
f->glVertexAttribDivisor(color_loc, 1);
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
for (int i = 0; i < 4; ++i)
|
||||
f->glVertexAttribDivisor(modelmatrix_loc + i, 1);
|
||||
}
|
||||
for (int i = 0; i < 2; ++i)
|
||||
f->glVertexAttribDivisor(texturematrix_loc + i, 1);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -27,32 +27,34 @@ namespace QGLEngineShaders {
|
||||
/// VBO
|
||||
|
||||
// geometry
|
||||
const GLsizei pos_offset = 0;
|
||||
const GLsizei normal_offset = sizeof(QVector3D) + pos_offset;
|
||||
const GLsizei tangent_offset = sizeof(QVector3D) + normal_offset;
|
||||
const GLsizei bitangent_offset = sizeof(QVector3D) + tangent_offset;
|
||||
const GLsizei tex_offset = sizeof(QVector3D) + bitangent_offset;
|
||||
const GLsizei pos_offset = 0;
|
||||
const GLsizei normal_offset = sizeof(QVector3D) + pos_offset;
|
||||
const GLsizei tangent_offset = sizeof(QVector3D) + normal_offset;
|
||||
const GLsizei bitangent_offset = sizeof(QVector3D) + tangent_offset;
|
||||
const GLsizei tex_offset = sizeof(QVector3D) + bitangent_offset;
|
||||
|
||||
// object
|
||||
const GLsizei material_offset = 0;
|
||||
const GLsizei object_id_offset = sizeof(GLuint) + material_offset;
|
||||
const GLsizei color_offset = sizeof(GLuint) + object_id_offset;
|
||||
const GLsizei modelmatrix_offset = sizeof(QVector4D) + color_offset;
|
||||
const GLsizei material_offset = 0;
|
||||
const GLsizei object_id_offset = sizeof(GLuint) + material_offset;
|
||||
const GLsizei color_offset = sizeof(GLuint) + object_id_offset;
|
||||
const GLsizei modelmatrix_offset = sizeof(QVector4D) + color_offset;
|
||||
const GLsizei texturematrix_offset = sizeof(QVector4D) * 4 + modelmatrix_offset;
|
||||
|
||||
const GLsizei is_selected_offset = 0;
|
||||
const GLsizei is_selected_offset = 0;
|
||||
|
||||
const GLuint pos_loc = 1; // qgl_Vertex
|
||||
const GLuint normal_loc = 2; // qgl_Normal
|
||||
const GLuint tangent_loc = 3; // qgl_Tangent
|
||||
const GLuint bitangent_loc = 4; // qgl_Bitangent
|
||||
const GLuint tex_loc = 5; // qgl_Texture
|
||||
const GLuint pos_loc = 1; // qgl_Vertex
|
||||
const GLuint normal_loc = 2; // qgl_Normal
|
||||
const GLuint tangent_loc = 3; // qgl_Tangent
|
||||
const GLuint bitangent_loc = 4; // qgl_Bitangent
|
||||
const GLuint tex_loc = 5; // qgl_Texture
|
||||
|
||||
const GLuint material_loc = 6; // qgl_Material
|
||||
const GLuint object_id_loc = 8; // qgl_ObjectID
|
||||
const GLuint color_loc = 9; // qgl_ObjectColor
|
||||
const GLuint modelmatrix_loc = 10; // qgl_ModelViewProjectionMatrix
|
||||
const GLuint material_loc = 6; // qgl_Material
|
||||
const GLuint object_id_loc = 8; // qgl_ObjectID
|
||||
const GLuint color_loc = 9; // qgl_ObjectColor
|
||||
const GLuint modelmatrix_loc = 10; // qgl_ModelViewProjectionMatrix
|
||||
const GLuint texturematrix_loc = 14; // qgl_TextureMatrix
|
||||
|
||||
const GLuint is_selected_loc = 7; // qgl_ObjectSelected
|
||||
const GLuint is_selected_loc = 7; // qgl_ObjectSelected
|
||||
|
||||
#pragma pack(push, 1)
|
||||
struct Vertex {
|
||||
@@ -67,11 +69,13 @@ struct Object {
|
||||
material = object_id = 0;
|
||||
color = QVector4D(1, 1, 1, 1);
|
||||
QMatrix4x4().copyDataTo(modelmatrix);
|
||||
QMatrix2x3().transposed().copyDataTo(texturematrix);
|
||||
}
|
||||
GLuint material;
|
||||
GLuint object_id;
|
||||
QVector4D color;
|
||||
GLfloat modelmatrix[16];
|
||||
GLfloat texturematrix[6];
|
||||
};
|
||||
#pragma pack(pop)
|
||||
|
||||
|
||||
@@ -77,6 +77,7 @@
|
||||
# include <complex.h>
|
||||
# include <math.h>
|
||||
#endif
|
||||
#include "pimathbase.h"
|
||||
#include "qglengine_core_export.h"
|
||||
#include "qglengine_version.h"
|
||||
|
||||
|
||||
39
src/core/core/measurer.cpp
Normal file
39
src/core/core/measurer.cpp
Normal file
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
Time mesurer
|
||||
Ivan Pelipenko peri4ko@yandex.ru
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser 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 Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "measurer.h"
|
||||
|
||||
#include <QTextStream>
|
||||
|
||||
|
||||
Measurer::Measurer(QString * output): out(output) {}
|
||||
|
||||
|
||||
Measurer::~Measurer() {}
|
||||
|
||||
|
||||
void Measurer::begin(const QString & name) {
|
||||
n = name;
|
||||
et.reset();
|
||||
}
|
||||
|
||||
void Measurer::end() {
|
||||
auto ms = et.elapsed_m();
|
||||
QTextStream ts(out);
|
||||
ts << n << ": " << QString::number(ms, 'f', 2) << " ms\n";
|
||||
}
|
||||
44
src/core/core/measurer.h
Normal file
44
src/core/core/measurer.h
Normal file
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
Time mesurer
|
||||
Ivan Pelipenko peri4ko@yandex.ru
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser 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 Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef measurer_H
|
||||
#define measurer_H
|
||||
|
||||
#include "qglengine_core_export.h"
|
||||
|
||||
#include <QString>
|
||||
#include <pitime.h>
|
||||
|
||||
|
||||
class QGLENGINE_CORE_EXPORT Measurer {
|
||||
friend class ObjectBase;
|
||||
|
||||
public:
|
||||
Measurer(QString * output);
|
||||
~Measurer();
|
||||
|
||||
void begin(const QString & name);
|
||||
void end();
|
||||
|
||||
private:
|
||||
PITimeMeasurer et;
|
||||
QString n, *out;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
@@ -28,6 +28,10 @@ QVector3D colorVector(QRgb c) {
|
||||
}
|
||||
|
||||
|
||||
void TextureManager::addSearchPath(const QString & path) {
|
||||
if (!search_pathes.contains(path)) search_pathes << path;
|
||||
}
|
||||
|
||||
QString TextureManager::findFile(const QString & path) {
|
||||
return ::findFile(path, search_pathes);
|
||||
}
|
||||
@@ -38,7 +42,7 @@ GLuint TextureManager::loadTexture(const QString & path, bool ownership, bool bu
|
||||
if (p.isEmpty()) return 0;
|
||||
int tid = textureID(p, bump);
|
||||
if (tid > 0) {
|
||||
// qDebug() << "[TextureManager] Found" << path << "as" << tid;
|
||||
qDebug() << "[TextureManager] Found" << path << "as" << tid;
|
||||
return tid;
|
||||
}
|
||||
QImage image(p);
|
||||
@@ -70,7 +74,7 @@ GLuint TextureManager::loadTexture(const QImage & im, bool ownership, bool bump)
|
||||
qDebug() << "[TextureManager] Can`t load image";
|
||||
return tid;
|
||||
}
|
||||
// qDebug() << "[TextureManager] Loaded image as" << tid;
|
||||
qDebug() << "[TextureManager] Loaded image as" << tid;
|
||||
return tid;
|
||||
}
|
||||
|
||||
|
||||
@@ -34,9 +34,7 @@ public:
|
||||
virtual ~TextureManager() {}
|
||||
|
||||
static void addSearchPath(const QString & path) {
|
||||
if (!search_pathes.contains(path)) search_pathes << path;
|
||||
}
|
||||
static void clearSearchPathes() { search_pathes.clear(); }
|
||||
if (!search_pathes; { search_pathes.clear(); }
|
||||
static QStringList searchPathes() { return search_pathes; }
|
||||
static QString findFile(const QString & path);
|
||||
GLuint loadTexture(const QString & path, bool ownership = true, bool bump = false);
|
||||
|
||||
@@ -160,16 +160,12 @@ void Renderer::initShaders() {
|
||||
if (!need_init_shaders) return;
|
||||
need_init_shaders = false;
|
||||
initUniformBuffer(shaders.value(srGeometryPass), &buffer_materials, bpMaterials, "QGLMaterialData");
|
||||
initUniformBuffer(shaders.value(srLightOmniPass), &buffer_materials, bpMaterials, "QGLMaterialData");
|
||||
initUniformBuffer(shaders.value(srLightOmniPass), &buffer_lights, bpLightParameters, "QGLLightParameterData");
|
||||
initUniformBuffer(shaders.value(srLightOmniPass), &buffer_lights_pos, bpLightPositions, "QGLLightPositionData");
|
||||
initUniformBuffer(shaders.value(srLightSpotPass), &buffer_materials, bpMaterials, "QGLMaterialData");
|
||||
initUniformBuffer(shaders.value(srLightSpotPass), &buffer_lights, bpLightParameters, "QGLLightParameterData");
|
||||
initUniformBuffer(shaders.value(srLightSpotPass), &buffer_lights_pos, bpLightPositions, "QGLLightPositionData");
|
||||
ShaderRole roles[] = {srLightOmniPass, srLightSpotPass};
|
||||
QOpenGLShaderProgram * prog = 0;
|
||||
for (int p = 0; p < 2; ++p) {
|
||||
if (!bindShader(roles[p], &prog)) continue;
|
||||
for (ShaderRole role: {srLightOmniPass, srLightSpotPass}) {
|
||||
initUniformBuffer(shaders.value(role), &buffer_materials, bpMaterials, "QGLMaterialData");
|
||||
initUniformBuffer(shaders.value(role), &buffer_lights, bpLightParameters, "QGLLightParameterData");
|
||||
initUniformBuffer(shaders.value(role), &buffer_lights_pos, bpLightPositions, "QGLLightPositionData");
|
||||
if (!bindShader(role, &prog)) continue;
|
||||
for (int i = 0; i < 5; ++i)
|
||||
prog->setUniformValue(QString("tex_%1").arg(i).toLatin1().constData(), i);
|
||||
prog->setUniformValue("tex_coeffs[0]", (int)Renderer::dbrBuffersCount);
|
||||
@@ -232,7 +228,8 @@ void Renderer::fillObjectsBuffer(const ObjectBaseList & ol, RenderPass pass) {
|
||||
}
|
||||
so.object_id = o->id();
|
||||
o->worldTransform().transposed().copyDataTo(so.modelmatrix);
|
||||
// qDebug() << "load obj" << o->name() << o->worldTransform();
|
||||
o->textureGLMatrix().copyDataTo(so.texturematrix);
|
||||
// qDebug() << "load obj" << o->name() << o->textureMatrix() << tmat;
|
||||
}
|
||||
// qDebug() << "fillObjectsBuffer" << ol.size();
|
||||
}
|
||||
@@ -300,6 +297,10 @@ void Renderer::renderLight(int first_wr_buff, bool clear_only) {
|
||||
|
||||
|
||||
void Renderer::renderScene() {
|
||||
timings.clear();
|
||||
Measurer phase(&timings);
|
||||
|
||||
phase.begin("init");
|
||||
initShaders();
|
||||
tex_env.load();
|
||||
QOpenGLExtraFunctions * f = view;
|
||||
@@ -308,21 +309,27 @@ void Renderer::renderScene() {
|
||||
QOpenGLShaderProgram * prog = 0;
|
||||
bool scene_changed = scene.prepare();
|
||||
scene.destroyUnused(f);
|
||||
phase.end();
|
||||
|
||||
/// reload materials on change
|
||||
phase.begin("scene reload");
|
||||
if (scene_changed || scene.need_reload_materials) {
|
||||
rend_selection.generateObjectsID(scene);
|
||||
reloadMaterials(scene);
|
||||
if (edit_mode) recreateMaterialThumbnails();
|
||||
emit view->materialsChanged();
|
||||
}
|
||||
phase.end();
|
||||
|
||||
/// material thumbnails
|
||||
phase.begin("materials");
|
||||
if (edit_mode && !scene_changed) {
|
||||
rend_mat.procQueue();
|
||||
}
|
||||
phase.end();
|
||||
|
||||
/// lights
|
||||
phase.begin("lights prepare");
|
||||
cur_lights = scene.lights_used;
|
||||
bool use_camlight = (camera_light_mode == QGLView::clmOn);
|
||||
if ((camera_light_mode == QGLView::clmAuto) && cur_lights.isEmpty()) {
|
||||
@@ -337,13 +344,17 @@ void Renderer::renderScene() {
|
||||
reloadLightsParameters(cur_lights);
|
||||
}
|
||||
reloadLightsPositions(cam);
|
||||
phase.end();
|
||||
|
||||
/// selection
|
||||
phase.begin("selection");
|
||||
if (edit_mode) {
|
||||
rend_selection.renderSelection(scene);
|
||||
}
|
||||
phase.end();
|
||||
|
||||
/// solid geometry pass
|
||||
phase.begin("geometry solid");
|
||||
fbo_ds.bind();
|
||||
glEnableDepth();
|
||||
glClearFramebuffer();
|
||||
@@ -356,11 +367,15 @@ void Renderer::renderScene() {
|
||||
fbo_ds.blit(dbrNormalZ, fbo_ds.id(), dbrNormalZSolid, fbo_ds.rect(), fbo_ds.rect());
|
||||
fbo_ds.blit(dbrSpecularReflect, fbo_ds.id(), dbrSpecularReflectSolid, fbo_ds.rect(), fbo_ds.rect());
|
||||
fbo_ds.release();
|
||||
phase.end();
|
||||
|
||||
/// lighting passes
|
||||
phase.begin("... light");
|
||||
renderLight(obrSolidOmni, scene.geometries_used[rpSolid].isEmpty());
|
||||
phase.end();
|
||||
|
||||
/// transparent geometry pass
|
||||
phase.begin("geometry trans");
|
||||
fbo_ds.bind();
|
||||
glEnableDepth();
|
||||
fbo_ds.setWriteBuffers({0, 1, 2, 3, 4});
|
||||
@@ -370,11 +385,15 @@ void Renderer::renderScene() {
|
||||
renderObjects(scene, rpTransparent);
|
||||
}
|
||||
fbo_ds.release();
|
||||
phase.end();
|
||||
|
||||
/// lighting passes
|
||||
phase.begin("... light");
|
||||
renderLight(obrTransparentOmni, scene.geometries_used[rpTransparent].isEmpty());
|
||||
phase.end();
|
||||
|
||||
/// blending layers
|
||||
phase.begin("blending");
|
||||
if (bindShader(srFinalPass, &prog)) {
|
||||
fbo_out.bindColorTexture(obrSolidOmni, 1);
|
||||
fbo_out.bindColorTexture(obrSolidSpot, 2);
|
||||
@@ -383,10 +402,12 @@ void Renderer::renderScene() {
|
||||
fbo_out.setWriteBuffer(obrGeneral0);
|
||||
renderQuad(prog, quad);
|
||||
}
|
||||
phase.end();
|
||||
|
||||
cur_write_plane = obrGeneral0;
|
||||
|
||||
/// tonemapping
|
||||
phase.begin("tonemap");
|
||||
tone_proc.process();
|
||||
auto free = getFreePlanes(0);
|
||||
if (bindShader(srTonemapPass, &prog)) {
|
||||
@@ -398,8 +419,10 @@ void Renderer::renderScene() {
|
||||
} else {
|
||||
fbo_out.blit(prev_write_plane, fbo_out.id(), cur_write_plane, fbo_out.rect(), fbo_out.rect());
|
||||
}
|
||||
phase.end();
|
||||
|
||||
/// FXAA
|
||||
phase.begin("fxaa");
|
||||
if (view->isFeatureEnabled(QGLView::qglFXAA)) {
|
||||
prog = shader_fxaa;
|
||||
if (bindShader(prog)) {
|
||||
@@ -409,27 +432,37 @@ void Renderer::renderScene() {
|
||||
renderQuad(prog, quad, 0, false);
|
||||
}
|
||||
}
|
||||
phase.end();
|
||||
|
||||
/// custom effects
|
||||
for (auto * e: fb_effects) {
|
||||
if (!e->isEnabled()) continue;
|
||||
phase.begin("fb effect " + e->name());
|
||||
e->reloadShadersInternal();
|
||||
e->drawInternal();
|
||||
phase.end();
|
||||
}
|
||||
|
||||
fbo_out.release();
|
||||
|
||||
/// apply hovers and selection frame
|
||||
phase.begin("service");
|
||||
if (edit_mode) {
|
||||
rend_selection.drawSelection(fbo_out, cur_write_plane);
|
||||
rend_service.renderService();
|
||||
} else {
|
||||
fbo_out.blit(cur_write_plane, 0, 0, fbo_out.rect(), QRect(QPoint(), view->size()));
|
||||
}
|
||||
phase.end();
|
||||
|
||||
/// grab framebuffer
|
||||
phase.begin("grab");
|
||||
if (is_grabbing) {
|
||||
fbo_out.queryImage(0);
|
||||
last_img = fbo_out.getImage().mirrored();
|
||||
// qDebug() << last_img.size();
|
||||
}
|
||||
phase.end();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -99,6 +99,7 @@ public:
|
||||
QImage getImage() const { return last_img; }
|
||||
void addFramebufferEffect(FramebufferEffectBase * e);
|
||||
void clearFramebufferEffects() { fb_effects.clear(); }
|
||||
QString getTimings() const { return timings; }
|
||||
|
||||
QImage materialThumbnail(Material * m) { return rend_mat.materialThumbnail(m); }
|
||||
void recreateMaterialThumbnails(bool force_all = false) { rend_mat.recreateMaterialThumbnails(force_all); }
|
||||
@@ -144,6 +145,7 @@ private:
|
||||
QMap<int, QList<Light *>> cur_lights;
|
||||
QVector<FramebufferEffectBase *> fb_effects;
|
||||
QImage last_img;
|
||||
QString timings;
|
||||
bool is_grabbing = false;
|
||||
};
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#include "glbuffer.h"
|
||||
#include "glshaders_types.h"
|
||||
#include "gltexturearray.h"
|
||||
#include "measurer.h"
|
||||
|
||||
|
||||
class QGLENGINE_CORE_EXPORT RendererBase {
|
||||
|
||||
@@ -31,7 +31,7 @@ TonemappingProc::TonemappingProc(Renderer * rend)
|
||||
: QThread()
|
||||
, r(rend)
|
||||
, fbo_1x1(r->view, 1, false, GL_RGB32F)
|
||||
, fbomm(r->fbo_out, Renderer::obrGeneral1, 3)
|
||||
, fbomm(r->fbo_out, Renderer::obrGeneral0, 3)
|
||||
, buffer_vbo(GL_ARRAY_BUFFER, GL_DYNAMIC_DRAW) {
|
||||
shader_sum = 0;
|
||||
timer_delim = 0;
|
||||
|
||||
@@ -63,27 +63,28 @@ ObjectBase::~ObjectBase() {
|
||||
|
||||
|
||||
ObjectBase * ObjectBase::clone(bool withChildren) {
|
||||
ObjectBase * o = new ObjectBase();
|
||||
o->prev_pass = prev_pass;
|
||||
o->is_init = false;
|
||||
o->accept_light = accept_light;
|
||||
o->accept_fog = accept_fog;
|
||||
o->visible_ = visible_;
|
||||
o->color_ = color_;
|
||||
o->type_ = type_;
|
||||
o->raw_matrix = raw_matrix;
|
||||
o->mat_ = mat_;
|
||||
o->trans = trans;
|
||||
o->itransform_ = itransform_;
|
||||
o->bound = bound;
|
||||
o->name_ = name_; // + "_copy";
|
||||
o->blend_src = blend_src;
|
||||
o->blend_dest = blend_dest;
|
||||
o->pos_h = pos_h;
|
||||
o->material_ = material_;
|
||||
o->mesh_ = mesh_;
|
||||
o->meta = meta;
|
||||
o->scene_ = nullptr;
|
||||
ObjectBase * o = new ObjectBase();
|
||||
o->prev_pass = prev_pass;
|
||||
o->is_init = false;
|
||||
o->accept_light = accept_light;
|
||||
o->accept_fog = accept_fog;
|
||||
o->visible_ = visible_;
|
||||
o->color_ = color_;
|
||||
o->type_ = type_;
|
||||
o->raw_matrix = raw_matrix;
|
||||
o->mat_ = mat_;
|
||||
o->trans = trans;
|
||||
o->trans_texture = trans_texture;
|
||||
o->itransform_ = itransform_;
|
||||
o->bound = bound;
|
||||
o->name_ = name_; // + "_copy";
|
||||
o->blend_src = blend_src;
|
||||
o->blend_dest = blend_dest;
|
||||
o->pos_h = pos_h;
|
||||
o->material_ = material_;
|
||||
o->mesh_ = mesh_;
|
||||
o->meta = meta;
|
||||
o->scene_ = nullptr;
|
||||
if (withChildren) {
|
||||
for (int i = 0; i < children_.size(); ++i)
|
||||
o->addChild(children_[i]->clone(withChildren));
|
||||
@@ -345,6 +346,31 @@ void ObjectBase::cleanTree() {
|
||||
}
|
||||
|
||||
|
||||
void ObjectBase::setTextureTransform(const Transform & t) {
|
||||
trans_texture = t;
|
||||
setObjectsChanged();
|
||||
}
|
||||
|
||||
|
||||
void ObjectBase::setTextureMatrix(const QMatrix4x4 & t) {
|
||||
trans_texture.setMatrix(t);
|
||||
setObjectsChanged();
|
||||
}
|
||||
|
||||
|
||||
QMatrix4x4 ObjectBase::textureMatrix() const {
|
||||
return trans_texture.matrix();
|
||||
}
|
||||
|
||||
|
||||
QGenericMatrix<3, 2, float> ObjectBase::textureGLMatrix() const {
|
||||
QGenericMatrix<3, 2, float> ret = textureMatrix().toGenericMatrix<3, 2>();
|
||||
ret(0, 2) = -trans_texture.translation().x();
|
||||
ret(1, 2) = -trans_texture.translation().y();
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
bool ObjectBase::isSelected(bool check_parents) const {
|
||||
if (!check_parents) return selected_;
|
||||
if (selected_) return true;
|
||||
@@ -600,6 +626,7 @@ ObjectBase * Light::clone(bool withChildren) {
|
||||
o->color_ = color_;
|
||||
o->light_type = light_type;
|
||||
o->trans = trans;
|
||||
o->trans_texture = trans_texture;
|
||||
o->aim_dist = aim_dist;
|
||||
o->angle_start = angle_start;
|
||||
o->angle_end = angle_end;
|
||||
@@ -634,7 +661,8 @@ QDataStream & operator<<(QDataStream & s, const ObjectBase * p) {
|
||||
.add(17, p->name_)
|
||||
.add(18, p->meta)
|
||||
.add(19, p->color_)
|
||||
.add(20, p->trans);
|
||||
.add(20, p->trans)
|
||||
.add(21, p->trans_texture);
|
||||
// qDebug() << "place self done";
|
||||
if (p->type_ == ObjectBase::glLight) {
|
||||
// qDebug() << "place light ...";
|
||||
@@ -734,6 +762,9 @@ QDataStream & operator>>(QDataStream & s, ObjectBase *& p) {
|
||||
case 20:
|
||||
if (p) p->trans = cs.getData<Transform>();
|
||||
break;
|
||||
case 21:
|
||||
if (p) p->trans_texture = cs.getData<Transform>();
|
||||
break;
|
||||
case 100:
|
||||
if (l) l->setAim(cs.getData<QVector3D>());
|
||||
break;
|
||||
|
||||
@@ -267,11 +267,18 @@ public:
|
||||
void setTransform(const Transform & t);
|
||||
void setMatrix(const QMatrix4x4 & t);
|
||||
QMatrix4x4 matrix() const;
|
||||
|
||||
bool isRawMatrix() { return raw_matrix; }
|
||||
QVector3D inParentSpace(const QVector3D & v) const;
|
||||
void transferTransformToChildren(bool only_scale = false);
|
||||
void cleanTree();
|
||||
|
||||
Transform textureTransform() { return trans_texture; }
|
||||
void setTextureTransform(const Transform & t);
|
||||
void setTextureMatrix(const QMatrix4x4 & t);
|
||||
QMatrix4x4 textureMatrix() const;
|
||||
QGenericMatrix<3, 2, float> textureGLMatrix() const;
|
||||
|
||||
bool isAcceptLight() const { return accept_light; }
|
||||
void setAcceptLight(bool yes) { accept_light = yes; }
|
||||
|
||||
@@ -333,7 +340,7 @@ protected:
|
||||
Type type_;
|
||||
RenderMode render_mode;
|
||||
Box3D bound;
|
||||
Transform trans;
|
||||
Transform trans, trans_texture;
|
||||
ObjectBaseList children_;
|
||||
QMatrix4x4 itransform_, mat_;
|
||||
QString name_;
|
||||
|
||||
BIN
src/icons/legend.png
Normal file
BIN
src/icons/legend.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 907 B |
@@ -31,6 +31,7 @@
|
||||
|
||||
class Effect1: public FramebufferEffectBase {
|
||||
public:
|
||||
QString name() const { return "Blur"; }
|
||||
void reloadShaders() { QGLEngineShaders::loadShadersMulti(mys, "test1.glsl"); }
|
||||
void draw() {
|
||||
auto planes = getFreePlanes(1);
|
||||
@@ -98,6 +99,7 @@ QGLViewWindow::QGLViewWindow(QWidget * parent): QMainWindow(parent), Ui::QGLView
|
||||
startTimer(1000 / 60);
|
||||
|
||||
connect(view->view(), SIGNAL(keyEvent(Qt::Key, Qt::KeyboardModifiers)), this, SLOT(view_keyEvent(Qt::Key, Qt::KeyboardModifiers)));
|
||||
connect(view->view(), &QGLView::glEndPaint, this, [this]() { labelTimings->setText(view->view()->renderer_.getTimings()); });
|
||||
// connect(matEditor, SIGNAL(changed()), this, SLOT(materialChanged()));
|
||||
sceneTree->assignQGLView(view->view());
|
||||
matEditor->assignQGLView(view->view());
|
||||
@@ -206,7 +208,7 @@ void QGLViewWindow::on_actionSaveSelected_triggered() {
|
||||
if (f.right(4).toLower() != ".qgl") f += ".qgl";
|
||||
prev_path = f;
|
||||
QApplication::setOverrideCursor(Qt::WaitCursor);
|
||||
/// saveToQGLFile(f, sel_obj);
|
||||
// saveToQGLFile(f, sel_obj);
|
||||
QApplication::restoreOverrideCursor();
|
||||
}
|
||||
|
||||
|
||||
@@ -80,7 +80,7 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>904</width>
|
||||
<width>881</width>
|
||||
<height>840</height>
|
||||
</rect>
|
||||
</property>
|
||||
@@ -723,6 +723,13 @@
|
||||
<item>
|
||||
<widget class="SceneTree" name="sceneTree" native="true"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="labelTimings">
|
||||
<property name="text">
|
||||
<string>TextLabel</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
MaterialMapEditor::MaterialMapEditor(QWidget * parent): QWidget(parent) {
|
||||
ui = new Ui::MaterialMapEditor();
|
||||
ui->setupUi(this);
|
||||
ui->buttonChannels->addActions({ui->actionInvert_R, ui->actionInvert_G, ui->actionInvert_B});
|
||||
ui->widgetMap->hide();
|
||||
active = true;
|
||||
}
|
||||
@@ -67,7 +68,10 @@ void MaterialMapEditor::mapChanged() {
|
||||
}
|
||||
map->bitmap_scale.setX(ui->spinScaleX->value());
|
||||
map->bitmap_scale.setY(ui->spinScaleY->value());
|
||||
active = true;
|
||||
map->invert_R = ui->actionInvert_R->isChecked();
|
||||
map->invert_G = ui->actionInvert_G->isChecked();
|
||||
map->invert_B = ui->actionInvert_B->isChecked();
|
||||
active = true;
|
||||
emit changed();
|
||||
}
|
||||
|
||||
@@ -86,6 +90,9 @@ void MaterialMapEditor::setMap(Map * m) {
|
||||
ui->spinScaleY->setValue(map->bitmap_scale.y());
|
||||
ui->linePath->setProperty("GLpath", map->bitmap_path);
|
||||
ui->linePath->setText(QFileInfo(map->bitmap_path).fileName());
|
||||
ui->actionInvert_R->setChecked(map->invert_R);
|
||||
ui->actionInvert_G->setChecked(map->invert_G);
|
||||
ui->actionInvert_B->setChecked(map->invert_B);
|
||||
updateIcon();
|
||||
active = true;
|
||||
}
|
||||
@@ -152,3 +159,18 @@ void MaterialMapEditor::on_checkMap_toggled(bool checked) {
|
||||
ui->stackedWidget->setCurrentIndex(checked ? 1 : 0);
|
||||
mapChanged();
|
||||
}
|
||||
|
||||
|
||||
void MaterialMapEditor::on_actionInvert_R_toggled(bool checked) {
|
||||
mapChanged();
|
||||
}
|
||||
|
||||
|
||||
void MaterialMapEditor::on_actionInvert_G_toggled(bool checked) {
|
||||
mapChanged();
|
||||
}
|
||||
|
||||
|
||||
void MaterialMapEditor::on_actionInvert_B_toggled(bool checked) {
|
||||
mapChanged();
|
||||
}
|
||||
|
||||
@@ -52,6 +52,9 @@ private slots:
|
||||
void on_buttonSelect_clicked();
|
||||
void on_buttonClear_clicked();
|
||||
void on_checkMap_toggled(bool checked);
|
||||
void on_actionInvert_R_toggled(bool checked);
|
||||
void on_actionInvert_G_toggled(bool checked);
|
||||
void on_actionInvert_B_toggled(bool checked);
|
||||
|
||||
signals:
|
||||
void changed();
|
||||
|
||||
@@ -156,7 +156,7 @@
|
||||
<item>
|
||||
<widget class="QToolButton" name="buttonClear">
|
||||
<property name="icon">
|
||||
<iconset resource="../../qad/utils/qad_utils.qrc">
|
||||
<iconset resource="../../../qad/libs/blockview/qad_blockview.qrc">
|
||||
<normaloff>:/icons/edit-delete.png</normaloff>:/icons/edit-delete.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
@@ -164,11 +164,22 @@
|
||||
<item>
|
||||
<widget class="QToolButton" name="buttonSelect">
|
||||
<property name="icon">
|
||||
<iconset resource="../../qad/application/qad_application.qrc">
|
||||
<iconset resource="../../../qad/libs/blockview/qad_blockview.qrc">
|
||||
<normaloff>:/icons/document-open.png</normaloff>:/icons/document-open.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="buttonChannels">
|
||||
<property name="icon">
|
||||
<iconset resource="../../../qad/libs/graphic/qad_graphic.qrc">
|
||||
<normaloff>:/icons/legend.png</normaloff>:/icons/legend.png</iconset>
|
||||
</property>
|
||||
<property name="popupMode">
|
||||
<enum>QToolButton::InstantPopup</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
@@ -332,6 +343,36 @@
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
<action name="actionInvert_R">
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Invert R</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionInvert_G">
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Invert G</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Invert G</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionInvert_B">
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Invert B</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Invert B</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
@@ -351,8 +392,8 @@
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources>
|
||||
<include location="../../qad/utils/qad_utils.qrc"/>
|
||||
<include location="../../qad/application/qad_application.qrc"/>
|
||||
<include location="../../../qad/libs/blockview/qad_blockview.qrc"/>
|
||||
<include location="../../../qad/libs/graphic/qad_graphic.qrc"/>
|
||||
</resources>
|
||||
<connections>
|
||||
<connection>
|
||||
|
||||
@@ -90,7 +90,7 @@
|
||||
<string>Unset</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../qcd_utils/pult/cdpult.qrc">
|
||||
<iconset resource="widgets.qrc">
|
||||
<normaloff>:/icons/dialog-cancel.png</normaloff>:/icons/dialog-cancel.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
@@ -101,7 +101,7 @@
|
||||
<string>Assign</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="widgets.qrc">
|
||||
<iconset resource="../core/qglengine_core.qrc">
|
||||
<normaloff>:/icons/go-jump.png</normaloff>:/icons/go-jump.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
@@ -112,7 +112,7 @@
|
||||
<string>Add</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../qad/utils/qad_utils.qrc">
|
||||
<iconset resource="../../../qad/libs/piqt_utils/qad_piqt_widgets.qrc">
|
||||
<normaloff>:/icons/list-add.png</normaloff>:/icons/list-add.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
@@ -123,7 +123,7 @@
|
||||
<string>Delete</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../qad/utils/qad_utils.qrc">
|
||||
<iconset resource="../../../qad/libs/blockview/qad_blockview.qrc">
|
||||
<normaloff>:/icons/edit-delete.png</normaloff>:/icons/edit-delete.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
@@ -134,7 +134,7 @@
|
||||
<string>Rename ...</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../qglview.qrc">
|
||||
<iconset resource="../core/qglengine_core.qrc">
|
||||
<normaloff>:/icons/edit-rename.png</normaloff>:/icons/edit-rename.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
@@ -145,7 +145,7 @@
|
||||
<string>Clone</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../qad/utils/qad_utils.qrc">
|
||||
<iconset resource="../../../qad/libs/application/qad_application.qrc">
|
||||
<normaloff>:/icons/edit-copy.png</normaloff>:/icons/edit-copy.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
@@ -187,7 +187,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>386</width>
|
||||
<height>440</height>
|
||||
<height>418</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="autoFillBackground">
|
||||
@@ -239,10 +239,9 @@
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources>
|
||||
<include location="../../qad/utils/qad_utils.qrc"/>
|
||||
<include location="../../qcd_utils/pult/cdpult.qrc"/>
|
||||
<include location="../../../qad/libs/application/qad_application.qrc"/>
|
||||
<include location="../../../qad/libs/piqt_utils/qad_piqt_widgets.qrc"/>
|
||||
<include location="widgets.qrc"/>
|
||||
<include location="../qglview.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
<slots>
|
||||
|
||||
@@ -42,6 +42,11 @@ ObjectEditor::ObjectEditor(QWidget * parent): QWidget(parent) {
|
||||
foreach(QObject * o, ol)
|
||||
connect(o, SIGNAL(valueChanged(double)), this, SLOT(spinChanged(double)));
|
||||
|
||||
ol.clear();
|
||||
ol << ui->spinRotationTexture << ui->spinOffsetTextureX << ui->spinOffsetTextureY << ui->spinScaleTextureX << ui->spinScaleTextureY;
|
||||
foreach(QObject * o, ol)
|
||||
connect(o, SIGNAL(valueChanged(double)), this, SLOT(spinTextureChanged(double)));
|
||||
|
||||
ol.clear();
|
||||
ol << ui->spinLightIntensity << ui->spinLightDecayConst << ui->spinLightDecayLinear << ui->spinLightDecayQuadratic
|
||||
<< ui->spinLightAngleStart << ui->spinLightAngleEnd << ui->spinAimDist;
|
||||
@@ -117,6 +122,13 @@ void ObjectEditor::setObject(ObjectBase * o) {
|
||||
ui->spinScaleX->setValue(o->scaleX());
|
||||
ui->spinScaleY->setValue(o->scaleY());
|
||||
ui->spinScaleZ->setValue(o->scaleZ());
|
||||
|
||||
ui->spinRotationTexture->setValue(o->textureTransform().rotationZ());
|
||||
ui->spinOffsetTextureX->setValue(o->textureTransform().translation().x());
|
||||
ui->spinOffsetTextureY->setValue(o->textureTransform().translation().y());
|
||||
ui->spinScaleTextureX->setValue(o->textureTransform().scale3D().x());
|
||||
ui->spinScaleTextureY->setValue(o->textureTransform().scale3D().y());
|
||||
|
||||
ui->checkVisible->setChecked(o->isVisible());
|
||||
ui->checkAcceptLight->setChecked(o->isAcceptLight());
|
||||
ui->checkAcceptFog->setChecked(o->isAcceptFog());
|
||||
@@ -210,6 +222,23 @@ void ObjectEditor::spinChanged(double v) {
|
||||
}
|
||||
|
||||
|
||||
void ObjectEditor::spinTextureChanged(double v) {
|
||||
if (!view || !active) return;
|
||||
ObjectBaseList sol = view->selectedObjects(true);
|
||||
QObject * s = sender();
|
||||
foreach(ObjectBase * o, sol) {
|
||||
auto ttr = o->textureTransform();
|
||||
if (s == ui->spinRotationTexture) ttr.setRotationZ(v);
|
||||
if (s == ui->spinOffsetTextureX) ttr.setTranslationX(v);
|
||||
if (s == ui->spinOffsetTextureY) ttr.setTranslationY(v);
|
||||
if (s == ui->spinScaleTextureX) ttr.setScaleX(v);
|
||||
if (s == ui->spinScaleTextureY) ttr.setScaleY(v);
|
||||
o->setTextureTransform(ttr);
|
||||
}
|
||||
ignore_next = true;
|
||||
}
|
||||
|
||||
|
||||
void ObjectEditor::spinLightChanged(double v) {
|
||||
if (!view || !active) return;
|
||||
QList<Light *> sll = view->selectedLights();
|
||||
|
||||
@@ -51,6 +51,7 @@ private slots:
|
||||
void on_comboLightType_currentIndexChanged(int index);
|
||||
void on_buttonColor_colorChanged(const QColor & v);
|
||||
void spinChanged(double v);
|
||||
void spinTextureChanged(double v);
|
||||
void spinLightChanged(double v);
|
||||
void spinCameraChanged(double v);
|
||||
void checkChanged(bool v);
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>466</width>
|
||||
<height>778</height>
|
||||
<height>915</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
@@ -297,26 +297,134 @@
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_4">
|
||||
<property name="title">
|
||||
<string>Texture</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="1" column="1">
|
||||
<widget class="ScrollSpinBox" name="spinOffsetTextureX"/>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="QLabel" name="label_33">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>SX:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="3">
|
||||
<widget class="ScrollSpinBox" name="spinScaleTextureX">
|
||||
<property name="value">
|
||||
<double>1.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="ScrollSpinBox" name="spinOffsetTextureY"/>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_31">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>X:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_32">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Y:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_7">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>R:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="3">
|
||||
<widget class="ScrollSpinBox" name="spinScaleTextureY">
|
||||
<property name="value">
|
||||
<double>1.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1" colspan="3">
|
||||
<widget class="SpinSlider" name="spinRotationTexture">
|
||||
<property name="minimum">
|
||||
<double>-360.000000000000000</double>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>360.000000000000000</double>
|
||||
</property>
|
||||
<property name="decimals">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<double>4.500000000000000</double>
|
||||
</property>
|
||||
<property name="pageStep">
|
||||
<double>90.000000000000000</double>
|
||||
</property>
|
||||
<property name="suffix">
|
||||
<string>°</string>
|
||||
</property>
|
||||
<property name="tickPosition">
|
||||
<enum>QSlider::TicksAbove</enum>
|
||||
</property>
|
||||
<property name="tickInterval">
|
||||
<number>90</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="2">
|
||||
<widget class="QLabel" name="label_34">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>SY:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="1" column="2">
|
||||
<widget class="QCheckBox" name="checkAcceptFog">
|
||||
<item row="1" column="1">
|
||||
<widget class="QCheckBox" name="checkReceiveShadows">
|
||||
<property name="text">
|
||||
<string>Accept fog</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QCheckBox" name="checkAcceptLight">
|
||||
<property name="text">
|
||||
<string>Accept light</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QCheckBox" name="checkVisible">
|
||||
<property name="text">
|
||||
<string>Visible</string>
|
||||
<string>Receive shadows</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@@ -327,10 +435,24 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QCheckBox" name="checkReceiveShadows">
|
||||
<item row="1" column="2">
|
||||
<widget class="QCheckBox" name="checkAcceptFog">
|
||||
<property name="text">
|
||||
<string>Receive shadows</string>
|
||||
<string>Accept fog</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QCheckBox" name="checkVisible">
|
||||
<property name="text">
|
||||
<string>Visible</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QCheckBox" name="checkAcceptLight">
|
||||
<property name="text">
|
||||
<string>Accept light</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
||||
@@ -379,7 +379,7 @@
|
||||
<string>Add</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../qad/utils/qad_utils.qrc">
|
||||
<iconset resource="../../../qad/libs/piqt_utils/qad_piqt_widgets.qrc">
|
||||
<normaloff>:/icons/list-add.png</normaloff>:/icons/list-add.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
@@ -411,7 +411,7 @@
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources>
|
||||
<include location="../../qad/utils/qad_utils.qrc"/>
|
||||
<include location="../../../qad/libs/piqt_utils/qad_piqt_widgets.qrc"/>
|
||||
</resources>
|
||||
<connections>
|
||||
<connection>
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
<item>
|
||||
<widget class="QToolButton" name="buttonFilter">
|
||||
<property name="icon">
|
||||
<iconset resource="../../qad/libs/application/qad_application.qrc">
|
||||
<iconset resource="../../../qad/libs/application/qad_application.qrc">
|
||||
<normaloff>:/icons/configure.png</normaloff>:/icons/configure.png</iconset>
|
||||
</property>
|
||||
<property name="popupMode">
|
||||
@@ -59,7 +59,7 @@
|
||||
<string>Expand tree</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../qglview.qrc">
|
||||
<iconset resource="../core/qglengine_core.qrc">
|
||||
<normaloff>:/icons/expand.png</normaloff>:/icons/expand.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
@@ -70,7 +70,7 @@
|
||||
<string>Collapse tree</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../qglview.qrc">
|
||||
<iconset resource="../core/qglengine_core.qrc">
|
||||
<normaloff>:/icons/collapse.png</normaloff>:/icons/collapse.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
@@ -127,7 +127,7 @@
|
||||
</layout>
|
||||
<action name="actionFocus">
|
||||
<property name="icon">
|
||||
<iconset resource="../../qad/libs/qglview/qglview.qrc">
|
||||
<iconset resource="../core/qglengine_core.qrc">
|
||||
<normaloff>:/icons/type-camera.png</normaloff>:/icons/type-camera.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
@@ -136,7 +136,7 @@
|
||||
</action>
|
||||
<action name="actionRemove">
|
||||
<property name="icon">
|
||||
<iconset resource="../../qad/libs/blockview/qad_blockview.qrc">
|
||||
<iconset resource="../../../qad/libs/blockview/qad_blockview.qrc">
|
||||
<normaloff>:/icons/edit-delete.png</normaloff>:/icons/edit-delete.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
@@ -145,7 +145,7 @@
|
||||
</action>
|
||||
<action name="actionClone">
|
||||
<property name="icon">
|
||||
<iconset resource="../../qad/libs/application/qad_application.qrc">
|
||||
<iconset resource="../../../qad/libs/application/qad_application.qrc">
|
||||
<normaloff>:/icons/edit-copy.png</normaloff>:/icons/edit-copy.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
@@ -163,7 +163,7 @@
|
||||
</action>
|
||||
<action name="actionSelect_parent">
|
||||
<property name="icon">
|
||||
<iconset resource="../qglview.qrc">
|
||||
<iconset resource="../core/qglengine_core.qrc">
|
||||
<normaloff>:/icons/go-top.png</normaloff>:/icons/go-top.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
@@ -172,7 +172,7 @@
|
||||
</action>
|
||||
<action name="actionSelect_by_mesh">
|
||||
<property name="icon">
|
||||
<iconset resource="../../qad/libs/qglview/qglview.qrc">
|
||||
<iconset resource="../core/qglengine_core.qrc">
|
||||
<normaloff>:/icons/type-geo.png</normaloff>:/icons/type-geo.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
@@ -181,7 +181,7 @@
|
||||
</action>
|
||||
<action name="actionSelect_by_material">
|
||||
<property name="icon">
|
||||
<iconset resource="../../qad/libs/blockview/qad_blockview.qrc">
|
||||
<iconset resource="../../../qad/libs/blockview/qad_blockview.qrc">
|
||||
<normaloff>:/icons/format-fill-color.png</normaloff>:/icons/format-fill-color.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
@@ -190,7 +190,7 @@
|
||||
</action>
|
||||
<action name="actionAdd_node">
|
||||
<property name="icon">
|
||||
<iconset resource="../qglview.qrc">
|
||||
<iconset resource="../core/qglengine_core.qrc">
|
||||
<normaloff>:/icons/add-type-empty.png</normaloff>:/icons/add-type-empty.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
@@ -199,7 +199,7 @@
|
||||
</action>
|
||||
<action name="actionAdd_light">
|
||||
<property name="icon">
|
||||
<iconset resource="../qglview.qrc">
|
||||
<iconset resource="../core/qglengine_core.qrc">
|
||||
<normaloff>:/icons/add-type-light.png</normaloff>:/icons/add-type-light.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
@@ -208,7 +208,7 @@
|
||||
</action>
|
||||
<action name="actionAdd_camera">
|
||||
<property name="icon">
|
||||
<iconset resource="../qglview.qrc">
|
||||
<iconset resource="../core/qglengine_core.qrc">
|
||||
<normaloff>:/icons/add-type-camera.png</normaloff>:/icons/add-type-camera.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
@@ -220,7 +220,7 @@
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../qglview.qrc">
|
||||
<iconset resource="../core/qglengine_core.qrc">
|
||||
<normaloff>:/icons/type-empty.png</normaloff>:/icons/type-empty.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
@@ -232,7 +232,7 @@
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../qad/libs/qglview/qglview.qrc">
|
||||
<iconset resource="../core/qglengine_core.qrc">
|
||||
<normaloff>:/icons/type-geo.png</normaloff>:/icons/type-geo.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
@@ -244,7 +244,7 @@
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../qad/libs/qglview/qglview.qrc">
|
||||
<iconset resource="../core/qglengine_core.qrc">
|
||||
<normaloff>:/icons/type-light.png</normaloff>:/icons/type-light.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
@@ -256,7 +256,7 @@
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../qad/libs/qglview/qglview.qrc">
|
||||
<iconset resource="../core/qglengine_core.qrc">
|
||||
<normaloff>:/icons/type-camera.png</normaloff>:/icons/type-camera.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
@@ -270,7 +270,7 @@
|
||||
</action>
|
||||
<action name="actionActive_camera">
|
||||
<property name="icon">
|
||||
<iconset resource="../../qad/libs/qglview/qglview.qrc">
|
||||
<iconset resource="../core/qglengine_core.qrc">
|
||||
<normaloff>:/icons/type-camera.png</normaloff>:/icons/type-camera.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
@@ -279,7 +279,7 @@
|
||||
</action>
|
||||
<action name="actionDefault_camera">
|
||||
<property name="icon">
|
||||
<iconset resource="../../qad/libs/qglview/qglview.qrc">
|
||||
<iconset resource="../core/qglengine_core.qrc">
|
||||
<normaloff>:/icons/type-camera.png</normaloff>:/icons/type-camera.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
@@ -300,15 +300,7 @@
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources>
|
||||
<include location="../../qad/libs/application/qad_application.qrc"/>
|
||||
<include location="../../qad/libs/blockview/qad_blockview.qrc"/>
|
||||
<include location="../../qad/libs/qglview/qglview.qrc"/>
|
||||
<include location="widgets.qrc"/>
|
||||
<include location="../qglview.qrc"/>
|
||||
<include location="../../qad/libs/application/qad_application.qrc"/>
|
||||
<include location="../../qad/libs/blockview/qad_blockview.qrc"/>
|
||||
<include location="../../qad/libs/qglview/qglview.qrc"/>
|
||||
<include location="../qglview.qrc"/>
|
||||
<include location="../../../qad/libs/application/qad_application.qrc"/>
|
||||
<include location="widgets.qrc"/>
|
||||
</resources>
|
||||
<connections>
|
||||
|
||||
@@ -506,7 +506,7 @@
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources>
|
||||
<include location="../../qad/libs/blockview/qad_blockview.qrc"/>
|
||||
<include location="widgets.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
<file>../icons/edit-paste.png</file>
|
||||
<file>../icons/document-edit.png</file>
|
||||
<file>../icons/group.png</file>
|
||||
<file>../icons/legend.png</file>
|
||||
<file>../icons/format-fill-color.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
||||
Reference in New Issue
Block a user