Photorealism
-
I'm interested in creating photorealistic gauges for a dashboard. I've searched around and haven't (yet) seen this being done with QT. I'm guessing it isn't as simple as animating a needle over an image of a gauge to create a 'realistic' looking one? Not sure how I would even start!
I would appreciate hearing thoughts on how this might be possible, or pointers to where it has already been done.
Thanks!
-
-
I'm interested in creating photorealistic gauges for a dashboard. I've searched around and haven't (yet) seen this being done with QT. I'm guessing it isn't as simple as animating a needle over an image of a gauge to create a 'realistic' looking one? Not sure how I would even start!
I would appreciate hearing thoughts on how this might be possible, or pointers to where it has already been done.
Thanks!
-
Thanks for the replies.
By photo-realistic what I mean is, the gauge looks like it could be, say, the tachometer out of a Ferrari Dino, because it is an actual photo of a Dino tachometer (*.png, or *.jpg for example), only the pointer responds to input from software. I think I've seen this done in a flight simulator a while back, but I can't remember which.
@aha_1980 I appreciate the link to the QT dashboard, its very interesting, but it isn't quite what I mean. those gauges are drawn programmatically, like from the gauge library. I hope I'm describing the distinction I'm trying for clearly enough!
-Scott
-
Hi
It really depend on the photos how you
would paint the pointer as to look good.
If you are skilled with 3D software, its possible to render a really
authentic look version. -
Okay - I managed to put a needle onto a photo of a gauge that I downloaded and photo-edited the original needle out of:
Original:
Mine:
Here is the code I kluged together:
#include "mainwindow.h" #include "ui_mainwindow.h" #include "QBitmap" #include "QPainter" #include "QTime" #include <QtGui> //#include "rasterwindow.h" /*class gaugeWindow //{ //public: // gaugeWindow(); //protected: // void timerEvent(QTimerEvent *); // void render(QPainter *painter); //private: // int m_timerId; //}; //gaugeWindow::gaugeWindow() { // m_timerId = startTimer(1000); //} //void gaugeWindow::timerEvent() { // if (event->timerId() == m_timerId) // renderLater(); //} */ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); static const QPoint needle[3] = { QPoint(7, 8), QPoint(-7, 8), QPoint(0, -70) }; QColor needleColor(0, 0, 0); //QLabel lblRpm; QPixmap pixmap("C:\\Users\\scott\\Documents\\Qt\\Gauge_Test\\RPM_Gauge_no_needle.png"); QPainter painter(&pixmap); //painter.setPen(needleColor); painter.setRenderHint(QPainter::Antialiasing); painter.translate(151, 146); //center painter.setPen(Qt::NoPen); painter.setBrush(needleColor); painter.save(); painter.rotate(angle); //degrees painter.drawConvexPolygon(needle, 3); painter.restore(); ui->lblRpm->setPixmap(pixmap); ui->lblRpm->setMask(pixmap.mask()); ui->lblRpm->show(); } //int MainWindow::updateAngle(int angle) //{ // int newAngle = -90; // for (int i=0; i<180; i++) { // newAngle += 1; // } // return angle; //} MainWindow::~MainWindow() { delete ui; }
Now I'm trying to figure out how to attach the needle to something that will let me update it on the fly for demonstration, like a timer, or a slider. I would appreciate if someone could give me a pointer (HA!) towards some way to make that work...
Thanks!!
-
Hi
Looking good.
Convert it to a custom widget, give it a setSpeed slot and
hook slot up to a timer to make it do something.