Commit 7a8d90ad authored by DUFAY Arthur's avatar DUFAY Arthur

add export lights function (blender to msf)

parent 33822245
......@@ -6,4 +6,14 @@
#!bin/sh
tar czvf MRF.tar.gz assets/scenes/* assets/light_sources/* assets/envmaps/* cmake/* externals/* mdl/* mrf/* tools/* apps/iray_renderer/CMakeLists.txt apps/iray_renderer/main.cpp
tar czvf MRF.tar.gz \
assets/scenes/* \
assets/light_sources/* \
assets/envmaps/* \
cmake/* \
externals/* \
mdl/* \
mrf/* \
tools/* \
apps/iray_renderer/CMakeLists.txt apps/iray_renderer/main.cpp \
apps/spectral_image_converter/CMakeLists.txt apps/spectral_image_converter/main.cpp
......@@ -672,8 +672,25 @@ def export_meshes(root_node, directory_full_path, directory_relative_path, use_p
else:
add_mesh(root_node,relative_path,material_name,"obj")
def remove_all_lights_in_xml_file(mrf_filename):
print(mrf_filename)
#camera_file = open(mrf_filename, 'r')
#for line in camera_file:
# print(line)
#camera_file.close()
tree = ET.parse(mrf_filename)
root = tree.getroot()
lights = root.find('lights')
root.remove(lights)
lights = ET.Element('lights')
root.append(lights)
indent_xml(root)
tree.write(mrf_filename)
def export_lights(root_node,directory_full_path, directory_relative_path):
def lib_export_lights(root_node,directory_full_path, directory_relative_path):
#light_num = 0
for obj in bpy.data.objects:
print(obj.name)
......@@ -910,6 +927,50 @@ def export_background():
print(background_node.inputs[0].rna_type)
def export_lights(mrf_filename,obj_sub_directory_name):
MRF_DIR = os.environ.get('MRF_DIR')
if(not os.path.isdir(MRF_DIR)):
print("Your Environment variable MRF_DIR is not set properly, ABORTING EXPORT")
return
blend_file_path = bpy.data.filepath
directory = os.path.dirname(mrf_filename)
print("START EXPORTING LIGHTS ------------\n"+blend_file_path+"\n----------------------------")
sub_directory = os.path.join(directory,obj_sub_directory_name)
# if not os.path.exists(sub_directory):
# os.makedirs(sub_directory)
# mrf_file = open(mrf_filename, 'w')
# write_mrf_scene(mrf_file)
# mrf_file.close()
remove_all_lights_in_xml_file(mrf_filename)
tree = ET.parse(mrf_filename)
root = tree.getroot()
#add_material_lambert(root,'default_lambert','0.8','0.8','0.8')
unselect_all_objects()
#export_meshes(root,sub_directory,"./"+obj_sub_directory_name,use_ply)
lib_export_lights(root,sub_directory,"./"+obj_sub_directory_name)
indent_xml(root)
tree.write(mrf_filename)
#export_camera(camera_filename)
#export_background()
print("END EXPORTING LIGHTS ------------\n"+blend_file_path+"\n---------------------------")
def export(mrf_filename,camera_filename,obj_sub_directory_name,use_ply):
MRF_DIR = os.environ.get('MRF_DIR')
......@@ -940,7 +1001,7 @@ def export(mrf_filename,camera_filename,obj_sub_directory_name,use_ply):
add_material_lambert(root,'default_lambert','0.8','0.8','0.8')
unselect_all_objects()
export_meshes(root,sub_directory,"./"+obj_sub_directory_name,use_ply)
export_lights(root,sub_directory,"./"+obj_sub_directory_name)
lib_export_lights(root,sub_directory,"./"+obj_sub_directory_name)
indent_xml(root)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment