Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArystanbek Dyussenov <arystan.d@gmail.com>2010-09-04 22:49:07 +0400
committerArystanbek Dyussenov <arystan.d@gmail.com>2010-09-04 22:49:07 +0400
commit90b464d3728d9ed8ec26fdf59058d236b99dbcd9 (patch)
treee88cab4fb1358e962b19f658064ca8c9f8d29f5b /release/scripts/io/export_3ds.py
parent08d02dd04d836976b25793bb1d4c6a86b3f924c7 (diff)
parentb0b787ef38f9947b3176642556f5282eb3518f69 (diff)
COLLADA branch: merge from trunk -r 28015:31610.soc-2009-chingachgook
Diffstat (limited to 'release/scripts/io/export_3ds.py')
-rw-r--r--release/scripts/io/export_3ds.py79
1 files changed, 37 insertions, 42 deletions
diff --git a/release/scripts/io/export_3ds.py b/release/scripts/io/export_3ds.py
index d46cc712e9a..706e7eb1516 100644
--- a/release/scripts/io/export_3ds.py
+++ b/release/scripts/io/export_3ds.py
@@ -74,15 +74,15 @@ import bpy
# also used by X3D exporter
# return a tuple (free, object list), free is True if memory should be freed later with free_derived_objects()
-def create_derived_objects(ob):
+def create_derived_objects(scene, ob):
if ob.parent and ob.parent.dupli_type != 'NONE':
return False, None
if ob.dupli_type != 'NONE':
- ob.create_dupli_list()
+ ob.create_dupli_list(scene)
return True, [(dob.object, dob.matrix) for dob in ob.dupli_list]
else:
- return False, [(ob, ob.matrix)]
+ return False, [(ob, ob.matrix_world)]
# also used by X3D exporter
def free_derived_objects(ob):
@@ -494,8 +494,7 @@ def make_material_texture_chunk(id, images):
mat_sub = _3ds_chunk(id)
def add_image(img):
- filename = os.path.basename(image.filename)
-# filename = image.filename.split('\\')[-1].split('/')[-1]
+ filename = os.path.basename(image.filepath)
mat_sub_file = _3ds_chunk(MATMAPFILE)
mat_sub_file.add_variable("mapfile", _3ds_string(sane_name(filename)))
mat_sub.add_subchunk(mat_sub_file)
@@ -565,14 +564,14 @@ def extract_triangles(mesh):
img = None
for i, face in enumerate(mesh.faces):
- f_v = face.verts
+ f_v = face.vertices
# f_v = face.v
- uf = mesh.active_uv_texture.data[i] if do_uv else None
+ uf = mesh.uv_textures.active.data[i] if do_uv else None
if do_uv:
f_uv = uf.uv
- # f_uv = (uf.uv1, uf.uv2, uf.uv3, uf.uv4) if face.verts[3] else (uf.uv1, uf.uv2, uf.uv3)
+ # f_uv = (uf.uv1, uf.uv2, uf.uv3, uf.uv4) if face.vertices[3] else (uf.uv1, uf.uv2, uf.uv3)
# f_uv = face.uv
img = uf.image if uf else None
# img = face.image
@@ -762,18 +761,18 @@ def make_mesh_chunk(mesh, materialDict):
if len(mesh.uv_textures):
# if mesh.faceUV:
# Remove the face UVs and convert it to vertex UV:
- vert_array, uv_array, tri_list = remove_face_uv(mesh.verts, tri_list)
+ vert_array, uv_array, tri_list = remove_face_uv(mesh.vertices, tri_list)
else:
# Add the vertices to the vertex array:
vert_array = _3ds_array()
- for vert in mesh.verts:
+ for vert in mesh.vertices:
vert_array.add(_3ds_point_3d(vert.co))
# If the mesh has vertex UVs, create an array of UVs:
if len(mesh.sticky):
# if mesh.vertexUV:
uv_array = _3ds_array()
for uv in mesh.sticky:
-# for vert in mesh.verts:
+# for vert in mesh.vertices:
uv_array.add(_3ds_point_uv(uv.co))
# uv_array.add(_3ds_point_uv(vert.uvco))
else:
@@ -923,7 +922,7 @@ def make_kf_obj_node(obj, name_to_id):
"""
# import BPyMessages
-def save_3ds(filename, context):
+def write(filename, context):
'''Save the Blender scene to a 3ds file.'''
# Time the export
@@ -942,7 +941,8 @@ def save_3ds(filename, context):
sce = context.scene
# sce= bpy.data.scenes.active
- bpy.ops.object.mode_set(mode='OBJECT')
+ if context.object:
+ bpy.ops.object.mode_set(mode='OBJECT')
# Initialize the main chunk (primary):
primary = _3ds_chunk(PRIMARY)
@@ -968,11 +968,12 @@ def save_3ds(filename, context):
# each material is added once):
materialDict = {}
mesh_objects = []
- for ob in [ob for ob in context.scene.objects if ob.is_visible()]:
+ scene = context.scene
+ for ob in [ob for ob in scene.objects if ob.is_visible(scene)]:
# for ob in sce.objects.context:
# get derived objects
- free, derived = create_derived_objects(ob)
+ free, derived = create_derived_objects(scene, ob)
if derived == None: continue
@@ -982,7 +983,7 @@ def save_3ds(filename, context):
if ob.type not in ('MESH', 'CURVE', 'SURFACE', 'TEXT', 'META'):
continue
- data = ob_derived.create_mesh(True, 'PREVIEW')
+ data = ob_derived.create_mesh(scene, True, 'PREVIEW')
# data = getMeshFromObject(ob_derived, None, True, False, sce)
if data:
data.transform(mat)
@@ -997,7 +998,7 @@ def save_3ds(filename, context):
if not mat_ls:
mat = mat_name = None
- for f, uf in zip(data.faces, data.active_uv_texture.data):
+ for f, uf in zip(data.faces, data.uv_textures.active.data):
if mat_ls:
mat_index = f.material_index
# mat_index = f.mat
@@ -1006,7 +1007,7 @@ def save_3ds(filename, context):
mat = mat_ls[mat_index]
if mat: mat_name = mat.name
else: mat_name = None
- # else there alredy set to none
+ # else there already set to none
img = uf.image
# img = f.image
@@ -1064,7 +1065,7 @@ def save_3ds(filename, context):
'''
if not blender_mesh.users:
bpy.data.meshes.remove(blender_mesh)
-# blender_mesh.verts = None
+# blender_mesh.vertices = None
i+=i
@@ -1106,53 +1107,47 @@ def save_3ds(filename, context):
#primary.dump()
-# if __name__=='__main__':
-# if struct:
-# Blender.Window.FileSelector(save_3ds, "Export 3DS", Blender.sys.makename(ext='.3ds'))
-# else:
-# Blender.Draw.PupMenu("Error%t|This script requires a full python installation")
-# # save_3ds('/test_b.3ds')
+# # write('/test_b.3ds')
from bpy.props import *
class Export3DS(bpy.types.Operator):
'''Export to 3DS file format (.3ds)'''
bl_idname = "export.autodesk_3ds"
bl_label = 'Export 3DS'
- # List of operator properties, the attributes will be assigned
- # to the class instance from the operator settings before calling.
-
-
- # filename = StringProperty(name="File Name", description="File name used for exporting the 3DS file", maxlen= 1024, default= ""),
- path = StringProperty(name="File Path", description="File path used for exporting the 3DS file", maxlen= 1024, default= "")
+ filepath = StringProperty(name="File Path", description="Filepath used for exporting the 3DS file", maxlen= 1024, default= "")
check_existing = BoolProperty(name="Check Existing", description="Check and warn on overwriting existing files", default=True, options={'HIDDEN'})
+ @classmethod
+ def poll(cls, context): # Poll isnt working yet
+ return context.active_object != None
+
def execute(self, context):
- save_3ds(self.properties.path, context)
+ filepath = self.properties.filepath
+ filepath = bpy.path.ensure_ext(filepath, ".3ds")
+
+ write(filepath, context)
return {'FINISHED'}
def invoke(self, context, event):
- wm = context.manager
- wm.add_fileselect(self)
- return {'RUNNING_MODAL'}
+ import os
+ if not self.properties.is_property_set("filepath"):
+ self.properties.filepath = os.path.splitext(bpy.data.filepath)[0] + ".3ds"
- def poll(self, context): # Poll isnt working yet
- return context.active_object != None
+ context.manager.add_fileselect(self)
+ return {'RUNNING_MODAL'}
# Add to a menu
def menu_func(self, context):
- default_path = bpy.data.filename.replace(".blend", ".3ds")
- self.layout.operator(Export3DS.bl_idname, text="3D Studio (.3ds)").path = default_path
+ self.layout.operator(Export3DS.bl_idname, text="3D Studio (.3ds)")
def register():
- bpy.types.register(Export3DS)
bpy.types.INFO_MT_file_export.append(menu_func)
+
def unregister():
- bpy.types.unregister(Export3DS)
bpy.types.INFO_MT_file_export.remove(menu_func)
if __name__ == "__main__":
register()
-