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>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>300</height>
|
||||
<height>358</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Settings</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<item row="1" column="0">
|
||||
<widget class="QGroupBox" name="groupBackground">
|
||||
<property name="title">
|
||||
<string>Background</string>
|
||||
@ -281,46 +281,28 @@
|
||||
</property>
|
||||
</widget>
|
||||
</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>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<item row="3" column="0">
|
||||
<widget class="QGroupBox" name="groupLight">
|
||||
<property name="title">
|
||||
<string>Light</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<item row="2" column="0" colspan="4">
|
||||
<widget class="QLabel" name="labelAmbCoeff">
|
||||
<property name="text">
|
||||
<string>Ambientcoefficient:</string>
|
||||
<item row="1" column="1">
|
||||
<widget class="QSpinBox" name="light_R_SB">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>30</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0" colspan="4">
|
||||
<widget class="QLabel" name="labelAttFac">
|
||||
<property name="text">
|
||||
<string>Attenuationfactor:</string>
|
||||
<property name="buttonSymbols">
|
||||
<enum>QAbstractSpinBox::NoButtons</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="6">
|
||||
<widget class="QLabel" name="label_8">
|
||||
<property name="text">
|
||||
<string>B:</string>
|
||||
<property name="maximum">
|
||||
<number>255</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@ -331,6 +313,13 @@
|
||||
</property>
|
||||
</widget>
|
||||
</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">
|
||||
<widget class="QSpinBox" name="light_G_SB">
|
||||
<property name="maximumSize">
|
||||
@ -347,29 +336,10 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QSpinBox" name="light_R_SB">
|
||||
<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">
|
||||
<item row="1" column="6">
|
||||
<widget class="QLabel" name="label_8">
|
||||
<property name="text">
|
||||
<string>Directional light</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
<string>B:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@ -389,13 +359,6 @@
|
||||
</property>
|
||||
</widget>
|
||||
</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">
|
||||
<widget class="QSlider" name="light_R_S">
|
||||
<property name="maximum">
|
||||
@ -422,31 +385,22 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<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>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_6">
|
||||
<property name="text">
|
||||
<string>R:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="4">
|
||||
<spacer name="verticalSpacerLight">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
<item row="0" column="0" colspan="4">
|
||||
<widget class="QRadioButton" name="radioDirectLight">
|
||||
<property name="text">
|
||||
<string>Directional light</string>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</spacer>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="4" colspan="2">
|
||||
<widget class="QDoubleSpinBox" name="attFac">
|
||||
@ -492,7 +446,34 @@
|
||||
</property>
|
||||
</widget>
|
||||
</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">
|
||||
<property name="text">
|
||||
<string>Point light</string>
|
||||
@ -502,6 +483,74 @@
|
||||
</layout>
|
||||
</widget>
|
||||
</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>
|
||||
</widget>
|
||||
<resources/>
|
||||
|
@ -87,6 +87,8 @@ public slots:
|
||||
void setLightColor(QVector3D value);
|
||||
void setAttFac(double value);
|
||||
void setAmbCoef(double value);
|
||||
void setBackfaceCulling(bool value);
|
||||
void setZoomSpeed(int percent);
|
||||
|
||||
};
|
||||
|
||||
|
@ -30,4 +30,6 @@ signals:
|
||||
void updateLightColor(QVector3D value);
|
||||
void updateAttFac(double value);
|
||||
void updateAmbCoef(double value);
|
||||
void sendBackfaceCulling(bool value);
|
||||
void sendZommSpeed(int percent);
|
||||
};
|
@ -8,7 +8,6 @@ left mouse - rotate
|
||||
right mouse - move
|
||||
scroll - zoom
|
||||
space - reset view
|
||||
+/- - adjust zoom speed
|
||||
L - set light to current position
|
||||
esc - close
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
#include "..\Header\OglViewerWidget.h"
|
||||
#include "..\Header\OutputDevice.h"
|
||||
#include "..\Header\MainWindow.h"
|
||||
#include <QMouseEvent>
|
||||
#include <QDropEvent>
|
||||
@ -26,6 +25,8 @@ OglViewerWidget::OglViewerWidget(QWidget *parent)
|
||||
connect(m_settings, &SettingsWindow::updateLightColor, this, &OglViewerWidget::setLightColor);
|
||||
connect(m_settings, &SettingsWindow::updateAttFac, this, &OglViewerWidget::setAttFac);
|
||||
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()
|
||||
@ -91,9 +92,9 @@ void OglViewerWidget::initializeGL()
|
||||
// Enable depth buffer
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
|
||||
//TODO: make this optional
|
||||
//TODO: does not work
|
||||
// Enable back face culling
|
||||
//glEnable(GL_CULL_FACE);
|
||||
glEnable(GL_CULL_FACE);
|
||||
|
||||
// Enable transparency
|
||||
glEnable(GL_BLEND);
|
||||
@ -303,17 +304,6 @@ void OglViewerWidget::keyPressEvent(QKeyEvent *e)
|
||||
updateLightPosition();
|
||||
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)
|
||||
@ -417,3 +407,18 @@ void OglViewerWidget::setAmbCoef(double value)
|
||||
if (m_lightOn)
|
||||
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->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->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));
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user