added headlight option to settings,
added cullface option to settings, zoom speed now adjust at settings, bugs: cullface does not work anymore, todo: connect headlight
This commit is contained in:
parent
7b739ab892
commit
538453c1db
|
@ -7,14 +7,14 @@
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>400</width>
|
<width>400</width>
|
||||||
<height>300</height>
|
<height>358</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>Settings</string>
|
<string>Settings</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout">
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
<item row="0" column="0">
|
<item row="1" column="0">
|
||||||
<widget class="QGroupBox" name="groupBackground">
|
<widget class="QGroupBox" name="groupBackground">
|
||||||
<property name="title">
|
<property name="title">
|
||||||
<string>Background</string>
|
<string>Background</string>
|
||||||
|
@ -281,46 +281,28 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="5" column="5">
|
|
||||||
<spacer name="verticalSpacerBackground">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Vertical</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>20</width>
|
|
||||||
<height>40</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="0">
|
<item row="3" column="0">
|
||||||
<widget class="QGroupBox" name="groupLight">
|
<widget class="QGroupBox" name="groupLight">
|
||||||
<property name="title">
|
<property name="title">
|
||||||
<string>Light</string>
|
<string>Light</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout_3">
|
<layout class="QGridLayout" name="gridLayout_3">
|
||||||
<item row="2" column="0" colspan="4">
|
<item row="1" column="1">
|
||||||
<widget class="QLabel" name="labelAmbCoeff">
|
<widget class="QSpinBox" name="light_R_SB">
|
||||||
<property name="text">
|
<property name="maximumSize">
|
||||||
<string>Ambientcoefficient:</string>
|
<size>
|
||||||
|
<width>30</width>
|
||||||
|
<height>16777215</height>
|
||||||
|
</size>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
<property name="buttonSymbols">
|
||||||
</item>
|
<enum>QAbstractSpinBox::NoButtons</enum>
|
||||||
<item row="3" column="0" colspan="4">
|
|
||||||
<widget class="QLabel" name="labelAttFac">
|
|
||||||
<property name="text">
|
|
||||||
<string>Attenuationfactor:</string>
|
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
<property name="maximum">
|
||||||
</item>
|
<number>255</number>
|
||||||
<item row="1" column="6">
|
|
||||||
<widget class="QLabel" name="label_8">
|
|
||||||
<property name="text">
|
|
||||||
<string>B:</string>
|
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
@ -331,6 +313,13 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="3" column="0" colspan="4">
|
||||||
|
<widget class="QLabel" name="labelAttFac">
|
||||||
|
<property name="text">
|
||||||
|
<string>Attenuationfactor:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item row="1" column="4">
|
<item row="1" column="4">
|
||||||
<widget class="QSpinBox" name="light_G_SB">
|
<widget class="QSpinBox" name="light_G_SB">
|
||||||
<property name="maximumSize">
|
<property name="maximumSize">
|
||||||
|
@ -347,29 +336,10 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="1">
|
<item row="1" column="6">
|
||||||
<widget class="QSpinBox" name="light_R_SB">
|
<widget class="QLabel" name="label_8">
|
||||||
<property name="maximumSize">
|
|
||||||
<size>
|
|
||||||
<width>30</width>
|
|
||||||
<height>16777215</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="buttonSymbols">
|
|
||||||
<enum>QAbstractSpinBox::NoButtons</enum>
|
|
||||||
</property>
|
|
||||||
<property name="maximum">
|
|
||||||
<number>255</number>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="0" colspan="4">
|
|
||||||
<widget class="QRadioButton" name="radioDirectLight">
|
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Directional light</string>
|
<string>B:</string>
|
||||||
</property>
|
|
||||||
<property name="checked">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
@ -389,13 +359,6 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="0">
|
|
||||||
<widget class="QLabel" name="label_6">
|
|
||||||
<property name="text">
|
|
||||||
<string>R:</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="1" column="2">
|
<item row="1" column="2">
|
||||||
<widget class="QSlider" name="light_R_S">
|
<widget class="QSlider" name="light_R_S">
|
||||||
<property name="maximum">
|
<property name="maximum">
|
||||||
|
@ -422,31 +385,22 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="5">
|
<item row="1" column="0">
|
||||||
<widget class="QSlider" name="light_G_S">
|
<widget class="QLabel" name="label_6">
|
||||||
<property name="maximum">
|
<property name="text">
|
||||||
<number>255</number>
|
<string>R:</string>
|
||||||
</property>
|
|
||||||
<property name="value">
|
|
||||||
<number>255</number>
|
|
||||||
</property>
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="4" column="4">
|
<item row="0" column="0" colspan="4">
|
||||||
<spacer name="verticalSpacerLight">
|
<widget class="QRadioButton" name="radioDirectLight">
|
||||||
<property name="orientation">
|
<property name="text">
|
||||||
<enum>Qt::Vertical</enum>
|
<string>Directional light</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizeHint" stdset="0">
|
<property name="checked">
|
||||||
<size>
|
<bool>true</bool>
|
||||||
<width>20</width>
|
|
||||||
<height>40</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
</property>
|
||||||
</spacer>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="3" column="4" colspan="2">
|
<item row="3" column="4" colspan="2">
|
||||||
<widget class="QDoubleSpinBox" name="attFac">
|
<widget class="QDoubleSpinBox" name="attFac">
|
||||||
|
@ -492,7 +446,34 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="4" colspan="4">
|
<item row="1" column="5">
|
||||||
|
<widget class="QSlider" name="light_G_S">
|
||||||
|
<property name="maximum">
|
||||||
|
<number>255</number>
|
||||||
|
</property>
|
||||||
|
<property name="value">
|
||||||
|
<number>255</number>
|
||||||
|
</property>
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="0" colspan="4">
|
||||||
|
<widget class="QLabel" name="labelAmbCoeff">
|
||||||
|
<property name="text">
|
||||||
|
<string>Ambientcoefficient:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="7" colspan="2">
|
||||||
|
<widget class="QCheckBox" name="checkHeadlight">
|
||||||
|
<property name="text">
|
||||||
|
<string>Headlight</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="4" colspan="3">
|
||||||
<widget class="QRadioButton" name="radioPointLight">
|
<widget class="QRadioButton" name="radioPointLight">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Point light</string>
|
<string>Point light</string>
|
||||||
|
@ -502,6 +483,74 @@
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QGroupBox" name="groupGeneral">
|
||||||
|
<property name="title">
|
||||||
|
<string>General</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QGridLayout" name="gridLayout_4">
|
||||||
|
<item row="1" column="3">
|
||||||
|
<spacer name="horizontalSpacer">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>40</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="1">
|
||||||
|
<widget class="QLabel" name="labelZoomSpeed">
|
||||||
|
<property name="text">
|
||||||
|
<string>Zoom speed:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="2">
|
||||||
|
<widget class="QSpinBox" name="spinZSpeed">
|
||||||
|
<property name="suffix">
|
||||||
|
<string>%</string>
|
||||||
|
</property>
|
||||||
|
<property name="maximum">
|
||||||
|
<number>200</number>
|
||||||
|
</property>
|
||||||
|
<property name="singleStep">
|
||||||
|
<number>10</number>
|
||||||
|
</property>
|
||||||
|
<property name="value">
|
||||||
|
<number>100</number>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="1" colspan="2">
|
||||||
|
<widget class="QCheckBox" name="checkBackfaceCulling">
|
||||||
|
<property name="text">
|
||||||
|
<string>Backface Culling</string>
|
||||||
|
</property>
|
||||||
|
<property name="checked">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="4" column="0">
|
||||||
|
<spacer name="verticalSpacer">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Vertical</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>20</width>
|
||||||
|
<height>40</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<resources/>
|
<resources/>
|
||||||
|
|
|
@ -87,6 +87,8 @@ public slots:
|
||||||
void setLightColor(QVector3D value);
|
void setLightColor(QVector3D value);
|
||||||
void setAttFac(double value);
|
void setAttFac(double value);
|
||||||
void setAmbCoef(double value);
|
void setAmbCoef(double value);
|
||||||
|
void setBackfaceCulling(bool value);
|
||||||
|
void setZoomSpeed(int percent);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -30,4 +30,6 @@ signals:
|
||||||
void updateLightColor(QVector3D value);
|
void updateLightColor(QVector3D value);
|
||||||
void updateAttFac(double value);
|
void updateAttFac(double value);
|
||||||
void updateAmbCoef(double value);
|
void updateAmbCoef(double value);
|
||||||
|
void sendBackfaceCulling(bool value);
|
||||||
|
void sendZommSpeed(int percent);
|
||||||
};
|
};
|
|
@ -8,7 +8,6 @@ left mouse - rotate
|
||||||
right mouse - move
|
right mouse - move
|
||||||
scroll - zoom
|
scroll - zoom
|
||||||
space - reset view
|
space - reset view
|
||||||
+/- - adjust zoom speed
|
|
||||||
L - set light to current position
|
L - set light to current position
|
||||||
esc - close
|
esc - close
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
#include "..\Header\OglViewerWidget.h"
|
#include "..\Header\OglViewerWidget.h"
|
||||||
#include "..\Header\OutputDevice.h"
|
|
||||||
#include "..\Header\MainWindow.h"
|
#include "..\Header\MainWindow.h"
|
||||||
#include <QMouseEvent>
|
#include <QMouseEvent>
|
||||||
#include <QDropEvent>
|
#include <QDropEvent>
|
||||||
|
@ -26,6 +25,8 @@ OglViewerWidget::OglViewerWidget(QWidget *parent)
|
||||||
connect(m_settings, &SettingsWindow::updateLightColor, this, &OglViewerWidget::setLightColor);
|
connect(m_settings, &SettingsWindow::updateLightColor, this, &OglViewerWidget::setLightColor);
|
||||||
connect(m_settings, &SettingsWindow::updateAttFac, this, &OglViewerWidget::setAttFac);
|
connect(m_settings, &SettingsWindow::updateAttFac, this, &OglViewerWidget::setAttFac);
|
||||||
connect(m_settings, &SettingsWindow::updateAmbCoef, this, &OglViewerWidget::setAmbCoef);
|
connect(m_settings, &SettingsWindow::updateAmbCoef, this, &OglViewerWidget::setAmbCoef);
|
||||||
|
connect(m_settings, &SettingsWindow::sendBackfaceCulling, this, &OglViewerWidget::setBackfaceCulling);
|
||||||
|
connect(m_settings, &SettingsWindow::sendZommSpeed, this, &OglViewerWidget::setZoomSpeed);
|
||||||
}
|
}
|
||||||
|
|
||||||
OglViewerWidget::~OglViewerWidget()
|
OglViewerWidget::~OglViewerWidget()
|
||||||
|
@ -91,9 +92,9 @@ void OglViewerWidget::initializeGL()
|
||||||
// Enable depth buffer
|
// Enable depth buffer
|
||||||
glEnable(GL_DEPTH_TEST);
|
glEnable(GL_DEPTH_TEST);
|
||||||
|
|
||||||
//TODO: make this optional
|
//TODO: does not work
|
||||||
// Enable back face culling
|
// Enable back face culling
|
||||||
//glEnable(GL_CULL_FACE);
|
glEnable(GL_CULL_FACE);
|
||||||
|
|
||||||
// Enable transparency
|
// Enable transparency
|
||||||
glEnable(GL_BLEND);
|
glEnable(GL_BLEND);
|
||||||
|
@ -303,17 +304,6 @@ void OglViewerWidget::keyPressEvent(QKeyEvent *e)
|
||||||
updateLightPosition();
|
updateLightPosition();
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
else if (e->key() == Qt::Key_Minus)
|
|
||||||
{
|
|
||||||
m_zSpeed -= 0.1;
|
|
||||||
m_zSpeed < 0.09 ? m_zSpeed = 0 : NULL;
|
|
||||||
OutputDevice::getInstance()->print(QString("Zoom speed = %1%").arg(m_zSpeed * 100), 0);
|
|
||||||
}
|
|
||||||
else if (e->key() == Qt::Key_Plus)
|
|
||||||
{
|
|
||||||
m_zSpeed += 0.1;
|
|
||||||
OutputDevice::getInstance()->print(QString("Zoom speed = %1%").arg(m_zSpeed * 100), 0);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void OglViewerWidget::dragEnterEvent(QDragEnterEvent *e)
|
void OglViewerWidget::dragEnterEvent(QDragEnterEvent *e)
|
||||||
|
@ -417,3 +407,18 @@ void OglViewerWidget::setAmbCoef(double value)
|
||||||
if (m_lightOn)
|
if (m_lightOn)
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void OglViewerWidget::setBackfaceCulling(bool value)
|
||||||
|
{
|
||||||
|
if (value)
|
||||||
|
glCullFace(GL_FRONT_AND_BACK);
|
||||||
|
else if(!value)
|
||||||
|
glCullFace(GL_FRONT);
|
||||||
|
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
|
void OglViewerWidget::setZoomSpeed(int percent)
|
||||||
|
{
|
||||||
|
m_zSpeed = percent / 100;
|
||||||
|
}
|
||||||
|
|
|
@ -91,6 +91,9 @@ void SettingsWindow::setupConnections()
|
||||||
connect(ui->radioDirectLight, &QRadioButton::toggled, this, &SettingsWindow::radioToggled);
|
connect(ui->radioDirectLight, &QRadioButton::toggled, this, &SettingsWindow::radioToggled);
|
||||||
connect(ui->ambCoef, static_cast<void(QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged), [this](double value) {emit updateAmbCoef(value); });
|
connect(ui->ambCoef, static_cast<void(QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged), [this](double value) {emit updateAmbCoef(value); });
|
||||||
connect(ui->attFac, static_cast<void(QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged), [this](double value) {emit updateAttFac(value); });
|
connect(ui->attFac, static_cast<void(QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged), [this](double value) {emit updateAttFac(value); });
|
||||||
|
|
||||||
|
connect(ui->checkBackfaceCulling, &QCheckBox::toggled, [this]() {emit sendBackfaceCulling(ui->checkBackfaceCulling->isChecked()); });
|
||||||
|
connect(ui->spinZSpeed, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), [this](int value) {emit sendZommSpeed(value); });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -157,4 +160,3 @@ void SettingsWindow::lightColorChanged()
|
||||||
ui->lightOn_B_S->setValue((int)(ui->light_B_S->value() / 50));
|
ui->lightOn_B_S->setValue((int)(ui->light_B_S->value() / 50));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue