libpython: make MTS_VERSION/MTS_YEAR available. Documentation: xml serialization for further types

metadata
Wenzel Jakob 2014-03-27 12:36:44 +01:00
parent b942c0de31
commit 7d7e253b8f
2 changed files with 31 additions and 1 deletions

View File

@ -388,8 +388,36 @@ def scene_descr_to_xml(descr):
el = et.SubElement(parent, 'rgb') el = et.SubElement(parent, 'rgb')
el.set('name', key) el.set('name', key)
el.set('value', "%.15g %.15g %.15g" % (r, g, b)) el.set('value', "%.15g %.15g %.15g" % (r, g, b))
elif type(value) is Point:
el = et.SubElement(parent, 'point')
el.set('name', key)
el.set('x', '%.15g' % value.x)
el.set('y', '%.15g' % value.y)
el.set('z', '%.15g' % value.z)
elif type(value) is Vector:
el = et.SubElement(parent, 'vector')
el.set('name', key)
el.set('x', '%.15g' % value.x)
el.set('y', '%.15g' % value.y)
el.set('z', '%.15g' % value.z)
elif type(value) is float:
el = et.SubElement(parent, 'float')
el.set('name', key)
el.set('value', '%.15g' % value)
elif type(value) is int:
el = et.SubElement(parent, 'int')
el.set('name', key)
el.set('value', '%i' % value)
elif type(value) is bool:
el = et.SubElement(parent, 'boolean')
el.set('name', key)
el.set('value', '%s' % ('true' if value else 'false'))
elif type(value) is str:
el = et.SubElement(parent, 'string')
el.set('name', key)
el.set('value', value)
else: else:
return None # (More kinds of attributes need to be supported here..) return None # (More kinds of attributes may need to be supported here..)
return el return el
def dict_to_xml(name, item, parent): def dict_to_xml(name, item, parent):

View File

@ -1060,6 +1060,8 @@ void export_core() {
coreModule.attr("ShadowEpsilon") = ShadowEpsilon; coreModule.attr("ShadowEpsilon") = ShadowEpsilon;
coreModule.attr("DeltaEpsilon") = DeltaEpsilon; coreModule.attr("DeltaEpsilon") = DeltaEpsilon;
coreModule.attr("SPECTRUM_SAMPLES") = SPECTRUM_SAMPLES; coreModule.attr("SPECTRUM_SAMPLES") = SPECTRUM_SAMPLES;
coreModule.attr("MTS_VERSION") = MTS_VERSION;
coreModule.attr("MTS_YEAR") = MTS_YEAR;
bp::class_<Class, boost::noncopyable>("Class", bp::no_init) bp::class_<Class, boost::noncopyable>("Class", bp::no_init)
.def("getName", &Class::getName, BP_RETURN_CONSTREF) .def("getName", &Class::getName, BP_RETURN_CONSTREF)