mtsutil feature is done

metadata
Wenzel Jakob 2010-08-16 17:16:13 +02:00
parent 1867232a89
commit 094a0226b6
5 changed files with 37 additions and 15 deletions

View File

@ -11,7 +11,7 @@ MTS_NAMESPACE_BEGIN
*/
class MTS_EXPORT_RENDER UtilityServices {
public:
virtual Scene *loadScene(const std::string &filename) = 0;
virtual ref<Scene> 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<Scene> loadScene(const std::string &fname) {
return m_utilityServices->loadScene(fname);
}
private:

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -115,9 +115,31 @@ private:
class UtilityServicesImpl : public UtilityServices {
public:
Scene *loadScene(const std::string &filename) {
cout << "asdf" << endl;
return NULL;
ref<Scene> 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<std::string, std::string> parameters;
SceneHandler *handler = new SceneHandler(parameters);
parser->setDoNamespaces(true);
parser->setDocumentHandler(handler);
parser->setErrorHandler(handler);
parser->parse(filename.c_str());
ref<Scene> scene = handler->getScene();
delete parser;
delete handler;
return scene;
}
};