mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-02 09:52:27 -04:00
Added feature to export to Maya
This commit is contained in:
parent
76c3f1268b
commit
aec3ff0e3d
@ -356,6 +356,22 @@ class LevelEditorBase(DirectObject):
|
|||||||
mayaConverter = MayaConverter(self.ui, self, modelname, callBack, None, False)
|
mayaConverter = MayaConverter(self.ui, self, modelname, callBack, None, False)
|
||||||
mayaConverter.Show()
|
mayaConverter.Show()
|
||||||
|
|
||||||
|
def exportToMaya(self, mayaFileName):
|
||||||
|
exportRootNP = render
|
||||||
|
self.exportToMayaCB(mayaFileName, exportRootNP)
|
||||||
|
|
||||||
|
def exportToMayaCB(self, mayaFileName, exportRootNP):
|
||||||
|
bamFileName = mayaFileName + ".bam"
|
||||||
|
|
||||||
|
if base.direct.selected.last:
|
||||||
|
obj = self.objectMgr.findObjectByNodePath(base.direct.selected.last)
|
||||||
|
if obj:
|
||||||
|
exportRootNP = obj[OG.OBJ_NP]
|
||||||
|
|
||||||
|
exportRootNP.writeBamFile(bamFileName)
|
||||||
|
mayaConverter = MayaConverter(self.ui, self, mayaFileName, None, None, False, FROM_BAM_TO_MAYA)
|
||||||
|
mayaConverter.Show()
|
||||||
|
|
||||||
def updateStatusReadout(self, status, color=None):
|
def updateStatusReadout(self, status, color=None):
|
||||||
if status:
|
if status:
|
||||||
# add new status line, first check to see if it already exists
|
# add new status line, first check to see if it already exists
|
||||||
|
@ -102,6 +102,7 @@ ID_NEW = 101
|
|||||||
ID_OPEN = 102
|
ID_OPEN = 102
|
||||||
ID_SAVE = 103
|
ID_SAVE = 103
|
||||||
ID_SAVE_AS = 104
|
ID_SAVE_AS = 104
|
||||||
|
ID_EXPORT_TO_MAYA = 105
|
||||||
|
|
||||||
ID_DUPLICATE = 201
|
ID_DUPLICATE = 201
|
||||||
ID_MAKE_LIVE = 202
|
ID_MAKE_LIVE = 202
|
||||||
@ -126,6 +127,7 @@ class LevelEditorUIBase(WxPandaShell):
|
|||||||
ID_OPEN : ("&Open", "LE-OpenScene"),
|
ID_OPEN : ("&Open", "LE-OpenScene"),
|
||||||
ID_SAVE : ("&Save", "LE-SaveScene"),
|
ID_SAVE : ("&Save", "LE-SaveScene"),
|
||||||
ID_SAVE_AS : ("Save &As", None),
|
ID_SAVE_AS : ("Save &As", None),
|
||||||
|
ID_EXPORT_TO_MAYA : ("Export to Maya", None),
|
||||||
wx.ID_EXIT : ("&Quit", "LE-Quit"),
|
wx.ID_EXIT : ("&Quit", "LE-Quit"),
|
||||||
ID_DUPLICATE : ("&Duplicate", "LE-Duplicate"),
|
ID_DUPLICATE : ("&Duplicate", "LE-Duplicate"),
|
||||||
ID_MAKE_LIVE : ("Make &Live", "LE-MakeLive"),
|
ID_MAKE_LIVE : ("Make &Live", "LE-MakeLive"),
|
||||||
@ -169,6 +171,9 @@ class LevelEditorUIBase(WxPandaShell):
|
|||||||
menuItem = self.menuFile.Insert(3, ID_SAVE_AS, self.MENU_TEXTS[ID_SAVE_AS][0])
|
menuItem = self.menuFile.Insert(3, ID_SAVE_AS, self.MENU_TEXTS[ID_SAVE_AS][0])
|
||||||
self.Bind(wx.EVT_MENU, self.onSaveAs, menuItem)
|
self.Bind(wx.EVT_MENU, self.onSaveAs, menuItem)
|
||||||
|
|
||||||
|
menuItem = self.menuFile.Insert(4, ID_EXPORT_TO_MAYA, self.MENU_TEXTS[ID_EXPORT_TO_MAYA][0])
|
||||||
|
self.Bind(wx.EVT_MENU, self.onExportToMaya, menuItem)
|
||||||
|
|
||||||
self.menuEdit = wx.Menu()
|
self.menuEdit = wx.Menu()
|
||||||
self.menuBar.Insert(1, self.menuEdit, "&Edit")
|
self.menuBar.Insert(1, self.menuEdit, "&Edit")
|
||||||
|
|
||||||
@ -450,6 +455,12 @@ class LevelEditorUIBase(WxPandaShell):
|
|||||||
dialog.Destroy()
|
dialog.Destroy()
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
def onExportToMaya(self, evt):
|
||||||
|
dialog = wx.FileDialog(None, "Choose a file", os.getcwd(), "", "*.mb", wx.SAVE)
|
||||||
|
if dialog.ShowModal() == wx.ID_OK:
|
||||||
|
self.editor.exportToMaya(dialog.GetPath())
|
||||||
|
dialog.Destroy()
|
||||||
|
|
||||||
def onDuplicate(self, evt):
|
def onDuplicate(self, evt):
|
||||||
self.editor.objectMgr.duplicateSelected()
|
self.editor.objectMgr.duplicateSelected()
|
||||||
|
|
||||||
@ -627,4 +638,4 @@ class CurveDegreeUI(wx.Dialog):
|
|||||||
self.parent.editor.curveEditor.degree = 3
|
self.parent.editor.curveEditor.degree = 3
|
||||||
if(str(self.degree.GetSelection())=='2'):
|
if(str(self.degree.GetSelection())=='2'):
|
||||||
self.parent.editor.curveEditor.degree = 4
|
self.parent.editor.curveEditor.degree = 4
|
||||||
self.Destroy()
|
self.Destroy()
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
from direct.wxwidgets.WxAppShell import *
|
from direct.wxwidgets.WxAppShell import *
|
||||||
import os, re, shutil
|
import os, re, shutil
|
||||||
|
|
||||||
import ObjectGlobals as OG
|
import ObjectGlobals as OG
|
||||||
|
|
||||||
CLOSE_STDIN = "<CLOSE STDIN>"
|
CLOSE_STDIN = "<CLOSE STDIN>"
|
||||||
@ -72,8 +71,11 @@ class Process:
|
|||||||
else:
|
else:
|
||||||
return 1, None
|
return 1, None
|
||||||
|
|
||||||
|
FROM_MAYA_TO_EGG = 0
|
||||||
|
FROM_BAM_TO_MAYA = 1
|
||||||
|
|
||||||
class MayaConverter(wx.Dialog):
|
class MayaConverter(wx.Dialog):
|
||||||
def __init__(self, parent, editor, mayaFile, callBack=None, obj=None, isAnim=False):
|
def __init__(self, parent, editor, mayaFile, callBack=None, obj=None, isAnim=False, convertMode=FROM_MAYA_TO_EGG):
|
||||||
wx.Dialog.__init__(self, parent, id=wx.ID_ANY, title="Maya Converter",
|
wx.Dialog.__init__(self, parent, id=wx.ID_ANY, title="Maya Converter",
|
||||||
pos=wx.DefaultPosition, size=(300, 200))
|
pos=wx.DefaultPosition, size=(300, 200))
|
||||||
|
|
||||||
@ -81,6 +83,7 @@ class MayaConverter(wx.Dialog):
|
|||||||
self.obj = obj
|
self.obj = obj
|
||||||
self.isAnim = isAnim
|
self.isAnim = isAnim
|
||||||
self.callBack = callBack
|
self.callBack = callBack
|
||||||
|
self.mayaFile = mayaFile
|
||||||
|
|
||||||
self.mainPanel = wx.Panel(self, -1)
|
self.mainPanel = wx.Panel(self, -1)
|
||||||
sizer = wx.BoxSizer(wx.VERTICAL)
|
sizer = wx.BoxSizer(wx.VERTICAL)
|
||||||
@ -92,48 +95,76 @@ class MayaConverter(wx.Dialog):
|
|||||||
sizer2.Add(self.output, 1, wx.EXPAND, 0)
|
sizer2.Add(self.output, 1, wx.EXPAND, 0)
|
||||||
self.mainPanel.SetSizer(sizer2)
|
self.mainPanel.SetSizer(sizer2)
|
||||||
|
|
||||||
if self.isAnim:
|
if convertMode == FROM_MAYA_TO_EGG:
|
||||||
if self.obj:
|
self.convertFromMaya()
|
||||||
command = 'maya2egg -uo ft -a chan %s -o %s.anim.egg'%(mayaFile, mayaFile)
|
elif convertMode == FROM_BAM_TO_MAYA:
|
||||||
self.process = Process(self, command, lambda p0=None, p1=mayaFile: self.onProcessEnded(p0, p1))
|
self.convertToMaya()
|
||||||
else:
|
|
||||||
command = 'maya2egg -uo ft -a model %s -o %s.model.egg'%(mayaFile, mayaFile)
|
|
||||||
self.process = Process(self, command, lambda p0=None, p1=mayaFile: self.onModelProcessEnded(p0, p1))
|
|
||||||
else:
|
else:
|
||||||
command = 'maya2egg -uo ft %s -o %s.egg'%(mayaFile, mayaFile)
|
pass
|
||||||
self.process = Process(self, command, lambda p0=None, p1=mayaFile: self.onProcessEnded(p0, p1))
|
|
||||||
|
|
||||||
self.timer = wx.Timer(self, -1)
|
self.timer = wx.Timer(self, -1)
|
||||||
self.Bind(wx.EVT_TIMER, self.onPoll, self.timer)
|
self.Bind(wx.EVT_TIMER, self.onPoll, self.timer)
|
||||||
self.timer.Start(100)
|
self.timer.Start(100)
|
||||||
|
|
||||||
|
def convertFromMaya(self):
|
||||||
|
if self.isAnim:
|
||||||
|
if self.obj:
|
||||||
|
command = 'maya2egg -uo ft -a chan %s -o %s.anim.egg'%(self.mayaFile, self.mayaFile)
|
||||||
|
self.process = Process(self, command, lambda p0=None: self.onProcessEnded(p0))
|
||||||
|
else:
|
||||||
|
command = 'maya2egg -uo ft -a model %s -o %s.model.egg'%(self.mayaFile, self.mayaFile)
|
||||||
|
self.process = Process(self, command, lambda p0=None: self.onModelProcessEnded(p0))
|
||||||
|
else:
|
||||||
|
command = 'maya2egg -uo ft %s -o %s.egg'%(self.mayaFile, self.mayaFile)
|
||||||
|
self.process = Process(self, command, lambda p0=None: self.onProcessEnded(p0))
|
||||||
|
|
||||||
|
def convertToMaya(self):
|
||||||
|
bamFileName = self.mayaFile + ".bam"
|
||||||
|
eggFileName = self.mayaFile + ".egg"
|
||||||
|
command = 'bam2egg %s -o %s'%(bamFileName, eggFileName)
|
||||||
|
self.process = Process(self, command, lambda p0=None: self.onBam2EggEnded(p0))
|
||||||
|
|
||||||
|
def onEgg2MayaEnded(self, evt):
|
||||||
|
self.process.CloseInp()
|
||||||
|
for i in self.process.Poll():
|
||||||
|
self.output.AppendText(i)
|
||||||
|
self.process = None
|
||||||
|
|
||||||
|
def onBam2EggEnded(self, evt):
|
||||||
|
self.process.CloseInp()
|
||||||
|
for i in self.process.Poll():
|
||||||
|
self.output.AppendText(i)
|
||||||
|
eggFileName = self.mayaFile + ".egg"
|
||||||
|
command = 'egg2maya -ui ft -uo ft %s -o %s'%(eggFileName, self.mayaFile)
|
||||||
|
self.process = Process(self, command, lambda p0=None: self.onEgg2MayaEnded(p0))
|
||||||
|
|
||||||
def onPoll(self, evt):
|
def onPoll(self, evt):
|
||||||
if self.process:
|
if self.process:
|
||||||
for i in self.process.Poll():
|
for i in self.process.Poll():
|
||||||
self.output.AppendText(i)
|
self.output.AppendText(i)
|
||||||
|
|
||||||
def onModelProcessEnded(self, evt, mayaFile):
|
def onModelProcessEnded(self, evt):
|
||||||
self.process.CloseInp()
|
self.process.CloseInp()
|
||||||
for i in self.process.Poll():
|
for i in self.process.Poll():
|
||||||
self.output.AppendText(i)
|
self.output.AppendText(i)
|
||||||
self.process = None
|
self.process = None
|
||||||
command = 'maya2egg -uo ft -a chan %s -o %s.anim.egg'%(mayaFile, mayaFile)
|
command = 'maya2egg -uo ft -a chan %s -o %s.anim.egg'%(self.mayaFile, self.mayaFile)
|
||||||
self.process = Process(self, command, lambda p0 = None, p1=mayaFile: self.onProcessEnded(p0, p1))
|
self.process = Process(self, command, lambda p0 = None: self.onProcessEnded(p0))
|
||||||
|
|
||||||
def onProcessEnded(self, evt, mayaFile):
|
def onProcessEnded(self, evt):
|
||||||
self.process.CloseInp()
|
self.process.CloseInp()
|
||||||
for i in self.process.Poll():
|
for i in self.process.Poll():
|
||||||
self.output.AppendText(i)
|
self.output.AppendText(i)
|
||||||
|
|
||||||
self.output.AppendText('Converting %s is finished\n'%mayaFile)
|
self.output.AppendText('Converting %s is finished\n'%self.mayaFile)
|
||||||
self.process = None
|
self.process = None
|
||||||
|
|
||||||
name = os.path.basename(mayaFile)
|
name = os.path.basename(self.mayaFile)
|
||||||
if self.isAnim:
|
if self.isAnim:
|
||||||
if self.obj:
|
if self.obj:
|
||||||
objDef = self.obj[OG.OBJ_DEF]
|
objDef = self.obj[OG.OBJ_DEF]
|
||||||
objNP = self.obj[OG.OBJ_NP]
|
objNP = self.obj[OG.OBJ_NP]
|
||||||
animName = "%s.anim.egg"%mayaFile
|
animName = "%s.anim.egg"%self.mayaFile
|
||||||
if animName not in objDef.anims:
|
if animName not in objDef.anims:
|
||||||
objDef.anims.append(animName)
|
objDef.anims.append(animName)
|
||||||
name = os.path.basename(animName)
|
name = os.path.basename(animName)
|
||||||
@ -143,11 +174,11 @@ class MayaConverter(wx.Dialog):
|
|||||||
self.editor.ui.objectPropertyUI.updateProps(self.obj)
|
self.editor.ui.objectPropertyUI.updateProps(self.obj)
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
modelName = "%s.model.egg"%mayaFile
|
modelName = "%s.model.egg"%self.mayaFile
|
||||||
animName = "%s.anim.egg"%mayaFile
|
animName = "%s.anim.egg"%self.mayaFile
|
||||||
result = [name, modelName, animName]
|
result = [name, modelName, animName]
|
||||||
else:
|
else:
|
||||||
modelName = "%s.egg"%mayaFile
|
modelName = "%s.egg"%self.mayaFile
|
||||||
result = [name, modelName]
|
result = [name, modelName]
|
||||||
|
|
||||||
if self.callBack:
|
if self.callBack:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user