[DEV] update exporter but not the reader

This commit is contained in:
Edouard DUPIN 2017-03-19 22:51:12 +01:00
parent 7cb5880af2
commit 6fa74968b6
3 changed files with 356 additions and 308 deletions

View File

@ -22,6 +22,11 @@ create user addon directory: (replace 2.xx with the blender version)
- Select "Addons" tab - Select "Addons" tab
- Enable "Import-export: Ewol Mesh file format emf" - Enable "Import-export: Ewol Mesh file format emf"
Some error classile with awesome and blender
============================================
- file -> user preferences -> system -> Windows draw methode: triple bufferings
License (MPL v2.0) License (MPL v2.0)
===================== =====================

View File

@ -64,7 +64,7 @@ def out_quaternion_z_up( q ):
return "%g %g %g %g" % ( q.w, q.x, q.y, q.z ) return "%g %g %g %g" % ( q.w, q.x, q.y, q.z )
def getPhysicsShape(obj, mainObjScale, use_y_up=False): def get_physics_shape(obj, mainObjScale, use_y_up=False):
shape = "" shape = ""
props = { } props = { }
name = obj.name.lower() name = obj.name.lower()
@ -114,7 +114,7 @@ def getPhysicsShape(obj, mainObjScale, use_y_up=False):
props["scale"] = out_scale3( scale ) props["scale"] = out_scale3( scale )
# remove mesh # remove mesh
print(" shape type : '%s' from element name : '%s'" % (shape, obj.name)) print(" shape type: '" + str(shape) + "' from element name:'" + str(obj.name) + "'")
if obj.location != Vector((0,0,0)): if obj.location != Vector((0,0,0)):
props["origin"] = out_point3(obj.location) props["origin"] = out_point3(obj.location)
@ -130,23 +130,26 @@ def getPhysicsShape(obj, mainObjScale, use_y_up=False):
return (shape, props) return (shape, props)
def writeCollisionShape(object, file, mainObjScale): def write_collision_shape(object, file, mainObjScale, offset):
if len(getChildren(object))==0: if len(getChildren(object))==0:
# no phisical shape ... # no phisical shape ...
return return
fw = file.write string_offset = ""
fw('\t\tPhysics : \n') for iii in range(offset):
string_offset += "\t"
file.write(string_offset + 'Physics:\n')
for subObj in getChildren(object): for subObj in getChildren(object):
print(" element='%s' type '%s'" % (subObj.name,str(subObj.type))) print(" element='" + subObj.name + "' type '" + str(subObj.type) + "'")
if subObj.type != 'MESH': if subObj.type != 'MESH' \
and subObj.type != 'EMPTY':
continue continue
(shape, props) = getPhysicsShape(subObj, mainObjScale) (shape, props) = get_physics_shape(subObj, mainObjScale)
if shape=="": if shape=="":
print("error of shape detection type ..."); print("error of shape detection type ...");
continue continue
fw("\t\t\t" + shape + "\n" ) file.write(string_offset + "\t" + shape + "\n" )
for (k,v) in props.items(): for (k,v) in props.items():
fw("\t\t\t\t%s : %s\n" % (k, v) ) file.write(string_offset + "\t\t%s:%s\n" % (k, v) )
@ -175,8 +178,8 @@ def write_mtl(scene, file, filepath, path_mode, copy_set, mtl_dict):
world_amb = Color((0.0, 0.0, 0.0)) world_amb = Color((0.0, 0.0, 0.0))
source_dir = os.path.dirname(bpy.data.filepath) source_dir = os.path.dirname(bpy.data.filepath)
dest_dir = os.path.dirname(filepath) dest_dir = os.path.dirname(filepath)
fw = file.write file.write('\n')
fw('\nMaterials : %i\n' % len(mtl_dict)) #file.write('\nMaterials:%i\n' % len(mtl_dict))
mtl_dict_values = list(mtl_dict.values()) mtl_dict_values = list(mtl_dict.values())
mtl_dict_values.sort(key=lambda m: m[0]) mtl_dict_values.sort(key=lambda m: m[0])
# Write material/image combinations we have used. # Write material/image combinations we have used.
@ -184,38 +187,38 @@ def write_mtl(scene, file, filepath, path_mode, copy_set, mtl_dict):
for mtl_mat_name, mat, face_img in mtl_dict_values: for mtl_mat_name, mat, face_img in mtl_dict_values:
# Get the Blender data for the material and the image. # Get the Blender data for the material and the image.
# Having an image named None will make a bug, dont do it:) # Having an image named None will make a bug, dont do it:)
fw('\t%s\n' % mtl_mat_name) # Define a new material: matname_imgname file.write('Materials:%s\n' % mtl_mat_name) # Define a new material: matname_imgname
if mat: if mat:
# convert from blenders spec to 0 - 1000 range. # convert from blenders spec to 0 - 1000 range.
if mat.specular_shader == 'WARDISO': if mat.specular_shader == 'WARDISO':
tspec = (0.4 - mat.specular_slope) / 0.0004 tspec = (0.4 - mat.specular_slope) / 0.0004
else: else:
tspec = (mat.specular_hardness - 1) * 1.9607843137254901 tspec = (mat.specular_hardness - 1) * 1.9607843137254901
fw('\t\tNs %.6f\n' % tspec) file.write('\tNs %.6f\n' % tspec)
del tspec del tspec
fw('\t\tKa %.6f %.6f %.6f\n' % (mat.ambient * world_amb)[:]) # Ambient, uses mirror color, file.write('\tKa %.6f %.6f %.6f\n' % (mat.ambient * world_amb)[:]) # Ambient, uses mirror color,
fw('\t\tKd %.6f %.6f %.6f\n' % (mat.diffuse_intensity * mat.diffuse_color)[:]) # Diffuse file.write('\tKd %.6f %.6f %.6f\n' % (mat.diffuse_intensity * mat.diffuse_color)[:]) # Diffuse
fw('\t\tKs %.6f %.6f %.6f\n' % (mat.specular_intensity * mat.specular_color)[:]) # Specular file.write('\tKs %.6f %.6f %.6f\n' % (mat.specular_intensity * mat.specular_color)[:]) # Specular
if hasattr(mat, "ior"): if hasattr(mat, "ior"):
fw('\t\tNi %.6f\n' % mat.ior) # Refraction index file.write('\tNi %.6f\n' % mat.ior) # Refraction index
else: else:
fw('\t\tNi %.6f\n' % 1.0) file.write('\tNi %.6f\n' % 1.0)
fw('\t\td %.6f\n' % mat.alpha) # Alpha (obj uses 'd' for dissolve) file.write('\td %.6f\n' % mat.alpha) # Alpha (obj uses 'd' for dissolve)
# 0 to disable lighting, 1 for ambient & diffuse only (specular color set to black), 2 for full lighting. # 0 to disable lighting, 1 for ambient & diffuse only (specular color set to black), 2 for full lighting.
if mat.use_shadeless: if mat.use_shadeless:
fw('\t\tillum 0\n') # ignore lighting file.write('\tillum 0\n') # ignore lighting
elif mat.specular_intensity == 0: elif mat.specular_intensity == 0:
fw('\t\tillum 1\n') # no specular. file.write('\tillum 1\n') # no specular.
else: else:
fw('\t\tillum 2\n') # light normaly file.write('\tillum 2\n') # light normaly
else: else:
#write a dummy material here? #write a dummy material here?
fw('\t\tNs 0\n') file.write('\tNs 0\n')
fw('\t\tKa %.6f %.6f %.6f\n' % world_amb[:]) # Ambient, uses mirror color, file.write('\tKa %.6f %.6f %.6f\n' % world_amb[:]) # Ambient, uses mirror color,
fw('\t\tKd 0.8 0.8 0.8\n') file.write('\tKd 0.8 0.8 0.8\n')
fw('\t\tKs 0.8 0.8 0.8\n') file.write('\tKs 0.8 0.8 0.8\n')
fw('\t\td 1\n') # No alpha file.write('\td 1\n') # No alpha
fw('\t\tillum 2\n') # light normaly file.write('\tillum 2\n') # light normaly
# Write images! # Write images!
if face_img: # We have an image on the face! if face_img: # We have an image on the face!
filepath = face_img.filepath filepath = face_img.filepath
@ -228,7 +231,7 @@ def write_mtl(scene, file, filepath, path_mode, copy_set, mtl_dict):
"", "",
copy_set, copy_set,
face_img.library) face_img.library)
fw('\t\tmap_Kd %s\n' % filepath) # Diffuse mapping image file.write('\tmap_Kd %s\n' % filepath) # Diffuse mapping image
del filepath del filepath
else: else:
# so we write the materials image. # so we write the materials image.
@ -274,22 +277,7 @@ def write_mtl(scene, file, filepath, path_mode, copy_set, mtl_dict):
"", "",
copy_set, copy_set,
image.library) image.library)
fw('\t\t%s %s\n' % (key, repr(filepath)[1:-1])) file.write('\t%s %s\n' % (key, repr(filepath)[1:-1]))
"""
" @brief Basic write function. The context and options must be already set.
"""
def write_file(filepath,
objects,
scene,
EXPORT_GLOBAL_MATRIX=None,
EXPORT_PATH_MODE='AUTO',
EXPORT_BINARY_MODE=False,
EXPORT_COLLISION_NAME=""
):
if EXPORT_GLOBAL_MATRIX is None:
EXPORT_GLOBAL_MATRIX = mathutils.Matrix()
def veckey3d(v): def veckey3d(v):
return round(v.x, 6), round(v.y, 6), round(v.z, 6) return round(v.x, 6), round(v.y, 6), round(v.z, 6)
@ -297,62 +285,43 @@ def write_file(filepath,
def veckey2d(v): def veckey2d(v):
return round(v[0], 6), round(v[1], 6) return round(v[0], 6), round(v[1], 6)
print('EMF Export path: %r' % filepath) def write_mesh(scene, file, object, EXPORT_GLOBAL_MATRIX, mtl_dict):
print("**************** '" + str(object.name) + "' *******************")
time1 = time.time()
mtlfilepath = os.path.splitext(filepath)[0] + ".mtl"
file = open(filepath, "w", encoding="utf8", newline="\n")
fw = file.write
# Write Header
fw('EMF(STRING)\n') # if binary : fw('EMF(BINARY)\n')
fw('# Blender v%s EMF File: %r\n' % (bpy.app.version_string, os.path.basename(bpy.data.filepath)))
# Initialize totals, these are updated each object # Initialize totals, these are updated each object
totverts = totuvco = totno = 1 totverts = 1
totuvco = 1
face_vert_index = 1 totno = 1
globalNormals = {} globalNormals = {}
face_vert_index = 1
# A Dict of Materials
# (material.name, image.name):matname_imagename # matname_imagename has gaps removed.
mtl_dict = {}
# Used to reduce the usage of matname_texname materials, which can become annoying in case of # Used to reduce the usage of matname_texname materials, which can become annoying in case of
# repeated exports/imports, yet keeping unique mat names per keys! # repeated exports/imports, yet keeping unique mat names per keys!
# mtl_name: (material.name, image.name) # mtl_name: (material.name, image.name)
mtl_rev_dict = {} mtl_rev_dict = {}
copy_set = set()
# Get all meshes if object.type != 'MESH':
for ob_main in objects: print(object.name + 'is not a mesh type - ignoring type=' + object.type)
print("**************** '%s' *******************" % str(ob_main.name)) file.write('# can not export:"%s":type="%s"\n' % (object.name, str(object.type)))
if ob_main.type != 'MESH': return
print(ob_main.name, 'is not a mesh type - ignoring') #print("name:'%s'" % object.name)
fw('# can not export : "%s" : type="%s"\n' % (ob_main.name, str(ob_main.type))) #for plop in object.child:
continue
#print("name : '%s'" % ob_main.name)
#for plop in ob_main.child:
# print(" child:'%s'" % plop.name) # print(" child:'%s'" % plop.name)
# ignore dupli children # ignore dupli children
if ob_main.parent and ob_main.parent.dupli_type in {'VERTS', 'FACES'}: if object.parent and object.parent.dupli_type in {'VERTS', 'FACES'}:
# XXX # XXX
print(ob_main.name, 'is a dupli child - ignoring') print(object.name, 'is a dupli child - ignoring')
continue return
obs = [] obs = []
if ob_main.dupli_type != 'NONE': if object.dupli_type != 'NONE':
# XXX # XXX
print('creating dupli_list on', ob_main.name) print('creating dupli_list on', object.name)
ob_main.dupli_list_create(scene) object.dupli_list_create(scene)
obs = [(dob.object, dob.matrix) for dob in ob_main.dupli_list] obs = [(dob.object, dob.matrix) for dob in object.dupli_list]
# XXX debug print # XXX debug print
print(ob_main.name, 'has', len(obs), 'dupli children') print(object.name, 'has', len(obs), 'dupli children')
else: else:
obs = [(ob_main, ob_main.matrix_world)] obs = [(object, object.matrix_world)]
idMesh=0
for ob, ob_mat in obs: for ob, ob_mat in obs:
try: try:
# apply the mesh modifieur at the curent object: # apply the mesh modifieur at the curent object:
@ -361,8 +330,6 @@ def write_file(filepath,
me = None me = None
if me is None: if me is None:
continue continue
idMesh = idMesh+1;
fw('Mesh : %d\n' % idMesh)
me.transform(EXPORT_GLOBAL_MATRIX * ob_mat) me.transform(EXPORT_GLOBAL_MATRIX * ob_mat)
#print("ploppp:" + str(EXPORT_GLOBAL_MATRIX) ) #print("ploppp:" + str(EXPORT_GLOBAL_MATRIX) )
#print("ploppp:" + str(ob_mat) ) #print("ploppp:" + str(ob_mat) )
@ -405,26 +372,25 @@ def write_file(filepath,
contextMat = 0, 0 # Can never be this, so we will label a new material the first chance we get. contextMat = 0, 0 # Can never be this, so we will label a new material the first chance we get.
contextSmooth = None # Will either be true or false, set bad to force initialization switch. contextSmooth = None # Will either be true or false, set bad to force initialization switch.
# use:blen obs ??? what is this .... # use:blen obs ??? what is this ....
if True:
name1 = ob.name name1 = ob.name
name2 = ob.data.name name2 = ob.data.name
if name1 == name2: if name1 == name2:
obnamestring = name_compat(name1) obnamestring = name_compat(name1)
else: else:
obnamestring = '%s_%s' % (name_compat(name1), name_compat(name2)) obnamestring = '%s_%s' % (name_compat(name1), name_compat(name2))
fw('\t%s\n' % obnamestring) # Write Object name file.write('Mesh:%s\n' % obnamestring) # Write Object name
########################################################### ###########################################################
## Vert ## Vert
########################################################### ###########################################################
fw('\t\tVertex : %d\n\t\t\t' % len(me_verts)) file.write('\tVertex:%d\n\t\t' % len(me_verts))
for v in me_verts: for v in me_verts:
fw('%.6f %.6f %.6f|' % v.co[:]) file.write('%.6f %.6f %.6f|' % v.co[:])
fw('\n') file.write('\n')
########################################################### ###########################################################
## UV ## UV
########################################################### ###########################################################
if faceuv: if faceuv:
fw('\t\tUV-mapping :\n\t\t\t') file.write('\tUV-mapping:\n\t\t')
# in case removing some of these dont get defined. # in case removing some of these dont get defined.
uv = uvkey = uv_dict = f_index = uv_index = None uv = uvkey = uv_dict = f_index = uv_index = None
uv_face_mapping = [None] * len(face_index_pairs) uv_face_mapping = [None] * len(face_index_pairs)
@ -438,12 +404,12 @@ def write_file(filepath,
uv_k = uv_dict[uvkey] uv_k = uv_dict[uvkey]
except: except:
uv_k = uv_dict[uvkey] = len(uv_dict) uv_k = uv_dict[uvkey] = len(uv_dict)
fw('%.6f %.6f|' % uv[:]) file.write('%.6f %.6f|' % uv[:])
uv_ls.append(uv_k) uv_ls.append(uv_k)
uv_unique_count = len(uv_dict) uv_unique_count = len(uv_dict)
del uv, uvkey, uv_dict, f_index, uv_index, uv_ls, uv_k del uv, uvkey, uv_dict, f_index, uv_index, uv_ls, uv_k
# Only need uv_unique_count and uv_face_mapping # Only need uv_unique_count and uv_face_mapping
fw('\n') file.write('\n')
else: else:
print("does not use UV-MAPPING") print("does not use UV-MAPPING")
########################################################### ###########################################################
@ -456,7 +422,7 @@ def write_file(filepath,
localIsSmooth = 'face' localIsSmooth = 'face'
else: else:
localIsSmooth = 'face' localIsSmooth = 'face'
fw('\t\tNormal(%s) : %d\n\t\t\t' % (localIsSmooth, len(face_index_pairs)) ) file.write('\tNormal(%s):%d\n\t\t' % (localIsSmooth, len(face_index_pairs)) )
for f, f_index in face_index_pairs: for f, f_index in face_index_pairs:
if f.use_smooth: if f.use_smooth:
for v_idx in f.vertices: for v_idx in f.vertices:
@ -465,22 +431,22 @@ def write_file(filepath,
if noKey not in globalNormals: if noKey not in globalNormals:
globalNormals[noKey] = totno globalNormals[noKey] = totno
totno += 1 totno += 1
fw('%.6f %.6f %.6f|' % noKey) file.write('%.6f %.6f %.6f|' % noKey)
else: else:
# Hard, 1 normal from the face. # Hard, 1 normal from the face.
noKey = veckey3d(f.normal) noKey = veckey3d(f.normal)
if noKey not in globalNormals: if noKey not in globalNormals:
globalNormals[noKey] = totno globalNormals[noKey] = totno
totno += 1 totno += 1
fw('%.6f %.6f %.6f|' % noKey) file.write('%.6f %.6f %.6f|' % noKey)
fw('\n') file.write('\n')
if not faceuv: if not faceuv:
f_image = None f_image = None
########################################################### ###########################################################
## faces ## faces
########################################################### ###########################################################
fw('\t\tFace : %d' % len(face_index_pairs)) file.write('\tFace:%d' % len(face_index_pairs))
for f, f_index in face_index_pairs: for f, f_index in face_index_pairs:
f_smooth = f.use_smooth f_smooth = f.use_smooth
f_mat = min(f.material_index, len(materials) - 1) f_mat = min(f.material_index, len(materials) - 1)
@ -498,7 +464,7 @@ def write_file(filepath,
else: else:
if key[0] is None and key[1] is None: if key[0] is None and key[1] is None:
# inform the use of a material: # inform the use of a material:
fw("\n\t\t\t---:") # mat, image file.write("\n\t\t---:") # mat, image
else: else:
mat_data = mtl_dict.get(key) mat_data = mtl_dict.get(key)
if not mat_data: if not mat_data:
@ -523,14 +489,14 @@ def write_file(filepath,
mat_data = mtl_dict[key] = mtl_name, materials[f_mat], f_image mat_data = mtl_dict[key] = mtl_name, materials[f_mat], f_image
mtl_rev_dict[mtl_name] = key mtl_rev_dict[mtl_name] = key
# set the use of a material: # set the use of a material:
fw("\n\t\t\t%s\n\t\t\t\t" % mat_data[0]) # can be mat_image or (null) file.write("\n\t\t%s\n\t\t\t" % mat_data[0]) # can be mat_image or (null)
contextMat = key contextMat = key
f_v = [(vi, me_verts[v_idx]) for vi, v_idx in enumerate(f.vertices)] f_v = [(vi, me_verts[v_idx]) for vi, v_idx in enumerate(f.vertices)]
if faceuv: if faceuv:
# export the normals: # export the normals:
if f_smooth: # Smoothed, use vertex normals if f_smooth: # Smoothed, use vertex normals
for vi, v in f_v: for vi, v in f_v:
fw(" %d/%d/%d" % file.write(" %d/%d/%d" %
(v.index + totverts-1, (v.index + totverts-1,
totuvco + uv_face_mapping[f_index][vi]-1, totuvco + uv_face_mapping[f_index][vi]-1,
globalNormals[veckey3d(v.normal)]-1, globalNormals[veckey3d(v.normal)]-1,
@ -538,7 +504,7 @@ def write_file(filepath,
else: # No smoothing, face normals else: # No smoothing, face normals
no = globalNormals[veckey3d(f.normal)] no = globalNormals[veckey3d(f.normal)]
for vi, v in f_v: for vi, v in f_v:
fw(" %d/%d/%d" % file.write(" %d/%d/%d" %
(v.index + totverts-1, (v.index + totverts-1,
totuvco + uv_face_mapping[f_index][vi]-1, totuvco + uv_face_mapping[f_index][vi]-1,
no-1, no-1,
@ -548,21 +514,21 @@ def write_file(filepath,
# export the normals: # export the normals:
if f_smooth: # Smoothed, use vertex normals if f_smooth: # Smoothed, use vertex normals
for vi, v in f_v: for vi, v in f_v:
fw(" %d/%d" % ( file.write(" %d/%d" % (
v.index + totverts-1, v.index + totverts-1,
globalNormals[veckey3d(v.normal)]-1, globalNormals[veckey3d(v.normal)]-1,
)) ))
else: # No smoothing, face normals else: # No smoothing, face normals
no = globalNormals[veckey3d(f.normal)] no = globalNormals[veckey3d(f.normal)]
for vi, v in f_v: for vi, v in f_v:
fw(" %d/%d" % (v.index + totverts-1, no-1)) file.write(" %d/%d" % (v.index + totverts-1, no-1))
fw('|') file.write('|')
fw('\n') file.write('\n')
# Write edges. ==> did not know what it is ... # Write edges. ==> did not know what it is ...
#fw('Faces : %d' % len(edges)) #file.write('Faces:%d' % len(edges))
#for ed in edges: #for ed in edges:
# if ed.is_loose: # if ed.is_loose:
# fw('%d %d\n' % (ed.vertices[0] + totverts, ed.vertices[1] + totverts)) # file.write('%d %d\n' % (ed.vertices[0] + totverts, ed.vertices[1] + totverts))
# Make the indices global rather then per mesh # Make the indices global rather then per mesh
totverts += len(me_verts) totverts += len(me_verts)
@ -570,16 +536,92 @@ def write_file(filepath,
totuvco += uv_unique_count totuvco += uv_unique_count
# clean up # clean up
bpy.data.meshes.remove(me) bpy.data.meshes.remove(me)
if ob_main.dupli_type != 'NONE':
ob_main.dupli_list_clear() if object.dupli_type != 'NONE':
object.dupli_list_clear()
##################################################################### #####################################################################
## Save collision shapes (for one object: ## Save collision shapes (for one object:
##################################################################### #####################################################################
for subObj in getChildren(ob_main): for subObj in getChildren(object):
print(" child:'%s'" % (subObj.name)) print(" child:'%s'" % (subObj.name))
if subObj.name.lower().startswith(EXPORT_COLLISION_NAME): if subObj.name.lower().startswith(EXPORT_COLLISION_NAME):
print(" find physics:'%s'" % (subObj.name)) print(" find physics:'%s'" % (subObj.name))
writeCollisionShape(subObj, file, ob_main.scale) write_collision_shape(subObj, file, object.scale, 1)
"""
" @brief Basic write function. The context and options must be already set.
"""
def write_file(filepath,
objects,
scene,
EXPORT_GLOBAL_MATRIX=None,
EXPORT_PATH_MODE='AUTO',
EXPORT_BINARY_MODE=False,
EXPORT_COLLISION_NAME=""
):
if EXPORT_GLOBAL_MATRIX is None:
EXPORT_GLOBAL_MATRIX = mathutils.Matrix()
print('EMF Export path: %r' % filepath)
time1 = time.time()
mtlfilepath = os.path.splitext(filepath)[0] + ".mtl"
file = open(filepath, "w", encoding="utf8", newline="\n")
# Write Header
file.write('EMF(STRING)\n') # if binary:file.write('EMF(BINARY)\n')
file.write('# Blender v%s EMF File: %r\n' % (bpy.app.version_string, os.path.basename(bpy.data.filepath)))
# A Dict of Materials
# (material.name, image.name):matname_imagename # matname_imagename has gaps removed.
mtl_dict = {}
copy_set = set()
"""
nb_total_mesh = 0
nb_total_physic = 0
for ob_main in objects:
print("**************** '" + str(ob_main.name) + "' *******************")
if ob_main.type == 'EMPTY':
for sub_obj in getChildren(ob_main):
print(" child:'" + str(sub_obj.name) + "' type=" + sub_obj.type)
if sub_obj.type == 'MESH':
nb_total_mesh += 1
elif sub_obj.type == 'EMPTY' \
and sub_obj.name.lower().startswith("physic"):
nb_total_physic += 1
for sub_obj_2 in getChildren(sub_obj):
print(" child:'" + str(sub_obj_2.name) + "' type=" + sub_obj_2.type)
for sub_obj_3 in getChildren(sub_obj_2):
print(" child:'" + str(sub_obj_3.name) + "' type=" + sub_obj_3.type)
if ob_main.type == 'MESH':
nb_total_mesh += 1
print("nb_total_mesh: " + str(nb_total_mesh))
print("nb_total_physic: " + str(nb_total_physic))
"""
# Get all meshes
for ob_main in objects:
if ob_main.type == 'MESH':
write_mesh(scene, file, ob_main, EXPORT_GLOBAL_MATRIX, mtl_dict)
elif ob_main.type == 'EMPTY':
for sub_obj in getChildren(ob_main):
print(" child:'" + str(sub_obj.name) + "' type=" + sub_obj.type)
if sub_obj.type == 'MESH':
write_mesh(scene, file, sub_obj, EXPORT_GLOBAL_MATRIX, mtl_dict)
elif sub_obj.type == 'EMPTY' \
and sub_obj.name.lower().startswith("physic"):
print(" child:'" + str(sub_obj.name) + "' type=" + sub_obj.type)
#####################################################################
## Save collision shapes (for one all):
#####################################################################
write_collision_shape(sub_obj, file, sub_obj.scale, 0)
else:
print(" child:'" + str(sub_obj.name) + "' type=" + sub_obj.type + " not parsed ...")
##################################################################### #####################################################################
## Now we have all our materials, save them in the material section ## Now we have all our materials, save them in the material section

View File

@ -183,17 +183,18 @@ bool ege::resource::Mesh::loadEMF(const std::string& _fileName) {
// reach end of file ... // reach end of file ...
break; break;
} }
if(strncmp(inputDataLine, "Mesh :", 6) == 0) { if(strncmp(inputDataLine, "Mesh:", 5) == 0) {
currentMode = EMFModuleMesh; currentMode = EMFModuleMesh;
EGE_VERBOSE("Parse Mesh :"); EGE_VERBOSE("Parse Mesh :");
} else if(strncmp(inputDataLine, "Materials : ", 11) == 0) { } else if(strncmp(inputDataLine, "Materials:", 9) == 0) {
currentMode = EMFModuleMaterial; currentMode = EMFModuleMaterial;
EGE_VERBOSE("Parse Material :"); EGE_VERBOSE("Parse Material :");
} else { } else {
currentMode = EMFModuleNone; currentMode = EMFModuleNone;
} }
} else { } else {
if (currentMode >= EMFModuleMesh && currentMode <= EMFModuleMesh_END) { if ( currentMode >= EMFModuleMesh
&& currentMode <= EMFModuleMesh_END) {
if (level == 1) { if (level == 1) {
//Find mesh name ... //Find mesh name ...
if (loadNextData(inputDataLine, 2048, fileName, true) == nullptr) { if (loadNextData(inputDataLine, 2048, fileName, true) == nullptr) {