add textureTransform to ObjectBase

before textures load refactoring
This commit is contained in:
2023-02-05 21:23:41 +03:00
parent 7d30802cbd
commit 7c6ca07323
39 changed files with 570 additions and 144 deletions

View File

@@ -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();
}

View File

@@ -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();

View File

@@ -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>

View File

@@ -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>

View File

@@ -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();

View File

@@ -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);

View File

@@ -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>

View File

@@ -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>

View File

@@ -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>

View File

@@ -506,7 +506,7 @@
</customwidget>
</customwidgets>
<resources>
<include location="../../qad/libs/blockview/qad_blockview.qrc"/>
<include location="widgets.qrc"/>
</resources>
<connections/>
</ui>

View File

@@ -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>