# Path: psychoblend/util.py
# def escape_name(name):
#     name = name.replace("\\", "\\\\")
#     name = name.replace(" ", "\\ ")
#     name = name.replace("$", "\\$")
#     name = name.replace("[", "\\[")
#     name = name.replace("]", "\\]")
#     name = name.replace("{", "\\{")
#     name = name.replace("}", "\\}")
#     return name
# 
# def mat2str(m):
#     """ Converts a matrix into a single-line string of values.
#     """
#     s = ""
#     for j in range(4):
#         for i in range(4):
#             s += (" %f" % m[i][j])
#     return s[1:]
# 
# class ExportCancelled(Exception):
#     """ Indicates that the render was cancelled in the middle of exporting
#         the scene file.
#     """
#     pass


import bpy
from math import degrees, tan, atan
from mathutils import Vector, Matrix
from .util import escape_name, mat2str, ExportCancelled



class World:
    def __init__(self, render_engine, scene, visible_layers, aspect_ratio):
        self.background_shader = BackgroundShader(render_engine, scene.world)
        self.camera = Camera(render_engine, scene.camera, aspect_ratio)
        self.lights = []

        # Collect infinite-extent light sources.
        # TODO: also get sun lamps inside group instances.
        for ob in scene.objects:
            if ob.type == 'LAMP' and ob.data.type == 'SUN':

# Path: psychoblend/util.py
# def escape_name(name):
#     name = name.replace("\\", "\\\\")
#     name = name.replace(" ", "\\ ")
#     name = name.replace("$", "\\$")
#     name = name.replace("[", "\\[")
#     name = name.replace("]", "\\]")
#     name = name.replace("{", "\\{")
#     name = name.replace("}", "\\}")
#     return name
# 
# def mat2str(m):
#     """ Converts a matrix into a single-line string of values.
#     """
#     s = ""
#     for j in range(4):
#         for i in range(4):
#             s += (" %f" % m[i][j])
#     return s[1:]
# 
# class ExportCancelled(Exception):
#     """ Indicates that the render was cancelled in the middle of exporting
#         the scene file.
#     """
#     pass


# Path: psychoblend/world.py
import bpy
from math import degrees, tan, atan
from mathutils import Vector, Matrix
from .util import escape_name, mat2str, ExportCancelled




class World:
    def __init__(self, render_engine, scene, visible_layers, aspect_ratio):
        self.background_shader = BackgroundShader(render_engine, scene.world)
        self.camera = Camera(render_engine, scene.camera, aspect_ratio)
        self.lights = []

        # Collect infinite-extent light sources.
        # TODO: also get sun lamps inside group instances.
        for ob in scene.objects:
            if ob.type == 'LAMP' and ob.data.type == 'SUN':

                name = escape_name(ob.name)