@fjuhec: Ok, I figured out the Duplicate ID naming problem mentioned above, but it involves altering a few defs inside init.py in the export folder.
Here is what I did, feel free to change or adjust as needed.
At the top of exportMesh we need to create a single name and use it consistently through out all export operations.
# Generate a name for this object.
if passedObjectName == None:
name_to_use = obj.name
else:
name_to_use = passedObjectName
if name_to_use in self.exported_meshes:
self.exported_meshes[name_to_use]['objects'] += [{'obj' : obj, 'mtx' : passedMatrix, <i>'name': name_to_use</i>}]
return False
else:
self.exported_meshes[name_to_use] = {'meshes' : [], 'objects' : [{'obj' : obj, 'mtx' : passedMatrix, <i>'name': name_to_use</i>}]}
I also extended the dictionary (see underline above) to store this name_to_use so other export defs can find the correct name to operate upon and not have to recreate it blindly from the object given.
Further down in exportMesh we need to make sure we keep using the name_to_use.
# Store a list of exported meshes for later use to export shapes
self.exported_meshes[name_to_use]['meshes'] += [{
'loop' : i,
'id' : translate_id(name_to_use),
'shapeIndex' : self.mesh_index,
'material' : mat}]
Now, when exportShape get’s called it can fetch the correct name_to_use.
def exportShape(self, scene, object, data):
obj = object['obj']
mtx = object['mtx']
<i> name_to_use = object['name']</i>
self.openElement('shape', { 'id' : translate_id(data['id']) + '-shape_' + str(self.shape_index), 'type' : 'serialized'})
self.parameter('string', 'filename', {'value' : self.srl_filename})
self.parameter('integer', 'shapeIndex', {'value' : data['shapeIndex']})
if mtx == None:
self.exportWorldTrafo(obj.matrix_world)
else:
self.exportWorldTrafo(mtx)
if data['material'] != None:
if data['material'].mitsuba_emission.use_emission:
<b><i>self.exportEmission(obj,name_to_use)</i></b>
else:
self.element('ref', {'name' : 'bsdf', 'id' : '%s-material' % translate_id(data['material'].name)})
if obj.data.mitsuba_mesh.normals == 'facenormals':
self.parameter('boolean', 'faceNormals', {'value' : 'true'})
self.closeElement()
self.shape_index += 1
And finally….exportEmission is passed the correct name for it’s material.
def exportEmission(self, obj, passedName = None):
if passedName == None:
name_to_use = obj.name
else:
name_to_use = passedName
lamp = obj.data.materials[0].mitsuba_emission
if obj.data.users > 1:
MtsLog("Error: emitters cannot be instantiated!")
return
mult = lamp.intensity
name = translate_id(<i>name_to_use</i>) + "-mesh_0"
print("Using name [%s] for emission." % name)
self.openElement('emitter', { 'id' : '%s-emission' % name, 'type' : 'area'})
self.parameter('float', 'samplingWeight', {'value' : '%f' % lamp.samplingWeight})
self.parameter('rgb', 'radiance', { 'value' : "%f %f %f"
% (lamp.color.r*mult, lamp.color.g*mult, lamp.color.b*mult)})
self.closeElement()
I am attaching the BLEND file for the test scene below. You can find the revised init.py, with all the above mentioned code changes, in the text window of the attached BLEND file. Try rendering the scene with the current Mitsuba exporter. Save the revised _init.py from the attached BLEND file over top the existing one in the export folder of the Mitsuba AddOn. Try rendering again and Mitsuba should render something like this.
Attachments
26_mitsuba_particle_test.blend (144 KB)