Changeset 5877


Ignore:
Timestamp:
06/11/19 22:50:17 (10 months ago)
Author:
beherith
Message:

Add command line usage to obj2s3o converter

Location:
etc/Tools/OBJtoS3O_Converter
Files:
1 deleted
1 edited

Legend:

Unmodified
Added
Removed
  • etc/Tools/OBJtoS3O_Converter/obj2s3o.py

    r5875 r5877  
    44import vertex_cache 
    55import sys 
    6 from Tkinter import * 
    7 import tkFileDialog 
     6 
    87import math 
    98import os 
     9 
     10print "You can use this from the command line too without a gui:" 
     11print "Specify any number of .obj and .s3o files, and each will be converted to the opposite (obj->s3o, s3o->obj) type" 
     12print "python obj2s3o.py myexampleunit.s3o  (will convert s3o to obj)" 
     13print "python obj2s3o.py myexampleunit.obj myotherunit.obj  (will convert both objs)" 
     14 
    1015 
    1116howtoemit=('''const unsigned int count = piece->GetVertexCount(); 
     
    266271                model.S3OtoOBJ(outputfilename,optimize_for_wings3d) 
    267272                print "Succesfully converted", filename,'to',outputfilename 
    268 def OBJtoS3O(objfile,transform,outputfilename,a,b,c,d): 
     273        else: 
     274                print 'Bad file name', filename 
     275def OBJtoS3O(objfile,transform,outputfilename,a=1.0,b=0.0,c=1.0,d=0.0): 
    269276        if '.obj' in objfile.lower(): 
    270277                data = open(objfile).readlines() 
     
    314321                numverts+=countvertices(child) 
    315322        return numverts 
    316 root = Tk() 
    317 app = App(root) 
    318 root.mainloop() 
     323         
     324if len(sys.argv)<2:  
     325         
     326        from Tkinter import * 
     327        import tkFileDialog 
     328        root = Tk() 
     329        app = App(root) 
     330        root.mainloop() 
     331else : 
     332        for filename in sys.argv[1:]: 
     333         
     334                print "working on :",filename 
     335                if filename.lower().endswith('.s3o'): 
     336                        S3OtoOBJ(filename,filename.lower().replace('.s3o','.obj')) 
     337                elif filename.lower().endswith('.obj'): 
     338                        OBJtoS3O(filename,0,filename.lower().replace('.obj','.s3o'),1.0,0.0,1.0,0.0) 
     339                else: 
     340                        print 'File type not recognized, skipping' 
Note: See TracChangeset for help on using the changeset viewer.