Compare commits
5 Commits
Version_1.
...
master
Author | SHA1 | Date |
---|---|---|
itdominator | 64d5584698 | |
Anakin | 7e87b14fe1 | |
Anakin | da0b7e3c5f | |
Anakin | fa75e17d58 | |
Anakin | 49585945c3 |
|
@ -19,7 +19,9 @@
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>MainWindow</string>
|
<string>MainWindow</string>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="centralWidget"/>
|
<widget class="QWidget" name="centralWidget">
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout"/>
|
||||||
|
</widget>
|
||||||
<widget class="QToolBar" name="mainToolBar">
|
<widget class="QToolBar" name="mainToolBar">
|
||||||
<property name="allowedAreas">
|
<property name="allowedAreas">
|
||||||
<set>Qt::LeftToolBarArea|Qt::RightToolBarArea|Qt::TopToolBarArea</set>
|
<set>Qt::LeftToolBarArea|Qt::RightToolBarArea|Qt::TopToolBarArea</set>
|
||||||
|
@ -32,6 +34,72 @@
|
||||||
</attribute>
|
</attribute>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QStatusBar" name="statusBar"/>
|
<widget class="QStatusBar" name="statusBar"/>
|
||||||
|
<widget class="QDockWidget" name="dockWidget">
|
||||||
|
<property name="autoFillBackground">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<property name="features">
|
||||||
|
<set>QDockWidget::DockWidgetClosable|QDockWidget::DockWidgetFloatable</set>
|
||||||
|
</property>
|
||||||
|
<property name="allowedAreas">
|
||||||
|
<set>Qt::RightDockWidgetArea</set>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>Asset library</string>
|
||||||
|
</property>
|
||||||
|
<attribute name="dockWidgetArea">
|
||||||
|
<number>2</number>
|
||||||
|
</attribute>
|
||||||
|
<widget class="QWidget" name="dockWidgetContents">
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
|
<property name="spacing">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="leftMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="topMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="rightMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="bottomMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<widget class="QTreeWidget" name="treeWidget">
|
||||||
|
<property name="showDropIndicator" stdset="0">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<property name="dragEnabled">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="dragDropMode">
|
||||||
|
<enum>QAbstractItemView::DragOnly</enum>
|
||||||
|
</property>
|
||||||
|
<property name="selectionBehavior">
|
||||||
|
<enum>QAbstractItemView::SelectItems</enum>
|
||||||
|
</property>
|
||||||
|
<property name="verticalScrollMode">
|
||||||
|
<enum>QAbstractItemView::ScrollPerPixel</enum>
|
||||||
|
</property>
|
||||||
|
<property name="headerHidden">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="expandsOnDoubleClick">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<column>
|
||||||
|
<property name="text">
|
||||||
|
<string notr="true">1</string>
|
||||||
|
</property>
|
||||||
|
</column>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</widget>
|
||||||
</widget>
|
</widget>
|
||||||
<layoutdefault spacing="6" margin="11"/>
|
<layoutdefault spacing="6" margin="11"/>
|
||||||
<resources>
|
<resources>
|
||||||
|
|
|
@ -30,6 +30,8 @@ private:
|
||||||
// functions
|
// functions
|
||||||
private:
|
private:
|
||||||
void setupWidgets();
|
void setupWidgets();
|
||||||
|
void getAssetLibrary();
|
||||||
|
void searchMeshFiles(QString path);
|
||||||
void openFile();
|
void openFile();
|
||||||
void takeScreenShot();
|
void takeScreenShot();
|
||||||
void aboutTool();
|
void aboutTool();
|
||||||
|
|
|
@ -23,19 +23,19 @@ private:
|
||||||
QOpenGLShaderProgram m_program;
|
QOpenGLShaderProgram m_program;
|
||||||
GeometryEngine *m_dataEngine;
|
GeometryEngine *m_dataEngine;
|
||||||
|
|
||||||
QVector4D m_backgroundColorOn = { 0.02f, 0.02f, 0.02f, 1.0f };
|
QVector4D m_backgroundColorOn;
|
||||||
QVector4D m_backgroundColorOff = { 0.5f, 0.8f, 1.0f, 1.0f };
|
QVector4D m_backgroundColorOff;
|
||||||
|
|
||||||
bool m_wireframe = false;
|
bool m_wireframe;
|
||||||
bool m_lightOn = false;
|
bool m_lightOn;
|
||||||
bool m_backfaceCulling = false;
|
bool m_backfaceCulling;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
QVector4D position = { 1,1,1,0 };
|
QVector4D position;
|
||||||
QVector3D intensities = { 1.0,1.0,1.0 };
|
QVector3D intensities;
|
||||||
float attenuationFactor = 0.0f;
|
float attenuationFactor;
|
||||||
float ambientCoefficient = 0.005f;
|
float ambientCoefficient;
|
||||||
bool headlight = false;
|
bool headlight;
|
||||||
} m_light;
|
} m_light;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
|
@ -51,6 +51,7 @@ private:
|
||||||
|
|
||||||
// functions
|
// functions
|
||||||
private:
|
private:
|
||||||
|
void setDefaultValues();
|
||||||
void initShaders();
|
void initShaders();
|
||||||
void resetView();
|
void resetView();
|
||||||
void updateLightPosition();
|
void updateLightPosition();
|
||||||
|
@ -89,5 +90,10 @@ public slots:
|
||||||
void setHeadlight(bool value);
|
void setHeadlight(bool value);
|
||||||
void setBackfaceCulling(bool value);
|
void setBackfaceCulling(bool value);
|
||||||
|
|
||||||
|
// signals
|
||||||
|
signals:
|
||||||
|
void lightChanged(bool value);
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,72 @@
|
||||||
|
#pragma once
|
||||||
|
#include <QObject>
|
||||||
|
#include <QFile>
|
||||||
|
#include <QVector3D>
|
||||||
|
#include <QVector4D>
|
||||||
|
|
||||||
|
|
||||||
|
class SettingsManager : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
private:
|
||||||
|
SettingsManager(QObject *parent = Q_NULLPTR);
|
||||||
|
|
||||||
|
public:
|
||||||
|
SettingsManager(SettingsManager const&) = delete;
|
||||||
|
void operator=(SettingsManager const&) = delete;
|
||||||
|
|
||||||
|
~SettingsManager();
|
||||||
|
|
||||||
|
static SettingsManager* getInstance(QObject *parent = Q_NULLPTR);
|
||||||
|
|
||||||
|
// attributes
|
||||||
|
private:
|
||||||
|
QFile file;
|
||||||
|
|
||||||
|
QVector3D m_bgColorOn = { 5, 5, 5 };
|
||||||
|
QVector3D m_bgColorOff = { 128, 204, 255 };
|
||||||
|
bool m_bfCulling = false;
|
||||||
|
bool m_light = false;
|
||||||
|
|
||||||
|
int m_lightType = 1; // 1 = direct, 2 = point
|
||||||
|
QVector3D m_lightColor = { 255,255,255 };
|
||||||
|
float m_attenuation = 0.0f;
|
||||||
|
float m_ambient = 0.005f;
|
||||||
|
bool m_headlight = false;
|
||||||
|
bool m_autoColor = true;
|
||||||
|
|
||||||
|
// functions
|
||||||
|
private:
|
||||||
|
void readFromFile();
|
||||||
|
void writeToFile();
|
||||||
|
|
||||||
|
public:
|
||||||
|
QVector3D getBgColorOn() const;
|
||||||
|
QVector3D getBgColorOff() const;
|
||||||
|
bool isBfCulling() const;
|
||||||
|
bool isLight() const;
|
||||||
|
|
||||||
|
int getLightType() const;
|
||||||
|
QVector3D getLightColor() const;
|
||||||
|
float getAttenuation() const;
|
||||||
|
float getAmbient() const;
|
||||||
|
bool isHeadlight() const;
|
||||||
|
bool isAutoColor() const;
|
||||||
|
|
||||||
|
|
||||||
|
// slots
|
||||||
|
public:
|
||||||
|
void setBgColorOn(QVector3D value);
|
||||||
|
void setBgColorOff(QVector3D value);
|
||||||
|
void setBfCulling(bool value);
|
||||||
|
void setLight(bool value);
|
||||||
|
|
||||||
|
void setLightType(int value);
|
||||||
|
void setLightColor(QVector3D value);
|
||||||
|
void setAttenuation(double value);
|
||||||
|
void setAmbient(double value);
|
||||||
|
void setHeadlight(bool value);
|
||||||
|
void setAutoColor(int value);
|
||||||
|
|
||||||
|
};
|
|
@ -9,7 +9,7 @@ class SettingsWindow : public QWidget
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
SettingsWindow(QVector3D bgOffColor, QVector3D bgOnColor, QVector3D lightColor, bool autoColor, double ambCoef, double attFac, int lightType, QWidget * parent = Q_NULLPTR);
|
SettingsWindow(QWidget * parent = Q_NULLPTR);
|
||||||
~SettingsWindow();
|
~SettingsWindow();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -33,5 +33,6 @@ signals:
|
||||||
void sendHeadlight(bool value);
|
void sendHeadlight(bool value);
|
||||||
void sendBackfaceCulling(bool value);
|
void sendBackfaceCulling(bool value);
|
||||||
void sendZommSpeed(int percent);
|
void sendZommSpeed(int percent);
|
||||||
|
void changeLightType(int value);
|
||||||
|
|
||||||
};
|
};
|
|
@ -1,4 +1,3 @@
|
||||||
#version 450
|
|
||||||
#ifdef GL_ES
|
#ifdef GL_ES
|
||||||
// Set default precision to medium
|
// Set default precision to medium
|
||||||
precision mediump int;
|
precision mediump int;
|
||||||
|
@ -70,8 +69,8 @@ void main()
|
||||||
mat3 tbn = transpose(mat3(surfaceTangent, surfaceBitangent, surfaceNormal));
|
mat3 tbn = transpose(mat3(surfaceTangent, surfaceBitangent, surfaceNormal));
|
||||||
normal = texture2D(tx1, v_surfaceUV).rgb;
|
normal = texture2D(tx1, v_surfaceUV).rgb;
|
||||||
normal = normalize(normal * 2.0 -1.0);
|
normal = normalize(normal * 2.0 -1.0);
|
||||||
surfaceToLight = tbn * surfaceToLight;
|
surfaceToLight = normalize(tbn * surfaceToLight);
|
||||||
surfaceToCamera = tbn * surfaceToCamera;
|
surfaceToCamera = normalize(tbn * surfaceToCamera);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -98,7 +97,7 @@ void main()
|
||||||
float specularWeight = 1;
|
float specularWeight = 1;
|
||||||
if(material.hasSpecularmap)
|
if(material.hasSpecularmap)
|
||||||
specularWeight = surfaceColor.a;
|
specularWeight = surfaceColor.a;
|
||||||
vec3 specColor = specularWeight * material.specularColor;
|
vec3 specColor = specularWeight * 1/255 * material.specularColor;
|
||||||
|
|
||||||
vec3 specular = specularCoefficient * specColor * light.intensities;
|
vec3 specular = specularCoefficient * specColor * light.intensities;
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
#version 450
|
|
||||||
#ifdef GL_ES
|
#ifdef GL_ES
|
||||||
// Set default precision to medium
|
// Set default precision to medium
|
||||||
precision mediump int;
|
precision mediump int;
|
||||||
|
|
|
@ -49,6 +49,8 @@ MainWindow::MainWindow(QWidget *parent)
|
||||||
styleSheet.open(QIODevice::ReadOnly);
|
styleSheet.open(QIODevice::ReadOnly);
|
||||||
this->setStyleSheet(styleSheet.readAll());
|
this->setStyleSheet(styleSheet.readAll());
|
||||||
|
|
||||||
|
getAssetLibrary();
|
||||||
|
|
||||||
printMessage("MeshViewer by Anakin", 0);
|
printMessage("MeshViewer by Anakin", 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -161,6 +163,33 @@ void MainWindow::setupWidgets()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::getAssetLibrary()
|
||||||
|
{
|
||||||
|
QTreeWidgetItem* item = new QTreeWidgetItem;
|
||||||
|
item->setData(0, Qt::DisplayRole, "Wuhu");
|
||||||
|
ui->treeWidget->addTopLevelItem(item);
|
||||||
|
|
||||||
|
searchMeshFiles("D:/workspaces/Visual Studio 2015/Projects/OpenGL/Release");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::searchMeshFiles(QString path)
|
||||||
|
{
|
||||||
|
QDir directory(path);
|
||||||
|
directory.setNameFilters(QStringList("*.msh"));
|
||||||
|
|
||||||
|
QStringList childDirectories = directory.entryList(QDir::AllDirs | QDir::NoDotAndDotDot);
|
||||||
|
|
||||||
|
QStringList fileNames = directory.entryList(QDir::Files);
|
||||||
|
|
||||||
|
for (auto &it : childDirectories)
|
||||||
|
qDebug() << it;
|
||||||
|
|
||||||
|
for (auto &it : fileNames)
|
||||||
|
qDebug() << it;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void MainWindow::openFile()
|
void MainWindow::openFile()
|
||||||
{
|
{
|
||||||
QString fileName = QFileDialog::getOpenFileName(this, "Open File", "", "Mesh (*.msh)");
|
QString fileName = QFileDialog::getOpenFileName(this, "Open File", "", "Mesh (*.msh)");
|
||||||
|
|
|
@ -707,7 +707,6 @@ void MshFile::analyseSegmChunks(Model * dataDestination, QList<ChunkHeader*>& ch
|
||||||
|
|
||||||
for (int k = 0; k < 3; k++)
|
for (int k = 0; k < 3; k++)
|
||||||
{
|
{
|
||||||
//TODO: buffer size == 1; k = 2;
|
|
||||||
// polygon normal wasn't calculated before
|
// polygon normal wasn't calculated before
|
||||||
if (new_segment->vertices[tmp_buffer[k]].polygonNormal == QVector3D(0, 0, 0))
|
if (new_segment->vertices[tmp_buffer[k]].polygonNormal == QVector3D(0, 0, 0))
|
||||||
{
|
{
|
||||||
|
@ -921,7 +920,7 @@ void MshFile::loadTexture(QOpenGLTexture *& destination, QString filepath, QStri
|
||||||
if (!loadSuccess)
|
if (!loadSuccess)
|
||||||
{
|
{
|
||||||
OutputDevice::getInstance()->print("WARNING: texture not found or corrupted: " + filename, 1);
|
OutputDevice::getInstance()->print("WARNING: texture not found or corrupted: " + filename, 1);
|
||||||
//TODO: use the correct diffuse color or return with null
|
//TODO: cloth use the wrong diffuse color. should be null
|
||||||
img = QImage(1, 1, QImage::Format_RGB32);
|
img = QImage(1, 1, QImage::Format_RGB32);
|
||||||
img.fill(QColor(m_materials->back().diffuseColor[0] * 255, m_materials->back().diffuseColor[1] * 255, m_materials->back().diffuseColor[2] * 255));
|
img.fill(QColor(m_materials->back().diffuseColor[0] * 255, m_materials->back().diffuseColor[1] * 255, m_materials->back().diffuseColor[2] * 255));
|
||||||
filename += " *";
|
filename += " *";
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
#include "..\Header\FreeCamera.h"
|
#include "..\Header\FreeCamera.h"
|
||||||
#include "..\Header\OrbitCamera.h"
|
#include "..\Header\OrbitCamera.h"
|
||||||
#include "..\Header\MoveCamera.h"
|
#include "..\Header\MoveCamera.h"
|
||||||
|
#include "..\Header\SettingsManager.h"
|
||||||
#include <QMouseEvent>
|
#include <QMouseEvent>
|
||||||
#include <QDropEvent>
|
#include <QDropEvent>
|
||||||
#include <QMimeData>
|
#include <QMimeData>
|
||||||
|
@ -24,7 +25,8 @@ OglViewerWidget::OglViewerWidget(QWidget *parent)
|
||||||
setAcceptDrops(true);
|
setAcceptDrops(true);
|
||||||
|
|
||||||
// settings window
|
// settings window
|
||||||
m_settings = new SettingsWindow(m_backgroundColorOff.toVector3D() * 255, m_backgroundColorOn.toVector3D() * 255, m_light.intensities * 255, true, m_light.ambientCoefficient, m_light.attenuationFactor, 1, this);
|
setDefaultValues();
|
||||||
|
m_settings = new SettingsWindow(this);
|
||||||
|
|
||||||
connect(m_settings, &SettingsWindow::updateBGColorOff, this, &OglViewerWidget::setBGColorOff);
|
connect(m_settings, &SettingsWindow::updateBGColorOff, this, &OglViewerWidget::setBGColorOff);
|
||||||
connect(m_settings, &SettingsWindow::updateBGColorOn, this, &OglViewerWidget::setBGColorOn);
|
connect(m_settings, &SettingsWindow::updateBGColorOn, this, &OglViewerWidget::setBGColorOn);
|
||||||
|
@ -52,6 +54,30 @@ OglViewerWidget::~OglViewerWidget()
|
||||||
/////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////
|
||||||
// functions
|
// functions
|
||||||
|
|
||||||
|
void OglViewerWidget::setDefaultValues()
|
||||||
|
{
|
||||||
|
SettingsManager* sm = SettingsManager::getInstance(this);
|
||||||
|
|
||||||
|
m_backgroundColorOn = QVector4D(sm->getBgColorOn() / 255, 1.0f);
|
||||||
|
m_backgroundColorOff = QVector4D(sm->getBgColorOff() / 255, 1.0f);
|
||||||
|
|
||||||
|
m_wireframe = false;
|
||||||
|
m_lightOn = sm->isLight();
|
||||||
|
m_backfaceCulling = sm->isBfCulling();
|
||||||
|
|
||||||
|
if (sm->getLightType() == 1) // directional
|
||||||
|
m_light.position = { 0.0,0.0,0.0,0.0 };
|
||||||
|
else // point
|
||||||
|
m_light.position = { 0.0,0.0,0.0,1.0 };
|
||||||
|
m_light.intensities = sm->getLightColor() / 255;
|
||||||
|
m_light.attenuationFactor = sm->getAttenuation();
|
||||||
|
m_light.ambientCoefficient = sm->getAmbient();
|
||||||
|
m_light.headlight = sm->isHeadlight();
|
||||||
|
|
||||||
|
connect(this, &OglViewerWidget::lightChanged, sm, &SettingsManager::setLight);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void OglViewerWidget::initShaders()
|
void OglViewerWidget::initShaders()
|
||||||
{
|
{
|
||||||
// Compile vertex shader
|
// Compile vertex shader
|
||||||
|
@ -371,6 +397,8 @@ void OglViewerWidget::toggleLight()
|
||||||
m_backgroundColorOff[3] = 1.0;
|
m_backgroundColorOff[3] = 1.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
emit lightChanged(m_lightOn);
|
||||||
|
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,222 @@
|
||||||
|
#include "..\Header\SettingsManager.h"
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////
|
||||||
|
// constructor/destructor
|
||||||
|
|
||||||
|
SettingsManager::SettingsManager(QObject *parent)
|
||||||
|
: QObject(parent)
|
||||||
|
{
|
||||||
|
file.setFileName("meshviewer.config");
|
||||||
|
readFromFile();
|
||||||
|
}
|
||||||
|
|
||||||
|
SettingsManager::~SettingsManager()
|
||||||
|
{
|
||||||
|
writeToFile();
|
||||||
|
}
|
||||||
|
|
||||||
|
SettingsManager* SettingsManager::getInstance(QObject *parent)
|
||||||
|
{
|
||||||
|
static SettingsManager* instance = new SettingsManager(parent);
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////
|
||||||
|
// functions
|
||||||
|
|
||||||
|
void SettingsManager::readFromFile()
|
||||||
|
{
|
||||||
|
if (file.open(QIODevice::ReadOnly))
|
||||||
|
{
|
||||||
|
|
||||||
|
QByteArray stream = file.readAll();
|
||||||
|
QList<QByteArray> lines = stream.split('\n');
|
||||||
|
|
||||||
|
for (auto& it : lines)
|
||||||
|
{
|
||||||
|
if (it.startsWith("<bgOn>"))
|
||||||
|
{
|
||||||
|
QList<QByteArray> values = it.right(it.size() - it.indexOf('>') - 1).split(';');
|
||||||
|
|
||||||
|
for (int i = 0; i < 3; i++)
|
||||||
|
m_bgColorOn[i] = values[i].toFloat();
|
||||||
|
}
|
||||||
|
else if (it.startsWith("<bgOff>"))
|
||||||
|
{
|
||||||
|
QList<QByteArray> values = it.right(it.size() - it.indexOf('>') - 1).split(';');
|
||||||
|
|
||||||
|
for (int i = 0; i < 3; i++)
|
||||||
|
m_bgColorOff[i] = values[i].toFloat();
|
||||||
|
}
|
||||||
|
else if (it.startsWith("<liCo>"))
|
||||||
|
{
|
||||||
|
QList<QByteArray> values = it.right(it.size() - it.indexOf('>') - 1).split(';');
|
||||||
|
|
||||||
|
for (int i = 0; i < 3; i++)
|
||||||
|
m_lightColor[i] = values[i].toFloat();
|
||||||
|
}
|
||||||
|
else if (it.startsWith("<bfCul>"))
|
||||||
|
{
|
||||||
|
m_bfCulling = it.right(it.size() - it.indexOf('>') - 1).toInt();
|
||||||
|
}
|
||||||
|
else if (it.startsWith("<liOn>"))
|
||||||
|
{
|
||||||
|
m_light = it.right(it.size() - it.indexOf('>') - 1).toInt();
|
||||||
|
}
|
||||||
|
else if (it.startsWith("<heLi>"))
|
||||||
|
{
|
||||||
|
m_headlight = it.right(it.size() - it.indexOf('>') - 1).toInt();
|
||||||
|
}
|
||||||
|
else if (it.startsWith("<auCo>"))
|
||||||
|
{
|
||||||
|
m_autoColor = it.right(it.size() - it.indexOf('>') - 1).toInt();
|
||||||
|
}
|
||||||
|
else if (it.startsWith("<liTy>"))
|
||||||
|
{
|
||||||
|
m_lightType = it.right(it.size() - it.indexOf('>') - 1).toInt();
|
||||||
|
}
|
||||||
|
else if (it.startsWith("<atFa>"))
|
||||||
|
{
|
||||||
|
m_attenuation = it.right(it.size() - it.indexOf('>') - 1).toFloat();
|
||||||
|
}
|
||||||
|
else if (it.startsWith("<amCo>"))
|
||||||
|
{
|
||||||
|
m_ambient = it.right(it.size() - it.indexOf('>') - 1).toFloat();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
file.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void SettingsManager::writeToFile()
|
||||||
|
{
|
||||||
|
file.open(QIODevice::WriteOnly);
|
||||||
|
|
||||||
|
file.write(QString("<bgOn>%1;%2;%3\n").arg(m_bgColorOn.x()).arg(m_bgColorOn.y()).arg(m_bgColorOn.z()).toUtf8());
|
||||||
|
file.write(QString("<bgOff>%1;%2;%3\n").arg(m_bgColorOff.x()).arg(m_bgColorOff.y()).arg(m_bgColorOff.z()).toUtf8());
|
||||||
|
file.write(QString("<liCo>%1;%2;%3\n").arg(m_lightColor.x()).arg(m_lightColor.y()).arg(m_lightColor.z()).toUtf8());
|
||||||
|
|
||||||
|
file.write(QString("<bfCul>%1\n").arg(m_bfCulling).toUtf8());
|
||||||
|
file.write(QString("<liOn>%1\n").arg(m_light).toUtf8());
|
||||||
|
file.write(QString("<heLi>%1\n").arg(m_headlight).toUtf8());
|
||||||
|
file.write(QString("<auCo>%1\n").arg(m_autoColor).toUtf8());
|
||||||
|
|
||||||
|
file.write(QString("<liTy>%1\n").arg(m_lightType).toUtf8());
|
||||||
|
file.write(QString("<atFa>%1\n").arg(m_attenuation).toUtf8());
|
||||||
|
file.write(QString("<amCo>%1\n").arg(m_ambient).toUtf8());
|
||||||
|
|
||||||
|
file.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
// getter ///////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
QVector3D SettingsManager::getBgColorOn() const
|
||||||
|
{
|
||||||
|
return m_bgColorOn;
|
||||||
|
}
|
||||||
|
|
||||||
|
QVector3D SettingsManager::getBgColorOff() const
|
||||||
|
{
|
||||||
|
return m_bgColorOff;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool SettingsManager::isBfCulling() const
|
||||||
|
{
|
||||||
|
return m_bfCulling;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool SettingsManager::isLight() const
|
||||||
|
{
|
||||||
|
return m_light;
|
||||||
|
}
|
||||||
|
|
||||||
|
int SettingsManager::getLightType() const
|
||||||
|
{
|
||||||
|
return m_lightType;
|
||||||
|
}
|
||||||
|
|
||||||
|
QVector3D SettingsManager::getLightColor() const
|
||||||
|
{
|
||||||
|
return m_lightColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
float SettingsManager::getAttenuation() const
|
||||||
|
{
|
||||||
|
return m_attenuation;
|
||||||
|
}
|
||||||
|
|
||||||
|
float SettingsManager::getAmbient() const
|
||||||
|
{
|
||||||
|
return m_ambient;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool SettingsManager::isHeadlight() const
|
||||||
|
{
|
||||||
|
return m_headlight;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool SettingsManager::isAutoColor() const
|
||||||
|
{
|
||||||
|
return m_autoColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////
|
||||||
|
// slots
|
||||||
|
|
||||||
|
void SettingsManager::setBgColorOn(QVector3D value)
|
||||||
|
{
|
||||||
|
m_bgColorOn = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SettingsManager::setBgColorOff(QVector3D value)
|
||||||
|
{
|
||||||
|
m_bgColorOff = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SettingsManager::setBfCulling(bool value)
|
||||||
|
{
|
||||||
|
m_bfCulling = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SettingsManager::setLight(bool value)
|
||||||
|
{
|
||||||
|
m_light = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SettingsManager::setLightType(int value)
|
||||||
|
{
|
||||||
|
m_lightType = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SettingsManager::setLightColor(QVector3D value)
|
||||||
|
{
|
||||||
|
m_lightColor = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SettingsManager::setAttenuation(double value)
|
||||||
|
{
|
||||||
|
m_attenuation = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SettingsManager::setAmbient(double value)
|
||||||
|
{
|
||||||
|
m_ambient = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SettingsManager::setHeadlight(bool value)
|
||||||
|
{
|
||||||
|
m_headlight = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SettingsManager::setAutoColor(int value)
|
||||||
|
{
|
||||||
|
if (value == 0)
|
||||||
|
m_autoColor = false;
|
||||||
|
else
|
||||||
|
m_autoColor = true;
|
||||||
|
}
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
#include "..\Header\SettingsWindow.h"
|
#include "..\Header\SettingsWindow.h"
|
||||||
|
#include "..\Header\SettingsManager.h"
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////
|
||||||
// constructor/destructor
|
// constructor/destructor
|
||||||
|
|
||||||
SettingsWindow::SettingsWindow(QVector3D bgOffColor, QVector3D bgOnColor, QVector3D lightColor, bool autoColor, double ambCoef, double attFac, int lightType, QWidget * parent)
|
SettingsWindow::SettingsWindow(QWidget * parent)
|
||||||
: QWidget(parent)
|
: QWidget(parent)
|
||||||
, ui(new Ui::SettingsWindow)
|
, ui(new Ui::SettingsWindow)
|
||||||
{
|
{
|
||||||
|
@ -15,24 +16,41 @@ SettingsWindow::SettingsWindow(QVector3D bgOffColor, QVector3D bgOnColor, QVecto
|
||||||
setupConnections();
|
setupConnections();
|
||||||
|
|
||||||
// set default values
|
// set default values
|
||||||
ui->lightOff_R_SB->setValue((int)bgOffColor[0]);
|
SettingsManager* sm = SettingsManager::getInstance(this);
|
||||||
ui->lightOff_G_SB->setValue((int)bgOffColor[1]);
|
|
||||||
ui->lightOff_B_SB->setValue((int)bgOffColor[2]);
|
|
||||||
|
|
||||||
ui->lightOn_R_SB->setValue((int)bgOnColor[0]);
|
ui->lightOff_R_SB->setValue((int)(sm->getBgColorOff()[0]));
|
||||||
ui->lightOn_G_SB->setValue((int)bgOnColor[1]);
|
ui->lightOff_G_SB->setValue((int)(sm->getBgColorOff()[1]));
|
||||||
ui->lightOn_B_SB->setValue((int)bgOnColor[2]);
|
ui->lightOff_B_SB->setValue((int)(sm->getBgColorOff()[2]));
|
||||||
|
|
||||||
ui->light_R_SB->setValue((int)lightColor[0]);
|
ui->lightOn_R_SB->setValue((int)(sm->getBgColorOn()[0]));
|
||||||
ui->light_G_SB->setValue((int)lightColor[1]);
|
ui->lightOn_G_SB->setValue((int)(sm->getBgColorOn()[1]));
|
||||||
ui->light_B_SB->setValue((int)lightColor[2]);
|
ui->lightOn_B_SB->setValue((int)(sm->getBgColorOn()[2]));
|
||||||
|
|
||||||
ui->ambCoef->setValue(ambCoef);
|
ui->light_R_SB->setValue((int)(sm->getLightColor()[0]));
|
||||||
ui->attFac->setValue(attFac);
|
ui->light_G_SB->setValue((int)(sm->getLightColor()[1]));
|
||||||
|
ui->light_B_SB->setValue((int)(sm->getLightColor()[2]));
|
||||||
|
|
||||||
ui->checkAutoColor->setChecked(autoColor);
|
ui->ambCoef->setValue(sm->getAmbient());
|
||||||
if (lightType == 1)
|
ui->attFac->setValue(sm->getAttenuation());
|
||||||
|
|
||||||
|
ui->checkBackfaceCulling->setChecked(sm->isBfCulling());
|
||||||
|
ui->checkAutoColor->setChecked(sm->isAutoColor());
|
||||||
|
ui->checkHeadlight->setChecked(sm->isHeadlight());
|
||||||
|
|
||||||
|
if (sm->getLightType() == 1)
|
||||||
ui->radioDirectLight->setChecked(true);
|
ui->radioDirectLight->setChecked(true);
|
||||||
|
else
|
||||||
|
ui->radioPointLight->setChecked(true);
|
||||||
|
|
||||||
|
connect(this, &SettingsWindow::updateBGColorOff, sm, &SettingsManager::setBgColorOff);
|
||||||
|
connect(this, &SettingsWindow::updateBGColorOn, sm, &SettingsManager::setBgColorOn);
|
||||||
|
connect(this, &SettingsWindow::updateLightColor, sm, &SettingsManager::setLightColor);
|
||||||
|
connect(this, &SettingsWindow::updateAttFac, sm, &SettingsManager::setAttenuation);
|
||||||
|
connect(this, &SettingsWindow::updateAmbCoef, sm, &SettingsManager::setAmbient);
|
||||||
|
connect(this, &SettingsWindow::sendHeadlight, sm, &SettingsManager::setHeadlight);
|
||||||
|
connect(this, &SettingsWindow::sendBackfaceCulling, sm, &SettingsManager::setBfCulling);
|
||||||
|
connect(ui->checkAutoColor, &QCheckBox::stateChanged, sm, &SettingsManager::setAutoColor);
|
||||||
|
connect(this, &SettingsWindow::changeLightType, sm, &SettingsManager::setLightType);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -133,10 +151,12 @@ void SettingsWindow::radioToggled()
|
||||||
{
|
{
|
||||||
ui->attFac->setValue(0.0);
|
ui->attFac->setValue(0.0);
|
||||||
ui->attFac->setEnabled(false);
|
ui->attFac->setEnabled(false);
|
||||||
|
emit changeLightType(1);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ui->attFac->setEnabled(true);
|
ui->attFac->setEnabled(true);
|
||||||
|
emit changeLightType(2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
17
README.md
17
README.md
|
@ -1,3 +1,12 @@
|
||||||
|
|
||||||
|
https://git.rwth-aachen.de/carstenf/OpenGL
|
||||||
|
|
||||||
|
Pulled from here as backup of work that I did under the develop branch. I hope to come back to this and port to Python using this as a reference for logic and how-to.
|
||||||
|
|
||||||
|
Below is original README text.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# MshViewer
|
# MshViewer
|
||||||
|
|
||||||
I started to learn OpenGL. Therefore i decided to implement a .msh viewer for SWBFII assets, since the old one
|
I started to learn OpenGL. Therefore i decided to implement a .msh viewer for SWBFII assets, since the old one
|
||||||
|
@ -12,10 +21,4 @@ So far it is just me. If you wanna help me, let me know :D
|
||||||
Feel free to use my code the way you like. But remember i used some public libraries. Make sure you read their
|
Feel free to use my code the way you like. But remember i used some public libraries. Make sure you read their
|
||||||
licence, too.
|
licence, too.
|
||||||
|
|
||||||
### To Do
|
|
||||||
- normal map,
|
|
||||||
- list all msh in a directory
|
|
||||||
- glow/emissive
|
|
||||||
- optional display bones, shadow, collision
|
|
||||||
- change pose
|
|
||||||
- animation
|
|
||||||
|
|
Binary file not shown.
BIN
preview.jpg
BIN
preview.jpg
Binary file not shown.
Before Width: | Height: | Size: 50 KiB After Width: | Height: | Size: 46 KiB |
Loading…
Reference in New Issue