Compare commits
42 Commits
Version_1.
...
Version_1.
Author | SHA1 | Date | |
---|---|---|---|
![]() |
3167f1acb8 | ||
![]() |
308d238b2d | ||
![]() |
30d41f7d85 | ||
![]() |
15cd551f7c | ||
![]() |
16c9d35580 | ||
![]() |
11af758eee | ||
![]() |
73ee8a4040 | ||
![]() |
0a9103fdc5 | ||
![]() |
10718f2269 | ||
![]() |
b2df84eb4c | ||
![]() |
2ed9e475ce | ||
![]() |
cdd6ace701 | ||
![]() |
91488c55b2 | ||
![]() |
5f104e46f2 | ||
![]() |
a948590255 | ||
![]() |
6fa81a8ccc | ||
![]() |
c4444bcefd | ||
![]() |
5ea90723b4 | ||
![]() |
af94ecd541 | ||
![]() |
9808cd03c0 | ||
![]() |
abd9070e90 | ||
![]() |
eb0592373f | ||
![]() |
28d17b2fdd | ||
![]() |
9fb3ca03bd | ||
![]() |
4c177f2ddc | ||
![]() |
a521dfc292 | ||
![]() |
f5863752e2 | ||
![]() |
1c962a481f | ||
![]() |
86c0559fdc | ||
![]() |
1bcb4d67c1 | ||
![]() |
152d436dd7 | ||
![]() |
5191a46f72 | ||
![]() |
9b3ff7f737 | ||
![]() |
91b3f25dbb | ||
![]() |
47c73ed881 | ||
![]() |
86dfe32145 | ||
![]() |
454ed45fa1 | ||
![]() |
b8f8a5c2ad | ||
![]() |
6ead5d7bc6 | ||
![]() |
f469dff656 | ||
![]() |
930c49e9c7 | ||
![]() |
77ffe7baf4 |
60
QtMeshViewer/Form Files/FileInfoWindow.ui
Normal file
@@ -0,0 +1,60 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>FileInfoWindow</class>
|
||||
<widget class="QWidget" name="FileInfoWindow">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>320</width>
|
||||
<height>400</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>File information</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="basic">
|
||||
<property name="text">
|
||||
<string>Name: -
|
||||
Materials: -
|
||||
Vertices: -
|
||||
Triangles: -</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QScrollArea" name="scrollArea">
|
||||
<property name="widgetResizable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<widget class="QWidget" name="scrollAreaWidgetContents">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>300</width>
|
||||
<height>322</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QLabel" name="detail">
|
||||
<property name="text">
|
||||
<string>No file is open</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
@@ -10,13 +10,22 @@
|
||||
<height>400</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>600</width>
|
||||
<height>400</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>MainWindow</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralWidget"/>
|
||||
<widget class="QToolBar" name="mainToolBar">
|
||||
<property name="allowedAreas">
|
||||
<set>Qt::LeftToolBarArea|Qt::RightToolBarArea|Qt::TopToolBarArea</set>
|
||||
</property>
|
||||
<attribute name="toolBarArea">
|
||||
<enum>TopToolBarArea</enum>
|
||||
<enum>LeftToolBarArea</enum>
|
||||
</attribute>
|
||||
<attribute name="toolBarBreak">
|
||||
<bool>false</bool>
|
||||
|
482
QtMeshViewer/Form Files/SettingsWindow.ui
Normal file
@@ -0,0 +1,482 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>SettingsWindow</class>
|
||||
<widget class="QWidget" name="SettingsWindow">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>300</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Settings</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QGroupBox" name="groupBackground">
|
||||
<property name="title">
|
||||
<string>Background</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="4" column="5">
|
||||
<widget class="QLineEdit" name="lightOn_G_LE">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>30</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>5</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="7">
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="text">
|
||||
<string>B:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="6">
|
||||
<widget class="QSlider" name="lightOn_G_S">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>255</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>5</number>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="9">
|
||||
<widget class="QSlider" name="lightOn_B_S">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>255</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>5</number>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="3" colspan="3">
|
||||
<widget class="QCheckBox" name="checkAutoColor">
|
||||
<property name="text">
|
||||
<string>auto color</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="8">
|
||||
<widget class="QLineEdit" name="lightOn_B_LE">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>30</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>5</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0" colspan="2">
|
||||
<widget class="QLabel" name="label_0">
|
||||
<property name="text">
|
||||
<string>R:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="4">
|
||||
<widget class="QLabel" name="label_1">
|
||||
<property name="text">
|
||||
<string>G:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="7">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>B:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="5">
|
||||
<widget class="QLineEdit" name="lightOff_G_LE">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>30</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>204</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="8">
|
||||
<widget class="QLineEdit" name="lightOff_B_LE">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>30</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>255</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="9">
|
||||
<widget class="QSlider" name="lightOff_B_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="2">
|
||||
<widget class="QLineEdit" name="lightOff_R_LE">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>30</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>127</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="6">
|
||||
<widget class="QSlider" name="lightOff_G_S">
|
||||
<property name="maximum">
|
||||
<number>255</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>204</number>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="3">
|
||||
<widget class="QSlider" name="lightOff_R_S">
|
||||
<property name="maximum">
|
||||
<number>255</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>127</number>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0" colspan="3">
|
||||
<widget class="QLabel" name="labelLightOn">
|
||||
<property name="text">
|
||||
<string>Light on:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0" colspan="10">
|
||||
<widget class="QLabel" name="labelLightOff">
|
||||
<property name="text">
|
||||
<string>Light off:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>R:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="2">
|
||||
<widget class="QLineEdit" name="lightOn_R_LE">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>30</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>5</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="3">
|
||||
<widget class="QSlider" name="lightOn_R_S">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>255</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>5</number>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="4">
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>G:</string>
|
||||
</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">
|
||||
<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>
|
||||
</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="6">
|
||||
<widget class="QLabel" name="label_8">
|
||||
<property name="text">
|
||||
<string>B:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="3">
|
||||
<widget class="QLabel" name="label_7">
|
||||
<property name="text">
|
||||
<string>G:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="4">
|
||||
<widget class="QLineEdit" name="light_G_LE">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>30</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>255</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="light_R_LE">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>30</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>255</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0" colspan="4">
|
||||
<widget class="QRadioButton" name="radioDirectLight">
|
||||
<property name="text">
|
||||
<string>Directional light</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="7">
|
||||
<widget class="QLineEdit" name="light_B_LE">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>30</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>255</string>
|
||||
</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">
|
||||
<number>255</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>255</number>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="8">
|
||||
<widget class="QSlider" name="light_B_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="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="4" column="4">
|
||||
<spacer name="verticalSpacerLight">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="3" column="4" colspan="2">
|
||||
<widget class="QDoubleSpinBox" name="attFac">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>55</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="decimals">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<double>0.100000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="4" colspan="2">
|
||||
<widget class="QDoubleSpinBox" name="ambCoef">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>55</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="decimals">
|
||||
<number>3</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>1.000000000000000</double>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<double>0.001000000000000</double>
|
||||
</property>
|
||||
<property name="value">
|
||||
<double>0.005000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="4" colspan="4">
|
||||
<widget class="QRadioButton" name="radioPointLight">
|
||||
<property name="text">
|
||||
<string>Point light</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
20
QtMeshViewer/Header/FileInfoWindow.h
Normal file
@@ -0,0 +1,20 @@
|
||||
#pragma once
|
||||
#include <QWidget>
|
||||
#include <QString>
|
||||
#include "ui_FileInfoWindow.h"
|
||||
|
||||
class FileInfoWindow : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
FileInfoWindow(QWidget *parent = Q_NULLPTR);
|
||||
~FileInfoWindow();
|
||||
|
||||
private:
|
||||
Ui::FileInfoWindow* ui;
|
||||
|
||||
public:
|
||||
void setBasicText(QString text);
|
||||
void setDetailText(QString text);
|
||||
};
|
@@ -3,11 +3,13 @@
|
||||
#include <QVector>
|
||||
#include <QVector2D>
|
||||
#include <QVector3D>
|
||||
#include <QStringList>
|
||||
#include <QMatrix4x4>
|
||||
#include <QQuaternion>
|
||||
#include <QOpenGLFunctions>
|
||||
#include <QOpenGlTexture>
|
||||
#include <QObject>
|
||||
#include <QOpenGLTexture>
|
||||
#include <QRegExp>
|
||||
#include <..\Header\MainWindow.h>
|
||||
|
||||
|
||||
@@ -21,7 +23,7 @@ struct VertexData
|
||||
{
|
||||
QVector3D position;
|
||||
QVector2D texCoord;
|
||||
QVector3D normal;
|
||||
QVector3D vertexNormal;
|
||||
};
|
||||
|
||||
struct Segment {
|
||||
@@ -38,6 +40,24 @@ struct Model {
|
||||
std::vector<Segment*> segmList;
|
||||
};
|
||||
|
||||
struct Material {
|
||||
QString name;
|
||||
QString tx0d;
|
||||
QString tx1d;
|
||||
QString tx2d;
|
||||
QString tx3d;
|
||||
QOpenGLTexture* texture0 = Q_NULLPTR;
|
||||
QOpenGLTexture* texture1 = Q_NULLPTR;
|
||||
QVector4D specularColor = { 1.0, 1.0, 1.0, 1.0 };
|
||||
QVector4D diffuseColor = { 1.0, 0.0, 0.0, 1.0 };
|
||||
QVector4D ambientColor = { 1.0, 1.0, 1.0, 1.0 };
|
||||
float shininess = 80;
|
||||
bool flags[8] = { false };
|
||||
bool transparent = false;
|
||||
std::uint8_t rendertype = 0;
|
||||
std::uint8_t dataValues[2] = { 0 };
|
||||
};
|
||||
|
||||
class FileInterface : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
@@ -46,7 +66,7 @@ public:
|
||||
explicit FileInterface(QString path, QObject *parent)
|
||||
: QObject(parent)
|
||||
, m_models(new QVector<Model*>)
|
||||
, m_textureNames(new QStringList)
|
||||
, m_materials(new QVector<Material>)
|
||||
{
|
||||
//open file
|
||||
m_file.open(path.toStdString().c_str(), std::ios::in | std::ios::binary);
|
||||
@@ -58,6 +78,7 @@ public:
|
||||
if(tmp != NULL)
|
||||
connect(this, SIGNAL(sendMessage(QString, int)), tmp, SLOT(printMessage(QString, int)));
|
||||
|
||||
m_filepath = path.left(path.lastIndexOf(QRegExp("/|\\\\")));
|
||||
|
||||
};
|
||||
|
||||
@@ -67,9 +88,6 @@ public:
|
||||
m_file.close();
|
||||
|
||||
//clean up
|
||||
m_textureNames->clear();
|
||||
delete m_textureNames;
|
||||
|
||||
for (Model* modelIt : *m_models)
|
||||
{
|
||||
for (Segment* segIt : modelIt->segmList)
|
||||
@@ -89,16 +107,41 @@ public:
|
||||
protected:
|
||||
QVector<Model*>* m_models;
|
||||
std::fstream m_file;
|
||||
QStringList* m_textureNames;
|
||||
QVector<Material>* m_materials;
|
||||
BoundingBox m_sceneBbox;
|
||||
QString m_filepath;
|
||||
|
||||
virtual void import() = 0;
|
||||
|
||||
public:
|
||||
virtual QVector<Model*>* getModels() const { return m_models; };
|
||||
virtual QStringList* getTextureNames() const { return m_textureNames; };
|
||||
virtual QVector<Material>* getMaterials() const { return m_materials; };
|
||||
virtual BoundingBox getBoundingBox() const { return m_sceneBbox; };
|
||||
|
||||
static Material* getDefaultMaterial() {
|
||||
Material* defMaterial = new Material;
|
||||
|
||||
QImage img(1, 1, QImage::Format_RGB32);
|
||||
img.fill(Qt::red);
|
||||
|
||||
QOpenGLTexture* new_texture = new QOpenGLTexture(img.mirrored());
|
||||
|
||||
// Set nearest filtering mode for texture minification
|
||||
new_texture->setMinificationFilter(QOpenGLTexture::Nearest);
|
||||
|
||||
// Set bilinear filtering mode for texture magnification
|
||||
new_texture->setMagnificationFilter(QOpenGLTexture::Linear);
|
||||
|
||||
// Wrap texture coordinates by repeating
|
||||
// f.ex. texture coordinate (1.1, 1.2) is same as (0.1, 0.2)
|
||||
new_texture->setWrapMode(QOpenGLTexture::Repeat);
|
||||
|
||||
defMaterial->texture0 = new_texture;
|
||||
defMaterial->name = "Default Material";
|
||||
|
||||
return defMaterial;
|
||||
};
|
||||
|
||||
signals:
|
||||
void sendMessage(QString msg, int severity);
|
||||
};
|
@@ -25,21 +25,21 @@ public:
|
||||
private:
|
||||
QOpenGLBuffer m_arrayBuf;
|
||||
QOpenGLBuffer m_indexBuf;
|
||||
QVector<QOpenGLTexture*> m_textures;
|
||||
QVector<Material>* m_materials = Q_NULLPTR;
|
||||
QVector<DrawInformation> m_drawList;
|
||||
BoundingBox m_boundings;
|
||||
Material* m_defaultMaterial;
|
||||
|
||||
void loadTexture(QString filePath, QString fileName);
|
||||
void clearData();
|
||||
|
||||
public slots:
|
||||
void loadFile(QString filePath);
|
||||
void drawGeometry(QOpenGLShaderProgram *program);
|
||||
void drawGeometry(QOpenGLShaderProgram *program, bool wireframe);
|
||||
|
||||
signals:
|
||||
void requestResetView();
|
||||
void sendMessage(QString message, int severity);
|
||||
void requestUpdate();
|
||||
void sendFileInfo(QString name, QStringList textures, int vertices, int triangle);
|
||||
void sendFileInfo(QString name, QVector<Material>* materials, int vertices, int triangle);
|
||||
};
|
||||
|
||||
|
@@ -1,9 +1,14 @@
|
||||
#pragma once
|
||||
|
||||
#include <QtWidgets/QMainWindow>
|
||||
#include <qwidget.h>
|
||||
#include <QByteArray>
|
||||
#include <QStringList>
|
||||
#include <QLabel>
|
||||
#include "ui_MainWindow.h"
|
||||
#include "..\Header\FileInfoWindow.h"
|
||||
|
||||
struct Material;
|
||||
|
||||
class MainWindow : public QMainWindow
|
||||
{
|
||||
@@ -18,16 +23,21 @@ private:
|
||||
int m_curSeverity;
|
||||
void setupWidgets();
|
||||
QByteArray m_fileInfo;
|
||||
|
||||
QLabel* m_output;
|
||||
FileInfoWindow* m_infoWindow;
|
||||
|
||||
private slots:
|
||||
private:
|
||||
void openFile();
|
||||
void aboutFile();
|
||||
void aboutTool();
|
||||
void takeScreenShot();
|
||||
|
||||
protected:
|
||||
virtual void resizeEvent(QResizeEvent * e) Q_DECL_OVERRIDE;
|
||||
|
||||
public slots:
|
||||
void printMessage(QString message, int severity);
|
||||
void setFileInfo(QString name, QStringList textures, int vertices, int triangle);
|
||||
void setFileInfo(QString name, QVector<Material>* materials, int vertices, int triangle);
|
||||
|
||||
signals:
|
||||
void loadFile(QString);
|
||||
|
@@ -43,6 +43,8 @@ private:
|
||||
void readVertex(Segment* dataDestination, std::streampos position);
|
||||
void readUV(Segment* dataDestination, std::streampos position);
|
||||
|
||||
void loadTexture(QOpenGLTexture*& destination, QString filepath, QString& filename);
|
||||
|
||||
QMatrix4x4 getParentMatrix(std::string parent) const;
|
||||
QQuaternion getParentRotation(std::string parent) const;
|
||||
};
|
@@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "geometryengine.h"
|
||||
|
||||
#include "..\Header\SettingsWindow.h"
|
||||
#include <QOpenGLWidget>
|
||||
#include <QOpenGLFunctions>
|
||||
#include <QMatrix4x4>
|
||||
@@ -37,6 +37,18 @@ private:
|
||||
bool z = true;
|
||||
} m_rotDirections;
|
||||
|
||||
struct {
|
||||
QVector4D position = { 1,1,1,0 };
|
||||
QVector3D intensities = { 1.0,1.0,1.0 };
|
||||
float attenuationFactor = 0.0f;
|
||||
float ambientCoefficient = 0.005f;
|
||||
} m_light;
|
||||
|
||||
SettingsWindow* m_settings;
|
||||
|
||||
QVector4D m_backgroundColorOn = {0.02f, 0.02f, 0.02f, 1.0f};
|
||||
QVector4D m_backgroundColorOff = { 0.5f, 0.8f, 1.0f, 1.0f };
|
||||
|
||||
QOpenGLShaderProgram m_program;
|
||||
GeometryEngine *m_dataEngine;
|
||||
|
||||
@@ -44,6 +56,11 @@ private:
|
||||
QVector3D m_translation;
|
||||
QQuaternion m_rotation;
|
||||
|
||||
bool m_wireframe = false;
|
||||
bool m_lightOn = false;
|
||||
|
||||
double m_zSpeed = 1.0;
|
||||
|
||||
protected:
|
||||
void mousePressEvent(QMouseEvent *e) Q_DECL_OVERRIDE;
|
||||
void mouseReleaseEvent(QMouseEvent *e) Q_DECL_OVERRIDE;
|
||||
@@ -60,11 +77,23 @@ protected:
|
||||
private:
|
||||
void initShaders();
|
||||
void setConnections();
|
||||
void updateLightPosition();
|
||||
|
||||
private slots:
|
||||
void resetView();
|
||||
|
||||
public slots:
|
||||
void changeDirection(int direction);
|
||||
void toggleWireframe();
|
||||
void toggleLight();
|
||||
void showSettings();
|
||||
void setBGColorOff(QVector3D value);
|
||||
void setBGColorOn(QVector3D value);
|
||||
void setLightColor(QVector3D value);
|
||||
void setAttFac(double value);
|
||||
void setAmbCoef(double value);
|
||||
|
||||
signals:
|
||||
void sendMessage(QString message, int severity);
|
||||
};
|
||||
|
||||
|
30
QtMeshViewer/Header/SettingsWindow.h
Normal file
@@ -0,0 +1,30 @@
|
||||
#pragma once
|
||||
#include <QWidget>
|
||||
#include "ui_SettingsWindow.h"
|
||||
#include <QVector3D>
|
||||
|
||||
class SettingsWindow : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
SettingsWindow(QWidget * parent = Q_NULLPTR);
|
||||
~SettingsWindow();
|
||||
|
||||
private:
|
||||
Ui::SettingsWindow* ui;
|
||||
|
||||
private slots:
|
||||
void autoColorToggled();
|
||||
void radioToggled();
|
||||
void backgroundColorOffChanged();
|
||||
void backgroundColorOnChanged();
|
||||
void lightColorChanged();
|
||||
|
||||
signals:
|
||||
void updateBGColorOff(QVector3D value);
|
||||
void updateBGColorOn(QVector3D value);
|
||||
void updateLightColor(QVector3D value);
|
||||
void updateAttFac(double value);
|
||||
void updateAmbCoef(double value);
|
||||
};
|
@@ -8,5 +8,24 @@
|
||||
</qresource>
|
||||
<qresource prefix="/files">
|
||||
<file>about.txt</file>
|
||||
<file>StyleSheet.txt</file>
|
||||
</qresource>
|
||||
<qresource prefix="/images/toolbar">
|
||||
<file>placeholder.png</file>
|
||||
<file>info.png</file>
|
||||
<file>about.png</file>
|
||||
<file>open.png</file>
|
||||
<file>X.png</file>
|
||||
<file>Y.png</file>
|
||||
<file>Z.png</file>
|
||||
<file>screenshot.png</file>
|
||||
<file>wireframe.png</file>
|
||||
<file>light_off.png</file>
|
||||
<file>light_on.png</file>
|
||||
<file>solid.png</file>
|
||||
<file>X_disabled.png</file>
|
||||
<file>Y_disabled.png</file>
|
||||
<file>Z_disabled.png</file>
|
||||
<file>settings.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
85
QtMeshViewer/Resources/StyleSheet.txt
Normal file
@@ -0,0 +1,85 @@
|
||||
QToolButton {
|
||||
image: url(:/images/toolbar/placeholder.png);
|
||||
border-style: none;
|
||||
padding: 2px;
|
||||
width: 22px;
|
||||
height: 22px;
|
||||
}
|
||||
|
||||
QToolButton:checked {
|
||||
image: url(:/images/toolbar/placeholder.png);
|
||||
border-style: none;
|
||||
padding: 2px;
|
||||
width: 22px;
|
||||
height: 22px;
|
||||
}
|
||||
|
||||
QToolButton:hover {
|
||||
border-style: solid;
|
||||
padding: 1px;
|
||||
border-width: 1px;
|
||||
border-radius: 5px;
|
||||
border-color: #a4daff;
|
||||
min-height: 25px
|
||||
}
|
||||
|
||||
QToolButton#openFile {
|
||||
image: url(:/images/toolbar/open.png);
|
||||
}
|
||||
|
||||
QToolButton#screenshot {
|
||||
image: url(:/images/toolbar/screenshot.png);
|
||||
}
|
||||
|
||||
QToolButton#x {
|
||||
image: url(:/images/toolbar/X_disabled.png);
|
||||
}
|
||||
|
||||
QToolButton#x:checked {
|
||||
image: url(:/images/toolbar/X.png);
|
||||
}
|
||||
|
||||
QToolButton#y {
|
||||
image: url(:/images/toolbar/Y_disabled.png);
|
||||
}
|
||||
|
||||
QToolButton#y:checked {
|
||||
image: url(:/images/toolbar/Y.png);
|
||||
}
|
||||
|
||||
QToolButton#z {
|
||||
image: url(:/images/toolbar/Z_disabled.png);
|
||||
}
|
||||
|
||||
QToolButton#z:checked {
|
||||
image: url(:/images/toolbar/Z.png);
|
||||
}
|
||||
|
||||
QToolButton#wireframe {
|
||||
image: url(:/images/toolbar/solid.png);
|
||||
}
|
||||
|
||||
QToolButton#wireframe:checked {
|
||||
image: url(:/images/toolbar/wireframe.png);
|
||||
}
|
||||
|
||||
QToolButton#light {
|
||||
image: url(:/images/toolbar/light_off.png);
|
||||
}
|
||||
|
||||
QToolButton#light:checked {
|
||||
image: url(:/images/toolbar/light_on.png);
|
||||
}
|
||||
|
||||
QToolButton#settings {
|
||||
image: url(:/images/toolbar/settings.png);
|
||||
}
|
||||
|
||||
QToolButton#fileInfo {
|
||||
image: url(:/images/toolbar/info.png);
|
||||
}
|
||||
|
||||
QToolButton#help {
|
||||
image: url(:/images/toolbar/about.png);
|
||||
}
|
||||
|
BIN
QtMeshViewer/Resources/X.png
Normal file
After Width: | Height: | Size: 932 B |
BIN
QtMeshViewer/Resources/X_disabled.png
Normal file
After Width: | Height: | Size: 1.1 KiB |
BIN
QtMeshViewer/Resources/Y.png
Normal file
After Width: | Height: | Size: 885 B |
BIN
QtMeshViewer/Resources/Y_disabled.png
Normal file
After Width: | Height: | Size: 1.1 KiB |
BIN
QtMeshViewer/Resources/Z.png
Normal file
After Width: | Height: | Size: 884 B |
BIN
QtMeshViewer/Resources/Z_disabled.png
Normal file
After Width: | Height: | Size: 1.1 KiB |
BIN
QtMeshViewer/Resources/about.png
Normal file
After Width: | Height: | Size: 883 B |
@@ -8,12 +8,16 @@ left mouse - rotate
|
||||
right mouse - move
|
||||
scroll - zoom
|
||||
space - reset view
|
||||
+/- - adjust zoom speed
|
||||
L - set light to current position
|
||||
esc - close
|
||||
|
||||
using the X, Y, Z Button you can activate/deactivate the rotating directions
|
||||
using the X, Y, Z buttons you can activate/deactivate the rotating directions.
|
||||
|
||||
tipp: do round movement to rotate the object in z-direction, when all directions are acitvated
|
||||
|
||||
textures marked with a '*' couldn't be open.
|
||||
|
||||
===============================================================
|
||||
Credits:
|
||||
ANDEWEGET
|
||||
|
@@ -4,12 +4,86 @@ precision mediump int;
|
||||
precision mediump float;
|
||||
#endif
|
||||
|
||||
uniform sampler2D texture;
|
||||
uniform mat3 n_matrix;
|
||||
uniform vec3 cameraPosition;
|
||||
|
||||
varying vec2 v_texcoord;
|
||||
uniform sampler2D texture;
|
||||
uniform float materialShininess;
|
||||
uniform vec3 materialSpecularColor;
|
||||
|
||||
uniform bool b_transparent;
|
||||
uniform bool b_specular;
|
||||
uniform bool b_light;
|
||||
|
||||
uniform struct Light {
|
||||
vec4 position;
|
||||
vec3 intensities;
|
||||
float attenuationFactor;
|
||||
float ambientCoefficient;
|
||||
} light;
|
||||
|
||||
varying vec2 v_surfaceUV;
|
||||
varying vec3 v_surfacePosition;
|
||||
varying vec3 v_surfaceNormal;
|
||||
|
||||
void main()
|
||||
{
|
||||
// Set fragment color from texture
|
||||
gl_FragColor = texture2D(texture, v_texcoord);
|
||||
if(b_light)
|
||||
{
|
||||
// some values
|
||||
vec3 normalWorld = normalize(n_matrix * v_surfaceNormal);
|
||||
|
||||
vec4 surfaceColor = vec4(texture2D(texture, v_surfaceUV));
|
||||
surfaceColor.rgb = pow(surfaceColor.rgb, vec3(2.2));
|
||||
|
||||
vec3 surfaceToLight;
|
||||
float attenuation;
|
||||
// directional light
|
||||
if(light.position.w == 0)
|
||||
{
|
||||
surfaceToLight = normalize(light.position.xyz);
|
||||
}
|
||||
// point light
|
||||
else
|
||||
{
|
||||
surfaceToLight = normalize(light.position.xyz - v_surfacePosition);
|
||||
}
|
||||
|
||||
float distanceToLight = length(light.position.xyz - v_surfacePosition);
|
||||
attenuation = 1.0 / (1.0 + light.attenuationFactor * pow(distanceToLight, 2));
|
||||
|
||||
vec3 surfaceToCamera = normalize(cameraPosition - v_surfacePosition);
|
||||
|
||||
// ambient
|
||||
vec3 ambient = light.ambientCoefficient * surfaceColor.rgb * light.intensities;
|
||||
|
||||
// diffuse
|
||||
float diffuseCoefficient = max(0.0, dot(normalWorld, surfaceToLight));
|
||||
vec3 diffuse = diffuseCoefficient * surfaceColor.rgb * light.intensities;
|
||||
|
||||
// specular
|
||||
float specularCoefficient = 0.0;
|
||||
if(diffuseCoefficient > 0.0)
|
||||
specularCoefficient = pow(max(0.0, dot(surfaceToCamera, reflect(-surfaceToLight, normalWorld))), materialShininess);
|
||||
if(b_specular)
|
||||
materialSpecularColor = vec3(surfaceColor.a);
|
||||
vec3 specular = specularCoefficient * materialSpecularColor * light.intensities;
|
||||
|
||||
// linear color before gamma correction)
|
||||
vec3 linearColor = ambient + attenuation * (diffuse + specular);
|
||||
|
||||
// final color after gama correction
|
||||
vec3 gamma = vec3(1.0/2.2);
|
||||
if(!b_transparent)
|
||||
surfaceColor.a = 1.0f;
|
||||
gl_FragColor = vec4(pow(linearColor, gamma), surfaceColor.a);
|
||||
}
|
||||
else
|
||||
{
|
||||
vec4 surfaceColor = vec4(texture2D(texture, v_surfaceUV));
|
||||
if(!b_transparent)
|
||||
surfaceColor.a = 1.0f;
|
||||
|
||||
gl_FragColor = surfaceColor;
|
||||
}
|
||||
}
|
||||
|
BIN
QtMeshViewer/Resources/info.png
Normal file
After Width: | Height: | Size: 859 B |
BIN
QtMeshViewer/Resources/light_off.png
Normal file
After Width: | Height: | Size: 883 B |
BIN
QtMeshViewer/Resources/light_on.png
Normal file
After Width: | Height: | Size: 974 B |
BIN
QtMeshViewer/Resources/open.png
Normal file
After Width: | Height: | Size: 879 B |
BIN
QtMeshViewer/Resources/placeholder.png
Normal file
After Width: | Height: | Size: 940 B |
BIN
QtMeshViewer/Resources/screenshot.png
Normal file
After Width: | Height: | Size: 982 B |
BIN
QtMeshViewer/Resources/settings.png
Normal file
After Width: | Height: | Size: 1.3 KiB |
BIN
QtMeshViewer/Resources/solid.png
Normal file
After Width: | Height: | Size: 880 B |
@@ -12,14 +12,18 @@ attribute vec4 a_position;
|
||||
attribute vec2 a_texcoord;
|
||||
attribute vec3 a_normal;
|
||||
|
||||
varying vec2 v_texcoord;
|
||||
varying vec2 v_surfaceUV;
|
||||
varying vec3 v_surfacePosition;
|
||||
varying vec3 v_surfaceNormal;
|
||||
|
||||
void main()
|
||||
{
|
||||
// Calculate vertex position in screen space
|
||||
gl_Position = vp_matrix * norm_matrix * m_matrix * a_position;
|
||||
|
||||
// Pass texture coordinate to fragment shader
|
||||
// Pass data to fragment shader
|
||||
// Value will be automatically interpolated to fragments inside polygon faces
|
||||
v_texcoord = a_texcoord;
|
||||
v_surfaceUV = a_texcoord;
|
||||
v_surfacePosition = vec3(norm_matrix * m_matrix * a_position);
|
||||
v_surfaceNormal = a_normal;
|
||||
}
|
||||
|
BIN
QtMeshViewer/Resources/wireframe.png
Normal file
After Width: | Height: | Size: 898 B |
29
QtMeshViewer/Source/FileInfoWindow.cpp
Normal file
@@ -0,0 +1,29 @@
|
||||
#include "..\Header\FileInfoWindow.h"
|
||||
#include <QIcon>
|
||||
|
||||
FileInfoWindow::FileInfoWindow(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
, ui(new Ui::FileInfoWindow)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
setWindowFlags(Qt::Tool | Qt::NoDropShadowWindowHint);
|
||||
|
||||
ui->scrollArea->widget()->setStyleSheet("background-color: #ffffff");
|
||||
|
||||
}
|
||||
|
||||
FileInfoWindow::~FileInfoWindow()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void FileInfoWindow::setBasicText(QString text)
|
||||
{
|
||||
ui->basic->setText(text);
|
||||
}
|
||||
|
||||
void FileInfoWindow::setDetailText(QString text)
|
||||
{
|
||||
ui->detail->setText(text);
|
||||
}
|
@@ -2,7 +2,6 @@
|
||||
#include "..\Header\MshFile.h"
|
||||
#include "..\Header\OglViewerWidget.h"
|
||||
#include "..\Header\MainWindow.h"
|
||||
#include "..\Header\tga.h"
|
||||
#include <cmath>
|
||||
#include <QRegExp>
|
||||
|
||||
@@ -15,50 +14,21 @@ GeometryEngine::GeometryEngine(QObject *parent)
|
||||
, m_indexBuf(QOpenGLBuffer::IndexBuffer)
|
||||
{
|
||||
initializeOpenGLFunctions();
|
||||
|
||||
m_defaultMaterial = FileInterface::getDefaultMaterial();
|
||||
}
|
||||
|
||||
GeometryEngine::~GeometryEngine()
|
||||
{
|
||||
clearData();
|
||||
delete m_defaultMaterial->texture0;
|
||||
delete m_defaultMaterial;
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// private functions
|
||||
|
||||
void GeometryEngine::loadTexture(QString filePath, QString fileName)
|
||||
{
|
||||
bool loadSuccess(false);
|
||||
QImage img;
|
||||
|
||||
if (fileName.isEmpty())
|
||||
{
|
||||
loadSuccess = true;
|
||||
img = QImage(1, 1, QImage::Format_RGB32);
|
||||
img.fill(Qt::red);
|
||||
}
|
||||
else
|
||||
img = loadTga(filePath + "/" + fileName, loadSuccess);
|
||||
|
||||
if (!loadSuccess)
|
||||
emit sendMessage("WARNING: texture not found or corrupted: " + QString(fileName), 1);
|
||||
|
||||
// Load image to OglTexture
|
||||
QOpenGLTexture* new_texture = new QOpenGLTexture(img.mirrored());
|
||||
|
||||
// Set nearest filtering mode for texture minification
|
||||
new_texture->setMinificationFilter(QOpenGLTexture::Nearest);
|
||||
|
||||
// Set bilinear filtering mode for texture magnification
|
||||
new_texture->setMagnificationFilter(QOpenGLTexture::Linear);
|
||||
|
||||
// Wrap texture coordinates by repeating
|
||||
// f.ex. texture coordinate (1.1, 1.2) is same as (0.1, 0.2)
|
||||
new_texture->setWrapMode(QOpenGLTexture::Repeat);
|
||||
|
||||
m_textures.push_back(new_texture);
|
||||
}
|
||||
|
||||
void GeometryEngine::clearData()
|
||||
{
|
||||
if (m_arrayBuf.isCreated())
|
||||
@@ -66,9 +36,19 @@ void GeometryEngine::clearData()
|
||||
if (m_indexBuf.isCreated())
|
||||
m_indexBuf.destroy();
|
||||
|
||||
for (auto it : m_textures)
|
||||
delete it;
|
||||
m_textures.clear();
|
||||
if (m_materials != Q_NULLPTR)
|
||||
{
|
||||
for (auto it : *m_materials)
|
||||
{
|
||||
if (it.texture0 != Q_NULLPTR)
|
||||
delete it.texture0;
|
||||
|
||||
if (it.texture1 != Q_NULLPTR)
|
||||
delete it.texture1;
|
||||
}
|
||||
m_materials->clear();
|
||||
delete m_materials;
|
||||
}
|
||||
m_drawList.clear();
|
||||
}
|
||||
|
||||
@@ -90,7 +70,6 @@ void GeometryEngine::loadFile(QString filePath)
|
||||
try
|
||||
{
|
||||
QVector<Model*>* models;
|
||||
QStringList* textureNames;
|
||||
QVector<VertexData> vertexData;
|
||||
QVector<GLuint> indexData;
|
||||
|
||||
@@ -98,7 +77,7 @@ void GeometryEngine::loadFile(QString filePath)
|
||||
MshFile file(filePath, this);
|
||||
|
||||
models = file.getModels();
|
||||
textureNames = file.getTextureNames();
|
||||
m_materials = file.getMaterials();
|
||||
m_boundings = file.getBoundingBox();
|
||||
|
||||
// collect data
|
||||
@@ -124,7 +103,11 @@ void GeometryEngine::loadFile(QString filePath)
|
||||
// save data
|
||||
vertexData += segmentIterator->vertices;
|
||||
indexData += segmentIterator->indices;
|
||||
m_drawList.push_back(new_info);
|
||||
|
||||
if (segmentIterator->textureIndex < m_materials->size() && m_materials->at(segmentIterator->textureIndex).transparent)
|
||||
m_drawList.push_back(new_info);
|
||||
else
|
||||
m_drawList.push_front(new_info);
|
||||
|
||||
// update offset
|
||||
indexOffset += new_info.size;
|
||||
@@ -140,18 +123,9 @@ void GeometryEngine::loadFile(QString filePath)
|
||||
m_indexBuf.bind();
|
||||
m_indexBuf.allocate(indexData.data(), indexData.size() * sizeof(GLuint));
|
||||
|
||||
emit sendMessage("loading textures..", 0);
|
||||
|
||||
// load the textures
|
||||
int split = filePath.lastIndexOf(QRegExp("/|\\\\"));
|
||||
for (auto& it : *textureNames)
|
||||
loadTexture(filePath.left(split), it);
|
||||
|
||||
loadTexture("", "");
|
||||
|
||||
emit requestUpdate();
|
||||
emit sendMessage("done..", 0);
|
||||
emit sendFileInfo(filePath.right(filePath.size() - split - 1), QStringList(*textureNames), vertexData.size(), indexData.size() / 3);
|
||||
emit sendFileInfo(filePath.right(filePath.size() - filePath.lastIndexOf(QRegExp("/|\\\\")) - 1), m_materials, vertexData.size(), indexData.size() / 3);
|
||||
}
|
||||
catch (std::invalid_argument e)
|
||||
{
|
||||
@@ -160,7 +134,7 @@ void GeometryEngine::loadFile(QString filePath)
|
||||
}
|
||||
}
|
||||
|
||||
void GeometryEngine::drawGeometry(QOpenGLShaderProgram *program)
|
||||
void GeometryEngine::drawGeometry(QOpenGLShaderProgram *program, bool wireframe)
|
||||
{
|
||||
if (!m_arrayBuf.isCreated() || !m_indexBuf.isCreated())
|
||||
return;
|
||||
@@ -208,17 +182,46 @@ void GeometryEngine::drawGeometry(QOpenGLShaderProgram *program)
|
||||
|
||||
for (auto& it : m_drawList)
|
||||
{
|
||||
// bind the correct texture
|
||||
if (it.textureIndex < m_textures.size())
|
||||
m_textures.at(it.textureIndex)->bind();
|
||||
else
|
||||
m_textures.last()->bind();
|
||||
bool tmp_transparent(false);
|
||||
bool tmp_specular(false);
|
||||
float shininess;
|
||||
QVector3D specularColor;
|
||||
|
||||
// bind the correct texture
|
||||
if (it.textureIndex < m_materials->size() && m_materials->at(it.textureIndex).texture0 != Q_NULLPTR)
|
||||
{
|
||||
m_materials->at(it.textureIndex).texture0->bind();
|
||||
tmp_transparent = m_materials->at(it.textureIndex).transparent;
|
||||
tmp_specular = m_materials->at(it.textureIndex).flags[7];
|
||||
shininess = m_materials->at(it.textureIndex).shininess;
|
||||
specularColor = m_materials->at(it.textureIndex).specularColor.toVector3D();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_defaultMaterial->texture0->bind();
|
||||
tmp_transparent = m_defaultMaterial->transparent;
|
||||
}
|
||||
// Set model matrix
|
||||
program->setUniformValue("m_matrix", it.modelMatrix);
|
||||
|
||||
// Set normal matrix
|
||||
program->setUniformValue("n_matrix", (normMatrix * it.modelMatrix).normalMatrix());
|
||||
|
||||
// set some more values
|
||||
program->setUniformValue("b_transparent", tmp_transparent);
|
||||
program->setUniformValue("b_specular", tmp_specular);
|
||||
|
||||
// set some material attributes
|
||||
program->setUniformValue("materialShininess", shininess);
|
||||
program->setUniformValue("materialSpecularColor", specularColor);
|
||||
|
||||
// Draw cube geometry using indices from VBO 1
|
||||
if(wireframe)
|
||||
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
|
||||
|
||||
glDrawElements(GL_TRIANGLES, it.size, GL_UNSIGNED_INT, (void*)(it.offset * sizeof(GLuint)));
|
||||
|
||||
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -8,6 +8,9 @@
|
||||
#include <QSignalMapper>
|
||||
#include <QFile>
|
||||
#include <QSizePolicy>
|
||||
#include <QFont>
|
||||
#include <QResizeEvent>
|
||||
#include <QToolButton>
|
||||
#include "..\Header\FileInterface.h"
|
||||
|
||||
#define WINDOW_NAME "Mesh Viewer"
|
||||
@@ -16,6 +19,8 @@ MainWindow::MainWindow(QWidget *parent)
|
||||
: QMainWindow(parent)
|
||||
, ui(new Ui::MainWindowClass)
|
||||
, m_curSeverity(0)
|
||||
, m_output(new QLabel(this))
|
||||
, m_infoWindow(new FileInfoWindow(this))
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
@@ -24,18 +29,27 @@ MainWindow::MainWindow(QWidget *parent)
|
||||
|
||||
QSurfaceFormat format;
|
||||
format.setDepthBufferSize(24);
|
||||
format.setMajorVersion(2);
|
||||
format.setMinorVersion(0);
|
||||
format.setProfile(QSurfaceFormat::NoProfile);
|
||||
QSurfaceFormat::setDefaultFormat(format);
|
||||
|
||||
setupWidgets();
|
||||
|
||||
ui->statusBar->showMessage("MeshViewer by Anakin", 0);
|
||||
printMessage("MeshViewer by Anakin", 0);
|
||||
|
||||
m_fileInfo += "Filename: -\nMaterials: -\nVertices: -\nTriangle: -\n<detail>No file is open";
|
||||
m_fileInfo += "Filename: -\nMaterials: -\nVertices: -\nTriangle: -<detail>No file is open";
|
||||
|
||||
QFile styleSheet(":/files/StyleSheet.txt");
|
||||
styleSheet.open(QIODevice::ReadOnly);
|
||||
this->setStyleSheet(styleSheet.readAll());
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow()
|
||||
{
|
||||
delete ui;
|
||||
delete m_output;
|
||||
delete m_infoWindow;
|
||||
}
|
||||
|
||||
void MainWindow::openFile()
|
||||
@@ -49,31 +63,48 @@ void MainWindow::setupWidgets()
|
||||
{
|
||||
OglViewerWidget* viewer = new OglViewerWidget(this);
|
||||
setCentralWidget(viewer);
|
||||
connect(viewer, &OglViewerWidget::sendMessage, this, &MainWindow::printMessage);
|
||||
|
||||
QAction *openFile = new QAction("Open file", this);
|
||||
connect(openFile, &QAction::triggered, this, &MainWindow::openFile);
|
||||
ui->mainToolBar->addAction(openFile);
|
||||
QToolButton *openFile = new QToolButton(this);
|
||||
openFile->setObjectName("openFile");
|
||||
openFile->setToolTip("open file");
|
||||
connect(openFile, &QToolButton::pressed, this, &MainWindow::openFile);
|
||||
ui->mainToolBar->addWidget(openFile);
|
||||
|
||||
QToolButton *screenshot = new QToolButton(this);
|
||||
screenshot->setObjectName("screenshot");
|
||||
screenshot->setToolTip("take screenshot");
|
||||
connect(screenshot, &QToolButton::pressed, this, &MainWindow::takeScreenShot);
|
||||
ui->mainToolBar->addWidget(screenshot);
|
||||
|
||||
ui->mainToolBar->addSeparator();
|
||||
|
||||
QSignalMapper* signalMapper = new QSignalMapper(this);
|
||||
|
||||
QAction *x = new QAction("X", this);
|
||||
QToolButton *x = new QToolButton(this);
|
||||
x->setObjectName("x");
|
||||
x->setToolTip("x-direction");
|
||||
x->setCheckable(true);
|
||||
x->setChecked(true);
|
||||
ui->mainToolBar->addAction(x);
|
||||
ui->mainToolBar->addWidget(x);
|
||||
|
||||
QAction *y = new QAction("Y", this);
|
||||
QToolButton *y = new QToolButton(this);
|
||||
y->setObjectName("y");
|
||||
y->setToolTip("y-direction");
|
||||
y->setCheckable(true);
|
||||
y->setChecked(true);
|
||||
ui->mainToolBar->addAction(y);
|
||||
ui->mainToolBar->addWidget(y);
|
||||
|
||||
QAction *z = new QAction("Z", this);
|
||||
QToolButton *z = new QToolButton(this);
|
||||
z->setObjectName("z");
|
||||
z->setToolTip("z-direction");
|
||||
z->setCheckable(true);
|
||||
z->setChecked(true);
|
||||
ui->mainToolBar->addAction(z);
|
||||
ui->mainToolBar->addWidget(z);
|
||||
|
||||
connect(x, SIGNAL(triggered()), signalMapper, SLOT(map()));
|
||||
connect(y, SIGNAL(triggered()), signalMapper, SLOT(map()));
|
||||
connect(z, SIGNAL(triggered()), signalMapper, SLOT(map()));
|
||||
connect(x, SIGNAL(pressed()), signalMapper, SLOT(map()));
|
||||
connect(y, SIGNAL(pressed()), signalMapper, SLOT(map()));
|
||||
connect(z, SIGNAL(pressed()), signalMapper, SLOT(map()));
|
||||
|
||||
signalMapper->setMapping(x, 1);
|
||||
signalMapper->setMapping(y, 2);
|
||||
@@ -81,21 +112,55 @@ void MainWindow::setupWidgets()
|
||||
|
||||
connect(signalMapper, SIGNAL(mapped(int)), viewer, SLOT(changeDirection(int)));
|
||||
|
||||
ui->mainToolBar->addSeparator();
|
||||
|
||||
QAction *fileInfo = new QAction("File info", this);
|
||||
connect(fileInfo, &QAction::triggered, this, &MainWindow::aboutFile);
|
||||
ui->mainToolBar->addAction(fileInfo);
|
||||
QToolButton *wireframe = new QToolButton(this);
|
||||
wireframe->setObjectName("wireframe");
|
||||
wireframe->setToolTip("wireframe");
|
||||
wireframe->setCheckable(true);
|
||||
wireframe->setChecked(false);
|
||||
connect(wireframe, &QToolButton::pressed, viewer, &OglViewerWidget::toggleWireframe);
|
||||
ui->mainToolBar->addWidget(wireframe);
|
||||
|
||||
QAction *help = new QAction("Help", this);
|
||||
connect(help, &QAction::triggered, this, &MainWindow::aboutTool);
|
||||
ui->mainToolBar->addAction(help);
|
||||
QToolButton *light = new QToolButton(this);
|
||||
light->setObjectName("light");
|
||||
light->setToolTip("toggle light");
|
||||
light->setCheckable(true);
|
||||
light->setChecked(false);
|
||||
connect(light, &QToolButton::pressed, viewer, &OglViewerWidget::toggleLight);
|
||||
ui->mainToolBar->addWidget(light);
|
||||
|
||||
QToolButton *settings = new QToolButton(this);
|
||||
settings->setObjectName("settings");
|
||||
settings->setToolTip("settings");
|
||||
connect(settings, &QToolButton::pressed, viewer, &OglViewerWidget::showSettings);
|
||||
ui->mainToolBar->addWidget(settings);
|
||||
|
||||
ui->mainToolBar->addSeparator();
|
||||
|
||||
QToolButton *fileInfo = new QToolButton(this);
|
||||
fileInfo->setObjectName("fileInfo");
|
||||
fileInfo->setToolTip("file info");
|
||||
connect(fileInfo, &QToolButton::pressed, this, &MainWindow::aboutFile);
|
||||
ui->mainToolBar->addWidget(fileInfo);
|
||||
|
||||
QToolButton *help = new QToolButton(this);
|
||||
help->setObjectName("help");
|
||||
help->setToolTip("help");
|
||||
connect(help, &QToolButton::pressed, this, &MainWindow::aboutTool);
|
||||
ui->mainToolBar->addWidget(help);
|
||||
|
||||
m_output->setObjectName("output");
|
||||
m_output->setStyleSheet("QLabel#output{color : white; min-width: 400px; min-height: 50px;}");
|
||||
m_output->setAlignment(Qt::AlignTop);
|
||||
m_output->setText("Name: -\nMaterials: -\nVertice: -\nTriangle: -");
|
||||
m_output->raise();
|
||||
|
||||
|
||||
}
|
||||
|
||||
void MainWindow::aboutFile()
|
||||
{
|
||||
QMessageBox* dialog = new QMessageBox(QMessageBox::NoIcon,
|
||||
/*QMessageBox* dialog = new QMessageBox(QMessageBox::NoIcon,
|
||||
WINDOW_NAME,
|
||||
QString(m_fileInfo.left(m_fileInfo.indexOf("<detail>"))),
|
||||
QMessageBox::StandardButton::Close,
|
||||
@@ -105,7 +170,8 @@ void MainWindow::aboutFile()
|
||||
dialog->setStyleSheet("QLabel{min-width: 200px;}");
|
||||
dialog->setDetailedText(QString(m_fileInfo.right(m_fileInfo.size() - m_fileInfo.indexOf("<detail>") - 8)));
|
||||
dialog->exec();
|
||||
delete dialog;
|
||||
delete dialog;*/
|
||||
m_infoWindow->show();
|
||||
}
|
||||
|
||||
void MainWindow::aboutTool()
|
||||
@@ -127,27 +193,125 @@ void MainWindow::aboutTool()
|
||||
delete dialog;
|
||||
}
|
||||
|
||||
void MainWindow::setFileInfo(QString name, QStringList textures, int vertices, int triangle)
|
||||
void MainWindow::takeScreenShot()
|
||||
{
|
||||
QString destination = QFileDialog::getSaveFileName(this, "Save as...", "", "PNG (*.png);; BMP (*.bmp);;TIFF (*.tiff, *.tif);;JPEG (*.jpg *jpeg)");
|
||||
|
||||
OglViewerWidget* viewer = dynamic_cast<OglViewerWidget*>(centralWidget());
|
||||
if (!destination.isEmpty() && viewer != NULL)
|
||||
viewer->grab().save(destination);
|
||||
}
|
||||
|
||||
void MainWindow::resizeEvent(QResizeEvent * e)
|
||||
{
|
||||
m_output->move(40, e->size().height() - 80);
|
||||
}
|
||||
|
||||
void MainWindow::setFileInfo(QString name, QVector<Material>* materials, int vertices, int triangle)
|
||||
{
|
||||
m_fileInfo = QByteArray("Filename: ");
|
||||
m_fileInfo += name;
|
||||
m_fileInfo += "\nMaterials: ";
|
||||
m_fileInfo += QByteArray::number(textures.size());
|
||||
m_fileInfo += QByteArray::number(materials->size());
|
||||
m_fileInfo += "\nVertices: ";
|
||||
m_fileInfo += QByteArray::number(vertices);
|
||||
m_fileInfo += "\nTriangle: ";
|
||||
m_fileInfo += QByteArray::number(triangle);
|
||||
m_fileInfo += "<detail>";
|
||||
|
||||
int count(0);
|
||||
for (auto& it : textures)
|
||||
for (auto& it : *materials)
|
||||
{
|
||||
m_fileInfo += "Material ";
|
||||
m_fileInfo += QByteArray::number(count++);
|
||||
m_fileInfo += " - ";
|
||||
m_fileInfo += it;
|
||||
m_fileInfo += it.name;
|
||||
m_fileInfo += "\n";
|
||||
|
||||
m_fileInfo += "TX0D:\t\t";
|
||||
if (it.tx0d.isEmpty())
|
||||
m_fileInfo += "-";
|
||||
else
|
||||
m_fileInfo += it.tx0d;
|
||||
m_fileInfo += "\n";
|
||||
|
||||
m_fileInfo += "TX1D:\t\t";
|
||||
if (it.tx1d.isEmpty())
|
||||
m_fileInfo += "-";
|
||||
else
|
||||
m_fileInfo += it.tx1d;
|
||||
m_fileInfo += "\n";
|
||||
|
||||
m_fileInfo += "TX2D:\t\t";
|
||||
if (it.tx2d.isEmpty())
|
||||
m_fileInfo += "-";
|
||||
else
|
||||
m_fileInfo += it.tx2d;
|
||||
m_fileInfo += "\n";
|
||||
|
||||
m_fileInfo += "TX3D:\t\t";
|
||||
if (it.tx3d.isEmpty())
|
||||
m_fileInfo += "-";
|
||||
else
|
||||
m_fileInfo += it.tx3d;
|
||||
m_fileInfo += "\n";
|
||||
|
||||
m_fileInfo += "Flags:\t\t";
|
||||
for (int i = 0; i < 8; i++)
|
||||
{
|
||||
if (it.flags[i])
|
||||
m_fileInfo += "1";
|
||||
else
|
||||
m_fileInfo += "0";
|
||||
}
|
||||
m_fileInfo += "\n";
|
||||
|
||||
m_fileInfo += "Rendertype:\t";
|
||||
m_fileInfo += QByteArray::number(it.rendertype);
|
||||
m_fileInfo += "\n";
|
||||
|
||||
m_fileInfo += "Gloss:\t";
|
||||
m_fileInfo += QByteArray::number(it.shininess);
|
||||
m_fileInfo += "\tData0:\t";
|
||||
m_fileInfo += QByteArray::number(it.dataValues[0]);
|
||||
m_fileInfo += "\tData1:\t";
|
||||
m_fileInfo += QByteArray::number(it.dataValues[1]);
|
||||
m_fileInfo += "\n";
|
||||
|
||||
m_fileInfo += "Diffusecolor:\tR: ";
|
||||
m_fileInfo += QByteArray::number(it.diffuseColor.x());
|
||||
m_fileInfo += "\tG: ";
|
||||
m_fileInfo += QByteArray::number(it.diffuseColor.y());
|
||||
m_fileInfo += "\tB: ";
|
||||
m_fileInfo += QByteArray::number(it.diffuseColor.z());
|
||||
m_fileInfo += "\tA: ";
|
||||
m_fileInfo += QByteArray::number(it.diffuseColor.w());
|
||||
m_fileInfo += "\n";
|
||||
|
||||
m_fileInfo += "Ambientcolor:\tR: ";
|
||||
m_fileInfo += QByteArray::number(it.ambientColor.x());
|
||||
m_fileInfo += "\tG: ";
|
||||
m_fileInfo += QByteArray::number(it.ambientColor.y());
|
||||
m_fileInfo += "\tB: ";
|
||||
m_fileInfo += QByteArray::number(it.ambientColor.z());
|
||||
m_fileInfo += "\tA: ";
|
||||
m_fileInfo += QByteArray::number(it.ambientColor.w());
|
||||
m_fileInfo += "\n";
|
||||
|
||||
m_fileInfo += "Specularcolor:\tR: ";
|
||||
m_fileInfo += QByteArray::number(it.specularColor.x());
|
||||
m_fileInfo += "\tG: ";
|
||||
m_fileInfo += QByteArray::number(it.specularColor.y());
|
||||
m_fileInfo += " \tB: ";
|
||||
m_fileInfo += QByteArray::number(it.specularColor.z());
|
||||
m_fileInfo += " \tA: ";
|
||||
m_fileInfo += QByteArray::number(it.specularColor.w());
|
||||
m_fileInfo += "\n";
|
||||
|
||||
m_fileInfo += "-----------------------------------------------------------------\n";
|
||||
}
|
||||
|
||||
m_output->setText(m_fileInfo.left(m_fileInfo.indexOf("<detail>")));
|
||||
|
||||
m_infoWindow->setBasicText(QString(m_fileInfo.left(m_fileInfo.indexOf("<detail>"))));
|
||||
m_infoWindow->setDetailText(QString(m_fileInfo.right(m_fileInfo.size() - m_fileInfo.indexOf("<detail>") - 8)));
|
||||
|
||||
}
|
||||
|
||||
void MainWindow::printMessage(QString message, int severity)
|
||||
|
@@ -1,5 +1,6 @@
|
||||
#include "..\Header\MshFile.h"
|
||||
|
||||
#include "..\Header\tga.h"
|
||||
#include <QColor>
|
||||
|
||||
// helper function to save data from file to any variable type
|
||||
#define F2V(variableName) reinterpret_cast<char*>(&variableName)
|
||||
@@ -160,7 +161,7 @@ void MshFile::analyseMsh2Chunks(std::list<ChunkHeader*>& chunkList)
|
||||
std::list<ChunkHeader*> tmp_matdChunks;
|
||||
loadChunks(tmp_matdChunks, it->position, it->size);
|
||||
|
||||
m_textureNames->push_back("");
|
||||
m_materials->push_back(Material());
|
||||
|
||||
// analyse MATD subchunks
|
||||
analyseMatdChunks(tmp_matdChunks);
|
||||
@@ -216,13 +217,122 @@ void MshFile::analyseMatdChunks(std::list<ChunkHeader*>& chunkList)
|
||||
{
|
||||
for (auto& it : chunkList)
|
||||
{
|
||||
if (!strcmp("TX0D", it->name))
|
||||
// name
|
||||
if (!strcmp("NAME", it->name))
|
||||
{
|
||||
m_file.seekg(it->position);
|
||||
char* buffer = new char[it->size + 1];
|
||||
*buffer = { 0 };
|
||||
m_file.read(buffer, it->size);
|
||||
m_textureNames->back() = buffer;
|
||||
m_materials->back().name = buffer;
|
||||
delete[] buffer;
|
||||
}
|
||||
|
||||
// data
|
||||
else if(!strcmp("DATA", it->name))
|
||||
{
|
||||
m_file.seekg(it->position);
|
||||
|
||||
// diffuse
|
||||
for (unsigned int i = 0; i < 4; i++)
|
||||
m_file.read(F2V(m_materials->back().diffuseColor[i]), sizeof(float));
|
||||
|
||||
// specular
|
||||
for (unsigned int i = 0; i < 4; i++)
|
||||
m_file.read(F2V(m_materials->back().specularColor[i]), sizeof(float));
|
||||
|
||||
// ambient
|
||||
for (unsigned int i = 0; i < 4; i++)
|
||||
m_file.read(F2V(m_materials->back().ambientColor[i]), sizeof(float));
|
||||
|
||||
// shininess
|
||||
m_file.read(F2V(m_materials->back().shininess), sizeof(float));
|
||||
}
|
||||
|
||||
// attributes
|
||||
else if (!strcmp("ATRB", it->name))
|
||||
{
|
||||
// get pointer to current material
|
||||
Material* curMat = &m_materials->back();
|
||||
|
||||
// read the attributes
|
||||
m_file.seekg(it->position);
|
||||
std::uint8_t flag;
|
||||
m_file.read(F2V(flag), sizeof(flag));
|
||||
m_file.read(F2V(curMat->rendertype), sizeof(std::uint8_t));
|
||||
m_file.read(F2V(curMat->dataValues[0]), sizeof(std::uint8_t));
|
||||
m_file.read(F2V(curMat->dataValues[1]), sizeof(std::uint8_t));
|
||||
|
||||
// flags
|
||||
// 0: emissive
|
||||
// 1: glow
|
||||
// 2: single-sided transparency
|
||||
// 3: double-sided transparency
|
||||
// 4: hard-edged transparency
|
||||
// 5: per-pixel lighting
|
||||
// 6: additive transparency
|
||||
// 7: specular
|
||||
|
||||
for (unsigned int i = 0; i < 8; i++)
|
||||
curMat->flags[i] = (std::uint8_t)(flag << (7 - i)) >> 7;
|
||||
|
||||
curMat->transparent = curMat->flags[2] || curMat->flags[3] || curMat->flags[4] || curMat->flags[6] || curMat->rendertype == 4;
|
||||
|
||||
}
|
||||
|
||||
// texture 0
|
||||
else if (!strcmp("TX0D", it->name))
|
||||
{
|
||||
// get the texture name
|
||||
m_file.seekg(it->position);
|
||||
char* buffer = new char[it->size + 1];
|
||||
*buffer = { 0 };
|
||||
m_file.read(buffer, it->size);
|
||||
m_materials->back().tx0d = buffer;
|
||||
delete[] buffer;
|
||||
|
||||
// load the texture if the name is not empty
|
||||
if (!m_materials->back().tx0d.isEmpty())
|
||||
loadTexture(m_materials->back().texture0, m_filepath, m_materials->back().tx0d);
|
||||
}
|
||||
|
||||
// texture 1
|
||||
else if (!strcmp("TX1D", it->name))
|
||||
{
|
||||
// get the texture name
|
||||
m_file.seekg(it->position);
|
||||
char* buffer = new char[it->size + 1];
|
||||
*buffer = { 0 };
|
||||
m_file.read(buffer, it->size);
|
||||
m_materials->back().tx1d = buffer;
|
||||
delete[] buffer;
|
||||
|
||||
if (!m_materials->back().tx1d.isEmpty())
|
||||
loadTexture(m_materials->back().texture1, m_filepath, m_materials->back().tx1d);
|
||||
|
||||
}
|
||||
|
||||
// texture 2
|
||||
else if (!strcmp("TX2D", it->name))
|
||||
{
|
||||
// get the texture name
|
||||
m_file.seekg(it->position);
|
||||
char* buffer = new char[it->size + 1];
|
||||
*buffer = { 0 };
|
||||
m_file.read(buffer, it->size);
|
||||
m_materials->back().tx2d = buffer;
|
||||
delete[] buffer;
|
||||
}
|
||||
|
||||
// texture 3
|
||||
else if (!strcmp("TX3D", it->name))
|
||||
{
|
||||
// get the texture name
|
||||
m_file.seekg(it->position);
|
||||
char* buffer = new char[it->size + 1];
|
||||
*buffer = { 0 };
|
||||
m_file.read(buffer, it->size);
|
||||
m_materials->back().tx3d = buffer;
|
||||
delete[] buffer;
|
||||
}
|
||||
}
|
||||
@@ -302,6 +412,10 @@ void MshFile::analyseModlChunks(Model * dataDestination, std::list<ChunkHeader*>
|
||||
// geometry data
|
||||
else if (!strcmp("GEOM", it->name))
|
||||
{
|
||||
// don't get null, bone, shadowMesh and hidden mesh indices
|
||||
if (m_currentType == null || m_currentType == bone || m_currentType == shadowMesh || m_currentRenderFlag == 1)
|
||||
continue;
|
||||
|
||||
// get all GEOM subchunks
|
||||
std::list<ChunkHeader*> tmp_geomChunks;
|
||||
loadChunks(tmp_geomChunks, it->position, it->size);
|
||||
@@ -386,27 +500,27 @@ void MshFile::analyseSegmChunks(Model * dataDestination, std::list<ChunkHeader*>
|
||||
// normals
|
||||
else if (!strcmp("NRML", it->name))
|
||||
{
|
||||
std::uint32_t tmp_size;
|
||||
m_file.seekg(it->position);
|
||||
m_file.read(F2V(tmp_size), sizeof(tmp_size));
|
||||
std::uint32_t tmp_size;
|
||||
m_file.seekg(it->position);
|
||||
m_file.read(F2V(tmp_size), sizeof(tmp_size));
|
||||
|
||||
if (tmp_size < new_segment->vertices.size())
|
||||
{
|
||||
emit sendMessage("WARNING: too less normals " + QString::number(tmp_size) + " < " + QString::number(new_segment->vertices.size()), 1);
|
||||
if (tmp_size < new_segment->vertices.size())
|
||||
{
|
||||
emit sendMessage("WARNING: too less normals " + QString::number(tmp_size) + " < " + QString::number(new_segment->vertices.size()), 1);
|
||||
|
||||
for (unsigned int i = new_segment->vertices.size(); i != tmp_size; i--)
|
||||
for (unsigned int i = new_segment->vertices.size(); i != tmp_size; i--)
|
||||
for (unsigned int j = 0; j < 3; j++)
|
||||
new_segment->vertices[i - 1].vertexNormal[j] = 0;
|
||||
}
|
||||
else if (tmp_size > new_segment->vertices.size())
|
||||
{
|
||||
emit sendMessage("WARNING: too many normals " + QString::number(tmp_size) + " > " + QString::number(new_segment->vertices.size()), 1);
|
||||
tmp_size = new_segment->vertices.size();
|
||||
}
|
||||
|
||||
for (unsigned int i = 0; i < tmp_size; i++)
|
||||
for (unsigned int j = 0; j < 3; j++)
|
||||
new_segment->vertices[i - 1].normal[j] = 0;
|
||||
}
|
||||
else if (tmp_size > new_segment->vertices.size())
|
||||
{
|
||||
emit sendMessage("WARNING: too many normals " + QString::number(tmp_size) + " > " + QString::number(new_segment->vertices.size()), 1);
|
||||
tmp_size = new_segment->vertices.size();
|
||||
}
|
||||
|
||||
for (unsigned int i = 0; i < tmp_size; i++)
|
||||
for (unsigned int j = 0; j < 3; j++)
|
||||
m_file.read(F2V(new_segment->vertices[i].normal[j]), sizeof(float));
|
||||
m_file.read(F2V(new_segment->vertices[i].vertexNormal[j]), sizeof(float));
|
||||
|
||||
}
|
||||
|
||||
@@ -419,9 +533,6 @@ void MshFile::analyseSegmChunks(Model * dataDestination, std::list<ChunkHeader*>
|
||||
// polygons (indices into vertex/uv list)
|
||||
else if (!strcmp("STRP", it->name))
|
||||
{
|
||||
// don't get null, bone, shadowMesh and hidden mesh indices
|
||||
if (m_currentType == null || m_currentType == bone || m_currentType == shadowMesh || m_currentRenderFlag == 1)
|
||||
continue;
|
||||
|
||||
// jump to the data section and read the size;
|
||||
std::uint32_t tmp_size;
|
||||
@@ -511,17 +622,17 @@ void MshFile::analyseClthChunks(Model * dataDestination, std::list<ChunkHeader*>
|
||||
*buffer = { 0 };
|
||||
m_file.read(buffer, it->size);
|
||||
|
||||
// search if it is already known
|
||||
bool tmp_found(false);
|
||||
|
||||
m_materials->push_back(Material());
|
||||
m_materials->back().name = "Cloth Material";
|
||||
m_materials->back().tx0d = QString(buffer);
|
||||
|
||||
int index = m_textureNames->indexOf(QString::fromStdString(buffer));
|
||||
if (index != -1)
|
||||
new_segment->textureIndex = index;
|
||||
else
|
||||
{
|
||||
m_textureNames->push_back(QString::fromStdString(buffer));
|
||||
new_segment->textureIndex = m_textureNames->size() - 1;
|
||||
}
|
||||
m_materials->back().shininess = 10;
|
||||
|
||||
if (!m_materials->back().tx0d.isEmpty())
|
||||
loadTexture(m_materials->back().texture0, m_filepath, m_materials->back().tx0d);
|
||||
|
||||
new_segment->textureIndex = m_materials->size() - 1;
|
||||
|
||||
delete[] buffer;
|
||||
}
|
||||
@@ -604,6 +715,36 @@ void MshFile::readUV(Segment * dataDestination, std::streampos position)
|
||||
m_file.read(F2V(dataDestination->vertices[i].texCoord[j]), sizeof(float));
|
||||
}
|
||||
|
||||
void MshFile::loadTexture(QOpenGLTexture *& destination, QString filepath, QString& filename)
|
||||
{
|
||||
bool loadSuccess(false);
|
||||
QImage img = loadTga(filepath + "/" + filename, loadSuccess);
|
||||
|
||||
if (!loadSuccess)
|
||||
{
|
||||
emit sendMessage("WARNING: texture not found or corrupted: " + filename, 1);
|
||||
|
||||
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));
|
||||
filename += " *";
|
||||
}
|
||||
|
||||
// Load image to OglTexture
|
||||
QOpenGLTexture* new_texture = new QOpenGLTexture(img.mirrored());
|
||||
|
||||
// Set nearest filtering mode for texture minification
|
||||
new_texture->setMinificationFilter(QOpenGLTexture::Nearest);
|
||||
|
||||
// Set bilinear filtering mode for texture magnification
|
||||
new_texture->setMagnificationFilter(QOpenGLTexture::Linear);
|
||||
|
||||
// Wrap texture coordinates by repeating
|
||||
// f.ex. texture coordinate (1.1, 1.2) is same as (0.1, 0.2)
|
||||
new_texture->setWrapMode(QOpenGLTexture::Repeat);
|
||||
|
||||
destination = new_texture;
|
||||
}
|
||||
|
||||
QMatrix4x4 MshFile::getParentMatrix(std::string parent) const
|
||||
{
|
||||
QMatrix4x4 matrix;
|
||||
|
@@ -12,14 +12,20 @@
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// public constructor/destructor
|
||||
|
||||
OglViewerWidget::OglViewerWidget(QWidget *parent) :
|
||||
QOpenGLWidget(parent),
|
||||
m_dataEngine(0)
|
||||
OglViewerWidget::OglViewerWidget(QWidget *parent)
|
||||
: QOpenGLWidget(parent)
|
||||
, m_dataEngine(0)
|
||||
, m_settings(new SettingsWindow(this))
|
||||
{
|
||||
setFocus();
|
||||
m_translation.setZ(DEFAULT_Z_DISTANCE);
|
||||
setAcceptDrops(true);
|
||||
|
||||
connect(m_settings, &SettingsWindow::updateBGColorOff, this, &OglViewerWidget::setBGColorOff);
|
||||
connect(m_settings, &SettingsWindow::updateBGColorOn, this, &OglViewerWidget::setBGColorOn);
|
||||
connect(m_settings, &SettingsWindow::updateLightColor, this, &OglViewerWidget::setLightColor);
|
||||
connect(m_settings, &SettingsWindow::updateAttFac, this, &OglViewerWidget::setAttFac);
|
||||
connect(m_settings, &SettingsWindow::updateAmbCoef, this, &OglViewerWidget::setAmbCoef);
|
||||
}
|
||||
|
||||
OglViewerWidget::~OglViewerWidget()
|
||||
@@ -29,6 +35,8 @@ OglViewerWidget::~OglViewerWidget()
|
||||
makeCurrent();
|
||||
delete m_dataEngine;
|
||||
doneCurrent();
|
||||
|
||||
delete m_settings;
|
||||
}
|
||||
|
||||
|
||||
@@ -145,7 +153,7 @@ void OglViewerWidget::mouseMoveEvent(QMouseEvent *e)
|
||||
|
||||
void OglViewerWidget::wheelEvent(QWheelEvent *e)
|
||||
{
|
||||
m_translation += {0.0, 0.0, (float)e->angleDelta().y() / 240};
|
||||
m_translation += {0.0, 0.0, (float)m_zSpeed * e->angleDelta().y() / 240};
|
||||
update();
|
||||
}
|
||||
|
||||
@@ -173,13 +181,29 @@ void OglViewerWidget::keyPressEvent(QKeyEvent *e)
|
||||
{
|
||||
parentWidget()->close();
|
||||
}
|
||||
else if (e->key() == Qt::Key_L)
|
||||
{
|
||||
updateLightPosition();
|
||||
update();
|
||||
}
|
||||
else if (e->key() == Qt::Key_Minus)
|
||||
{
|
||||
m_zSpeed -= 0.1;
|
||||
m_zSpeed < 0.09 ? m_zSpeed = 0 : NULL;
|
||||
emit sendMessage(QString("Zoom speed = %1%").arg(m_zSpeed * 100), 0);
|
||||
}
|
||||
else if (e->key() == Qt::Key_Plus)
|
||||
{
|
||||
m_zSpeed += 0.1;
|
||||
emit sendMessage(QString("Zoom speed = %1%").arg(m_zSpeed * 100), 0);
|
||||
}
|
||||
}
|
||||
|
||||
void OglViewerWidget::initializeGL()
|
||||
{
|
||||
initializeOpenGLFunctions();
|
||||
|
||||
glClearColor(0.5000f, 0.8000f, 1.0000f, 0.0000f);
|
||||
//glClearColor(0.5000f, 0.8000f, 1.0000f, 0.0000f);
|
||||
|
||||
initShaders();
|
||||
|
||||
@@ -187,7 +211,11 @@ void OglViewerWidget::initializeGL()
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
|
||||
// Enable back face culling
|
||||
glEnable(GL_CULL_FACE);
|
||||
//glEnable(GL_CULL_FACE);
|
||||
|
||||
// Enable transparency
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
m_dataEngine = new GeometryEngine(this);
|
||||
setConnections();
|
||||
@@ -210,6 +238,17 @@ void OglViewerWidget::resizeGL(int w, int h)
|
||||
|
||||
void OglViewerWidget::paintGL()
|
||||
{
|
||||
if (m_lightOn && m_backgroundColorOn[3] == 1.0)
|
||||
{
|
||||
glClearColor(m_backgroundColorOn[0], m_backgroundColorOn[1], m_backgroundColorOn[2], 0.0000f);
|
||||
m_backgroundColorOn[3] = 0.0;
|
||||
}
|
||||
else if(!m_lightOn && m_backgroundColorOff[3] == 1.0)
|
||||
{
|
||||
glClearColor(m_backgroundColorOff[0], m_backgroundColorOff[1], m_backgroundColorOff[2], 0.0000f);
|
||||
m_backgroundColorOff[3] = 0.0;
|
||||
}
|
||||
|
||||
// Clear color and depth buffer
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
@@ -221,8 +260,20 @@ void OglViewerWidget::paintGL()
|
||||
// Set view-projection matrix
|
||||
m_program.setUniformValue("vp_matrix", m_projection * view);
|
||||
|
||||
// Set Light values
|
||||
m_program.setUniformValue("b_light", m_lightOn);
|
||||
m_program.setUniformValue("light.position", m_light.position);
|
||||
m_program.setUniformValue("light.intensities", m_light.intensities);
|
||||
m_program.setUniformValue("light.attenuationFactor", m_light.attenuationFactor);
|
||||
m_program.setUniformValue("light.ambientCoefficient", m_light.ambientCoefficient);
|
||||
|
||||
// Set camera position
|
||||
QMatrix4x4 rotateBack;
|
||||
rotateBack.rotate(m_rotation.inverted());
|
||||
m_program.setUniformValue("cameraPosition", rotateBack * (-m_translation));
|
||||
|
||||
// Draw cube geometry
|
||||
m_dataEngine->drawGeometry(&m_program);
|
||||
m_dataEngine->drawGeometry(&m_program, m_wireframe);
|
||||
}
|
||||
|
||||
|
||||
@@ -255,10 +306,21 @@ void OglViewerWidget::setConnections()
|
||||
connect(this, SIGNAL(loadFile(QString)), m_dataEngine, SLOT(loadFile(QString)));
|
||||
connect(m_dataEngine, SIGNAL(sendMessage(QString, int)), parentWidget(), SLOT(printMessage(QString, int)));
|
||||
connect(m_dataEngine, SIGNAL(requestUpdate()), this, SLOT(update()));
|
||||
connect(m_dataEngine, SIGNAL(sendFileInfo(QString, QStringList, int, int)), parentWidget(), SLOT(setFileInfo(QString, QStringList, int, int)));
|
||||
connect(m_dataEngine, SIGNAL(sendFileInfo(QString, QVector<Material>*, int, int)), parentWidget(), SLOT(setFileInfo(QString, QVector<Material>*, int, int)));
|
||||
|
||||
}
|
||||
|
||||
void OglViewerWidget::updateLightPosition()
|
||||
{
|
||||
QMatrix4x4 rotateBack;
|
||||
rotateBack.rotate(m_rotation.inverted());
|
||||
QVector3D cameraPosition = rotateBack * (-m_translation);
|
||||
|
||||
m_light.position.setX(cameraPosition.x());
|
||||
m_light.position.setY(cameraPosition.y());
|
||||
m_light.position.setZ(cameraPosition.z());
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// private slots
|
||||
@@ -267,6 +329,7 @@ void OglViewerWidget::resetView()
|
||||
{
|
||||
m_rotation = QQuaternion();
|
||||
m_translation = { 0.0, 0.0, DEFAULT_Z_DISTANCE };
|
||||
m_zSpeed = 1;
|
||||
update();
|
||||
}
|
||||
|
||||
@@ -289,3 +352,70 @@ void OglViewerWidget::changeDirection(int direction)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void OglViewerWidget::toggleWireframe()
|
||||
{
|
||||
m_wireframe = 1 - m_wireframe;
|
||||
update();
|
||||
}
|
||||
|
||||
void OglViewerWidget::toggleLight()
|
||||
{
|
||||
m_lightOn = 1 - m_lightOn;
|
||||
|
||||
if (m_lightOn)
|
||||
{
|
||||
m_backgroundColorOn[3] = 1.0;
|
||||
updateLightPosition();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_backgroundColorOff[3] = 1.0;
|
||||
}
|
||||
update();
|
||||
}
|
||||
|
||||
void OglViewerWidget::showSettings()
|
||||
{
|
||||
m_settings->show();
|
||||
}
|
||||
|
||||
void OglViewerWidget::setBGColorOff(QVector3D value)
|
||||
{
|
||||
m_backgroundColorOff = QVector4D(value / 255, 1.0f);
|
||||
|
||||
if (!m_lightOn)
|
||||
update();
|
||||
}
|
||||
|
||||
void OglViewerWidget::setBGColorOn(QVector3D value)
|
||||
{
|
||||
m_backgroundColorOn = QVector4D(value / 255, 1.0f);
|
||||
|
||||
if (m_lightOn)
|
||||
update();
|
||||
}
|
||||
|
||||
void OglViewerWidget::setLightColor(QVector3D value)
|
||||
{
|
||||
m_light.intensities = value / 255;
|
||||
|
||||
if (m_lightOn)
|
||||
update();
|
||||
}
|
||||
|
||||
void OglViewerWidget::setAttFac(double value)
|
||||
{
|
||||
m_light.attenuationFactor = (float)value;
|
||||
|
||||
if (m_lightOn)
|
||||
update();
|
||||
}
|
||||
|
||||
void OglViewerWidget::setAmbCoef(double value)
|
||||
{
|
||||
m_light.ambientCoefficient = (float)value;
|
||||
|
||||
if (m_lightOn)
|
||||
update();
|
||||
}
|
||||
|
124
QtMeshViewer/Source/SettingsWindow.cpp
Normal file
@@ -0,0 +1,124 @@
|
||||
#include "..\Header\SettingsWindow.h"
|
||||
#include <QString>
|
||||
|
||||
SettingsWindow::SettingsWindow(QWidget * parent)
|
||||
: QWidget(parent)
|
||||
, ui(new Ui::SettingsWindow)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
setWindowFlags(Qt::Tool | Qt::NoDropShadowWindowHint);
|
||||
|
||||
// light off
|
||||
connect(ui->lightOff_R_LE, &QLineEdit::textChanged, [this](const QString& value){ui->lightOff_R_S->setValue(value.toInt());});
|
||||
connect(ui->lightOff_R_S, &QSlider::valueChanged, [this](const int& value){ui->lightOff_R_LE->setText(QString::number(value));});
|
||||
connect(ui->lightOff_R_S, &QSlider::valueChanged, this, &SettingsWindow::backgroundColorOffChanged);
|
||||
|
||||
connect(ui->lightOff_G_LE, &QLineEdit::textChanged, [this](const QString& value){ui->lightOff_G_S->setValue(value.toInt());});
|
||||
connect(ui->lightOff_G_S, &QSlider::valueChanged, [this](const int& value){ui->lightOff_G_LE->setText(QString::number(value));});
|
||||
connect(ui->lightOff_G_S, &QSlider::valueChanged, this, &SettingsWindow::backgroundColorOffChanged);
|
||||
|
||||
connect(ui->lightOff_B_LE, &QLineEdit::textChanged, [this](const QString& value){ui->lightOff_B_S->setValue(value.toInt());});
|
||||
connect(ui->lightOff_B_S, &QSlider::valueChanged, [this](const int& value){ui->lightOff_B_LE->setText(QString::number(value));});
|
||||
connect(ui->lightOff_B_S, &QSlider::valueChanged, this, &SettingsWindow::backgroundColorOffChanged);
|
||||
|
||||
// light on
|
||||
connect(ui->lightOn_R_LE, &QLineEdit::textChanged, [this](const QString& value){ui->lightOn_R_S->setValue(value.toInt());});
|
||||
connect(ui->lightOn_R_S, &QSlider::valueChanged, [this](const int& value){ui->lightOn_R_LE->setText(QString::number(value));});
|
||||
connect(ui->lightOn_R_S, &QSlider::valueChanged, this, &SettingsWindow::backgroundColorOnChanged);
|
||||
|
||||
connect(ui->lightOn_G_LE, &QLineEdit::textChanged, [this](const QString& value){ui->lightOn_G_S->setValue(value.toInt());});
|
||||
connect(ui->lightOn_G_S, &QSlider::valueChanged, [this](const int& value){ui->lightOn_G_LE->setText(QString::number(value));});
|
||||
connect(ui->lightOn_G_S, &QSlider::valueChanged, this, &SettingsWindow::backgroundColorOnChanged);
|
||||
|
||||
connect(ui->lightOn_B_LE, &QLineEdit::textChanged, [this](const QString& value){ui->lightOn_B_S->setValue(value.toInt());});
|
||||
connect(ui->lightOn_B_S, &QSlider::valueChanged, [this](const int& value){ui->lightOn_B_LE->setText(QString::number(value));});
|
||||
connect(ui->lightOn_B_S, &QSlider::valueChanged, this, &SettingsWindow::backgroundColorOnChanged);
|
||||
|
||||
// light
|
||||
connect(ui->light_R_LE, &QLineEdit::textChanged, [this](const QString& value){ui->light_R_S->setValue(value.toInt());});
|
||||
connect(ui->light_R_S, &QSlider::valueChanged, [this](const int& value){ui->light_R_LE->setText(QString::number(value)); if(ui->checkAutoColor->isChecked()) ui->lightOn_R_S->setValue((int)(value / 50));});
|
||||
connect(ui->light_R_S, &QSlider::valueChanged, this, &SettingsWindow::lightColorChanged);
|
||||
|
||||
connect(ui->light_G_LE, &QLineEdit::textChanged, [this](const QString& value){ui->light_G_S->setValue(value.toInt());});
|
||||
connect(ui->light_G_S, &QSlider::valueChanged, [this](const int& value){ui->light_G_LE->setText(QString::number(value)); if(ui->checkAutoColor->isChecked()) ui->lightOn_G_S->setValue((int)(value / 50));});
|
||||
connect(ui->light_G_S, &QSlider::valueChanged, this, &SettingsWindow::lightColorChanged);
|
||||
|
||||
connect(ui->light_B_LE, &QLineEdit::textChanged, [this](const QString& value){ui->light_B_S->setValue(value.toInt());});
|
||||
connect(ui->light_B_S, &QSlider::valueChanged, [this](const int& value){ui->light_B_LE->setText(QString::number(value)); if(ui->checkAutoColor->isChecked()) ui->lightOn_B_S->setValue((int)(value / 50));});
|
||||
connect(ui->light_B_S, &QSlider::valueChanged, this, &SettingsWindow::lightColorChanged);
|
||||
|
||||
|
||||
connect(ui->checkAutoColor, &QCheckBox::toggled, this, &SettingsWindow::autoColorToggled);
|
||||
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); });
|
||||
}
|
||||
|
||||
SettingsWindow::~SettingsWindow()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// connection slots
|
||||
|
||||
void SettingsWindow::autoColorToggled()
|
||||
{
|
||||
if (!ui->checkAutoColor->isChecked())
|
||||
{
|
||||
ui->lightOn_R_LE->setEnabled(true);
|
||||
ui->lightOn_R_S->setEnabled(true);
|
||||
ui->lightOn_G_LE->setEnabled(true);
|
||||
ui->lightOn_G_S->setEnabled(true);
|
||||
ui->lightOn_B_LE->setEnabled(true);
|
||||
ui->lightOn_B_S->setEnabled(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->lightOn_R_LE->setEnabled(false);
|
||||
ui->lightOn_R_S->setEnabled(false);
|
||||
ui->lightOn_G_LE->setEnabled(false);
|
||||
ui->lightOn_G_S->setEnabled(false);
|
||||
ui->lightOn_B_LE->setEnabled(false);
|
||||
ui->lightOn_B_S->setEnabled(false);
|
||||
|
||||
ui->lightOn_R_LE->setText(QString::number((int)(ui->light_R_S->value() / 50)));
|
||||
ui->lightOn_R_S->setValue((int)(ui->light_R_S->value() / 50));
|
||||
ui->lightOn_G_LE->setText(QString::number((int)(ui->light_G_S->value() / 50)));
|
||||
ui->lightOn_G_S->setValue((int)(ui->light_G_S->value() / 50));
|
||||
ui->lightOn_B_LE->setText(QString::number((int)(ui->light_B_S->value() / 50)));
|
||||
ui->lightOn_B_S->setValue((int)(ui->light_B_S->value() / 50));
|
||||
}
|
||||
}
|
||||
|
||||
void SettingsWindow::radioToggled()
|
||||
{
|
||||
if(ui->radioDirectLight->isChecked())
|
||||
{
|
||||
ui->attFac->setValue(0.0);
|
||||
ui->attFac->setEnabled(false);
|
||||
ui->ambCoef->setEnabled(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->attFac->setEnabled(true);
|
||||
ui->ambCoef->setEnabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
void SettingsWindow::backgroundColorOffChanged()
|
||||
{
|
||||
emit updateBGColorOff(QVector3D(ui->lightOff_R_S->value(), ui->lightOff_G_S->value(), ui->lightOff_B_S->value()));
|
||||
}
|
||||
|
||||
void SettingsWindow::backgroundColorOnChanged()
|
||||
{
|
||||
emit updateBGColorOn(QVector3D(ui->lightOn_R_S->value(), ui->lightOn_G_S->value(), ui->lightOn_B_S->value()));
|
||||
}
|
||||
|
||||
void SettingsWindow::lightColorChanged()
|
||||
{
|
||||
emit updateLightColor(QVector3D(ui->light_R_S->value(), ui->light_G_S->value(), ui->light_B_S->value()));
|
||||
}
|
||||
|
@@ -1,6 +1,7 @@
|
||||
#include "Header\MainWindow.h"
|
||||
#include <QtWidgets/QApplication>
|
||||
|
||||
// TODO: add glow/emissive
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
|
14
README.md
@@ -13,11 +13,9 @@ Feel free to use my code the way you like. But remember i used some public libra
|
||||
licence, too.
|
||||
|
||||
### To Do
|
||||
- optional display bones, shadow, collision,...
|
||||
- integrate into a software:
|
||||
-> list all msh under a directory,
|
||||
-> display shadows,
|
||||
-> display colisions,
|
||||
-> lights,
|
||||
-> handle render flags,
|
||||
|
||||
- normal map,
|
||||
- list all msh in a directory
|
||||
- glow/emissive
|
||||
- optional display bones, shadow, collision
|
||||
- change pose
|
||||
- animation
|
||||
|
Before Width: | Height: | Size: 48 KiB After Width: | Height: | Size: 48 KiB |
Before Width: | Height: | Size: 48 KiB After Width: | Height: | Size: 64 KiB |