Hello I started writing a gui front end for meshmagick, it is written wxpython and so far it seems to work in linux and windows, you just have to put this program in the same folder as Meshmagick.exe and it should work in windows. In linux you would have to have meshmagick already installed.
please help me test it , and let me know if there are any other features you would like added . I'm thinking of handling , ogreXMLconverter and the mesh upgrade, anyway, here is the source code, you would need wxpython to run it.
Code: Select all
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# generated by wxGlade 0.6.3 on Thu Feb 26 15:04:43 2009
import sys
import os
try:
import wx
except:
if os.name == "posix":
r = os.system('zenity --error --text="Cannot run iserverGUI\nyou must first install wxpython"')
if r != 0:
r = os.system('kdialog --error "Cannot run iserverGUI\nYou must first install wxpython"')
# begin wxGlade: extracode
# end wxGlade
def progExist(ProgName):
paths = os.environ["PATH"]
binDirs = paths.split(":")
allProg = []
for each in binDirs:
bin = os.listdir(each)
allProg = allProg + bin
if ProgName in allProg: return True
return False
class InfoDialog(wx.Dialog):
def __init__(self, *args, **kwds):
# begin wxGlade: InfoDialog.__init__
kwds["style"] = wx.DEFAULT_DIALOG_STYLE
wx.Dialog.__init__(self, *args, **kwds)
self.label_2 = wx.StaticText(self, -1, "You must kill the iserver and then restart for this feature to take effect", style=wx.ALIGN_CENTRE)
self.ExitInfoButton = wx.Button(self, -1, "ok")
self.__set_properties()
self.__do_layout()
self.Bind(wx.EVT_BUTTON, self.onExitInfo, self.ExitInfoButton)
# end wxGlade
def __set_properties(self):
# begin wxGlade: InfoDialog.__set_properties
self.SetTitle("Info")
self.SetSize((250, 151))
# end wxGlade
def __do_layout(self):
# begin wxGlade: InfoDialog.__do_layout
sizer_7 = wx.BoxSizer(wx.VERTICAL)
sizer_7.Add(self.label_2, 2, wx.TOP|wx.EXPAND, 12)
sizer_7.Add(self.ExitInfoButton, 1, wx.BOTTOM|wx.ALIGN_CENTER_HORIZONTAL, 19)
self.SetSizer(sizer_7)
self.Layout()
# end wxGlade
def onExitInfo(self, event): # wxGlade: InfoDialog.<event_handler>
print "Event handler `onExitInfo' not implemented!"
event.Skip()
# end of class InfoDialog
class MyFrame(wx.Frame):
def __init__(self, *args, **kwds):
# begin wxGlade: MyFrame.__init__
kwds["style"] = wx.CAPTION|wx.CLOSE_BOX|wx.MINIMIZE_BOX|wx.MAXIMIZE_BOX|wx.SYSTEM_MENU|wx.RESIZE_BORDER|wx.FULL_REPAINT_ON_RESIZE|wx.TAB_TRAVERSAL|wx.CLIP_CHILDREN
wx.Frame.__init__(self, *args, **kwds)
self.notebook_1 = wx.Notebook(self, -1, style=0)
self.panel_1 = wx.Panel(self.notebook_1, -1)
self.OptimizePanel = wx.Panel(self.notebook_1, -1)
# Menu Bar
self.frame_1_menubar = wx.MenuBar()
self.FileMenu = wx.Menu()
self.FileMenu.AppendSeparator()
self.quit = wx.MenuItem(self.FileMenu, wx.NewId(), "Quit", "", wx.ITEM_NORMAL)
self.FileMenu.AppendItem(self.quit)
self.frame_1_menubar.Append(self.FileMenu, "&File")
wxglade_tmp_menu = wx.Menu()
wxglade_tmp_menu.Append(wx.NewId(), "About", "", wx.ITEM_NORMAL)
self.frame_1_menubar.Append(wxglade_tmp_menu, "&About")
self.SetMenuBar(self.frame_1_menubar)
# Menu Bar end
self.meshFile = wx.StaticText(self.OptimizePanel, -1, "mesh file", style=wx.ALIGN_CENTRE)
self.pickMeshButton = wx.Button(self.OptimizePanel, -1, "pick mesh file")
self.meshFilePathBox = wx.TextCtrl(self.OptimizePanel, -1, "", style=wx.TE_READONLY)
self.static_line_1_copy_copy_1 = wx.StaticLine(self.OptimizePanel, -1)
self.static_line_2 = wx.StaticLine(self.OptimizePanel, -1)
self.meshFile_copy_copy = wx.StaticText(self.OptimizePanel, -1, "Renaming", style=wx.ALIGN_CENTRE)
self.tolerance_copy_2 = wx.StaticText(self.OptimizePanel, -1, "-animation")
self.animationBefore = wx.TextCtrl(self.OptimizePanel, -1, "")
self.animationAfter = wx.TextCtrl(self.OptimizePanel, -1, "")
self.static_line_3 = wx.StaticLine(self.OptimizePanel, -1, style=wx.LI_VERTICAL)
self.tolerance_copy_2_copy = wx.StaticText(self.OptimizePanel, -1, "-bone ")
self.boneBefore = wx.TextCtrl(self.OptimizePanel, -1, "")
self.boneAfter = wx.TextCtrl(self.OptimizePanel, -1, "")
self.tolerance_copy_2_copy_1 = wx.StaticText(self.OptimizePanel, -1, "-material")
self.materialBefore = wx.TextCtrl(self.OptimizePanel, -1, "")
self.materialAfter = wx.TextCtrl(self.OptimizePanel, -1, "")
self.static_line_3_copy = wx.StaticLine(self.OptimizePanel, -1, style=wx.LI_VERTICAL)
self.tolerance_copy_2_copy_copy = wx.StaticText(self.OptimizePanel, -1, "-skeleton")
self.skeletonRenamed = wx.TextCtrl(self.OptimizePanel, -1, "")
self.static_line_3_copy_1 = wx.StaticLine(self.OptimizePanel, -1, style=wx.LI_VERTICAL)
self.tolerance_copy_2_copy_copy_copy = wx.StaticText(self.OptimizePanel, -1, "-submesh")
self.submeshBefore = wx.TextCtrl(self.OptimizePanel, -1, "")
self.submeshAfter = wx.TextCtrl(self.OptimizePanel, -1, "")
self.static_line_2_copy = wx.StaticLine(self.OptimizePanel, -1)
self.meshFile_copy_copy_copy = wx.StaticText(self.OptimizePanel, -1, "Transform", style=wx.ALIGN_CENTRE)
self.scaleX = wx.TextCtrl(self.OptimizePanel, -1, "")
self.scaleY = wx.TextCtrl(self.OptimizePanel, -1, "")
self.scaleZ = wx.TextCtrl(self.OptimizePanel, -1, "")
self.tolerance_copy_2_copy_copy_1 = wx.StaticText(self.OptimizePanel, -1, "-resize")
self.resizeX = wx.TextCtrl(self.OptimizePanel, -1, "")
self.resizeY = wx.TextCtrl(self.OptimizePanel, -1, "")
self.resizeZ = wx.TextCtrl(self.OptimizePanel, -1, "")
self.axesX = wx.TextCtrl(self.OptimizePanel, -1, "")
self.axesY = wx.TextCtrl(self.OptimizePanel, -1, "")
self.axesZ = wx.TextCtrl(self.OptimizePanel, -1, "")
self.tolerance_copy_2_copy_copy_1_copy = wx.StaticText(self.OptimizePanel, -1, "-translate")
self.translateX = wx.TextCtrl(self.OptimizePanel, -1, "")
self.translateY = wx.TextCtrl(self.OptimizePanel, -1, "")
self.translateZ = wx.TextCtrl(self.OptimizePanel, -1, "")
self.rotate = wx.TextCtrl(self.OptimizePanel, -1, "")
self.xaxis = wx.CheckBox(self.OptimizePanel, -1, "x axis")
self.yaxis = wx.CheckBox(self.OptimizePanel, -1, "y axis")
self.zaxis = wx.CheckBox(self.OptimizePanel, -1, "z axis")
self.clearChanges = wx.Button(self.OptimizePanel, -1, "clear Changes ")
self.commitChanges = wx.Button(self.OptimizePanel, -1, "commit changes")
self.optimizeMeshButton = wx.Button(self.OptimizePanel, -1, "Optimize Mesh")
self.meshFile_copy_1 = wx.StaticText(self.panel_1, -1, "Command output", style=wx.ALIGN_CENTRE)
self.OutputBox = wx.TextCtrl(self.panel_1, -1, "", style=wx.TE_PROCESS_TAB|wx.TE_MULTILINE|wx.TE_READONLY|wx.TE_WORDWRAP)
self.__set_properties()
self.__do_layout()
self.Bind(wx.EVT_MENU, self.onQuit, self.quit)
self.Bind(wx.EVT_MENU, self.onAbout, id=-1)
self.Bind(wx.EVT_BUTTON, self.onMediaDir, self.pickMeshButton)
# end wxGlade
self.Bind(wx.EVT_BUTTON, self.OnOptimizeMesh , self.optimizeMeshButton)
self.Bind(wx.EVT_BUTTON, self.OnclearChanges, self.clearChanges)
self.Bind(wx.EVT_BUTTON, self.OncommitChanges, self.commitChanges)
self.xaxis.SetValue(True)
self.Bind(wx.EVT_CHECKBOX, self.onChangeX, self.xaxis)
self.Bind(wx.EVT_CHECKBOX, self.onChangeY, self.yaxis)
self.Bind(wx.EVT_CHECKBOX, self.onChangeZ, self.zaxis)
self.progL = "C:\OgreCommandLineTools\MeshMagick.exe"
def __set_properties(self):
# begin wxGlade: MyFrame.__set_properties
self.SetTitle("meshmagic gui")
self.SetSize((775, 600))
self.meshFile.SetFont(wx.Font(16, wx.ROMAN, wx.NORMAL, wx.BOLD, 0, ""))
self.meshFile_copy_copy.SetFont(wx.Font(16, wx.ROMAN, wx.NORMAL, wx.BOLD, 0, ""))
self.meshFile_copy_copy_copy.SetFont(wx.Font(16, wx.ROMAN, wx.NORMAL, wx.BOLD, 0, ""))
self.clearChanges.SetMinSize((200, 68))
self.commitChanges.SetMinSize((200, 68))
self.optimizeMeshButton.SetMinSize((200, 68))
self.meshFile_copy_1.SetFont(wx.Font(16, wx.ROMAN, wx.NORMAL, wx.BOLD, 0, ""))
# end wxGlade
def __do_layout(self):
# begin wxGlade: MyFrame.__do_layout
sizer_1 = wx.BoxSizer(wx.VERTICAL)
sizer_8 = wx.BoxSizer(wx.VERTICAL)
sizer_5_copy_copy_1 = wx.BoxSizer(wx.VERTICAL)
sizer_6 = wx.BoxSizer(wx.HORIZONTAL)
sizer_5_copy_2_copy_copy = wx.BoxSizer(wx.HORIZONTAL)
sizer_5_copy_2_copy = wx.BoxSizer(wx.HORIZONTAL)
sizer_5_copy_2 = wx.BoxSizer(wx.HORIZONTAL)
sizer_5_copy_1 = wx.BoxSizer(wx.HORIZONTAL)
sizer_5 = wx.BoxSizer(wx.HORIZONTAL)
sizer_6_copy_1_copy_1 = wx.BoxSizer(wx.HORIZONTAL)
sizer_5_copy_copy_1.Add(self.meshFile, 0, wx.TOP|wx.ALIGN_CENTER_HORIZONTAL, 21)
sizer_6_copy_1_copy_1.Add(self.pickMeshButton, 1, wx.LEFT|wx.RIGHT, 3)
sizer_6_copy_1_copy_1.Add(self.meshFilePathBox, 3, wx.LEFT|wx.RIGHT, 4)
sizer_5_copy_copy_1.Add(sizer_6_copy_1_copy_1, 0, wx.TOP|wx.EXPAND, 9)
sizer_5_copy_copy_1.Add(self.static_line_1_copy_copy_1, 0, wx.TOP|wx.BOTTOM|wx.EXPAND, 15)
sizer_5_copy_copy_1.Add(self.static_line_2, 0, wx.TOP|wx.BOTTOM|wx.EXPAND, 15)
sizer_5_copy_copy_1.Add(self.meshFile_copy_copy, 0, wx.TOP|wx.ALIGN_CENTER_HORIZONTAL, 7)
sizer_5.Add(self.tolerance_copy_2, 0, wx.LEFT|wx.RIGHT|wx.ALIGN_CENTER_VERTICAL, 10)
sizer_5.Add(self.animationBefore, 0, wx.RIGHT|wx.ALIGN_CENTER_VERTICAL, 10)
sizer_5.Add(self.animationAfter, 0, wx.RIGHT|wx.ALIGN_CENTER_VERTICAL, 10)
sizer_5.Add(self.static_line_3, 0, wx.LEFT|wx.RIGHT|wx.EXPAND, 10)
sizer_5.Add(self.tolerance_copy_2_copy, 0, wx.LEFT|wx.RIGHT|wx.ALIGN_CENTER_VERTICAL, 10)
sizer_5.Add(self.boneBefore, 0, wx.RIGHT|wx.ALIGN_CENTER_VERTICAL, 10)
sizer_5.Add(self.boneAfter, 0, wx.RIGHT|wx.ALIGN_CENTER_VERTICAL, 10)
sizer_5_copy_copy_1.Add(sizer_5, 0, wx.EXPAND, 5)
sizer_5_copy_1.Add(self.tolerance_copy_2_copy_1, 0, wx.LEFT|wx.RIGHT|wx.ALIGN_CENTER_VERTICAL, 10)
sizer_5_copy_1.Add(self.materialBefore, 0, wx.RIGHT|wx.ALIGN_CENTER_VERTICAL, 10)
sizer_5_copy_1.Add(self.materialAfter, 0, wx.RIGHT|wx.ALIGN_CENTER_VERTICAL, 10)
sizer_5_copy_1.Add(self.static_line_3_copy, 0, wx.LEFT|wx.RIGHT|wx.EXPAND, 10)
sizer_5_copy_1.Add(self.tolerance_copy_2_copy_copy, 0, wx.LEFT|wx.RIGHT|wx.ALIGN_CENTER_VERTICAL, 10)
sizer_5_copy_1.Add(self.skeletonRenamed, 0, wx.RIGHT|wx.ALIGN_CENTER_VERTICAL, 10)
sizer_5_copy_1.Add(self.static_line_3_copy_1, 0, wx.LEFT|wx.RIGHT|wx.EXPAND, 10)
sizer_5_copy_1.Add(self.tolerance_copy_2_copy_copy_copy, 0, wx.LEFT|wx.RIGHT|wx.ALIGN_CENTER_VERTICAL, 10)
sizer_5_copy_1.Add(self.submeshBefore, 0, wx.RIGHT|wx.ALIGN_CENTER_VERTICAL, 10)
sizer_5_copy_1.Add(self.submeshAfter, 0, wx.RIGHT|wx.ALIGN_CENTER_VERTICAL, 10)
sizer_5_copy_copy_1.Add(sizer_5_copy_1, 0, wx.EXPAND, 0)
sizer_5_copy_copy_1.Add(self.static_line_2_copy, 0, wx.TOP|wx.BOTTOM|wx.EXPAND, 15)
sizer_5_copy_copy_1.Add(self.meshFile_copy_copy_copy, 0, wx.TOP|wx.ALIGN_CENTER_HORIZONTAL, 7)
tolerance_copy_2_copy_2 = wx.StaticText(self.OptimizePanel, -1, "-scale")
sizer_5_copy_2.Add(tolerance_copy_2_copy_2, 0, wx.LEFT|wx.RIGHT|wx.ALIGN_CENTER_VERTICAL, 10)
sizer_5_copy_2.Add(self.scaleX, 0, wx.RIGHT|wx.ALIGN_CENTER_VERTICAL, 10)
sizer_5_copy_2.Add(self.scaleY, 0, wx.RIGHT|wx.ALIGN_CENTER_VERTICAL, 10)
sizer_5_copy_2.Add(self.scaleZ, 0, wx.RIGHT|wx.ALIGN_CENTER_VERTICAL, 10)
sizer_5_copy_2.Add(self.tolerance_copy_2_copy_copy_1, 0, wx.LEFT|wx.RIGHT|wx.ALIGN_CENTER_VERTICAL, 10)
sizer_5_copy_2.Add(self.resizeX, 0, wx.RIGHT|wx.ALIGN_CENTER_VERTICAL, 10)
sizer_5_copy_2.Add(self.resizeY, 0, wx.RIGHT|wx.ALIGN_CENTER_VERTICAL, 10)
sizer_5_copy_2.Add(self.resizeZ, 0, wx.RIGHT|wx.ALIGN_CENTER_VERTICAL, 10)
sizer_5_copy_copy_1.Add(sizer_5_copy_2, 0, wx.EXPAND, 5)
tolerance_copy_2_copy_2_copy = wx.StaticText(self.OptimizePanel, -1, "-axes")
sizer_5_copy_2_copy.Add(tolerance_copy_2_copy_2_copy, 0, wx.LEFT|wx.RIGHT|wx.ALIGN_CENTER_VERTICAL, 10)
sizer_5_copy_2_copy.Add(self.axesX, 0, wx.RIGHT|wx.ALIGN_CENTER_VERTICAL, 10)
sizer_5_copy_2_copy.Add(self.axesY, 0, wx.RIGHT|wx.ALIGN_CENTER_VERTICAL, 10)
sizer_5_copy_2_copy.Add(self.axesZ, 0, wx.RIGHT|wx.ALIGN_CENTER_VERTICAL, 10)
sizer_5_copy_2_copy.Add(self.tolerance_copy_2_copy_copy_1_copy, 0, wx.LEFT|wx.RIGHT|wx.ALIGN_CENTER_VERTICAL, 10)
sizer_5_copy_2_copy.Add(self.translateX, 0, wx.RIGHT|wx.ALIGN_CENTER_VERTICAL, 10)
sizer_5_copy_2_copy.Add(self.translateY, 0, wx.RIGHT|wx.ALIGN_CENTER_VERTICAL, 10)
sizer_5_copy_2_copy.Add(self.translateZ, 0, wx.RIGHT|wx.ALIGN_CENTER_VERTICAL, 10)
sizer_5_copy_copy_1.Add(sizer_5_copy_2_copy, 0, wx.EXPAND, 5)
tolerance_copy_2_copy_2_copy_copy = wx.StaticText(self.OptimizePanel, -1, "-rotate")
sizer_5_copy_2_copy_copy.Add(tolerance_copy_2_copy_2_copy_copy, 0, wx.LEFT|wx.RIGHT|wx.ALIGN_CENTER_VERTICAL, 10)
sizer_5_copy_2_copy_copy.Add(self.rotate, 0, wx.RIGHT|wx.ALIGN_CENTER_VERTICAL, 10)
sizer_5_copy_2_copy_copy.Add(self.xaxis, 0, wx.LEFT|wx.RIGHT, 8)
sizer_5_copy_2_copy_copy.Add(self.yaxis, 0, wx.LEFT|wx.RIGHT, 8)
sizer_5_copy_2_copy_copy.Add(self.zaxis, 0, wx.LEFT|wx.RIGHT, 8)
sizer_5_copy_copy_1.Add(sizer_5_copy_2_copy_copy, 0, wx.EXPAND, 5)
sizer_6.Add(self.clearChanges, 0, wx.LEFT|wx.RIGHT|wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL, 17)
sizer_6.Add(self.commitChanges, 0, wx.LEFT|wx.RIGHT|wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL, 26)
sizer_6.Add(self.optimizeMeshButton, 0, wx.LEFT|wx.RIGHT|wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL, 26)
sizer_5_copy_copy_1.Add(sizer_6, 1, wx.EXPAND, 0)
self.OptimizePanel.SetSizer(sizer_5_copy_copy_1)
sizer_8.Add(self.meshFile_copy_1, 0, wx.TOP|wx.ALIGN_CENTER_HORIZONTAL, 21)
sizer_8.Add(self.OutputBox, 1, wx.ALL|wx.EXPAND, 10)
self.panel_1.SetSizer(sizer_8)
self.notebook_1.AddPage(self.OptimizePanel, "Commit Changes")
self.notebook_1.AddPage(self.panel_1, "Output")
sizer_1.Add(self.notebook_1, 1, wx.EXPAND, 0)
self.SetSizer(sizer_1)
self.Layout()
self.Centre()
# end wxGlade
def onQuit(self, event): # wxGlade: MyFrame.<event_handler>
self.Close()
sys.exit(1)
def isNum(self, stri):
try:
float(stri)
return True
except: return False
def onChangeX(self, event):
if self.xaxis.GetValue():
self.yaxis.SetValue(False)
self.zaxis.SetValue(False)
def onChangeY(self, event):
if self.yaxis.GetValue():
self.xaxis.SetValue(False)
self.zaxis.SetValue(False)
def onChangeZ(self, event):
if self.zaxis.GetValue():
self.xaxis.SetValue(False)
self.yaxis.SetValue(False)
def OncommitChanges(self, event):
pathStr = self.meshFilePathBox.GetValue()
if pathStr == "":
wx.MessageBox('You must select a mesh file', 'Error')
return
self.checkRotation(pathStr)
self.checkScale(pathStr)
self.checkAxes(pathStr)
self.checkResize(pathStr)
self.checkTranslate(pathStr)
self.checkAnimation(pathStr)
self.checkMaterial(pathStr)
self.checkSubMesh(pathStr)
self.checkBone(pathStr)
def runCommand(self, cmd):
self.OutputBox.AppendText(cmd)
result = os.popen(cmd).read()
self.OutputBox.AppendText(result)
print cmd
def checkTranslate(self, pth):
x = self.translateX.GetValue()
y = self.translateY.GetValue()
z = self.translateZ.GetValue()
if x == "" or y == "" or z == "":
return
if not self.isNum(x) or not self.isNum(y) or not self.isNum(z):
return
if os.name == "posix":
cmd = "meshmagick transform -translate=" + x + "/" + y + "/" + z + " " + pth
else:
pth = self.getFileName(pth)
cmd = self.progL + " transform -translate=" + x + "/" + y + "/" + z + " " + pth
self.runCommand(cmd)
def checkResize(self, pth):
x = self.resizeX.GetValue()
y = self.resizeY.GetValue()
z = self.resizeZ.GetValue()
if x == "" or y == "" or z == "":
return
if not self.isNum(x) or not self.isNum(y) or not self.isNum(z):
return
if os.name == "posix":
cmd = "meshmagick transform -resize=" + x + "/" + y + "/" + z + " " + pth
else:
pth = self.getFileName(pth)
cmd = self.progL + " transform -resize=" + x + "/" + y + "/" + z + " " + pth
self.runCommand(cmd)
def checkAxes(self, pth):
x = self.axesX.GetValue()
y = self.axesY.GetValue()
z = self.axesZ.GetValue()
if x == "" or y == "" or z == "":
return
if not self.isNum(x) or not self.isNum(y) or not self.isNum(z):
return
if os.name == "posix":
cmd = "meshmagick transform -axes=" + x + "/" + y + "/" + z + " " + pth
else:
pth = self.getFileName(pth)
cmd = self.progL + " transform -axes=" + x + "/" + y + "/" + z + " " + pth
self.runCommand(cmd)
def checkScale(self, pth):
x = self.scaleX.GetValue()
y = self.scaleY.GetValue()
z = self.scaleZ.GetValue()
if x == "" or y == "" or z == "":
return
if not self.isNum(x) or not self.isNum(y) or not self.isNum(z):
return
if os.name == "posix":
cmd = "meshmagick transform -scale=" + x + "/" + y + "/" + z + " " + pth
else:
pth = self.getFileName(pth)
cmd = self.progL + " transform -scale=" + x + "/" + y + "/" + z + " " + pth
self.runCommand(cmd)
def checkRotation(self, pth):
rotV = self.rotate.GetValue()
if rotV == "":
return
if not self.isNum(rotV):
wx.MessageBox('Your rotational value must be a number', 'Error')
return
rotS = "/0/0/0 "
if self.xaxis.GetValue():
rotS = "/1/0/0 "
elif self.yaxis.GetValue():
rotS = "/0/1/0 "
elif self.zaxis.GetValue():
rotS = "/0/0/1 "
if os.name == "posix":
cmd = "meshmagick transform -rotate=" + rotV + rotS + pth + "\n"
else:
pth = self.getFileName(pth)
cmd = self.progL + " transform -rotate=" + rotV + rotS + pth
self.runCommand(cmd)
def getFileName(self, pth):
os.chdir( os.path.split(pth)[0] )
return os.path.split(pth)[1]
def checkBone(self, pth):
after = self.boneAfter.GetValue()
before = self.boneBefore.GetValue()
if after == "" or before == "":
return
if os.path.splitext( os.path.split(pth)[1] )[1] != ".skeleton":
wx.MessageBox('You must pick a skeleton file to change the bone name', 'Error')
return
if os.name == "posix":
cmd = "meshmagick rename -bone=:" + before + ":" + after + ":" + " " + pth
else:
pth = self.getFileName(pth)
cmd = self.progL + " rename -bone=:" + before + ":" + after + ":" + " " + pth
self.runCommand(cmd)
def checkSkeleton(self, pth):
skeleValue = self.skeletonRenamed.GetValue()
if skeleValue == "":
return
if os.path.splitext( os.path.split(pth)[1] )[1] != ".mesh":
wx.MessageBox('You must pick a mesh file to change the skeleton name', 'Error')
return
if os.name == "posix":
cmd = "meshmagick rename -skeleton=" + skeleValue + " " + pth
else:
pth = self.getFileName(pth)
cmd = self.progL + " rename -skeleton=" + skeleValue + " " + pth
self.runCommand(cmd)
def checkMaterial(self, pth):
after = self.materialAfter.GetValue()
before = self.materialBefore.GetValue()
if after == "" or before == "":
return
if os.path.splitext( os.path.split(pth)[1] )[1] != ".mesh":
wx.MessageBox('You must pick a mesh file to change the material name', 'Error')
return
if os.name == "posix":
cmd = "meshmagick rename -material=:" + before + ":" + after + ":" + " " + pth
else:
pth = self.getFileName(pth)
cmd = self.progL + " rename -material=:" + before + ":" + after + ":" + " " + pth
self.runCommand(cmd)
def checkAnimation(self, pth):
after = self.animationAfter.GetValue()
before = self.animationBefore.GetValue()
if after == "" or before == "":
return
if os.path.splitext( os.path.split(pth)[1] )[1] != ".skeleton":
wx.MessageBox('You must pick a skeleton file to change animation name', 'Error')
return
if os.name == "posix":
cmd = "meshmagick rename -animation=:" + before + ":" + after + ":" + " " + pth
else:
pth = self.getFileName(pth)
cmd = self.progL + " rename -animation=:" + before + ":" + after + ":" + " " + pth
self.runCommand(cmd)
def checkSubMesh(self, pth):
after = self.submeshAfter.GetValue()
before = self.submeshBefore.GetValue()
if after == "" or before == "":
return
if os.path.splitext( os.path.split(pth)[1] )[1] != ".mesh":
wx.MessageBox('You must pick a mesh file to change submesh name', 'Error')
return
if os.name == "posix":
cmd = "meshmagick rename -submesh=:" + before + ":" + after + ":" + " " + pth
else:
pth = self.getFileName(pth)
cmd = self.progL + " rename -submesh=:" + before + ":" + after + ":" + " " + pth
self.runCommand(cmd)
def OnOptimizeMesh(self, event):
pathStr = self.meshFilePathBox.GetValue()
if pathStr == "":
wx.MessageBox('You must pick a file to be optimized.', 'Error')
return
if os.path.splitext( os.path.split(pathStr)[1] )[1] != ".mesh":
wx.MessageBox('You must pick a mesh file to change submesh name', 'Error')
return
if os.name == "posix":
cmd = "meshmagick optimise " + pathStr + " " + pth
else:
pth = self.getFileName(pth)
cmd = self.progL + " optimise " + pathStr + " " + pth
self.runCommand(cmd)
def OnclearChanges(self, event):
self.rotate.SetValue("")
self.translateX.SetValue("")
self.translateY.SetValue("")
self.translateZ.SetValue("")
self.resizeX.SetValue("")
self.resizeY.SetValue("")
self.resizeZ.SetValue("")
self.axesX.SetValue("")
self.axesY.SetValue("")
self.axesZ.SetValue("")
self.scaleX.SetValue("")
self.scaleY.SetValue("")
self.scaleZ.SetValue("")
self.submeshAfter.SetValue("")
self.submeshBefore.SetValue("")
self.skeletonRenamed.SetValue("")
self.materialAfter.SetValue("")
self.materialBefore.SetValue("")
self.boneAfter.SetValue("")
self.boneBefore.SetValue("")
self.animationAfter.SetValue("")
self.animationBefore.SetValue("")
def onMediaDir(self, event): # wxGlade: MyFrame.<event_handler>
dialog = wx.FileDialog ( None, "Please pick a mesh file")
wildcard = "MESH files (*.mesh)|*.mesh|SKELETON files (*.skeleton)|*.skeleton"
dialog.SetWildcard(wildcard)
if dialog.ShowModal() == wx.ID_OK:
slcted = dialog.GetPath()
self.meshFilePathBox.SetValue(slcted )
else:
print 'Nothing was selected.'
dialog.Destroy()
def onAbout(self, event):
wx.MessageBox('meshmagick gui was written by chieh', 'Info')
# end of class MyFrame
class MyApp(wx.App):
def OnInit(self):
if os.name == "posix":
if not progExist( "meshmagick" ):
wx.MessageBox('meshmagick was not found, did you install this program?', 'Error')
sys.exit(1)
wx.InitAllImageHandlers()
frame_1 = MyFrame(None, -1, "")
self.SetTopWindow(frame_1)
frame_1.Show()
return 1
# end of class MyApp
if __name__ == "__main__":
app = MyApp(0)
app.MainLoop()