Created
October 5, 2010 02:17
-
-
Save valda/610852 to your computer and use it in GitHub Desktop.
nif の NiTriShape の scale を 1.17 に書き換えるだけのスクリプ㌧
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8-dos; mode: python -*- | |
import sys | |
from optparse import OptionParser | |
from pyffi.formats.nif import NifFormat | |
parser = OptionParser(usage="usage: %prog [options] FILE") | |
parser.add_option("-o", dest="outfile", help="output file", default="out.nif", metavar="FILE") | |
parser.add_option("-q", dest="quiet", help="quiet mode", default=False) | |
(opts, args) = parser.parse_args(sys.argv) | |
if len(args) != 2: | |
parser.print_help() | |
exit() | |
istrm = open(args[1], 'rb') | |
data = NifFormat.Data() | |
data.read(istrm) | |
print ("NIF version 0x%x, User version %d" % (data.version, data.user_version)) | |
for root in data.roots: | |
for block in root.tree(): | |
if isinstance(block, NifFormat.NiTriShape): | |
print("%s: Current scale is %.4f" % (block.name.decode("ascii"), block.scale)) | |
if block.scale == 1.0000: | |
block.scale = 1.1700 | |
print " Changed to 1.1700" | |
ostrm = open(opts.outfile, 'wb') | |
data.write(ostrm) | |
ostrm.close() | |
istrm.close() | |
print "Wrote to '%s'" % opts.outfile |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment