better importer GUI integration
parent
7ab003c306
commit
63bb06d7c2
|
@ -431,6 +431,14 @@ if hasQt:
|
||||||
qtResources = [qtEnv.Qrc(qrc) for qrc in scanFiles('src/qtgui', ['*.qrc'])]
|
qtResources = [qtEnv.Qrc(qrc) for qrc in scanFiles('src/qtgui', ['*.qrc'])]
|
||||||
|
|
||||||
qtgui_files = scanFiles('src/qtgui', ['*.cpp']) + qtResources + shandler + resources
|
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':
|
if sys.platform == 'darwin':
|
||||||
qtEnv_osx = qtEnv.Clone();
|
qtEnv_osx = qtEnv.Clone();
|
||||||
qtEnv_osx['CXXFLAGS'].remove('-fstrict-aliasing');
|
qtEnv_osx['CXXFLAGS'].remove('-fstrict-aliasing');
|
||||||
|
|
|
@ -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\t<matrix value=\"" << matrixValues.substr(0, matrixValues.length()-1) << "\"/>" << endl;
|
||||||
os << "\t\t</transform>" << endl << endl;
|
os << "\t\t</transform>" << endl << endl;
|
||||||
os << "\t\t<sampler type=\"ldsampler\">" << 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</sampler>" << endl << endl;
|
||||||
os << "\t\t<film type=\"exrfilm\">" << endl;
|
os << "\t\t<film type=\"exrfilm\">" << endl;
|
||||||
os << "\t\t\t<integer name=\"width\" value=\"" << xres << "\"/>" << 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);
|
serializer->setErrorHandler(&errorHandler);
|
||||||
XMLFormatTarget *target = new LocalFileFormatTarget(outputFile.c_str());
|
XMLFormatTarget *target = new LocalFileFormatTarget(outputFile.c_str());
|
||||||
serializer->writeNode(target, *doc);
|
serializer->writeNode(target, *doc);
|
||||||
|
delete target;
|
||||||
delete wrapper;
|
delete wrapper;
|
||||||
delete memBufIS;
|
delete memBufIS;
|
||||||
delete serializer;
|
delete serializer;
|
||||||
|
@ -1105,5 +1105,6 @@ void ColladaConverter::convert(const std::string &inputFile,
|
||||||
ofile << os.str();
|
ofile << os.str();
|
||||||
ofile.close();
|
ofile.close();
|
||||||
}
|
}
|
||||||
|
m_filename = outputFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,7 @@ public:
|
||||||
m_srgb = false;
|
m_srgb = false;
|
||||||
m_mapSmallerSide = true;
|
m_mapSmallerSide = true;
|
||||||
m_xres = m_yres = -1;
|
m_xres = m_yres = -1;
|
||||||
|
m_samplesPerPixel = 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
void convert(const std::string &inputFile,
|
void convert(const std::string &inputFile,
|
||||||
|
@ -17,10 +18,13 @@ public:
|
||||||
|
|
||||||
virtual std::string locateResource(const std::string &resource) = 0;
|
virtual std::string locateResource(const std::string &resource) = 0;
|
||||||
|
|
||||||
void setSRGB(bool srgb) { m_srgb = srgb; }
|
inline void setSRGB(bool srgb) { m_srgb = srgb; }
|
||||||
void setMapSmallerSide(bool mapSmallerSide) { m_mapSmallerSide = mapSmallerSide; }
|
inline void setMapSmallerSide(bool mapSmallerSide) { m_mapSmallerSide = mapSmallerSide; }
|
||||||
void setResolution(int xres, int yres) { m_xres = xres; m_yres = yres; }
|
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:
|
public:
|
||||||
bool m_srgb, m_mapSmallerSide;
|
bool m_srgb, m_mapSmallerSide;
|
||||||
int m_xres, m_yres;
|
int m_xres, m_yres, m_samplesPerPixel;
|
||||||
|
std::string m_filename;
|
||||||
};
|
};
|
||||||
|
|
|
@ -52,6 +52,7 @@ void help() {
|
||||||
<< "Syntax: mtsimport [options] <DAE source file> <XML destination file> [Adjustment file]" << endl
|
<< "Syntax: mtsimport [options] <DAE source file> <XML destination file> [Adjustment file]" << endl
|
||||||
<< "Options/Arguments:" << endl
|
<< "Options/Arguments:" << endl
|
||||||
<< " -h Display this help text" << endl << 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
|
<< " -s Assume that colors are in sRGB space." << endl << endl
|
||||||
<< " -m Map the larger image side to the full field of view" << 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
|
<< " -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;
|
bool srgb = false, mapSmallerSide = true;
|
||||||
char optchar, *end_ptr = NULL;
|
char optchar, *end_ptr = NULL;
|
||||||
int xres = -1, yres = -1;
|
int xres = -1, yres = -1;
|
||||||
|
int samplesPerPixel = 8;
|
||||||
|
|
||||||
optind = 1;
|
optind = 1;
|
||||||
|
|
||||||
while ((optchar = getopt(argc, argv, "shmr:")) != -1) {
|
while ((optchar = getopt(argc, argv, "shmr:p:")) != -1) {
|
||||||
switch (optchar) {
|
switch (optchar) {
|
||||||
case 's':
|
case 's':
|
||||||
srgb = true;
|
srgb = true;
|
||||||
|
@ -73,6 +75,11 @@ int colladaMain(int argc, char **argv) {
|
||||||
case 'm':
|
case 'm':
|
||||||
mapSmallerSide = false;
|
mapSmallerSide = false;
|
||||||
break;
|
break;
|
||||||
|
case 'p':
|
||||||
|
samplesPerPixel = strtol(optarg, &end_ptr, 10);
|
||||||
|
if (*end_ptr != '\0')
|
||||||
|
SLog(EError, "Invalid number of samples per pixel!");
|
||||||
|
break;
|
||||||
case 'r': {
|
case 'r': {
|
||||||
std::vector<std::string> tokens = tokenize(optarg, "x");
|
std::vector<std::string> tokens = tokenize(optarg, "x");
|
||||||
if (tokens.size() != 2)
|
if (tokens.size() != 2)
|
||||||
|
@ -101,6 +108,7 @@ int colladaMain(int argc, char **argv) {
|
||||||
converter.setSRGB(srgb);
|
converter.setSRGB(srgb);
|
||||||
converter.setResolution(xres, yres);
|
converter.setResolution(xres, yres);
|
||||||
converter.setMapSmallerSide(mapSmallerSide);
|
converter.setMapSmallerSide(mapSmallerSide);
|
||||||
|
converter.setSamplesPerPixel(samplesPerPixel);
|
||||||
converter.convert(argv[optind], "", argv[optind+1], argc > optind+2 ? argv[optind+2] : "");
|
converter.convert(argv[optind], "", argv[optind+1], argc > optind+2 ? argv[optind+2] : "");
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -4,9 +4,9 @@ MTS_NAMESPACE_BEGIN
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Extended path tracer -- uses multiple importance sampling to combine
|
* Extended path tracer -- uses multiple importance sampling to combine
|
||||||
* two sampling strategies, namely BSDF and luminaire sampling. This class also
|
* two sampling strategies, namely BSDF and luminaire sampling.
|
||||||
* supports volumetric absorption, but does not attempt to solve the
|
* This class does not attempt to solve the full radiative transfer
|
||||||
* full radiative transfer equation (see <tt>volpath</tt> if this is needed).
|
* equation (see <tt>volpath</tt> if this is needed).
|
||||||
*/
|
*/
|
||||||
class MIPathTracer : public MonteCarloIntegrator {
|
class MIPathTracer : public MonteCarloIntegrator {
|
||||||
public:
|
public:
|
||||||
|
@ -63,7 +63,7 @@ public:
|
||||||
|
|
||||||
/* Estimate the direct illumination if this is requested */
|
/* Estimate the direct illumination if this is requested */
|
||||||
if (rRec.type & RadianceQueryRecord::EDirectRadiance &&
|
if (rRec.type & RadianceQueryRecord::EDirectRadiance &&
|
||||||
scene->sampleLuminaireAttenuated(its, lRec, rRec.nextSample2D())) {
|
scene->sampleLuminaire(its, lRec, rRec.nextSample2D())) {
|
||||||
/* Allocate a record for querying the BSDF */
|
/* Allocate a record for querying the BSDF */
|
||||||
const BSDFQueryRecord bRec(rRec, its, its.toLocal(-lRec.d));
|
const BSDFQueryRecord bRec(rRec, its, its.toLocal(-lRec.d));
|
||||||
|
|
||||||
|
@ -101,7 +101,6 @@ public:
|
||||||
bool hitLuminaire = false;
|
bool hitLuminaire = false;
|
||||||
if (scene->rayIntersect(ray, its)) {
|
if (scene->rayIntersect(ray, its)) {
|
||||||
ray.mint = 0; ray.maxt = its.t;
|
ray.mint = 0; ray.maxt = its.t;
|
||||||
pathThroughput *= scene->getAttenuation(ray);
|
|
||||||
/* Intersected something - check if it was a luminaire */
|
/* Intersected something - check if it was a luminaire */
|
||||||
if (its.isLuminaire()) {
|
if (its.isLuminaire()) {
|
||||||
lRec = LuminaireSamplingRecord(its, -ray.d);
|
lRec = LuminaireSamplingRecord(its, -ray.d);
|
||||||
|
@ -114,7 +113,6 @@ public:
|
||||||
lRec.luminaire = scene->getBackgroundLuminaire();
|
lRec.luminaire = scene->getBackgroundLuminaire();
|
||||||
lRec.d = -ray.d;
|
lRec.d = -ray.d;
|
||||||
hitLuminaire = true;
|
hitLuminaire = true;
|
||||||
pathThroughput *= scene->getAttenuation(ray);
|
|
||||||
} else {
|
} else {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -173,10 +173,11 @@ void GLProgram::setParameter(int id, const GPUTexture *value) {
|
||||||
if (id == -1)
|
if (id == -1)
|
||||||
return;
|
return;
|
||||||
const std::set<int> &units = value->getTextureUnits();
|
const std::set<int> &units = value->getTextureUnits();
|
||||||
Assert(units.size() > 0);
|
if (units.size() > 0)
|
||||||
int unit = *(units.begin());
|
glUniform1i(id, *(units.begin()));
|
||||||
|
else
|
||||||
glUniform1i(id, unit);
|
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) {
|
void GLProgram::setParameter(int id, const Transform &trafo) {
|
||||||
|
|
|
@ -67,7 +67,7 @@ public:
|
||||||
parent->configure();
|
parent->configure();
|
||||||
m_surfaceArea = m_shape->getSurfaceArea();
|
m_surfaceArea = m_shape->getSurfaceArea();
|
||||||
} else {
|
} 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");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,20 @@
|
||||||
#include "ui_importdlg.h"
|
#include "ui_importdlg.h"
|
||||||
#include "importdlg.h"
|
#include "importdlg.h"
|
||||||
#include "acknowledgmentdlg.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) :
|
ImportDialog::ImportDialog(QWidget *parent) :
|
||||||
QDialog(parent, Qt::Sheet),
|
QDialog(parent, Qt::Sheet),
|
||||||
|
@ -31,6 +45,7 @@ void ImportDialog::on_inputBrowse_clicked(bool checked) {
|
||||||
dialog.setAcceptMode(QFileDialog::AcceptOpen);
|
dialog.setAcceptMode(QFileDialog::AcceptOpen);
|
||||||
dialog.setViewMode(QFileDialog::Detail);
|
dialog.setViewMode(QFileDialog::Detail);
|
||||||
dialog.setWindowModality(Qt::ApplicationModal);
|
dialog.setWindowModality(Qt::ApplicationModal);
|
||||||
|
|
||||||
if (dialog.exec()) {
|
if (dialog.exec()) {
|
||||||
QString fname = dialog.selectedFiles()[0];
|
QString fname = dialog.selectedFiles()[0];
|
||||||
ui->inputEdit->setText(fname);
|
ui->inputEdit->setText(fname);
|
||||||
|
@ -82,6 +97,21 @@ void ImportDialog::accept() {
|
||||||
QDialog::accept();
|
QDialog::accept();
|
||||||
|
|
||||||
QString sourceFile = ui->inputEdit->text();
|
QString sourceFile = ui->inputEdit->text();
|
||||||
QString targetScene = ui->sceneEdit->text();
|
|
||||||
QString directory = ui->directoryEdit->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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,12 +6,12 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>357</width>
|
<width>353</width>
|
||||||
<height>250</height>
|
<height>273</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>Import COLLADA ..</string>
|
<string>Import COLLADA 1.4 ..</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout">
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
<item row="0" column="0" colspan="5">
|
<item row="0" column="0" colspan="5">
|
||||||
|
@ -197,7 +197,7 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="6" column="2" colspan="3">
|
<item row="7" column="2" colspan="3">
|
||||||
<spacer name="verticalSpacer">
|
<spacer name="verticalSpacer">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Vertical</enum>
|
<enum>Qt::Vertical</enum>
|
||||||
|
@ -210,7 +210,7 @@
|
||||||
</property>
|
</property>
|
||||||
</spacer>
|
</spacer>
|
||||||
</item>
|
</item>
|
||||||
<item row="7" column="1" colspan="5">
|
<item row="8" column="1" colspan="5">
|
||||||
<widget class="QDialogButtonBox" name="buttonBox">
|
<widget class="QDialogButtonBox" name="buttonBox">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Horizontal</enum>
|
<enum>Qt::Horizontal</enum>
|
||||||
|
@ -220,6 +220,52 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</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>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<resources/>
|
<resources/>
|
||||||
|
|
Loading…
Reference in New Issue