-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmainwindow.cpp
70 lines (58 loc) · 2 KB
/
mainwindow.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#include "tdraw.h"
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent), ui(new Ui::MainWindow) {
ui->setupUi(this);
connect(ui->actionReadObjfile, &QAction::triggered, this,
&MainWindow::createModel);
connect(ui->actionWireframe, &QAction::triggered, this,
&MainWindow::rasterize);
}
void MainWindow::createModel() {
QObject *obj = sender();
QString objName = obj->objectName();
// Solicitamos archivo obj
if (!objName.compare(ui->actionReadObjfile->objectName())) {
objfile = QFileDialog::getOpenFileName(this, tr("Open Objfile"),
tr("Files (*.obj)"));
}
model = new TModel(objfile.toStdString());
model->readObjFile(objfile.toStdString());
ui->statusBar->showMessage("Modelo actual: " + objfile);
}
void MainWindow::rasterize() {
QObject *obj = sender();
QString objName = obj->objectName();
// Wireframe
if (!objName.compare(ui->actionWireframe->objectName())) {
// Pedimos datos de las transformaciones a realizar
TDialog *dialog = new TDialog();
if (dialog->exec()) {
dialog->getOptions();
}
/*// Transformaciones
unsigned int imagen[1920 * 1080];
for (int i = 0; i < 1920 * 1080; i++) {
imagen[i] = 0xffffffff;
}
for (auto &i : model->list_vertexes) {
i *= 11;
}
TDraw draw;
TVector4D w1, w2, w3;
TPoint res{1920, 1080};
// Dibujamos en el framebuffer
for (auto &i : model->faces_for_vertexes) {
w1 = model->list_vertexes.at(i.v1 - 1);
w2 = model->list_vertexes.at(i.v2 - 1);
w3 = model->list_vertexes.at(i.v3 - 1);
draw.bresenhamLine(w1.toPoint(), w2.toPoint(), imagen, res);
draw.bresenhamLine(w2.toPoint(), w3.toPoint(), imagen, res);
draw.bresenhamLine(w3.toPoint(), w1.toPoint(), imagen, res);
}
QImage img(reinterpret_cast<unsigned char *>(imagen), 1920, 1080,
QImage::Format_ARGB32_Premultiplied);
img.save("salida.png");
*/
}
}
MainWindow::~MainWindow() { delete ui; }