3
""" Registration info for Blender menus: <- these words are ignored
4
Name: 'Lightwave Motion (.mot)...'
7
Tip: 'Export Loc Rot Size chanels to a Lightwave .mot file'
10
__author__ = "Daniel Salazar (ZanQdo)"
11
__url__ = ("blender", "elysiun",
12
"e-mail: zanqdo@gmail.com")
13
__version__ = "24/03/06"
16
This script exports the selected object's motion channels to a Lightwave
20
Run the script with one or more objects selected (any kind), frames exported
21
are between Start and End frames in Render buttons.
25
# $Id: export_lightwave_motion.py,v 1.2 2006/04/27 12:51:09 campbellbarton Exp $
26
# --------------------------------------------------------------------------
27
# ***** BEGIN GPL LICENSE BLOCK *****
29
# Copyright (C) 2003, 2004: A Vanpoucke
31
# This program is free software; you can redistribute it and/or
32
# modify it under the terms of the GNU General Public License
33
# as published by the Free Software Foundation; either version 2
34
# of the License, or (at your option) any later version.
36
# This program is distributed in the hope that it will be useful,
37
# but WITHOUT ANY WARRANTY; without even the implied warranty of
38
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
39
# GNU General Public License for more details.
41
# You should have received a copy of the GNU General Public License
42
# along with this program; if not, write to the Free Software Foundation,
43
# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
45
# ***** END GPL LICENCE BLOCK *****
46
# --------------------------------------------------------------------------
48
#------------------------------------
51
#------------------------------------
53
# Change the extension of the file path
55
return B.Get('filename')[: -len(B.Get('filename').split('.', -1)[-1]) -1 ] + ext
57
ObjSelect = B.Object.GetSelected()
59
def FuncionPrincipal (Dir):
60
B.Window.WaitCursor(1)
62
origName= NombreObjeto= ob.name
63
print '----\nExporting Object "%s" motion file...' % origName
65
SC = B.Scene.getCurrent()
66
SCR = SC.getRenderingContext()
68
FrameA = B.Get('curframe')
69
FrameP = B.Get('staframe')
70
FrameF = B.Get('endframe')
72
FrameRate = float(SCR.framesPerSec())
74
#---------------------------------------------
76
# Replace danger characters by '_'
77
for ch in ' /\\~!@#$%^&*()+=[];\':",./<>?\t\r\n':
78
NombreObjeto = NombreObjeto.replace(ch, '_')
80
# Check for file path extension
81
if Dir.lower().endswith('.mot'):
82
DirN= '%s_%s.mot' % (Dir[:-4], NombreObjeto)
84
DirN= '%s_%s.mot' % (Dir, NombreObjeto)
88
File.write ('LWMO\n3\n\n') # 3 is the version number.
91
File.write ('NumChannels %i\n' % TotalCanales)
93
# ----------------------------
96
def CicloPrimario(NumCanal):
97
B.Set('curframe', FrameP)
99
File.write ('Channel %i\n{ Envelope\n %i\n' % (NumCanal, (FrameF - FrameP + 1)))
102
while FrameA < (FrameF + 1):
104
B.Set('curframe', FrameA)
106
mat= ob.mat # Worldspace matrix
109
Val = mat.translationPart().x
111
Val = mat.translationPart().z
113
Val = mat.translationPart().y
115
Val = -mat.toEuler().z
117
Val = -mat.toEuler().x
119
Val = -mat.toEuler().y
121
Val = mat.scalePart().x
123
Val = mat.scalePart().z
125
Val = mat.scalePart().y
127
File.write (' Key %f %f 3 0 0 0 0 0 0\n' % (Val, (FrameA/FrameRate)))
131
File.write (' Behaviors 1 1\n}\n')
133
NumObjetoActual = len(ObjSelect)
136
while Iteraciones < TotalCanales:
137
CicloPrimario(Iteraciones)
140
B.Window.DrawProgressBar(ProgBarVal, origName)
141
ProgBarVal = (float(Iteraciones) / TotalCanales) * 0.98
144
B.Window.DrawProgressBar(1.0, '') # Done
145
print '\nDone, %s motion file location is:\n%s\n' % (origName, DirN)
147
# Check if there are selected objects
149
if len(ObjSelect) == 0:
150
B.Draw.PupMenu('Select 1 or more objects, aborting.')
153
B.Window.FileSelector(FuncionPrincipal, "Write .mot File", NuevoNombre('.mot'))
155
if __name__=='__main__':
b'\\ No newline at end of file'