version 1.2.1
spot light without shadows and with texture fix mesh information points width and points-only meshes support
This commit is contained in:
@@ -27,7 +27,7 @@ else()
|
||||
|
||||
set(QGLEngine_MAJOR 1)
|
||||
set(QGLEngine_MINOR 2)
|
||||
set(QGLEngine_REVISION 0)
|
||||
set(QGLEngine_REVISION 1)
|
||||
set(QGLEngine_SUFFIX "rc")
|
||||
set(QGLEngine_COMPANY SHS)
|
||||
set(QGLEngine_DOMAIN org.SHS)
|
||||
|
||||
@@ -172,12 +172,24 @@ bool Mesh::rebuffer(QOpenGLExtraFunctions * f) {
|
||||
buffer_geom.load(f, data_.constData(), gsize);
|
||||
|
||||
buffer_ind.bind(f);
|
||||
if (geom_type == GL_TRIANGLES) {
|
||||
switch (geom_type) {
|
||||
case GL_TRIANGLES:
|
||||
buffer_ind.resize(f, tsize);
|
||||
buffer_ind.load(f, triangles_.constData(), tsize);
|
||||
} else {
|
||||
break;
|
||||
case GL_LINES:
|
||||
buffer_ind.resize(f, lsize);
|
||||
buffer_ind.load(f, lines_.constData(), lsize);
|
||||
break;
|
||||
case GL_POINTS: {
|
||||
QVector<GLint> points;
|
||||
points.resize(vertices_.size());
|
||||
for (int i = 0; i < vertices_.size(); ++i)
|
||||
points[i] = i;
|
||||
int psize = points.size() * sizeof(GLint);
|
||||
buffer_ind.resize(f, psize);
|
||||
buffer_ind.load(f, points.constData(), psize);
|
||||
} break;
|
||||
}
|
||||
|
||||
return !isEmpty();
|
||||
@@ -192,10 +204,12 @@ void Mesh::draw(QOpenGLExtraFunctions * f, int count, int type) {
|
||||
|
||||
VertexObject * vao = vaoByType(type);
|
||||
vao->bindBuffers(f, buffer_geom, buffer_ind);
|
||||
if (geom_type == GL_TRIANGLES)
|
||||
vao->draw(f, geom_type, triangles_.size() * 3, count);
|
||||
else
|
||||
vao->draw(f, geom_type, lines_.size() * 2, count);
|
||||
switch (geom_type) {
|
||||
case GL_TRIANGLES: vao->draw(f, geom_type, triangles_.size() * 3, count); break;
|
||||
case GL_LINES: vao->draw(f, geom_type, lines_.size() * 2, count); break;
|
||||
case GL_POINTS: vao->draw(f, geom_type, vertices_.size(), count); break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -304,6 +304,24 @@ void Renderer::fillObjectsBuffer(const ObjectBaseList & ol, RenderPass pass) {
|
||||
}
|
||||
|
||||
|
||||
void Renderer::setConeShadowMatrix() {
|
||||
auto cone_ll = cur_lights.value(Light::Cone);
|
||||
for (int i = 0; i < cone_ll.size(); ++i) {
|
||||
Light * l = cone_ll[i];
|
||||
QMatrix4x4 pm = glMatrixPerspective(l->angle_end, 1., 0.1), om, vm;
|
||||
om.translate(-l->worldAim());
|
||||
vm.translate(0., 0., -l->distance());
|
||||
// vm.rotate(-roll_, 0., 0., 1.);
|
||||
QMatrix4x4 pmat = l->worldTransform();
|
||||
pmat(0, 3) = pmat(1, 3) = pmat(2, 3) = 0.;
|
||||
vm *= pmat.inverted();
|
||||
auto vpm = pm * (vm * om);
|
||||
l->view_proj_matrix = vpm;
|
||||
l->shadow_matrix = mat_norm_to_tex_coord * vpm * mat_camera_fullview_inv;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Renderer::renderObjects(Scene & scene, RenderPass pass) {
|
||||
QOpenGLExtraFunctions * f = view;
|
||||
QMapIterator<Mesh *, ObjectBaseList> it(scene.geometries_used[pass]);
|
||||
@@ -404,19 +422,10 @@ void Renderer::renderConeShadows() {
|
||||
depth_maps_cone.resize(f, view->shadow_map_size, cone_ll.size());
|
||||
for (int i = 0; i < cone_ll.size(); ++i) {
|
||||
Light * l = cone_ll[i];
|
||||
QMatrix4x4 pm = glMatrixPerspective(l->angle_end, 1., 0.1), om, vm;
|
||||
om.translate(-l->worldAim());
|
||||
vm.translate(0., 0., -l->distance());
|
||||
// vm.rotate(-roll_, 0., 0., 1.);
|
||||
QMatrix4x4 pmat = l->worldTransform();
|
||||
pmat(0, 3) = pmat(1, 3) = pmat(2, 3) = 0.;
|
||||
vm *= pmat.inverted();
|
||||
auto vpm = pm * (vm * om);
|
||||
if (l->isCastShadows()) {
|
||||
prog->setUniformValue("qgl_ViewProjMatrix", vpm);
|
||||
prog->setUniformValue("qgl_ViewProjMatrix", l->view_proj_matrix);
|
||||
renderConeShadow(i, l);
|
||||
}
|
||||
l->shadow_matrix = mat_norm_to_tex_coord * vpm * mat_camera_fullview_inv;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -533,6 +542,9 @@ void Renderer::renderScene() {
|
||||
}
|
||||
phase.end();
|
||||
|
||||
/// setup cone lights matrices
|
||||
setConeShadowMatrix();
|
||||
|
||||
if (view->shadows()) {
|
||||
/// cone shadows and shadow matrix
|
||||
phase.begin("shadows cone");
|
||||
|
||||
@@ -116,6 +116,7 @@ public:
|
||||
|
||||
protected:
|
||||
void fillObjectsBuffer(const ObjectBaseList & ol, RenderPass pass);
|
||||
void setConeShadowMatrix();
|
||||
void renderObjects(Scene & scene, RenderPass pass);
|
||||
void renderLight(int first_wr_buff, bool clear_only);
|
||||
void renderConeShadows();
|
||||
|
||||
@@ -319,7 +319,7 @@ public:
|
||||
float size;
|
||||
Type light_type;
|
||||
Framebuffer shadow_map;
|
||||
QMatrix4x4 shadow_matrix;
|
||||
QMatrix4x4 shadow_matrix, view_proj_matrix;
|
||||
Map light_map;
|
||||
};
|
||||
|
||||
|
||||
@@ -163,6 +163,8 @@ void QGLView::render() {
|
||||
if (!framebuffer_size.isEmpty()) render_size = framebuffer_size;
|
||||
resizeGL(render_size.width(), render_size.height());
|
||||
emit glBeginPaint();
|
||||
glPointSize(lineWidth_);
|
||||
glLineWidth(lineWidth_);
|
||||
QSizeF fbo_sz = renderer_.fbo_ds.size();
|
||||
renderer_.rend_selection.size_coeff = {double(fbo_sz.width()) / pixelWidth(), double(fbo_sz.height()) / pixelHeight()};
|
||||
renderer_.mouse_pos = mapFromGlobal(QCursor::pos()) * devicePixelRatio();
|
||||
|
||||
BIN
src/icons/dialog-information.png
Normal file
BIN
src/icons/dialog-information.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 35 KiB |
@@ -118,6 +118,7 @@ void MaterialsEditor::materialsChanged() {
|
||||
return;
|
||||
}
|
||||
Material * cm = currentMaterial();
|
||||
ui->comboMaterial->blockSignals(true);
|
||||
ui->comboMaterial->clear();
|
||||
if (!view) return;
|
||||
QVector<Material *> mats = view->scene()->getMaterials();
|
||||
@@ -128,6 +129,8 @@ void MaterialsEditor::materialsChanged() {
|
||||
ui->comboMaterial->setItemIcon(i, QIcon(QPixmap::fromImage(view->materialThumbnail(m))));
|
||||
if (cm == m) ui->comboMaterial->setCurrentIndex(i);
|
||||
}
|
||||
ui->comboMaterial->blockSignals(false);
|
||||
if (currentMaterial() != cm) on_comboMaterial_currentIndexChanged(ui->comboMaterial->currentIndex());
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -19,11 +19,13 @@
|
||||
#include "scene_tree.h"
|
||||
|
||||
#include "glcamera.h"
|
||||
#include "glmesh.h"
|
||||
#include "qglview.h"
|
||||
#include "ui_scene_tree.h"
|
||||
|
||||
#include <QAction>
|
||||
#include <QEvent>
|
||||
#include <QMessageBox>
|
||||
#include <QScrollBar>
|
||||
#include <QTreeWidget>
|
||||
#include <qad_types.h>
|
||||
@@ -110,9 +112,9 @@ QList<QAction *> SceneTree::actionsAdd() {
|
||||
QList<QAction *> SceneTree::actionsSelection() {
|
||||
QList<QAction *> ret;
|
||||
ret << ui->actionFocus << newSeparator() << ui->actionGroup << ui->actionClone << newSeparator() << ui->actionSelect_parent
|
||||
<< ui->actionSelect_by_mesh << ui->actionSelect_by_material << newSeparator() << ui->actionMove_to_parent
|
||||
<< ui->actionTransfer_transform_to_children << newSeparator() << ui->actionActive_camera << ui->actionDefault_camera
|
||||
<< newSeparator() << ui->actionRemove;
|
||||
<< ui->actionSelect_by_mesh << ui->actionSelect_by_material << newSeparator() << ui->actionMesh_info << newSeparator()
|
||||
<< ui->actionMove_to_parent << ui->actionTransfer_transform_to_children << newSeparator() << ui->actionActive_camera
|
||||
<< ui->actionDefault_camera << newSeparator() << ui->actionRemove;
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -310,6 +312,7 @@ void SceneTree::checkActions() {
|
||||
ui->actionSelect_parent->setEnabled(has_1);
|
||||
ui->actionSelect_by_mesh->setEnabled(has_mesh);
|
||||
ui->actionSelect_by_material->setEnabled(has_mesh);
|
||||
ui->actionMesh_info->setEnabled(has_mesh);
|
||||
ui->actionActive_camera->setEnabled(has_cam);
|
||||
ui->actionDefault_camera->setEnabled(!is_def_cam);
|
||||
}
|
||||
@@ -507,6 +510,31 @@ void SceneTree::on_actionSelect_by_material_triggered() {
|
||||
}
|
||||
|
||||
|
||||
void SceneTree::on_actionMesh_info_triggered() {
|
||||
if (!view) return;
|
||||
ObjectBaseList sol = view->scene()->selectedObjects(true);
|
||||
for (auto o: sol) {
|
||||
if (o->mesh()) {
|
||||
auto m = o->mesh();
|
||||
int objects = 0;
|
||||
ObjectBaseList aol = view->scene()->objects(true);
|
||||
for (auto i: aol)
|
||||
if (i->mesh() == m) ++objects;
|
||||
|
||||
auto bb = o->mesh()->boundingBox();
|
||||
QString info;
|
||||
QTextStream ts(&info);
|
||||
ts << "Vertices: " << m->verticesCount() << "\n";
|
||||
ts << "Triangles: " << m->trianglesCount() << "\n";
|
||||
ts << "Bounding box: " << bb.length << "x" << bb.width << "x" << bb.height << "\n";
|
||||
ts << "Objects with this mesh: " << objects << "\n";
|
||||
QMessageBox::information(nullptr, tr("Mesh info"), info);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void SceneTree::removeObjects() {
|
||||
if (!view) return;
|
||||
QAD::CursorOverrider curov;
|
||||
|
||||
@@ -88,6 +88,8 @@ private slots:
|
||||
void on_actionSelect_by_mesh_triggered();
|
||||
void on_actionSelect_by_material_triggered();
|
||||
|
||||
void on_actionMesh_info_triggered();
|
||||
|
||||
void objectsTreeChanged();
|
||||
void selectionChanged();
|
||||
void materialsChanged();
|
||||
|
||||
@@ -130,7 +130,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">
|
||||
@@ -175,7 +175,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">
|
||||
@@ -235,7 +235,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">
|
||||
@@ -247,7 +247,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">
|
||||
@@ -259,7 +259,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">
|
||||
@@ -273,7 +273,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">
|
||||
@@ -282,7 +282,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">
|
||||
@@ -298,6 +298,15 @@
|
||||
<string>Move to parent</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionMesh_info">
|
||||
<property name="icon">
|
||||
<iconset resource="../../../cd/utils/pult/cdpult.qrc">
|
||||
<normaloff>:/icons/dialog-information.png</normaloff>:/icons/dialog-information.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Mesh info ...</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
@@ -312,9 +321,9 @@
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources>
|
||||
<include location="../../../cd/utils/pult/cdpult.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="../core/qglengine_core.qrc"/>
|
||||
<include location="widgets.qrc"/>
|
||||
</resources>
|
||||
|
||||
@@ -70,6 +70,7 @@ void ViewEditor::assignQGLView(QGLView * v) {
|
||||
ui->checkSoftShadows->setChecked(view->softShadows());
|
||||
ui->spinSoftShadowSamples->setValue(view->softShadowsSamples());
|
||||
ui->spinSoftShadowQuality->setValue(view->softShadowsQuality());
|
||||
ui->spinLineWidth->setValue(view->lineWidth());
|
||||
auto setMapSize = [](QComboBox * combo, QSize sz) {
|
||||
for (int i = 0; i < combo->count(); ++i) {
|
||||
if (combo->itemData(i).toSize() == sz) {
|
||||
@@ -268,6 +269,12 @@ void ViewEditor::on_spinSoftShadowQuality_valueChanged(double arg1) {
|
||||
}
|
||||
|
||||
|
||||
void ViewEditor::on_spinLineWidth_valueChanged(double v) {
|
||||
if (!view || !active) return;
|
||||
view->setLineWidth(v);
|
||||
}
|
||||
|
||||
|
||||
void ViewEditor::on_checkVSync_clicked(bool val) {
|
||||
if (!view || !active) return;
|
||||
view->setVSync(val);
|
||||
|
||||
@@ -72,6 +72,7 @@ private slots:
|
||||
void on_checkSoftShadows_clicked(bool arg1);
|
||||
void on_spinSoftShadowSamples_valueChanged(double arg1);
|
||||
void on_spinSoftShadowQuality_valueChanged(double arg1);
|
||||
void on_spinLineWidth_valueChanged(double v);
|
||||
};
|
||||
|
||||
#endif // VIEW_EDITOR_H
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>479</width>
|
||||
<height>897</height>
|
||||
<height>976</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
@@ -37,7 +37,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>479</width>
|
||||
<height>897</height>
|
||||
<height>976</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
@@ -161,6 +161,30 @@
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="1" column="0">
|
||||
<widget class="QCheckBox" name="checkFXAA">
|
||||
<property name="text">
|
||||
<string>FXAA</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QCheckBox" name="checkVSync">
|
||||
<property name="text">
|
||||
<string>VSync</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QCheckBox" name="checkAutoExposure">
|
||||
<property name="text">
|
||||
<string>Auto exposure</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QCheckBox" name="checkCameraLight">
|
||||
<property name="text">
|
||||
@@ -181,30 +205,6 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QCheckBox" name="checkFXAA">
|
||||
<property name="text">
|
||||
<string>FXAA</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QCheckBox" name="checkAutoExposure">
|
||||
<property name="text">
|
||||
<string>Auto exposure</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QCheckBox" name="checkVSync">
|
||||
<property name="text">
|
||||
<string>VSync</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QWidget" name="widget_2" native="true">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
@@ -253,6 +253,50 @@
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QWidget" name="widget_3" native="true">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_12">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Line width:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDoubleSpinBox" name="spinLineWidth">
|
||||
<property name="decimals">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<double>0.100000000000000</double>
|
||||
</property>
|
||||
<property name="value">
|
||||
<double>1.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
|
||||
@@ -15,5 +15,6 @@
|
||||
<file>../icons/group.png</file>
|
||||
<file>../icons/legend.png</file>
|
||||
<file>../icons/format-fill-color.png</file>
|
||||
<file>../icons/dialog-information.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
||||
Reference in New Issue
Block a user