Skip to content

Commit 8c49f93

Browse files
committed
scale option for converter
1 parent eeabbfe commit 8c49f93

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

convert/convert.py

+4
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
# parse command line
1616
help = 'one of: ' + ', '.join(formats)
1717
parser = OptionParser('usage: [options] input_file output_file')
18+
parser.add_option('--scale', dest='scale', help='scales the model')
1819
parser.add_option('--center', action='store_true', help='centers the model above the origin')
1920
parser.add_option('--compute_normals', action='store_true', help='computes smoothed normals')
2021
parser.add_option('--in', dest='input_format', help=help)
@@ -52,6 +53,9 @@
5253
if options.compute_normals:
5354
print 'computing normals'
5455
model.compute_normals()
56+
if options.scale:
57+
print 'scaling model'
58+
model.scale(float(options.scale))
5559

5660
# save model
5761
out_file = open(out_path, 'wb')

convert/model.py

+4
Original file line numberDiff line numberDiff line change
@@ -74,3 +74,7 @@ def compute_normals(self):
7474
c.normal += n
7575
for v in self.vertices:
7676
v.normal = v.normal.unit()
77+
78+
def scale(self, scale):
79+
for v in self.vertices:
80+
v.pos = v.pos * scale

0 commit comments

Comments
 (0)