spot light map

This commit is contained in:
2023-02-14 10:43:51 +03:00
parent 36540468dc
commit 12695983d2
13 changed files with 119 additions and 62 deletions

View File

@@ -128,6 +128,7 @@ Map MaterialMapEditor::map() {
*/
void MaterialMapEditor::on_buttonSelect_clicked() {
if (!map) return;
QString str = QFileDialog::getOpenFileName(this,
"Select image",
ui->linePath->property("GLpath").toString(),
@@ -142,6 +143,7 @@ void MaterialMapEditor::on_buttonSelect_clicked() {
void MaterialMapEditor::on_buttonClear_clicked() {
if (!map) return;
ui->linePath->setText("");
ui->linePath->setProperty("GLpath", "");
map->clearBitmap();

View File

@@ -45,7 +45,7 @@ protected:
bool active;
Ui::MaterialMapEditor * ui;
Map * map;
Map * map = nullptr;
private slots:
void mapChanged();

View File

@@ -21,6 +21,7 @@
#include "qglview.h"
#include "ui_object_editor.h"
#include <QScrollBar>
#include <scroll_spin_box.h>
#include <spinslider.h>
@@ -30,6 +31,7 @@ ObjectEditor::ObjectEditor(QWidget * parent): QWidget(parent) {
ui->setupUi(this);
ui->scrollArea->viewport()->setAutoFillBackground(false);
ui->scrollAreaWidgetContents->setAutoFillBackground(false);
ui->mapLight->configure(tr("Map"), false);
view = 0;
active = true;
ignore_next = false;
@@ -37,6 +39,7 @@ ObjectEditor::ObjectEditor(QWidget * parent): QWidget(parent) {
ui->scrollArea->setEnabled(false);
ui->labelAimDist->hide();
ui->spinAimDist->hide();
ui->mapLight->hide();
QObjectList ol;
ol << ui->spinPosX << ui->spinPosY << ui->spinPosZ << ui->spinRotationX << ui->spinRotationY << ui->spinRotationZ << ui->spinScaleX
@@ -87,6 +90,7 @@ void ObjectEditor::changeEvent(QEvent * e) {
void ObjectEditor::selectionChanged() {
int vpos = ui->scrollArea->verticalScrollBar()->value();
if (ignore_next) {
ignore_next = false;
return;
@@ -101,6 +105,7 @@ void ObjectEditor::selectionChanged() {
ui->scrollArea->setEnabled(true);
if (sol.size() == 1) {
setObject(sol[0]);
ui->scrollArea->verticalScrollBar()->setValue(vpos);
return;
}
bool hl = !view->selectedLights().isEmpty(), hc = !view->selectedCameras().isEmpty();
@@ -156,6 +161,7 @@ void ObjectEditor::setObject(ObjectBase * o) {
ui->spinLightSize->setValue(l->size);
ui->spinAimDist->setValue(l->distance());
on_comboLightType_currentIndexChanged(ui->comboLightType->currentIndex());
if (l->light_type == Light::Cone) ui->mapLight->setMap(&(l->light_map));
}
if (is_c) {
Camera * c = globject_cast<Camera *>(o);
@@ -186,6 +192,7 @@ void ObjectEditor::on_comboLightType_currentIndexChanged(int index) {
ui->labelLightAngleDash->setVisible(ang);
ui->spinLightAngleStart->setVisible(ang);
ui->spinLightAngleEnd->setVisible(ang);
ui->mapLight->setVisible(ang);
if (!view || !active) return;
QList<Light *> sll = view->selectedLights();
foreach(Light * o, sll) {
@@ -206,6 +213,15 @@ void ObjectEditor::on_buttonColor_colorChanged(const QColor & v) {
}
void ObjectEditor::on_mapLight_changed() {
if (!view || !active) return;
QList<Light *> sll = view->selectedLights();
foreach(Light * o, sll) {
o->apply();
}
}
void ObjectEditor::spinChanged(double v) {
if (!view || !active) return;
ObjectBaseList sol = view->selectedObjects(true);

View File

@@ -50,6 +50,7 @@ private slots:
void on_comboLightType_currentIndexChanged(int index);
void on_buttonColor_colorChanged(const QColor & v);
void on_mapLight_changed();
void spinChanged(double v);
void spinTextureChanged(double v);
void spinLightChanged(double v);

View File

@@ -62,7 +62,7 @@
<x>0</x>
<y>-287</y>
<width>444</width>
<height>1081</height>
<height>1100</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
@@ -810,6 +810,13 @@
</layout>
</widget>
</item>
<item row="7" column="0" colspan="2">
<widget class="MaterialMapEditor" name="mapLight" native="true">
<property name="styleSheet">
<string notr="true">font:normal;</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
@@ -832,6 +839,19 @@
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QDoubleSpinBox" name="spinCameraDepthStart">
<property name="decimals">
<number>5</number>
</property>
<property name="maximum">
<double>999999999.000000000000000</double>
</property>
<property name="value">
<double>0.100000000000000</double>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_45">
<property name="text">
@@ -864,34 +884,10 @@
</property>
</widget>
</item>
<item row="3" column="1">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QCheckBox" name="checkCameraMirrorY">
<property name="text">
<string>Mirror Y</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkCameraMirrorX">
<property name="text">
<string>Mirror X</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="0" column="1">
<widget class="QDoubleSpinBox" name="spinCameraDepthStart">
<property name="decimals">
<number>5</number>
</property>
<property name="maximum">
<double>999999999.000000000000000</double>
</property>
<property name="value">
<double>0.100000000000000</double>
<item row="2" column="0">
<widget class="QLabel" name="label_47">
<property name="text">
<string>Roll:</string>
</property>
</widget>
</item>
@@ -920,12 +916,23 @@
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_47">
<property name="text">
<string>Roll:</string>
</property>
</widget>
<item row="3" column="1">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QCheckBox" name="checkCameraMirrorY">
<property name="text">
<string>Mirror Y</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkCameraMirrorX">
<property name="text">
<string>Mirror X</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
@@ -965,6 +972,15 @@
<extends>QWidget</extends>
<header>scroll_spin_box.h</header>
</customwidget>
<customwidget>
<class>MaterialMapEditor</class>
<extends>QWidget</extends>
<header>material_map_editor.h</header>
<container>1</container>
<slots>
<signal>changed()</signal>
</slots>
</customwidget>
</customwidgets>
<resources/>
<connections/>