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:
@@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user