mirror of
https://github.com/ConjureETS/LOG750-LAB2.git
synced 2026-03-24 03:21:19 +00:00
Phong Toggle
This commit is contained in:
parent
e7c2dc3e63
commit
d1ed0a00dd
@ -159,7 +159,23 @@
|
|||||||
</property>
|
</property>
|
||||||
<addaction name="action_Quit"/>
|
<addaction name="action_Quit"/>
|
||||||
</widget>
|
</widget>
|
||||||
|
<widget class="QMenu" name="menuAffichage">
|
||||||
|
<property name="title">
|
||||||
|
<string>Affichage</string>
|
||||||
|
</property>
|
||||||
|
<widget class="QMenu" name="menuInterpolation">
|
||||||
|
<property name="title">
|
||||||
|
<string>Interpolation</string>
|
||||||
|
</property>
|
||||||
|
<addaction name="actionPhong"/>
|
||||||
|
<addaction name="actionGouraud"/>
|
||||||
|
</widget>
|
||||||
|
<addaction name="actionTextures"/>
|
||||||
|
<addaction name="separator"/>
|
||||||
|
<addaction name="menuInterpolation"/>
|
||||||
|
</widget>
|
||||||
<addaction name="menu_File"/>
|
<addaction name="menu_File"/>
|
||||||
|
<addaction name="menuAffichage"/>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QStatusBar" name="statusBar">
|
<widget class="QStatusBar" name="statusBar">
|
||||||
<property name="enabled">
|
<property name="enabled">
|
||||||
@ -174,6 +190,36 @@
|
|||||||
<string>Esc</string>
|
<string>Esc</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
|
<action name="actionTextures">
|
||||||
|
<property name="checkable">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="checked">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Textures</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="actionPhong">
|
||||||
|
<property name="checkable">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="checked">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Phong</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="actionGouraud">
|
||||||
|
<property name="checkable">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Gouraud</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
</widget>
|
</widget>
|
||||||
<layoutdefault spacing="6" margin="11"/>
|
<layoutdefault spacing="6" margin="11"/>
|
||||||
<resources/>
|
<resources/>
|
||||||
|
|||||||
@ -506,6 +506,13 @@ void Viewer::visit(SceneGroup &s)
|
|||||||
modelStack.pop();
|
modelStack.pop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Viewer::setPhong(bool on) {
|
||||||
|
m_program->setUniformValue(m_isPhongLoc, on);
|
||||||
|
if(on) std::cout << "Phong ON\n";
|
||||||
|
else std::cout << "Phong OFF\n";
|
||||||
|
this->update();
|
||||||
|
}
|
||||||
|
|
||||||
void Viewer::changeColor(QColor c){
|
void Viewer::changeColor(QColor c){
|
||||||
if(activeCell->getChildren()->size()){
|
if(activeCell->getChildren()->size()){
|
||||||
Shape* shape = dynamic_cast<Shape*> (activeCell->childAt(0));
|
Shape* shape = dynamic_cast<Shape*> (activeCell->childAt(0));
|
||||||
|
|||||||
@ -52,6 +52,7 @@ public:
|
|||||||
public slots:
|
public slots:
|
||||||
void cleanup();
|
void cleanup();
|
||||||
void changeColor(QColor);
|
void changeColor(QColor);
|
||||||
|
void setPhong(bool);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
int shapeSelected(int);
|
int shapeSelected(int);
|
||||||
|
|||||||
@ -2,14 +2,23 @@
|
|||||||
#include "ui_mainwindow.h"
|
#include "ui_mainwindow.h"
|
||||||
#include <QBoxLayout>
|
#include <QBoxLayout>
|
||||||
#include <QColorDialog>
|
#include <QColorDialog>
|
||||||
|
#include <QActionGroup>
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
Viewer* view;
|
||||||
|
}
|
||||||
|
|
||||||
MainWindow::MainWindow(QWidget *parent) :
|
MainWindow::MainWindow(QWidget *parent) :
|
||||||
QMainWindow(parent),
|
QMainWindow(parent),
|
||||||
ui(new Ui::MainWindow),
|
ui(new Ui::MainWindow),
|
||||||
colordialog(new QColorDialog)
|
colordialog(new QColorDialog)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
|
lightTypeGroup = new QActionGroup(this);
|
||||||
|
lightTypeGroup->addAction(ui->actionGouraud);
|
||||||
|
lightTypeGroup->addAction(ui->actionPhong);
|
||||||
|
|
||||||
connect(ui->pushButton, SIGNAL(clicked(bool)), this, SLOT(onColorPickerActivate()));
|
connect(ui->pushButton, SIGNAL(clicked(bool)), this, SLOT(onColorPickerActivate()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -24,6 +33,8 @@ void MainWindow::addViewer(Viewer* viewer)
|
|||||||
layout->addWidget(viewer);
|
layout->addWidget(viewer);
|
||||||
ui->frame->setLayout(layout);
|
ui->frame->setLayout(layout);
|
||||||
|
|
||||||
|
// actionGouraud shouldn't need one, since they are mutual
|
||||||
|
connect(ui->actionPhong, SIGNAL(toggled(bool)), viewer, SLOT(setPhong(bool)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::onColorPickerActivate(){
|
void MainWindow::onColorPickerActivate(){
|
||||||
|
|||||||
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
#include <QMainWindow>
|
#include <QMainWindow>
|
||||||
#include <QColorDialog>
|
#include <QColorDialog>
|
||||||
|
#include <QActionGroup>
|
||||||
#include "src/viewer/simpleViewer.h"
|
#include "src/viewer/simpleViewer.h"
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
@ -21,10 +22,12 @@ public:
|
|||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void onColorPickerActivate();
|
void onColorPickerActivate();
|
||||||
|
//void onTextureToggle();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::MainWindow *ui;
|
Ui::MainWindow *ui;
|
||||||
QColorDialog *colordialog;
|
QColorDialog *colordialog;
|
||||||
|
QActionGroup *lightTypeGroup;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // MAINWINDOW_H
|
#endif // MAINWINDOW_H
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user