diff --git a/include/mitsuba/render/util.h b/include/mitsuba/render/util.h index 4046f746..9cf76c4f 100644 --- a/include/mitsuba/render/util.h +++ b/include/mitsuba/render/util.h @@ -11,7 +11,7 @@ MTS_NAMESPACE_BEGIN */ class MTS_EXPORT_RENDER UtilityServices { public: - virtual Scene *loadScene(const std::string &filename) = 0; + virtual ref loadScene(const std::string &filename) = 0; }; /** \brief Abstract utility class -- can be used to implement @@ -38,7 +38,7 @@ protected: virtual ~Utility() { } /// Load a scene - inline Scene *loadScene(const std::string &fname) { + inline ref loadScene(const std::string &fname) { return m_utilityServices->loadScene(fname); } private: diff --git a/src/bsdfs/microfacet.cpp b/src/bsdfs/microfacet.cpp index 0dae7323..84820bbd 100644 --- a/src/bsdfs/microfacet.cpp +++ b/src/bsdfs/microfacet.cpp @@ -260,7 +260,7 @@ public: std::string toString() const { std::ostringstream oss; - oss << "Microfacet[" + oss << "Microfacet[" << endl << " diffuseReflectance = " << indent(m_diffuseReflectance->toString()) << "," << endl << " specularReflectance = " << indent(m_specularReflectance->toString()) << "," << endl << " intIOR = " << m_intIOR << "," << endl diff --git a/src/bsdfs/phong.cpp b/src/bsdfs/phong.cpp index a7d27af1..a6077d75 100644 --- a/src/bsdfs/phong.cpp +++ b/src/bsdfs/phong.cpp @@ -219,7 +219,7 @@ public: std::string toString() const { std::ostringstream oss; - oss << "Phong[" + oss << "Phong[" << endl << " diffuseReflectance = " << indent(m_diffuseReflectance->toString()) << "," << endl << " specularReflectance = " << indent(m_specularReflectance->toString()) << "," << endl << " exponent = " << m_exponent << endl diff --git a/src/bsdfs/roughmetal.cpp b/src/bsdfs/roughmetal.cpp index df8b0dc3..c8102b07 100644 --- a/src/bsdfs/roughmetal.cpp +++ b/src/bsdfs/roughmetal.cpp @@ -3,7 +3,7 @@ MTS_NAMESPACE_BEGIN /** - * Microfacet BRDF model based on + * Rough metal BRDF model based on * "Microfacet Models for Refraction through Rough Surfaces" * by Bruce Walter, Stephen R. Marschner, Hongsong Li * and Kenneth E. Torrance. @@ -11,9 +11,9 @@ MTS_NAMESPACE_BEGIN * This is similar to the 'microfacet' implementation, but * the Fresnel term is now that of a conductor. */ -class Microfacet : public BSDF { +class RoughMetal : public BSDF { public: - Microfacet(const Properties &props) + RoughMetal(const Properties &props) : BSDF(props) { m_specularReflectance = props.getSpectrum("specularReflectance", Spectrum(1.0f)); @@ -27,7 +27,7 @@ public: m_usesRayDifferentials = false; } - Microfacet(Stream *stream, InstanceManager *manager) + RoughMetal(Stream *stream, InstanceManager *manager) : BSDF(stream, manager) { m_specularReflectance = Spectrum(stream); m_alphaB = stream->readFloat(); @@ -40,7 +40,7 @@ public: m_usesRayDifferentials = false; } - virtual ~Microfacet() { + virtual ~RoughMetal() { delete[] m_type; } @@ -156,7 +156,7 @@ public: std::string toString() const { std::ostringstream oss; - oss << "Microfacet[" + oss << "RoughMetal[" << endl << " specularReflectance=" << m_specularReflectance.toString() << "," << std::endl << ", ior=" << m_ior.toString() << "," << std::endl << ", k=" << m_k.toString() << "," << std::endl @@ -172,6 +172,6 @@ private: Spectrum m_ior, m_k; }; -MTS_IMPLEMENT_CLASS_S(Microfacet, false, BSDF) -MTS_EXPORT_PLUGIN(Microfacet, "Microfacet BRDF"); +MTS_IMPLEMENT_CLASS_S(RoughMetal, false, BSDF) +MTS_EXPORT_PLUGIN(RoughMetal, "Rough metal BRDF"); MTS_NAMESPACE_END diff --git a/src/mitsuba/mtsutil.cpp b/src/mitsuba/mtsutil.cpp index 4b8010b3..11628c55 100644 --- a/src/mitsuba/mtsutil.cpp +++ b/src/mitsuba/mtsutil.cpp @@ -115,9 +115,31 @@ private: class UtilityServicesImpl : public UtilityServices { public: - Scene *loadScene(const std::string &filename) { - cout << "asdf" << endl; - return NULL; + ref loadScene(const std::string &filename) { + /* Prepare for parsing scene descriptions */ + FileResolver *resolver = FileResolver::getInstance(); + SAXParser* parser = new SAXParser(); + std::string schemaPath = resolver->resolveAbsolute("schema/scene.xsd"); + + /* Check against the 'scene.xsd' XML Schema */ + parser->setDoSchema(true); + parser->setValidationSchemaFullChecking(true); + parser->setValidationScheme(SAXParser::Val_Always); + parser->setExternalNoNamespaceSchemaLocation(schemaPath.c_str()); + + std::map parameters; + SceneHandler *handler = new SceneHandler(parameters); + parser->setDoNamespaces(true); + parser->setDocumentHandler(handler); + parser->setErrorHandler(handler); + + parser->parse(filename.c_str()); + ref scene = handler->getScene(); + + delete parser; + delete handler; + + return scene; } };