Page MenuHome

export_x3d-Mesh.patch

Authored By
Paulo Dias (paxnubis)
Nov 13 2013, 4:09 PM
Size
3 KB
Subscribers
None

export_x3d-Mesh.patch

Index: export_x3d.py
===================================================================
--- export_x3d.py (revision 2611)
+++ export_x3d.py (working copy)
@@ -480,11 +480,17 @@
def writeIndexedFaceSet(ident, obj, mesh, matrix, world):
obj_id = quoteattr(unique_name(obj, 'OB_' + obj.name, uuid_cache_object, clean_func=clean_def, sep="_"))
- mesh_id = quoteattr(unique_name(mesh, 'ME_' + mesh.name, uuid_cache_mesh, clean_func=clean_def, sep="_"))
+ # The obj.data should be used intead of mesh because if some Object is transformed to a Mesh (obj.to_mesh()),
+ # the mesh is temporary and does not hold any permanent info (so also the tag cannot be used).
+ #mesh_id = quoteattr(unique_name(mesh, 'ME_' + mesh.name, uuid_cache_mesh, clean_func=clean_def, sep="_"))
+ mesh_id = quoteattr(unique_name(obj.data, 'ME_' + obj.data.name, uuid_cache_mesh, clean_func=clean_def, sep="_"))
+
mesh_id_group = prefix_quoted_str(mesh_id, 'group_')
mesh_id_coords = prefix_quoted_str(mesh_id, 'coords_')
mesh_id_normals = prefix_quoted_str(mesh_id, 'normals_')
+ # print ("Info: ObjName [%s] MeshName [%s], MeshIDGen [%s]" % (obj.name,mesh.name,mesh_id))
+
if not mesh.faces:
return
@@ -498,10 +504,10 @@
ident = writeTransform_begin(ident, matrix, suffix_quoted_str(obj_id, "_TRANSFORM"))
- if mesh.tag:
+ if obj.data.tag: # mesh.tag:
fw('%s<Group USE=%s />\n' % (ident, mesh_id_group))
else:
- mesh.tag = True
+ obj.data.tag = True # mesh.tag = True
fw('%s<Group DEF=%s>\n' % (ident, mesh_id_group))
ident += '\t'
@@ -1373,12 +1380,16 @@
if (obj_type != 'MESH') or (use_apply_modifiers and obj.is_modified(scene, 'PREVIEW')):
try:
me = obj.to_mesh(scene, use_apply_modifiers, 'PREVIEW')
+ me.name = obj.data.name + '.Mesh' # The default name is 'Mesh' for all newly created meshes
+ # me.tag = obj.data.tag # Because the mesh is temporary cannot be used for reference
+ #print ("Info: data.tag [%s]" % (obj.data.tag))
except:
me = None
else:
me = obj.data
if me is not None:
+ # print ("Info: Mesh [%s]" % (me))
writeIndexedFaceSet(ident, obj, me, obj_matrix, world)
# free mesh created with create_mesh()
@@ -1398,6 +1409,7 @@
writeDirectionalLight(ident, obj, obj_matrix, data, world)
else:
#print "Info: Ignoring [%s], object type [%s] not handle yet" % (object.name,object.getType)
+ # print ("Info: Ignoring [%s], object type [%s] not handle yet" % (obj.name,obj.type))
pass
if free:
@@ -1425,6 +1437,7 @@
# tag un-exported IDs
bpy.data.meshes.tag(False)
+ bpy.data.curves.tag(False) # for those transformed to meshes
bpy.data.materials.tag(False)
bpy.data.images.tag(False)

File Metadata

Mime Type
text/x-diff
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
6e/73/2a8ed7b4d948652a50a914518f42

Event Timeline