better importer GUI integration

metadata
Wenzel Jakob 2010-08-13 21:09:48 +02:00
parent 7ab003c306
commit 63bb06d7c2
9 changed files with 120 additions and 24 deletions

View File

@ -431,6 +431,14 @@ if hasQt:
qtResources = [qtEnv.Qrc(qrc) for qrc in scanFiles('src/qtgui', ['*.qrc'])]
qtgui_files = scanFiles('src/qtgui', ['*.cpp']) + qtResources + shandler + resources
if hasCollada:
qtgui_files += colladaConverter
if env.has_key('COLLADALIBDIR'):
qtEnv.Append(LIBPATH=env['COLLADALIBDIR'])
if env.has_key('COLLADALIB'):
qtEnv.Append(LIBS=env['COLLADALIB'])
if sys.platform == 'darwin':
qtEnv_osx = qtEnv.Clone();
qtEnv_osx['CXXFLAGS'].remove('-fstrict-aliasing');

View File

@ -791,7 +791,7 @@ void loadCamera(ColladaConverter *cvt, Transform transform, std::ostream &os, do
os << "\t\t\t<matrix value=\"" << matrixValues.substr(0, matrixValues.length()-1) << "\"/>" << endl;
os << "\t\t</transform>" << endl << endl;
os << "\t\t<sampler type=\"ldsampler\">" << endl;
os << "\t\t\t<integer name=\"sampleCount\" value=\"8\"/>" << endl;
os << "\t\t\t<integer name=\"sampleCount\" value=\"" << cvt->m_samplesPerPixel << "\"/>" << endl;
os << "\t\t</sampler>" << endl << endl;
os << "\t\t<film type=\"exrfilm\">" << endl;
os << "\t\t\t<integer name=\"width\" value=\"" << xres << "\"/>" << endl;
@ -1093,7 +1093,7 @@ void ColladaConverter::convert(const std::string &inputFile,
serializer->setErrorHandler(&errorHandler);
XMLFormatTarget *target = new LocalFileFormatTarget(outputFile.c_str());
serializer->writeNode(target, *doc);
delete target;
delete wrapper;
delete memBufIS;
delete serializer;
@ -1105,5 +1105,6 @@ void ColladaConverter::convert(const std::string &inputFile,
ofile << os.str();
ofile.close();
}
m_filename = outputFile;
}

View File

@ -8,6 +8,7 @@ public:
m_srgb = false;
m_mapSmallerSide = true;
m_xres = m_yres = -1;
m_samplesPerPixel = 8;
}
void convert(const std::string &inputFile,
@ -17,10 +18,13 @@ public:
virtual std::string locateResource(const std::string &resource) = 0;
void setSRGB(bool srgb) { m_srgb = srgb; }
void setMapSmallerSide(bool mapSmallerSide) { m_mapSmallerSide = mapSmallerSide; }
void setResolution(int xres, int yres) { m_xres = xres; m_yres = yres; }
inline void setSRGB(bool srgb) { m_srgb = srgb; }
inline void setMapSmallerSide(bool mapSmallerSide) { m_mapSmallerSide = mapSmallerSide; }
inline void setResolution(int xres, int yres) { m_xres = xres; m_yres = yres; }
inline void setSamplesPerPixel(int samplesPerPixel) { m_samplesPerPixel = samplesPerPixel; }
inline const std::string &getFilename() const { return m_filename; }
public:
bool m_srgb, m_mapSmallerSide;
int m_xres, m_yres;
int m_xres, m_yres, m_samplesPerPixel;
std::string m_filename;
};

View File

