source: OGRE/trunk/ogrenew/Tools/Wings3DExporter/w2o.py @ 657

Revision 657, 1.5 KB checked in by mattausch, 18 years ago (diff)

added ogre dependencies and patched ogre sources

Line 
1#!/usr/bin/python
2
3from erlang_ext import *
4import types
5import pprint
6
7import io3d_wings
8import io3d_ogre
9
10import getopt
11
12version = "0.93"
13
14def conv(infile, outfile, writeImages, keepRotation, scaleFactor):
15        obj = io3d_wings.read_wings(infile, writeImages, keepRotation)
16        if scaleFactor != 1.0: obj.scale(scaleFactor)
17        io3d_ogre.write_ogre(obj, outfile)
18
19if __name__ == "__main__":
20
21        try:
22                options, args = getopt.getopt(sys.argv[1:], "hviks:")
23
24                writeImages = 0
25                keepRotation = 0
26                scaleFactor = 1.0
27
28                for o in options:
29                        option, value = o
30
31                        if option == '-h':
32                                print """Usage:
33w2o [-iks] file1.wings file2.wings
34
35Options:
36    -h     This help
37    -v     Print version
38    -i     Export images from the wings file via PIL
39    -k     Keep the coordinates as they are, do not correct them
40           to the OGRE coordinate system. Use this if you
41           want to rotate your objects around the X axis in
42           code or if you already rotated the objects in Wings.
43    -s n   Scale the object uniformly using the given floating
44           point factor.
45"""
46                                sys.exit(1)
47
48                        elif option == '-v':
49                                print "w2o", version
50                                sys.exit(1)
51
52                        elif option == '-i': writeImages = 1
53
54                        elif option == '-k': keepRotation = 1
55
56                        elif option == '-s': scaleFactor = float(value)
57
58                for arg in args:
59
60                        # process filename
61                        if arg[-6:] == ".wings":
62                                dstname = arg[:-6]
63                        else:
64                                dstname = arg
65                        dstname += ".mesh.xml"
66                        conv(arg, dstname, writeImages, keepRotation, scaleFactor)
67
68        except getopt.GetoptError, e:
69                print e
70                print "try -h for help"
71                sys.exit(1)
72
Note: See TracBrowser for help on using the repository browser.