else:
anim_data = context.active_object.animation_data
if not anim_data:
- raise Exception("Object has no animation data")
+ raise Exception("Object {} has no animation data".format(context.active_object.name))
if not anim_data.action:
- raise Exception("No active action")
+ raise Exception("Object {} has no active action".format(context.active_object.name))
resource = self.export_animation(context, anim_data.action)
class ArmatureExporter:
def export_armature(self, obj):
if obj.type!="ARMATURE":
- raise ValueError("Object is not an armature")
+ raise ValueError("Object {} is not an armature".format(obj))
from .armature import Armature
armature = Armature(obj.data)
class CameraExporter:
def export_camera(self, obj):
if obj.type!='CAMERA':
- raise ValueError("Object is not a camera")
+ raise ValueError("Object {} is not a camera".format(obj.name))
from .datafile import Resource, Statement
resource = Resource(obj.name+".camera", "camera")
class LightExporter:
def export_light(self, obj):
if obj.type!='LIGHT':
- raise ValueError("Object is not a light")
+ raise ValueError("Object {} is not a light".format(obj.name))
light = obj.data
from .datafile import Resource, Statement
mat_res = Resource(material.name+".mat", "material")
if material.type!="pbr" and material.type!="unlit":
- raise Exception("Can't export unknown material type "+material.type)
+ raise Exception("Can't export material {} of unknown type {}".format(material.name, material.type))
mat_res.statements.append(Statement("type", Token(material.type)));
for p in material.properties:
lods += sorted([c for c in obj.children if c.lod_for_parent], key=(lambda l: l.lod_index))
for i, l in enumerate(lods):
if i>0 and l.lod_index!=i:
- raise Exception("Inconsistent LOD indices")
+ raise Exception("Invalid configuration on object {}: Inconsistent LOD indices".format(obj.name))
return lods
material_atlas_key = mmk(l.data.materials[0])
key_mismatch = any(mmk(m)!=material_atlas_key for m in l.data.materials)
if not all(atlas_flags) or key_mismatch:
- raise Exception("Conflicting settings in object materials")
+ raise Exception("Invalid configuration on object {}: Mixed material atlas state")
if material_atlas_key in material_atlases:
material_atlas = material_atlases[material_atlas_key]
def export_object(self, obj, resources, progress):
if obj.type!='MESH':
- raise ValueError("Object is not a mesh")
+ raise ValueError("Object {} is not a mesh".format(obj.name))
lods = self.collect_object_lods(obj)
colorspace = image.colorspace_settings.name
if usage=='GRAY' and colorspace=='sRGB':
- raise Exception("Grayscale textures with sRGB colorspace are not supported")
+ raise Exception("Unsupported configuration on texture {}: Grayscale with sRGB".format(image.name))
from .util import basename
fn = basename(image.filepath)
self.shader = material.shader
if self.render_mode=='EXTERNAL' and not self.technique:
- raise Exception("Missing technique with external rendering mode")
+ raise Exception("Invalid configuration on material {}: No technique for external rendering".format(self.name))
elif self.render_mode=='CUSTOM' and not self.shader:
- raise Exception("Missing shader with custom rendering mode")
+ raise Exception("Invalid configuration on material {}: No shader for custom rendering".format(self.name))
out_node = None
for n in material.node_tree.nodes:
break
if not out_node:
- raise Exception("No material output node found")
+ raise Exception("No output node found on material {}".format(self.name))
surface_node, _ = get_linked_node_and_socket(material.node_tree, out_node.inputs["Surface"])
if not surface_node:
if self.render_mode=='BUILTIN':
- raise Exception("Empty material can't use builtin rendering mode")
+ raise Exception("Invalid configuration on material {}: Empty material with builtin rendering".format(self.name))
return
elif surface_node.type=='BSDF_PRINCIPLED':
self.type = "pbr"
color.set_from_input(material.node_tree, surface_node.inputs["Color"])
else:
- raise Exception("Unsupported surface node type "+surface_node.type)
+ raise Exception("Unsupported surface node type {} on material {}".format(surface_node.type, self.name))
sampler_settings = None
for p in self.properties:
if sampler_settings is None:
sampler_settings = settings
elif settings!=sampler_settings:
- raise Exception("Conflicting sampler settings in material textures")
+ raise Exception("Material {} has conflicting texture sampler settings".format(self.name))
def create_property(self, *args):
prop = None
edge_map = {e.key: e for e in self.edges}
for f in self.faces:
if len(f.vertices)>4:
- raise ValueError("Ngons are not supported")
+ raise ValueError("Unsupported face on mesh {}: N-gon".format(self.name))
f.vertices = [self.vertices[i] for i in f.vertices]
for v in f.vertices:
def splice(self, other):
if len(self.uv_layers)!=len(other.uv_layers):
- raise ValueError("Meshes have incompatible UV layers")
+ raise ValueError("Meshes {} and {} have incompatible UV layers".format(self.name, other.name))
for i, u in enumerate(self.uv_layers):
if u.name!=other.uv_layers[i].name:
- raise ValueError("Meshes have incompatible UV layers")
+ raise ValueError("Meshes {} and {} have incompatible UV layers".format(self.name, other.name))
# Merge materials and form a lookup from source material indices to the
# merged material list
def apply_material_atlas(self, material_atlas):
for m in self.materials:
if m.name not in material_atlas.material_names:
- raise Exception("Material atlas is not compatible with Mesh")
+ raise Exception("Material atlas {} is not compatible with Mesh {}".format(material_atlas.name, self.name))
if self.use_uv=='NONE':
return
progress.pop_task()
prog_step = 2
else:
- raise Exception("Tangent UV layer not found")
+ raise Exception("Invalid configuration on mesh {}: No tangent UV layer".format(self.name))
# Split by the remaining UV layers
for i, u in enumerate(self.uv_layers):
def create_mesh_from_object(context, obj, material_atlas, progress):
if obj.type!="MESH":
- raise Exception("Object is not a mesh")
+ raise Exception("Object {} is not a mesh".format(obj.name))
progress.push_task("Preparing mesh", 0.0, 0.2)