]> git.tdb.fi Git - libs/gl.git/blob - blender/io_mspgl/outfile.py
Standard vertex components for tangent and binormal vectors
[libs/gl.git] / blender / io_mspgl / outfile.py
1 import sys
2
3 class OutFile:
4         def __init__(self, fn):
5                 if fn==None:
6                         self.file = sys.stdout
7                 else:
8                         self.file = open(fn, "w")
9                 self.indent = 0
10
11         def make(self, kwd, *params):
12                 pstr = ""
13                 for p in params:
14                         if type(p)==float:
15                                 pstr += " %.6g"%p
16                         else:
17                                 pstr += " %s"%p
18                 return "%s%s"%(kwd, pstr)
19
20         def write(self, kwd, *params):
21                 self.file.write("%s%s;\n"%('\t'*self.indent, self.make(kwd, *params)))
22
23         def begin(self, kwd, *params):
24                 i = '\t'*self.indent
25                 self.file.write("%s%s\n%s{\n"%(i, self.make(kwd, *params), i))
26                 self.indent += 1
27
28         def end(self):
29                 self.indent -= 1
30                 self.file.write("%s};\n"%('\t'*self.indent))