import math
def twiddle_tile(srcfile, destfile, twiddlefunc):
for line in srcfile:
gps = line.split()
if len(gps) == 4 and gps[0] == "v":
vert = [float(v) for v in gps[1:]]
if vert[1] < 0.0: # don't twiddle bottom of tile
dest.write(line + "\n")
else:
vert_prime = twiddlefunc(vert[0], vert[1], vert[2])
dest.write("v {} {} {}\n".format(*vert_prime))
else: # line is not a vertex, so write it back unchanged
dest.write(line + "\n")
def points(x, y, z):
theta = math.atan2(z, x)
amp = math.sin(theta * 25) * 1.5
return (x, y+amp, z)
if __name__ == '__main__':
srcfn = "tile_blank.obj"
destfn = "tile_transform.obj"
with open(srcfn, "rt") as src:
with open(destfn, "wt") as dest:
twiddle_tile(src, dest, points)
Click to Expand
Content Rating
Is this a good/useful/informative piece of content to include in the project? Have your say!
You must login before you can post a comment. .