# Path: export_mu/cfgfile.py
# def generate_cfg(mu, filepath):
#     cfgfile, cfgnode = find_template(mu, filepath)
#     if not cfgnode:
#         return
#     ntype = mu.type
#     if ntype == 'NONE':
#         ntype = bpy.context.scene.musceneprops.modelType
#     node = cfgnode.GetNode(ntype)
#     if not node:
#         return
#     parse_node(mu, cfgnode)
#     if ntype == 'PART':
#         if mu.CoMOffset != None:
#             node.AddValue("CoMOffset", vector_str(swapyz(mu.CoMOffset)))
#         if mu.CoPOffset != None:
#             node.AddValue("CoPOffset", vector_str(swapyz(mu.CoPOffset)))
#         if mu.CoLOffset != None:
#             node.AddValue("CoLOffset", vector_str(swapyz(mu.CoLOffset)))
#         if mu.internals:
#             add_internal_node(node, mu.internals[0])
#         mu.nodes.sort()
#         for n in mu.nodes:
#             n.save(node)
#     elif ntype == 'INTERNAL':
#         for prop in mu.props:
#             add_prop_node(node, prop)
#     # nothing meaningful for PROP
#     of = open(cfgfile, "wt")
#     for n in cfgnode.nodes:
#         of.write(n[0] + " " + n[1].ToString())


import bpy
from mathutils import Vector, Quaternion
from .. import properties
from ..mu import Mu
from ..mu import MuObject, MuTransform, MuTagLayer
from ..utils import strip_nnn, collect_collections
from .animation import collect_animations, find_path_root, make_animations
from .collider import make_collider
from .cfgfile import generate_cfg
from .export_util import is_collider
from .volume import model_volume
        if is_collider(o):
            colliders.append(o)
    if len(colliders) == 1 and not colliders[0].muproperties.separate:
        mat = colliders[0].matrix_local
        mat = mat - mat.Identity(4)
        sum = 0
        for i in range(4):
            for j in range(4):
                sum += mat[i][j]**2
        if sum < 1e-9:
            return colliders[0]
    return None

def make_obj_core(mu, obj, path, muobj):
    if path:
        path += "/"
    path += muobj.transform.name
    mu.object_paths[path] = muobj
    muobj.tag_and_layer = make_tag_and_layer(obj)
    if is_collider(obj):
        exported_objects.add(obj)
        muobj.collider = make_collider(mu, obj)
        return muobj
    elif type(obj.data) in type_handlers:
        mu.path = path  #needs to be reset as a type handler might modify it
        muobj = type_handlers[type(obj.data)](obj, muobj, mu)
        if not muobj:
            # the handler decided the object should not be exported
            return None
    exported_objects.add(obj)

# Path: export_mu/cfgfile.py
# def generate_cfg(mu, filepath):
#     cfgfile, cfgnode = find_template(mu, filepath)
#     if not cfgnode:
#         return
#     ntype = mu.type
#     if ntype == 'NONE':
#         ntype = bpy.context.scene.musceneprops.modelType
#     node = cfgnode.GetNode(ntype)
#     if not node:
#         return
#     parse_node(mu, cfgnode)
#     if ntype == 'PART':
#         if mu.CoMOffset != None:
#             node.AddValue("CoMOffset", vector_str(swapyz(mu.CoMOffset)))
#         if mu.CoPOffset != None:
#             node.AddValue("CoPOffset", vector_str(swapyz(mu.CoPOffset)))
#         if mu.CoLOffset != None:
#             node.AddValue("CoLOffset", vector_str(swapyz(mu.CoLOffset)))
#         if mu.internals:
#             add_internal_node(node, mu.internals[0])
#         mu.nodes.sort()
#         for n in mu.nodes:
#             n.save(node)
#     elif ntype == 'INTERNAL':
#         for prop in mu.props:
#             add_prop_node(node, prop)
#     # nothing meaningful for PROP
#     of = open(cfgfile, "wt")
#     for n in cfgnode.nodes:
#         of.write(n[0] + " " + n[1].ToString())


# Path: export_mu/export.py
import bpy
from mathutils import Vector, Quaternion
from .. import properties
from ..mu import Mu
from ..mu import MuObject, MuTransform, MuTagLayer
from ..utils import strip_nnn, collect_collections
from .animation import collect_animations, find_path_root, make_animations
from .collider import make_collider
from .cfgfile import generate_cfg
from .export_util import is_collider
from .volume import model_volume

        if is_collider(o):
            colliders.append(o)
    if len(colliders) == 1 and not colliders[0].muproperties.separate:
        mat = colliders[0].matrix_local
        mat = mat - mat.Identity(4)
        sum = 0
        for i in range(4):
            for j in range(4):
                sum += mat[i][j]**2
        if sum < 1e-9:
            return colliders[0]
    return None

def make_obj_core(mu, obj, path, muobj):
    if path:
        path += "/"
    path += muobj.transform.name
    mu.object_paths[path] = muobj
    muobj.tag_and_layer = make_tag_and_layer(obj)
    if is_collider(obj):
        exported_objects.add(obj)
        muobj.collider = make_collider(mu, obj)
        return muobj
    elif type(obj.data) in type_handlers:
        mu.path = path  #needs to be reset as a type handler might modify it
        muobj = type_handlers[type(obj.data)](obj, muobj, mu)
        if not muobj:
            # the handler decided the object should not be exported
            return None
    exported_objects.add(obj)

    col = find_single_collider(obj.children)