@ -52,6 +52,7 @@ void help() {
<< "Syntax: mtsimport [options] <DAE source file> <XML destination file> [Adjustment file]" << endl
<< "Options/Arguments:" << endl
<< " -h Display this help text" << endl << endl
<< " -p <num> Use the specified number of samples per pixel." << endl << endl
<< " -s Assume that colors are in sRGB space." << endl << endl
<< " -m Map the larger image side to the full field of view" << endl << endl
<< " -r <w>x<h> Override the image resolution to e.g. 1920×1080" << endl << endl
@ -62,10 +63,11 @@ int colladaMain(int argc, char **argv) {
bool srgb = false, mapSmallerSide = true;
char optchar, *end_ptr = NULL;
int xres = -1, yres = -1;
int samplesPerPixel = 8;
optind = 1;
while ((optchar = getopt(argc, argv, "shmr:")) != -1) {
while ((optchar = getopt(argc, argv, "shmr:p:")) != -1) {
switch (optchar) {
case 's':
srgb = true;
@ -73,6 +75,11 @@ int colladaMain(int argc, char **argv) {
case 'm':
mapSmallerSide = false;
break;
case 'p':
samplesPerPixel = strtol(optarg, &end_ptr, 10);
if (*end_ptr != '\0')
SLog(EError, "Invalid number of samples per pixel!");
break;
case 'r': {
std::vector<std::string> tokens = tokenize(optarg, "x");
if (tokens.size() != 2)
@ -101,6 +108,7 @@ int colladaMain(int argc, char **argv) {
converter.setSRGB(srgb);
converter.setResolution(xres, yres);
converter.setMapSmallerSide(mapSmallerSide);
converter.setSamplesPerPixel(samplesPerPixel);
converter.convert(argv[optind], "", argv[optind+1], argc > optind+2 ? argv[optind+2] : "");
return 0;

View File

@ -4,9 +4,9 @@ MTS_NAMESPACE_BEGIN
/**
* Extended path tracer -- uses multiple importance sampling to combine
* two sampling strategies, namely BSDF and luminaire sampling. This class also
* supports volumetric absorption, but does not attempt to solve the
* full radiative transfer equation (see <tt>volpath</tt> if this is needed).
* two sampling strategies, namely BSDF and luminaire sampling.
* This class does not attempt to solve the full radiative transfer
* equation (see <tt>volpath</tt> if this is needed).
*/
class MIPathTracer : public MonteCarloIntegrator {
public:
@ -63,7 +63,7 @@ public:
/* Estimate the direct illumination if this is requested */
if (rRec.type & RadianceQueryRecord::EDirectRadiance &&
scene->sampleLuminaireAttenuated(its, lRec, rRec.nextSample2D())) {
scene->sampleLuminaire(its, lRec, rRec.nextSample2D())) {
/* Allocate a record for querying the BSDF */
const BSDFQueryRecord bRec(rRec, its, its.toLocal(-lRec.d));
@ -101,7 +101,6 @@ public:
bool hitLuminaire = false;
if (scene->rayIntersect(ray, its)) {
ray.mint = 0; ray.maxt = its.t;
pathThroughput *= scene->getAttenuation(ray);
/* Intersected something - check if it was a luminaire */
if (its.isLuminaire()) {
lRec = LuminaireSamplingRecord(its, -ray.d);
@ -114,7 +113,6 @@ public:
lRec.luminaire = scene->getBackgroundLuminaire();
lRec.d = -ray.d;
hitLuminaire = true;
pathThroughput *= scene->getAttenuation(ray);
} else {
break;
}

View File

@ -173,10 +173,11 @@ void GLProgram::setParameter(int id, const GPUTexture *value) {
if (id == -1)
return;
const std::set<int> &units = value->getTextureUnits();
Assert(units.size() > 0);
int unit = *(units.begin());
glUniform1i(id, unit);
if (units.size() > 0)
glUniform1i(id, *(units.begin()));
else
Log(EWarn, "Unable to supply unbound texture \"%s\" to shader \"%s\"",
value->getName().c_str(), getName().c_str());
}
void GLProgram::setParameter(int id, const Transform &trafo) {

View File

@ -67,7 +67,7 @@ public:
parent->configure();
m_surfaceArea = m_shape->getSurfaceArea();
} else {
Log(EError, "An portal light source must be child of a shape instance");
Log(EError, "A portal light source must be child of a shape instance");
}
}

View File

@ -1,6 +1,20 @@
#include "ui_importdlg.h"
#include "importdlg.h"
#include "acknowledgmentdlg.h"
#include "../collada/converter.h"
#include "mainwindow.h"
class GUIColladaConverter : public ColladaConverter {
public:
inline GUIColladaConverter(QWidget *parent) : m_parent(parent) {
}
std::string locateResource(const std::string &resource) {
return "";
}
private:
QWidget *m_parent;
};
ImportDialog::ImportDialog(QWidget *parent) :
QDialog(parent, Qt::Sheet),
@ -31,6 +45,7 @@ void ImportDialog::on_inputBrowse_clicked(bool checked) {
dialog.setAcceptMode(QFileDialog::AcceptOpen);
dialog.setViewMode(QFileDialog::Detail);
dialog.setWindowModality(Qt::ApplicationModal);
if (dialog.exec()) {
QString fname = dialog.selectedFiles()[0];
ui->inputEdit->setText(fname);
@ -82,6 +97,21 @@ void ImportDialog::accept() {
QDialog::accept();
QString sourceFile = ui->inputEdit->text();
QString targetScene = ui->sceneEdit->text();
QString directory = ui->directoryEdit->text();
QString targetScene = ui->sceneEdit->text();
QString adjustmentFile = ui->adjustmentEdit->text();
GUIColladaConverter cvt(this);
cvt.setSRGB(ui->sRGBButton->isChecked());
try {
cvt.convert(sourceFile.toStdString(), directory.toStdString(),
targetScene.toStdString(), adjustmentFile.toStdString());
((MainWindow *) parent())->loadFile(QString(cvt.getFilename().c_str()));
} catch (const std::exception &ex) {
SLog(EWarn, "Conversion failed: %s", ex.what());
QMessageBox::critical(this, tr("COLLADA 1.4 import"),
tr("Conversion failed -- please see the log for details."),
QMessageBox::Ok);
}
}

View File

@ -6,12 +6,12 @@
<rect>
<x>0</x>
<y>0</y>
<width>357</width>
<height>250</height>
<width>353</width>
<height>273</height>
</rect>
</property>
<property name="windowTitle">
<string>Import COLLADA ..</string>
<string>Import COLLADA 1.4 ..</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0" colspan="5">
@ -197,7 +197,7 @@
</property>
</widget>
</item>
<item row="6" column="2" colspan="3">
<item row="7" column="2" colspan="3">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
@ -210,7 +210,7 @@
</property>
</spacer>
</item>
<item row="7" column="1" colspan="5">
<item row="8" column="1" colspan="5">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
@ -220,6 +220,52 @@
</property>
</widget>
</item>
<item row="6" column="1" colspan="2">
<widget class="QLabel" name="label_7">
<property name="text">
<string>Color interpretation :</string>
</property>
</widget>
</item>
<item row="6" column="4" colspan="2">
<widget class="QWidget" name="widget" native="true">
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="QRadioButton" name="linearButton">
<property name="text">
<string>Linear</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="sRGBButton">
<property name="text">
<string>sRGB</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>5</width>
<height>5</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<resources/>