cleanup duplicate GPL haeders, blender made 2.4x __bpydoc__ into __doc__, removed version info, (thats what svn logs are for).
also moved create_derived_objects & free_derived_objects into io_utils, used by x3d and 3ds.
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
# coding: utf-8
|
||||
# ##### BEGIN GPL LICENSE BLOCK #####
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
@@ -19,99 +18,14 @@
|
||||
|
||||
# <pep8 compliant>
|
||||
|
||||
__author__ = ["Campbell Barton", "Bob Holcomb", "Richard Lärkäng", "Damien McGinnes", "Mark Stijnman"]
|
||||
__url__ = ("blenderartists.org", "www.blender.org", "www.gametutorials.com", "lib3ds.sourceforge.net/")
|
||||
__version__ = "0.90a"
|
||||
__bpydoc__ = """\
|
||||
|
||||
3ds Exporter
|
||||
|
||||
This script Exports a 3ds file.
|
||||
# Script copyright (C) Bob Holcomb
|
||||
# Contributors: Campbell Barton, Bob Holcomb, Richard Lärkäng, Damien McGinnes, Mark Stijnman
|
||||
|
||||
"""
|
||||
Exporting is based on 3ds loader from www.gametutorials.com(Thanks DigiBen) and using information
|
||||
from the lib3ds project (http://lib3ds.sourceforge.net/) sourcecode.
|
||||
"""
|
||||
|
||||
# ***** BEGIN GPL LICENSE BLOCK *****
|
||||
#
|
||||
# Script copyright (C) Bob Holcomb
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software Foundation,
|
||||
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
#
|
||||
# ***** END GPL LICENCE BLOCK *****
|
||||
# --------------------------------------------------------------------------
|
||||
|
||||
|
||||
######################################################
|
||||
# Importing modules
|
||||
######################################################
|
||||
|
||||
import struct
|
||||
import os
|
||||
import time
|
||||
|
||||
import bpy
|
||||
|
||||
# import Blender
|
||||
# from BPyMesh import getMeshFromObject
|
||||
# from BPyObject import getDerivedObjects
|
||||
# try:
|
||||
# import struct
|
||||
# except:
|
||||
# struct = None
|
||||
|
||||
# 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(scene, ob):
|
||||
if ob.parent and ob.parent.dupli_type != 'NONE':
|
||||
return False, None
|
||||
|
||||
if ob.dupli_type != 'NONE':
|
||||
ob.create_dupli_list(scene)
|
||||
return True, [(dob.object, dob.matrix) for dob in ob.dupli_list]
|
||||
else:
|
||||
return False, [(ob, ob.matrix_world)]
|
||||
|
||||
# also used by X3D exporter
|
||||
def free_derived_objects(ob):
|
||||
ob.free_dupli_list()
|
||||
|
||||
# So 3ds max can open files, limit names to 12 in length
|
||||
# this is verry annoying for filenames!
|
||||
name_unique = []
|
||||
name_mapping = {}
|
||||
def sane_name(name):
|
||||
name_fixed = name_mapping.get(name)
|
||||
if name_fixed != None:
|
||||
return name_fixed
|
||||
|
||||
if len(name) > 12:
|
||||
new_name = name[:12]
|
||||
else:
|
||||
new_name = name
|
||||
|
||||
i = 0
|
||||
|
||||
while new_name in name_unique:
|
||||
new_name = new_name[:-4] + '.%.3d' % i
|
||||
i+=1
|
||||
|
||||
name_unique.append(new_name)
|
||||
name_mapping[name] = new_name
|
||||
return new_name
|
||||
|
||||
######################################################
|
||||
# Data Structures
|
||||
######################################################
|
||||
@@ -926,20 +840,14 @@ def write(filename, context):
|
||||
'''Save the Blender scene to a 3ds file.'''
|
||||
# Time the export
|
||||
|
||||
if not filename.lower().endswith('.3ds'):
|
||||
filename += '.3ds'
|
||||
|
||||
# XXX
|
||||
# if not BPyMessages.Warning_SaveOver(filename):
|
||||
# return
|
||||
|
||||
# XXX
|
||||
time1 = time.clock()
|
||||
# time1= Blender.sys.time()
|
||||
# Blender.Window.WaitCursor(1)
|
||||
|
||||
sce = context.scene
|
||||
# sce= bpy.data.scenes.active
|
||||
|
||||
if context.object:
|
||||
bpy.ops.object.mode_set(mode='OBJECT')
|
||||
@@ -1106,9 +1014,10 @@ def write(filename, context):
|
||||
# Debugging only: dump the chunk hierarchy:
|
||||
#primary.dump()
|
||||
|
||||
|
||||
import bpy
|
||||
from bpy.props import *
|
||||
from io_utils import ExportHelper
|
||||
from io_utils import create_derived_objects, free_derived_objects
|
||||
|
||||
|
||||
class Export3DS(bpy.types.Operator, ExportHelper):
|
||||
|
||||
@@ -18,36 +18,13 @@
|
||||
|
||||
# <pep8 compliant>
|
||||
|
||||
__author__ = "Campbell Barton"
|
||||
__url__ = ['www.blender.org', 'blenderartists.org']
|
||||
__version__ = "1.2"
|
||||
# Script copyright (C) Campbell Barton
|
||||
|
||||
__bpydoc__ = """\
|
||||
"""
|
||||
This script is an exporter to the FBX file format.
|
||||
|
||||
http://wiki.blender.org/index.php/Scripts/Manual/Export/autodesk_fbx
|
||||
"""
|
||||
# --------------------------------------------------------------------------
|
||||
# FBX Export v0.1 by Campbell Barton (AKA Ideasman)
|
||||
# --------------------------------------------------------------------------
|
||||
# ***** BEGIN GPL LICENSE BLOCK *****
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software Foundation,
|
||||
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
#
|
||||
# ***** END GPL LICENCE BLOCK *****
|
||||
# --------------------------------------------------------------------------
|
||||
|
||||
import os
|
||||
import time
|
||||
@@ -3026,300 +3003,8 @@ Takes: {''')
|
||||
# bpy.util.copy_images( [ tex[1] for tex in textures if tex[1] != None ], basepath)
|
||||
|
||||
print('export finished in %.4f sec.' % (time.clock() - start_time))
|
||||
# print 'export finished in %.4f sec.' % (Blender.sys.time() - start_time)
|
||||
return True
|
||||
|
||||
|
||||
# --------------------------------------------
|
||||
# UI Function - not a part of the exporter.
|
||||
# this is to separate the user interface from the rest of the exporter.
|
||||
# from Blender import Draw, Window
|
||||
EVENT_NONE = 0
|
||||
EVENT_EXIT = 1
|
||||
EVENT_REDRAW = 2
|
||||
EVENT_FILESEL = 3
|
||||
|
||||
GLOBALS = {}
|
||||
|
||||
# export opts
|
||||
|
||||
def do_redraw(e,v): GLOBALS['EVENT'] = e
|
||||
|
||||
# toggle between these 2, only allow one on at once
|
||||
def do_obs_sel(e,v):
|
||||
GLOBALS['EVENT'] = e
|
||||
GLOBALS['EXP_OBS_SCENE'].val = 0
|
||||
GLOBALS['EXP_OBS_SELECTED'].val = 1
|
||||
|
||||
def do_obs_sce(e,v):
|
||||
GLOBALS['EVENT'] = e
|
||||
GLOBALS['EXP_OBS_SCENE'].val = 1
|
||||
GLOBALS['EXP_OBS_SELECTED'].val = 0
|
||||
|
||||
def do_batch_type_grp(e,v):
|
||||
GLOBALS['EVENT'] = e
|
||||
GLOBALS['BATCH_GROUP'].val = 1
|
||||
GLOBALS['BATCH_SCENE'].val = 0
|
||||
|
||||
def do_batch_type_sce(e,v):
|
||||
GLOBALS['EVENT'] = e
|
||||
GLOBALS['BATCH_GROUP'].val = 0
|
||||
GLOBALS['BATCH_SCENE'].val = 1
|
||||
|
||||
def do_anim_act_all(e,v):
|
||||
GLOBALS['EVENT'] = e
|
||||
GLOBALS['ANIM_ACTION_ALL'][0].val = 1
|
||||
GLOBALS['ANIM_ACTION_ALL'][1].val = 0
|
||||
|
||||
def do_anim_act_cur(e,v):
|
||||
if GLOBALS['BATCH_ENABLE'].val and GLOBALS['BATCH_GROUP'].val:
|
||||
Draw.PupMenu('Warning%t|Cant use this with batch export group option')
|
||||
else:
|
||||
GLOBALS['EVENT'] = e
|
||||
GLOBALS['ANIM_ACTION_ALL'][0].val = 0
|
||||
GLOBALS['ANIM_ACTION_ALL'][1].val = 1
|
||||
|
||||
def fbx_ui_exit(e,v):
|
||||
GLOBALS['EVENT'] = e
|
||||
|
||||
def do_help(e,v):
|
||||
url = 'http://wiki.blender.org/index.php/Scripts/Manual/Export/autodesk_fbx'
|
||||
print('Trying to open web browser with documentation at this address...')
|
||||
print('\t' + url)
|
||||
|
||||
try:
|
||||
import webbrowser
|
||||
webbrowser.open(url)
|
||||
except:
|
||||
Blender.Draw.PupMenu("Error%t|Opening a webbrowser requires a full python installation")
|
||||
print('...could not open a browser window.')
|
||||
|
||||
|
||||
|
||||
# run when export is pressed
|
||||
#def fbx_ui_write(e,v):
|
||||
def fbx_ui_write(filename, context):
|
||||
|
||||
# Dont allow overwriting files when saving normally
|
||||
if not GLOBALS['BATCH_ENABLE'].val:
|
||||
if not BPyMessages.Warning_SaveOver(filename):
|
||||
return
|
||||
|
||||
GLOBALS['EVENT'] = EVENT_EXIT
|
||||
|
||||
# Keep the order the same as above for simplicity
|
||||
# the [] is a dummy arg used for objects
|
||||
|
||||
Blender.Window.WaitCursor(1)
|
||||
|
||||
# Make the matrix
|
||||
GLOBAL_MATRIX = mtx4_identity
|
||||
GLOBAL_MATRIX[0][0] = GLOBAL_MATRIX[1][1] = GLOBAL_MATRIX[2][2] = GLOBALS['_SCALE'].val
|
||||
if GLOBALS['_XROT90'].val: GLOBAL_MATRIX = mtx4_x90n * GLOBAL_MATRIX
|
||||
if GLOBALS['_YROT90'].val: GLOBAL_MATRIX = mtx4_y90n * GLOBAL_MATRIX
|
||||
if GLOBALS['_ZROT90'].val: GLOBAL_MATRIX = mtx4_z90n * GLOBAL_MATRIX
|
||||
|
||||
ret = write(\
|
||||
filename, None,\
|
||||
context,
|
||||
GLOBALS['EXP_OBS_SELECTED'].val,\
|
||||
GLOBALS['EXP_MESH'].val,\
|
||||
GLOBALS['EXP_MESH_APPLY_MOD'].val,\
|
||||
GLOBALS['EXP_MESH_HQ_NORMALS'].val,\
|
||||
GLOBALS['EXP_ARMATURE'].val,\
|
||||
GLOBALS['EXP_LAMP'].val,\
|
||||
GLOBALS['EXP_CAMERA'].val,\
|
||||
GLOBALS['EXP_EMPTY'].val,\
|
||||
GLOBALS['EXP_IMAGE_COPY'].val,\
|
||||
GLOBAL_MATRIX,\
|
||||
GLOBALS['ANIM_ENABLE'].val,\
|
||||
GLOBALS['ANIM_OPTIMIZE'].val,\
|
||||
GLOBALS['ANIM_OPTIMIZE_PRECISSION'].val,\
|
||||
GLOBALS['ANIM_ACTION_ALL'][0].val,\
|
||||
GLOBALS['BATCH_ENABLE'].val,\
|
||||
GLOBALS['BATCH_GROUP'].val,\
|
||||
GLOBALS['BATCH_SCENE'].val,\
|
||||
GLOBALS['BATCH_FILE_PREFIX'].val,\
|
||||
GLOBALS['BATCH_OWN_DIR'].val,\
|
||||
)
|
||||
|
||||
Blender.Window.WaitCursor(0)
|
||||
GLOBALS.clear()
|
||||
|
||||
if ret == False:
|
||||
Draw.PupMenu('Error%t|Path cannot be written to!')
|
||||
|
||||
|
||||
def fbx_ui():
|
||||
# Only to center the UI
|
||||
x,y = GLOBALS['MOUSE']
|
||||
x-=180; y-=0 # offset... just to get it centered
|
||||
|
||||
Draw.Label('Export Objects...', x+20,y+165, 200, 20)
|
||||
|
||||
if not GLOBALS['BATCH_ENABLE'].val:
|
||||
Draw.BeginAlign()
|
||||
GLOBALS['EXP_OBS_SELECTED'] = Draw.Toggle('Selected Objects', EVENT_REDRAW, x+20, y+145, 160, 20, GLOBALS['EXP_OBS_SELECTED'].val, 'Export selected objects on visible layers', do_obs_sel)
|
||||
GLOBALS['EXP_OBS_SCENE'] = Draw.Toggle('Scene Objects', EVENT_REDRAW, x+180, y+145, 160, 20, GLOBALS['EXP_OBS_SCENE'].val, 'Export all objects in this scene', do_obs_sce)
|
||||
Draw.EndAlign()
|
||||
|
||||
Draw.BeginAlign()
|
||||
GLOBALS['_SCALE'] = Draw.Number('Scale:', EVENT_NONE, x+20, y+120, 140, 20, GLOBALS['_SCALE'].val, 0.01, 1000.0, 'Scale all data, (Note! some imports dont support scaled armatures)')
|
||||
GLOBALS['_XROT90'] = Draw.Toggle('Rot X90', EVENT_NONE, x+160, y+120, 60, 20, GLOBALS['_XROT90'].val, 'Rotate all objects 90 degrees about the X axis')
|
||||
GLOBALS['_YROT90'] = Draw.Toggle('Rot Y90', EVENT_NONE, x+220, y+120, 60, 20, GLOBALS['_YROT90'].val, 'Rotate all objects 90 degrees about the Y axis')
|
||||
GLOBALS['_ZROT90'] = Draw.Toggle('Rot Z90', EVENT_NONE, x+280, y+120, 60, 20, GLOBALS['_ZROT90'].val, 'Rotate all objects 90 degrees about the Z axis')
|
||||
Draw.EndAlign()
|
||||
|
||||
y -= 35
|
||||
|
||||
Draw.BeginAlign()
|
||||
GLOBALS['EXP_EMPTY'] = Draw.Toggle('Empty', EVENT_NONE, x+20, y+120, 60, 20, GLOBALS['EXP_EMPTY'].val, 'Export empty objects')
|
||||
GLOBALS['EXP_CAMERA'] = Draw.Toggle('Camera', EVENT_NONE, x+80, y+120, 60, 20, GLOBALS['EXP_CAMERA'].val, 'Export camera objects')
|
||||
GLOBALS['EXP_LAMP'] = Draw.Toggle('Lamp', EVENT_NONE, x+140, y+120, 60, 20, GLOBALS['EXP_LAMP'].val, 'Export lamp objects')
|
||||
GLOBALS['EXP_ARMATURE'] = Draw.Toggle('Armature', EVENT_NONE, x+200, y+120, 60, 20, GLOBALS['EXP_ARMATURE'].val, 'Export armature objects')
|
||||
GLOBALS['EXP_MESH'] = Draw.Toggle('Mesh', EVENT_REDRAW, x+260, y+120, 80, 20, GLOBALS['EXP_MESH'].val, 'Export mesh objects', do_redraw) #, do_axis_z)
|
||||
Draw.EndAlign()
|
||||
|
||||
if GLOBALS['EXP_MESH'].val:
|
||||
# below mesh but
|
||||
Draw.BeginAlign()
|
||||
GLOBALS['EXP_MESH_APPLY_MOD'] = Draw.Toggle('Modifiers', EVENT_NONE, x+260, y+100, 80, 20, GLOBALS['EXP_MESH_APPLY_MOD'].val, 'Apply modifiers to mesh objects') #, do_axis_z)
|
||||
GLOBALS['EXP_MESH_HQ_NORMALS'] = Draw.Toggle('HQ Normals', EVENT_NONE, x+260, y+80, 80, 20, GLOBALS['EXP_MESH_HQ_NORMALS'].val, 'Generate high quality normals') #, do_axis_z)
|
||||
Draw.EndAlign()
|
||||
|
||||
GLOBALS['EXP_IMAGE_COPY'] = Draw.Toggle('Copy Image Files', EVENT_NONE, x+20, y+80, 160, 20, GLOBALS['EXP_IMAGE_COPY'].val, 'Copy image files to the destination path') #, do_axis_z)
|
||||
|
||||
|
||||
Draw.Label('Export Armature Animation...', x+20,y+45, 300, 20)
|
||||
|
||||
GLOBALS['ANIM_ENABLE'] = Draw.Toggle('Enable Animation', EVENT_REDRAW, x+20, y+25, 160, 20, GLOBALS['ANIM_ENABLE'].val, 'Export keyframe animation', do_redraw)
|
||||
if GLOBALS['ANIM_ENABLE'].val:
|
||||
Draw.BeginAlign()
|
||||
GLOBALS['ANIM_OPTIMIZE'] = Draw.Toggle('Optimize Keyframes', EVENT_REDRAW, x+20, y+0, 160, 20, GLOBALS['ANIM_OPTIMIZE'].val, 'Remove double keyframes', do_redraw)
|
||||
if GLOBALS['ANIM_OPTIMIZE'].val:
|
||||
GLOBALS['ANIM_OPTIMIZE_PRECISSION'] = Draw.Number('Precission: ', EVENT_NONE, x+180, y+0, 160, 20, GLOBALS['ANIM_OPTIMIZE_PRECISSION'].val, 1, 16, 'Tolerence for comparing double keyframes (higher for greater accuracy)')
|
||||
Draw.EndAlign()
|
||||
|
||||
Draw.BeginAlign()
|
||||
GLOBALS['ANIM_ACTION_ALL'][1] = Draw.Toggle('Current Action', EVENT_REDRAW, x+20, y-25, 160, 20, GLOBALS['ANIM_ACTION_ALL'][1].val, 'Use actions currently applied to the armatures (use scene start/end frame)', do_anim_act_cur)
|
||||
GLOBALS['ANIM_ACTION_ALL'][0] = Draw.Toggle('All Actions', EVENT_REDRAW, x+180,y-25, 160, 20, GLOBALS['ANIM_ACTION_ALL'][0].val, 'Use all actions for armatures', do_anim_act_all)
|
||||
Draw.EndAlign()
|
||||
|
||||
|
||||
Draw.Label('Export Batch...', x+20,y-60, 300, 20)
|
||||
GLOBALS['BATCH_ENABLE'] = Draw.Toggle('Enable Batch', EVENT_REDRAW, x+20, y-80, 160, 20, GLOBALS['BATCH_ENABLE'].val, 'Automate exporting multiple scenes or groups to files', do_redraw)
|
||||
|
||||
if GLOBALS['BATCH_ENABLE'].val:
|
||||
Draw.BeginAlign()
|
||||
GLOBALS['BATCH_GROUP'] = Draw.Toggle('Group > File', EVENT_REDRAW, x+20, y-105, 160, 20, GLOBALS['BATCH_GROUP'].val, 'Export each group as an FBX file', do_batch_type_grp)
|
||||
GLOBALS['BATCH_SCENE'] = Draw.Toggle('Scene > File', EVENT_REDRAW, x+180, y-105, 160, 20, GLOBALS['BATCH_SCENE'].val, 'Export each scene as an FBX file', do_batch_type_sce)
|
||||
|
||||
# Own dir requires OS module
|
||||
if os:
|
||||
GLOBALS['BATCH_OWN_DIR'] = Draw.Toggle('Own Dir', EVENT_NONE, x+20, y-125, 80, 20, GLOBALS['BATCH_OWN_DIR'].val, 'Create a dir for each exported file')
|
||||
GLOBALS['BATCH_FILE_PREFIX'] = Draw.String('Prefix: ', EVENT_NONE, x+100, y-125, 240, 20, GLOBALS['BATCH_FILE_PREFIX'].val, 64, 'Prefix each file with this name ')
|
||||
else:
|
||||
GLOBALS['BATCH_FILE_PREFIX'] = Draw.String('Prefix: ', EVENT_NONE, x+20, y-125, 320, 20, GLOBALS['BATCH_FILE_PREFIX'].val, 64, 'Prefix each file with this name ')
|
||||
|
||||
|
||||
Draw.EndAlign()
|
||||
|
||||
#y+=80
|
||||
|
||||
'''
|
||||
Draw.BeginAlign()
|
||||
GLOBALS['FILENAME'] = Draw.String('path: ', EVENT_NONE, x+20, y-170, 300, 20, GLOBALS['FILENAME'].val, 64, 'Prefix each file with this name ')
|
||||
Draw.PushButton('..', EVENT_FILESEL, x+320, y-170, 20, 20, 'Select the path', do_redraw)
|
||||
'''
|
||||
# Until batch is added
|
||||
#
|
||||
|
||||
|
||||
#Draw.BeginAlign()
|
||||
Draw.PushButton('Online Help', EVENT_REDRAW, x+20, y-160, 100, 20, 'Open online help in a browser window', do_help)
|
||||
Draw.PushButton('Cancel', EVENT_EXIT, x+130, y-160, 100, 20, 'Exit the exporter', fbx_ui_exit)
|
||||
Draw.PushButton('Export', EVENT_FILESEL, x+240, y-160, 100, 20, 'Export the fbx file', do_redraw)
|
||||
|
||||
#Draw.PushButton('Export', EVENT_EXIT, x+180, y-160, 160, 20, 'Export the fbx file', fbx_ui_write)
|
||||
#Draw.EndAlign()
|
||||
|
||||
# exit when mouse out of the view?
|
||||
# GLOBALS['EVENT'] = EVENT_EXIT
|
||||
|
||||
#def write_ui(filename):
|
||||
def write_ui():
|
||||
|
||||
# globals
|
||||
GLOBALS['EVENT'] = EVENT_REDRAW
|
||||
#GLOBALS['MOUSE'] = Window.GetMouseCoords()
|
||||
GLOBALS['MOUSE'] = [i/2 for i in Window.GetScreenSize()]
|
||||
GLOBALS['FILENAME'] = ''
|
||||
'''
|
||||
# IF called from the fileselector
|
||||
if filename == None:
|
||||
GLOBALS['FILENAME'] = filename # Draw.Create(Blender.sys.makename(ext='.fbx'))
|
||||
else:
|
||||
GLOBALS['FILENAME'].val = filename
|
||||
'''
|
||||
GLOBALS['EXP_OBS_SELECTED'] = Draw.Create(1) # dont need 2 variables but just do this for clarity
|
||||
GLOBALS['EXP_OBS_SCENE'] = Draw.Create(0)
|
||||
|
||||
GLOBALS['EXP_MESH'] = Draw.Create(1)
|
||||
GLOBALS['EXP_MESH_APPLY_MOD'] = Draw.Create(1)
|
||||
GLOBALS['EXP_MESH_HQ_NORMALS'] = Draw.Create(0)
|
||||
GLOBALS['EXP_ARMATURE'] = Draw.Create(1)
|
||||
GLOBALS['EXP_LAMP'] = Draw.Create(1)
|
||||
GLOBALS['EXP_CAMERA'] = Draw.Create(1)
|
||||
GLOBALS['EXP_EMPTY'] = Draw.Create(1)
|
||||
GLOBALS['EXP_IMAGE_COPY'] = Draw.Create(0)
|
||||
# animation opts
|
||||
GLOBALS['ANIM_ENABLE'] = Draw.Create(1)
|
||||
GLOBALS['ANIM_OPTIMIZE'] = Draw.Create(1)
|
||||
GLOBALS['ANIM_OPTIMIZE_PRECISSION'] = Draw.Create(4) # decimal places
|
||||
GLOBALS['ANIM_ACTION_ALL'] = [Draw.Create(0), Draw.Create(1)] # not just the current action
|
||||
|
||||
# batch export options
|
||||
GLOBALS['BATCH_ENABLE'] = Draw.Create(0)
|
||||
GLOBALS['BATCH_GROUP'] = Draw.Create(1) # cant have both of these enabled at once.
|
||||
GLOBALS['BATCH_SCENE'] = Draw.Create(0) # see above
|
||||
GLOBALS['BATCH_FILE_PREFIX'] = Draw.Create(Blender.sys.makename(ext='_').split('\\')[-1].split('/')[-1])
|
||||
GLOBALS['BATCH_OWN_DIR'] = Draw.Create(0)
|
||||
# done setting globals
|
||||
|
||||
# Used by the user interface
|
||||
GLOBALS['_SCALE'] = Draw.Create(1.0)
|
||||
GLOBALS['_XROT90'] = Draw.Create(True)
|
||||
GLOBALS['_YROT90'] = Draw.Create(False)
|
||||
GLOBALS['_ZROT90'] = Draw.Create(False)
|
||||
|
||||
# best not do move the cursor
|
||||
# Window.SetMouseCoords(*[i/2 for i in Window.GetScreenSize()])
|
||||
|
||||
# hack so the toggle buttons redraw. this is not nice at all
|
||||
while GLOBALS['EVENT'] != EVENT_EXIT:
|
||||
|
||||
if GLOBALS['BATCH_ENABLE'].val and GLOBALS['BATCH_GROUP'].val and GLOBALS['ANIM_ACTION_ALL'][1].val:
|
||||
#Draw.PupMenu("Warning%t|Cant batch export groups with 'Current Action' ")
|
||||
GLOBALS['ANIM_ACTION_ALL'][0].val = 1
|
||||
GLOBALS['ANIM_ACTION_ALL'][1].val = 0
|
||||
|
||||
if GLOBALS['EVENT'] == EVENT_FILESEL:
|
||||
if GLOBALS['BATCH_ENABLE'].val:
|
||||
txt = 'Batch FBX Dir'
|
||||
name = Blender.sys.expandpath('//')
|
||||
else:
|
||||
txt = 'Export FBX'
|
||||
name = Blender.sys.makename(ext='.fbx')
|
||||
|
||||
Blender.Window.FileSelector(fbx_ui_write, txt, name)
|
||||
#fbx_ui_write('/test.fbx')
|
||||
break
|
||||
|
||||
Draw.UIBlock(fbx_ui, 0)
|
||||
|
||||
|
||||
# GLOBALS.clear()
|
||||
|
||||
from bpy.props import *
|
||||
from io_utils import ExportHelper
|
||||
|
||||
|
||||
@@ -18,8 +18,9 @@
|
||||
|
||||
# <pep8 compliant>
|
||||
|
||||
__author__ = "Bill L.Nieuwendorp"
|
||||
__bpydoc__ = """\
|
||||
# Contributors: Bill L.Nieuwendorp
|
||||
|
||||
"""
|
||||
This script Exports Lightwaves MotionDesigner format.
|
||||
|
||||
The .mdd format has become quite a popular Pipeline format<br>
|
||||
@@ -27,25 +28,6 @@ for moving animations from package to package.
|
||||
|
||||
Be sure not to use modifiers that change the number or order of verts in the mesh
|
||||
"""
|
||||
#Please send any fixes,updates,bugs to Slow67_at_Gmail.com or cbarton_at_metavr.com
|
||||
#Bill Niewuendorp
|
||||
# ***** BEGIN GPL LICENSE BLOCK *****
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software Foundation,
|
||||
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
#
|
||||
# ***** END GPL LICENCE BLOCK *****
|
||||
|
||||
import bpy
|
||||
import mathutils
|
||||
|
||||
@@ -18,23 +18,6 @@
|
||||
|
||||
# <pep8 compliant>
|
||||
|
||||
__author__ = "Campbell Barton, Jiri Hnidek, Paolo Ciccone"
|
||||
__url__ = ['http://wiki.blender.org/index.php/Scripts/Manual/Export/wavefront_obj', 'www.blender.org', 'blenderartists.org']
|
||||
__version__ = "1.21"
|
||||
|
||||
__bpydoc__ = """\
|
||||
This script is an exporter to OBJ file format.
|
||||
|
||||
Usage:
|
||||
|
||||
Select the objects you wish to export and run this script from "File->Export" menu.
|
||||
Selecting the default options from the popup box will be good in most cases.
|
||||
All objects that can be represented as a mesh (mesh, curve, metaball, surface, text3d)
|
||||
will be exported as mesh data.
|
||||
"""
|
||||
|
||||
# import math and other in functions that use them for the sake of fast Blender startup
|
||||
# import math
|
||||
import os
|
||||
import time
|
||||
import shutil
|
||||
|
||||
@@ -18,55 +18,17 @@
|
||||
|
||||
# <pep8 compliant>
|
||||
|
||||
# Copyright (C) 2004, 2005: Bruce Merry, bmerry@cs.uct.ac.za
|
||||
# Contributors: Bruce Merry, Campbell Barton
|
||||
|
||||
import bpy
|
||||
|
||||
__author__ = "Bruce Merry"
|
||||
__version__ = "0.93"
|
||||
__bpydoc__ = """\
|
||||
"""
|
||||
This script exports Stanford PLY files from Blender. It supports normals,
|
||||
colours, and texture coordinates per face or per vertex.
|
||||
Only one mesh can be exported at a time.
|
||||
"""
|
||||
|
||||
# Copyright (C) 2004, 2005: Bruce Merry, bmerry@cs.uct.ac.za
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software Foundation,
|
||||
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
# Vector rounding se we can use as keys
|
||||
#
|
||||
# Updated on Aug 11, 2008 by Campbell Barton
|
||||
# - added 'comment' prefix to comments - Needed to comply with the PLY spec.
|
||||
#
|
||||
# Updated on Jan 1, 2007 by Gabe Ghearing
|
||||
# - fixed normals so they are correctly smooth/flat
|
||||
# - fixed crash when the model doesn't have uv coords or vertex colors
|
||||
# - fixed crash when the model has vertex colors but doesn't have uv coords
|
||||
# - changed float32 to float and uint8 to uchar for compatibility
|
||||
# Errata/Notes as of Jan 1, 2007
|
||||
# - script exports texture coords if they exist even if TexFace isn't selected (not a big deal to me)
|
||||
# - ST(R) should probably be renamed UV(T) like in most PLY files (importer needs to be updated to take either)
|
||||
#
|
||||
# Updated on Jan 3, 2007 by Gabe Ghearing
|
||||
# - fixed "sticky" vertex UV exporting
|
||||
# - added pupmenu to enable/disable exporting normals, uv coords, and colors
|
||||
# Errata/Notes as of Jan 3, 2007
|
||||
# - ST(R) coords should probably be renamed UV(T) like in most PLY files (importer needs to be updated to take either)
|
||||
# - edges should be exported since PLY files support them
|
||||
# - code is getting spaghettish, it should be refactored...
|
||||
#
|
||||
|
||||
|
||||
def rvec3d(v):
|
||||
return round(v[0], 6), round(v[1], 6), round(v[2], 6)
|
||||
|
||||
|
||||
@@ -18,68 +18,29 @@
|
||||
|
||||
# <pep8 compliant>
|
||||
|
||||
__author__ = ("Bart", "Campbell Barton")
|
||||
__email__ = ["Bart, bart:neeneenee*de"]
|
||||
__url__ = ["Author's (Bart) homepage, http://www.neeneenee.de/vrml"]
|
||||
__version__ = "2006/01/17"
|
||||
__bpydoc__ = """\
|
||||
# Contributors: bart:neeneenee*de, http://www.neeneenee.de/vrml, Campbell Barton
|
||||
|
||||
"""
|
||||
This script exports to X3D format.
|
||||
|
||||
Usage:
|
||||
|
||||
Run this script from "File->Export" menu. A pop-up will ask whether you
|
||||
want to export only selected or all relevant objects.
|
||||
|
||||
Known issues:<br>
|
||||
Known issues:
|
||||
Doesn't handle multiple materials (don't use material indices);<br>
|
||||
Doesn't handle multiple UV textures on a single mesh (create a mesh for each texture);<br>
|
||||
Can't get the texture array associated with material * not the UV ones;
|
||||
"""
|
||||
|
||||
|
||||
# $Id$
|
||||
#
|
||||
#------------------------------------------------------------------------
|
||||
# X3D exporter for blender 2.36 or above
|
||||
#
|
||||
# ***** BEGIN GPL LICENSE BLOCK *****
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software Foundation,
|
||||
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
#
|
||||
# ***** END GPL LICENCE BLOCK *****
|
||||
#
|
||||
|
||||
####################################
|
||||
# Library dependancies
|
||||
####################################
|
||||
|
||||
import math
|
||||
import os
|
||||
|
||||
import bpy
|
||||
import mathutils
|
||||
|
||||
from export_3ds import create_derived_objects, free_derived_objects
|
||||
from io_utils import create_derived_objects, free_derived_objects
|
||||
|
||||
# import Blender
|
||||
# from Blender import Object, Lamp, Draw, Image, Text, sys, Mesh
|
||||
# from Blender.Scene import Render
|
||||
# import BPyObject
|
||||
# import BPyMesh
|
||||
|
||||
#
|
||||
DEG2RAD=0.017453292519943295
|
||||
MATWORLD= mathutils.Matrix.Rotation(-90, 4, 'X')
|
||||
|
||||
|
||||
@@ -18,6 +18,8 @@
|
||||
|
||||
# <pep8 compliant>
|
||||
|
||||
# Script copyright (C) Campbell Barton
|
||||
|
||||
import math
|
||||
from math import radians
|
||||
|
||||
|
||||
@@ -18,124 +18,8 @@
|
||||
|
||||
# <pep8 compliant>
|
||||
|
||||
__author__= ['Bob Holcomb', 'Richard L?rk?ng', 'Damien McGinnes', 'Campbell Barton', 'Mario Lapin']
|
||||
__url__ = ("blenderartists.org", "www.blender.org", "www.gametutorials.com", "lib3ds.sourceforge.net/")
|
||||
__version__= '0.996'
|
||||
__bpydoc__= '''\
|
||||
|
||||
3ds Importer
|
||||
|
||||
This script imports a 3ds file and the materials into Blender for editing.
|
||||
|
||||
Loader is based on 3ds loader from www.gametutorials.com (Thanks DigiBen).
|
||||
|
||||
0.996 by Mario Lapin (mario.lapin@gmail.com) 13/04/200 <br>
|
||||
- Implemented workaround to correct association between name, geometry and materials of
|
||||
imported meshes.
|
||||
|
||||
Without this patch, version 0.995 of this importer would associate to each mesh object the
|
||||
geometry and the materials of the previously parsed mesh object. By so, the name of the
|
||||
first mesh object would be thrown away, and the name of the last mesh object would be
|
||||
automatically merged with a '.001' at the end. No object would desappear, however object's
|
||||
names and materials would be completely jumbled.
|
||||
|
||||
0.995 by Campbell Barton<br>
|
||||
- workaround for buggy mesh vert delete
|
||||
- minor tweaks
|
||||
|
||||
0.99 by Bob Holcomb<br>
|
||||
- added support for floating point color values that previously broke on import.
|
||||
|
||||
0.98 by Campbell Barton<br>
|
||||
- import faces and verts to lists instead of a mesh, convert to a mesh later
|
||||
- use new index mapping feature of mesh to re-map faces that were not added.
|
||||
|
||||
0.97 by Campbell Barton<br>
|
||||
- Strip material names of spaces
|
||||
- Added import as instance to import the 3ds into its own
|
||||
scene and add a group instance to the current scene
|
||||
- New option to scale down imported objects so they are within a limited bounding area.
|
||||
|
||||
0.96 by Campbell Barton<br>
|
||||
- Added workaround for bug in setting UV's for Zero vert index UV faces.
|
||||
- Removed unique name function, let blender make the names unique.
|
||||
|
||||
0.95 by Campbell Barton<br>
|
||||
- Removed workarounds for Blender 2.41
|
||||
- Mesh objects split by material- many 3ds objects used more then 16 per mesh.
|
||||
- Removed a lot of unneeded variable creation.
|
||||
|
||||
0.94 by Campbell Barton<br>
|
||||
- Face import tested to be about overall 16x speedup over 0.93.
|
||||
- Material importing speedup.
|
||||
- Tested with more models.
|
||||
- Support some corrupt models.
|
||||
|
||||
0.93 by Campbell Barton<br>
|
||||
- Tested with 400 3ds files from turbosquid and samples.
|
||||
- Tactfully ignore faces that used the same verts twice.
|
||||
- Rollback to 0.83 sloppy un-reorganized code, this broke UV coord loading.
|
||||
- Converted from NMesh to Mesh.
|
||||
- Faster and cleaner new names.
|
||||
- Use external comprehensive image loader.
|
||||
- Re intergrated 0.92 and 0.9 changes
|
||||
- Fixes for 2.41 compat.
|
||||
- Non textured faces do not use a texture flag.
|
||||
|
||||
0.92<br>
|
||||
- Added support for diffuse, alpha, spec, bump maps in a single material
|
||||
|
||||
0.9<br>
|
||||
- Reorganized code into object/material block functions<br>
|
||||
- Use of Matrix() to copy matrix data<br>
|
||||
- added support for material transparency<br>
|
||||
|
||||
0.83 2005-08-07: Campell Barton
|
||||
- Aggressive image finding and case insensitivy for posisx systems.
|
||||
|
||||
0.82a 2005-07-22
|
||||
- image texture loading (both for face uv and renderer)
|
||||
|
||||
0.82 - image texture loading (for face uv)
|
||||
|
||||
0.81a (fork- not 0.9) Campbell Barton 2005-06-08
|
||||
- Simplified import code
|
||||
- Never overwrite data
|
||||
- Faster list handling
|
||||
- Leaves import selected
|
||||
|
||||
0.81 Damien McGinnes 2005-01-09
|
||||
- handle missing images better
|
||||
|
||||
0.8 Damien McGinnes 2005-01-08
|
||||
- copies sticky UV coords to face ones
|
||||
- handles images better
|
||||
- Recommend that you run 'RemoveDoubles' on each imported mesh after using this script
|
||||
|
||||
'''
|
||||
|
||||
# ***** BEGIN GPL LICENSE BLOCK *****
|
||||
#
|
||||
# Script copyright (C) Bob Holcomb
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software Foundation,
|
||||
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
#
|
||||
# ***** END GPL LICENCE BLOCK *****
|
||||
# --------------------------------------------------------------------------
|
||||
|
||||
# Importing modules
|
||||
# Contributors: Bob Holcomb, Richard L?rk?ng, Damien McGinnes, Campbell Barton, Mario Lapin
|
||||
|
||||
import os
|
||||
import time
|
||||
|
||||
@@ -18,16 +18,17 @@
|
||||
|
||||
# <pep8 compliant>
|
||||
|
||||
__author__= "Campbell Barton", "Jiri Hnidek", "Paolo Ciccone"
|
||||
__url__= ['http://wiki.blender.org/index.php/Scripts/Manual/Import/wavefront_obj', 'blender.org', 'blenderartists.org']
|
||||
__version__= "2.11"
|
||||
# Script copyright (C) Campbell Barton
|
||||
# Contributors: Campbell Barton, Jiri Hnidek, Paolo Ciccone
|
||||
|
||||
__bpydoc__= """\
|
||||
"""
|
||||
This script imports a Wavefront OBJ files to Blender.
|
||||
|
||||
Usage:
|
||||
Run this script from "File->Import" menu and then load the desired OBJ file.
|
||||
Note, This loads mesh objects and materials only, nurbs and curves are not supported.
|
||||
|
||||
http://wiki.blender.org/index.php/Scripts/Manual/Import/wavefront_obj
|
||||
"""
|
||||
|
||||
import os
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# ***** BEGIN GPL LICENSE BLOCK *****
|
||||
# ##### BEGIN GPL LICENSE BLOCK #####
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
@@ -14,7 +14,7 @@
|
||||
# along with this program; if not, write to the Free Software Foundation,
|
||||
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
#
|
||||
# ***** END GPL LICENCE BLOCK *****
|
||||
# ##### END GPL LICENSE BLOCK #####
|
||||
|
||||
# <pep8 compliant>
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ class ExportHelper:
|
||||
def invoke(self, context, event):
|
||||
import os
|
||||
if not self.properties.is_property_set("filepath"):
|
||||
self.properties.filepath = os.path.splitext(context.main.filepath)[0] + self.file_extension
|
||||
self.properties.filepath = os.path.splitext(context.main.filepath)[0] + self.filename_ext
|
||||
|
||||
context.manager.add_fileselect(self)
|
||||
return {'RUNNING_MODAL'}
|
||||
@@ -42,6 +42,48 @@ class ImportHelper:
|
||||
return {'RUNNING_MODAL'}
|
||||
|
||||
|
||||
# return a tuple (free, object list), free is True if memory should be freed later with free_derived_objects()
|
||||
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(scene)
|
||||
return True, [(dob.object, dob.matrix) for dob in ob.dupli_list]
|
||||
else:
|
||||
return False, [(ob, ob.matrix_world)]
|
||||
|
||||
|
||||
|
||||
def free_derived_objects(ob):
|
||||
ob.free_dupli_list()
|
||||
|
||||
|
||||
# So 3ds max can open files, limit names to 12 in length
|
||||
# this is verry annoying for filenames!
|
||||
name_unique = []
|
||||
name_mapping = {}
|
||||
def sane_name(name):
|
||||
name_fixed = name_mapping.get(name)
|
||||
if name_fixed != None:
|
||||
return name_fixed
|
||||
|
||||
if len(name) > 12:
|
||||
new_name = name[:12]
|
||||
else:
|
||||
new_name = name
|
||||
|
||||
i = 0
|
||||
|
||||
while new_name in name_unique:
|
||||
new_name = new_name[:-4] + '.%.3d' % i
|
||||
i+=1
|
||||
|
||||
name_unique.append(new_name)
|
||||
name_mapping[name] = new_name
|
||||
return new_name
|
||||
|
||||
|
||||
def unpack_list(list_of_tuples):
|
||||
flat_list = []
|
||||
flat_list_extend = flat_list.extend # a tich faster
|
||||
|
||||
Reference in New Issue
Block a user