diff options
author | Aeva Ntsc <aeva.ntsc@gmail.com> | 2012-10-16 01:54:27 -0500 |
---|---|---|
committer | Christopher Allan Webber <cwebber@dustycloud.org> | 2012-12-03 14:40:48 -0600 |
commit | de69f43aab86ac0005b9e1abc51b37c3035f3d63 (patch) | |
tree | f6a81af61c270eb51eb0825828676e354beff6cb | |
parent | d93eac36fc2bbc10102d682128722c448aca5ded (diff) | |
download | mediagoblin-de69f43aab86ac0005b9e1abc51b37c3035f3d63.tar.lz mediagoblin-de69f43aab86ac0005b9e1abc51b37c3035f3d63.tar.xz mediagoblin-de69f43aab86ac0005b9e1abc51b37c3035f3d63.zip |
Fixed the binary stl loader.
-rw-r--r-- | mediagoblin/media_types/stl/model_loader.py | 31 |
1 files changed, 5 insertions, 26 deletions
diff --git a/mediagoblin/media_types/stl/model_loader.py b/mediagoblin/media_types/stl/model_loader.py index a417b04c..b9fbbb06 100644 --- a/mediagoblin/media_types/stl/model_loader.py +++ b/mediagoblin/media_types/stl/model_loader.py @@ -90,35 +90,14 @@ class BinaryStlModel(ThreeDee): http://en.wikipedia.org/wiki/STL_%28file_format%29#Binary_STL """ - def __num(self, fileob, hint): - assert hint == "uint" or hint == "real" or hint == "short" - form = None - bits = 0 - if hint == "uint": - form = "<I" # little-endian unsigned int - bits = 32 - elif hint == "real": - form = "<i" # little-endian signed int - bits = 32 - elif hint == "short": - form = "<H" # little-endian unsigned short - bits = 16 - return struct.unpack(form, fileob.read(bits/8))[0] - - def __vector(self, fileob): - return tuple([self.__num(fileob, "real") for n in range(3)]) - def load(self, fileob): fileob.seek(80) # skip the header - triangle_count = self.__num(fileob, "uint") - for i in range(triangle_count): - self.__vector(fileob) # skip the normal vector + count = struct.unpack("<I", fileob.read(4))[0] + for i in range(count): + fileob.read(12) # skip the normal vector for v in range(3): - # - FIXME - traingle_count IS reporting the correct - # number, but the vertex information appears to be - # total nonsense :( - self.verts.append(self.__vector(fileob)) - self.__num(fileob, "short") # skip the attribute byte count + self.verts.append(struct.unpack("<3f", fileob.read(12))) + fileob.read(2) # skip the attribute bytes def auto_detect(fileob, hint): |