parameters: (self)
docstring: Main method to write the blender scene into Nori format
docstring_summary: Main method to write the blender scene into Nori format
docstring_tokens: Main method to write the blender scene into Nori format
function: def write(self):
          """Main method to write the blender scene into Nori format"""
  
          n_samples = 32
          # create xml document
          self.doc = Document()
          self.scene = self.doc.createElement("scene")
          self.doc.appendChild(self.scene)
  
          # 1) write integrator configuration
          self.scene.appendChild(self.create_xml_element("integrator", {"type": "normals"}))
  
          # 2) write sampler
          sampler = self.create_xml_element("sampler", {"type": "independent"})
          sampler.appendChild(self.create_xml_element("integer", {"name": "sampleCount", "value": str(n_samples)}))
          self.scene.appendChild(sampler)
  
          # 3) export one camera
          cameras = [cam for cam in self.context.scene.objects
                     if cam.type in {'CAMERA'}]
          if(len(cameras) == 0):
              print("WARN: No camera to export")
          else:
              if(len(cameras) > 1):
                  print("WARN: Does not handle multiple camera, only export the active one")
              self.scene.appendChild(self.write_camera(self.context.scene.camera))  # export the active one
  
          # 4) export all meshes
          if not os.path.exists(self.working_dir + "/meshes"):
              os.makedirs(self.working_dir + "/meshes")
  
          meshes = [obj for obj in self.context.scene.objects
                    if obj.type in {'MESH', 'FONT', 'SURFACE', 'META'}]
          print(meshes)
          for mesh in meshes:
              self.write_mesh(mesh)
  
          # 6) write the xml file
          self.doc.writexml(open(self.filepath, "w"), "", "\t", "\n")
function_tokens: def write ( self ) : n_samples = 32 # create xml document self . doc = Document ( ) self . scene = self . doc . createElement ( "scene" ) self . doc . appendChild ( self . scene ) # 1) write integrator configuration self . scene . appendChild ( self . create_xml_element ( "integrator" , { "type" : "normals" } ) ) # 2) write sampler sampler = self . create_xml_element ( "sampler" , { "type" : "independent" } ) sampler . appendChild ( self . create_xml_element ( "integer" , { "name" : "sampleCount" , "value" : str ( n_samples ) } ) ) self . scene . appendChild ( sampler ) # 3) export one camera cameras = [ cam for cam in self . context . scene . objects if cam . type in { 'CAMERA' } ] if ( len ( cameras ) == 0 ) : print ( "WARN: No camera to export" ) else : if ( len ( cameras ) > 1 ) : print ( "WARN: Does not handle multiple camera, only export the active one" ) self . scene . appendChild ( self . write_camera ( self . context . scene . camera ) ) # export the active one # 4) export all meshes if not os . path . exists ( self . working_dir + "/meshes" ) : os . makedirs ( self . working_dir + "/meshes" ) meshes = [ obj for obj in self . context . scene . objects if obj . type in { 'MESH' , 'FONT' , 'SURFACE' , 'META' } ] print ( meshes ) for mesh in meshes : self . write_mesh ( mesh ) # 6) write the xml file self . doc . writexml ( open ( self . filepath , "w" ) , "" , "\t" , "\n" )