Mercurial > LightClone
diff LightTools/build.py @ 62:6d4437a24aeb
Added camera position to level definition
author | koryspansel |
---|---|
date | Mon, 03 Oct 2011 15:14:41 -0700 |
parents | 2444937929ae |
children |
line wrap: on
line diff
--- a/LightTools/build.py Mon Oct 03 15:05:09 2011 -0700 +++ b/LightTools/build.py Mon Oct 03 15:14:41 2011 -0700 @@ -14,10 +14,13 @@ class MapDefinition: Parse = functools.partial(string.split, sep=',') - def __init__(self, size, position, direction, grid): + def __init__(self, size, position, direction, distance, yaw, pitch, grid): self.Size = self._ParseVector(size) self.Position = self._ParseVector(position) self.Direction = self._ParseVector(direction) + self.Distance = self._ParseVectorF(distance) + self.Yaw = self._ParseVectorF(yaw) + self.Pitch = self._ParseVectorF(pitch) self.Grid = self._ParseList(grid) def Write(self, filename): @@ -25,6 +28,9 @@ handle.write(struct.pack('i' * len(self.Size), *self.Size)) # 8 handle.write(struct.pack('i' * len(self.Position), *self.Position)) # 8 handle.write(struct.pack('i' * len(self.Direction), *self.Direction)) # 4 + handle.write(struct.pack('f' * len(self.Distance), *self.Distance)) # 4 + handle.write(struct.pack('f' * len(self.Yaw), *self.Yaw)) # 4 + handle.write(struct.pack('f' * len(self.Pitch), *self.Pitch)) # 4 for tower in self.Grid: handle.write(struct.pack('i' * len(tower), *tower)) # 8 * Size.X * Size.Y @@ -32,6 +38,9 @@ def _ParseVector(self, line): return map(int, self.Parse(line)) + def _ParseVectorF(self, line): + return map(float, self.Parse(line)) + def _ParseList(self, lines): return [map(int, item.groups()) for item in _pattern.finditer(''.join(lines))] @@ -49,9 +58,12 @@ size = definition[0] position = definition[1] direction = definition[2] - grid = definition[3:] + distance = definition[3] + yaw = definition[4] + pitch = definition[5] + grid = definition[6:] - return MapDefinition(size, position, direction, grid) + return MapDefinition(size, position, direction, distance, yaw, pitch, grid) def Compile(input_map, output_map): if os.path.isfile(input_map): @@ -84,15 +96,3 @@ continue Compile(os.path.join(path_assets, filename), os.path.join(path_build, os.path.splitext(filename)[0] + '.map')) - #definition = ReadDefinition(os.path.join(path_assets, filename)) - #if not definition: - # continue - - #output = os.path.join(path_build, os.path.splitext(filename)[0] + '.map') - #folder = os.path.dirname(output) - - #if not os.path.isdir(folder): - # os.makedirs(folder) - - #print 'Building %s from %s' % (os.path.basename(output), os.path.basename(filename)) - #definition.Write(output)