Add base UI layout
parent
10a4a21183
commit
283e76b1b6
|
@ -9,6 +9,9 @@ HEADERS += src/mainwindow.h
|
|||
SOURCES += src/modelingwidget.cpp
|
||||
HEADERS += src/modelingwidget.h
|
||||
|
||||
SOURCES += src/skeletoneditwidget.cpp
|
||||
HEADERS += src/skeletoneditwidget.h
|
||||
|
||||
SOURCES += src/mesh.cpp
|
||||
HEADERS += src/mesh.h
|
||||
|
||||
|
|
30
src/main.cpp
30
src/main.cpp
|
@ -1,19 +1,33 @@
|
|||
#include <QApplication>
|
||||
#include <QDesktopWidget>
|
||||
#include <QStyleFactory>
|
||||
#include "mainwindow.h"
|
||||
#include "meshlite.h"
|
||||
|
||||
int main(int argc, char ** argv)
|
||||
{
|
||||
/*
|
||||
void *lite = meshlite_create_context();
|
||||
int first = meshlite_import(lite, "/Users/jeremy/cube.obj");
|
||||
int second = meshlite_import(lite, "/Users/jeremy/ball.obj");
|
||||
meshlite_scale(lite, first, 0.65);
|
||||
int result = meshlite_intersect(lite, first, second);
|
||||
meshlite_export(lite, result, "/Users/jeremy/testlib.obj");
|
||||
*/
|
||||
QApplication app(argc, argv);
|
||||
|
||||
// QuantumCD/Qt 5 Dark Fusion Palette
|
||||
// https://gist.github.com/QuantumCD/6245215
|
||||
qApp->setStyle(QStyleFactory::create("Fusion"));
|
||||
QPalette darkPalette;
|
||||
darkPalette.setColor(QPalette::Window, QColor(53,53,53));
|
||||
darkPalette.setColor(QPalette::WindowText, Qt::white);
|
||||
darkPalette.setColor(QPalette::Base, QColor(25,25,25));
|
||||
darkPalette.setColor(QPalette::AlternateBase, QColor(53,53,53));
|
||||
darkPalette.setColor(QPalette::ToolTipBase, Qt::white);
|
||||
darkPalette.setColor(QPalette::ToolTipText, Qt::white);
|
||||
darkPalette.setColor(QPalette::Text, Qt::white);
|
||||
darkPalette.setColor(QPalette::Button, QColor(53,53,53));
|
||||
darkPalette.setColor(QPalette::ButtonText, Qt::white);
|
||||
darkPalette.setColor(QPalette::BrightText, Qt::red);
|
||||
darkPalette.setColor(QPalette::Link, QColor(42, 130, 218));
|
||||
darkPalette.setColor(QPalette::Highlight, QColor(42, 130, 218));
|
||||
darkPalette.setColor(QPalette::HighlightedText, Qt::black);
|
||||
qApp->setPalette(darkPalette);
|
||||
qApp->setStyleSheet("QToolTip { color: #ffffff; background-color: #2a82da; border: 1px solid white; }");
|
||||
|
||||
QCoreApplication::setApplicationName("Dust 3D");
|
||||
MainWindow mainWindow;
|
||||
mainWindow.resize(mainWindow.sizeHint());
|
||||
|
|
|
@ -1,9 +1,78 @@
|
|||
#include "mainwindow.h"
|
||||
|
||||
#include "skeletoneditwidget.h"
|
||||
#include <QVBoxLayout>
|
||||
#include <QPushButton>
|
||||
#include <QButtonGroup>
|
||||
#include <QGridLayout>
|
||||
#include <QToolBar>
|
||||
|
||||
MainWindow::MainWindow()
|
||||
{
|
||||
modelingWidget = new ModelingWidget(this);
|
||||
setCentralWidget(modelingWidget);
|
||||
QPushButton *skeletonButton = new QPushButton("Skeleton");
|
||||
QPushButton *motionButton = new QPushButton("Motion");
|
||||
QPushButton *modelButton = new QPushButton("Model");
|
||||
|
||||
QButtonGroup *pageButtonGroup = new QButtonGroup;
|
||||
pageButtonGroup->addButton(skeletonButton);
|
||||
pageButtonGroup->addButton(motionButton);
|
||||
pageButtonGroup->addButton(modelButton);
|
||||
|
||||
skeletonButton->setCheckable(true);
|
||||
motionButton->setCheckable(true);
|
||||
modelButton->setCheckable(true);
|
||||
|
||||
pageButtonGroup->setExclusive(true);
|
||||
|
||||
skeletonButton->setChecked(true);
|
||||
|
||||
QHBoxLayout *topLayout = new QHBoxLayout;
|
||||
topLayout->addStretch();
|
||||
topLayout->addWidget(skeletonButton);
|
||||
topLayout->addWidget(motionButton);
|
||||
topLayout->addWidget(modelButton);
|
||||
topLayout->addStretch();
|
||||
|
||||
skeletonButton->adjustSize();
|
||||
motionButton->adjustSize();
|
||||
modelButton->adjustSize();
|
||||
|
||||
SkeletonEditWidget *skeletonEditWidget = new SkeletonEditWidget;
|
||||
ModelingWidget *modelViewWidget = new ModelingWidget;
|
||||
modelViewWidget->setFixedSize(128, 128);
|
||||
|
||||
QPushButton *changeTurnaroundButton = new QPushButton("Change turnaround..");
|
||||
|
||||
QVBoxLayout *rightLayout = new QVBoxLayout;
|
||||
rightLayout->addWidget(modelViewWidget);
|
||||
rightLayout->addSpacing(10);
|
||||
rightLayout->addWidget(changeTurnaroundButton);
|
||||
rightLayout->addStretch();
|
||||
|
||||
QToolBar *toolbar = new QToolBar;
|
||||
toolbar->setOrientation(Qt::Vertical);
|
||||
QAction *addAction = new QAction(tr("Add"), this);
|
||||
QAction *selectAction = new QAction(tr("Select"), this);
|
||||
toolbar->addAction(addAction);
|
||||
toolbar->addAction(selectAction);
|
||||
|
||||
QVBoxLayout *leftLayout = new QVBoxLayout;
|
||||
leftLayout->addWidget(toolbar);
|
||||
leftLayout->addStretch();
|
||||
|
||||
QHBoxLayout *middleLayout = new QHBoxLayout;
|
||||
middleLayout->addLayout(leftLayout);
|
||||
middleLayout->addWidget(skeletonEditWidget);
|
||||
middleLayout->addLayout(rightLayout);
|
||||
|
||||
QVBoxLayout *mainLayout = new QVBoxLayout;
|
||||
mainLayout->addLayout(topLayout);
|
||||
mainLayout->addSpacing(20);
|
||||
mainLayout->addLayout(middleLayout);
|
||||
|
||||
QWidget *centralWidget = new QWidget;
|
||||
centralWidget->setLayout(mainLayout);
|
||||
|
||||
setCentralWidget(centralWidget);
|
||||
setWindowTitle(tr("Dust 3D"));
|
||||
}
|
||||
|
||||
|
|
|
@ -27,12 +27,12 @@ ModelingWidget::ModelingWidget(QWidget *parent)
|
|||
}
|
||||
|
||||
void *lite = meshlite_create_context();
|
||||
int first = meshlite_import(lite, "/Users/jeremy/cube.obj");
|
||||
int second = meshlite_import(lite, "/Users/jeremy/ball.obj");
|
||||
int first = meshlite_import(lite, "../assets/cube.obj");
|
||||
int second = meshlite_import(lite, "../assets/ball.obj");
|
||||
meshlite_scale(lite, first, 0.65);
|
||||
int intersect = meshlite_intersect(lite, first, second);
|
||||
int triangulate = meshlite_triangulate(lite, intersect);
|
||||
meshlite_export(lite, triangulate, "/Users/jeremy/testlib.obj");
|
||||
int merged = meshlite_union(lite, first, second);
|
||||
int triangulate = meshlite_triangulate(lite, merged);
|
||||
//meshlite_export(lite, triangulate, "/Users/jeremy/testlib.obj");
|
||||
Mesh *mesh = new Mesh(lite, triangulate);
|
||||
updateMesh(mesh);
|
||||
}
|
||||
|
@ -126,7 +126,7 @@ static const char *fragmentShaderSourceCore =
|
|||
"void main() {\n"
|
||||
" highp vec3 L = normalize(lightPos - vert);\n"
|
||||
" highp float NL = max(dot(normalize(vertNormal), L), 0.0);\n"
|
||||
" highp vec3 color = vec3(0.39, 1.0, 0.0);\n"
|
||||
" highp vec3 color = vec3(1.0, 1.0, 1.0);\n"
|
||||
" highp vec3 col = clamp(color * 0.2 + color * 0.8 * NL, 0.0, 1.0);\n"
|
||||
" fragColor = vec4(col, 1.0);\n"
|
||||
"}\n";
|
||||
|
@ -152,7 +152,7 @@ static const char *fragmentShaderSource =
|
|||
"void main() {\n"
|
||||
" highp vec3 L = normalize(lightPos - vert);\n"
|
||||
" highp float NL = max(dot(normalize(vertNormal), L), 0.0);\n"
|
||||
" highp vec3 color = vec3(0.39, 1.0, 0.0);\n"
|
||||
" highp vec3 color = vec3(1.0, 1.0, 1.0);\n"
|
||||
" highp vec3 col = clamp(color * 0.2 + color * 0.8 * NL, 0.0, 1.0);\n"
|
||||
" gl_FragColor = vec4(col, 1.0);\n"
|
||||
"}\n";
|
||||
|
@ -169,7 +169,7 @@ void ModelingWidget::initializeGL()
|
|||
connect(context(), &QOpenGLContext::aboutToBeDestroyed, this, &ModelingWidget::cleanup);
|
||||
|
||||
initializeOpenGLFunctions();
|
||||
glClearColor(0, 0, 0, m_transparent ? 0 : 1);
|
||||
glClearColor(0.2078, 0.2078, 0.2078, m_transparent ? 0 : 1);
|
||||
|
||||
m_program = new QOpenGLShaderProgram;
|
||||
m_program->addShaderFromSourceCode(QOpenGLShader::Vertex, m_core ? vertexShaderSourceCore : vertexShaderSource);
|
||||
|
|
Loading…
Reference in New Issue