_protocols = ["Import"] # extension def extension(): """Return the file extensions for this format.""" return ["lwo"] extension = staticmethod(extension) # description def description(self): """Return a short description for the file dialog.""" return "Lightwave object file" description = staticmethod(description) # importFile def importFile(self, filename, parent=None): """Import an LWOB file.""" f = file(filename, "rb") reader = _LWOBReader(parent=parent) reader.read(f) f.close() ###################################################################### # Register the Importer class as a plugin class pluginmanager.register(LWOBImporter)
# OBJImporter class OBJImporter: _protocols = ["Import"] # extension def extension(): """Return the file extensions for this format.""" return ["obj"] extension = staticmethod(extension) # description def description(self): """Return a short description for the file dialog.""" return "Wavefront object file" description = staticmethod(description) # importFile def importFile(self, filename, parent=None): """Import an OBJ file.""" f = file(filename) reader = _OBJReader(root=parent) reader.read(f) ###################################################################### # Register the ObjImporter class as a plugin class pluginmanager.register(OBJImporter)
# Check for an ASF file with the same name than the AMC file asf, ext = os.path.splitext(filename) asf += ".asf" if not os.path.exists(asf): dir = os.path.dirname(filename) asflist = glob.glob(os.path.join(dir, "*.asf")) if len(asflist) == 1: asf = asflist[0] elif len(asflist) == 0: raise ValueError("No skeleton file found.") else: raise ValueError( "There are several skeleton files in the directory, please specify one or rename the ASF file so it is identical with the AMC file." ) asf = ASFReader(asf) asf.read() amc = AMCReader(filename) # print 'Reading motion file "%s"...'%amcfile amc.read() # print "Applying motion..." amc.applyMotion(asf, framerate=framerate) ###################################################################### # Register the Importer class as a plugin class pluginmanager.register(ASFImporter) pluginmanager.register(AMCImporter)
AZ = mat4(cz,sz,0,0, -sz,cz,0,0, 0,0,1,0, 0,0,0,1) RA = AX*AY*AZ # Euler-angle rotation (todo: quat) sx = sin(radians(r.x)) cx = cos(radians(r.x)) sy = sin(radians(r.y)) cy = cos(radians(r.y)) sz = sin(radians(r.z)) cz = cos(radians(r.z)) RX = mat4(1,0,0,0, 0,cx,sx,0, 0,-sx,cx,0, 0,0,0,1) RY = mat4(cy,0,-sy,0, 0,1,0,0, sy,0,cy,0, 0,0,0,1) RZ = mat4(cz,sz,0,0, -sz,cz,0,0, 0,0,1,0, 0,0,0,1) a,b,c = ["XYZ", "YZX", "ZXY", "XZY", "YXZ", "ZYX"][ro] exec "R=R%s*R%s*R%s"%(a,b,c) WT = SP.inverse()*S*SH*SP*ST*RP.inverse()*RA*R*RP*RT*T WT = WT.transpose() args["transform"] = WT # Visibility args["visible"] = tnode.getAttrValue("visibility", "v", "bool", 1, True) return args ###################################################################### # Register the importer class as a plugin class pluginmanager.register(MAImporter)
class STLImporter: _protocols = ["Import"] # extension def extension(): """Return the file extensions for this format.""" return ["stl"] extension = staticmethod(extension) # description def description(self): """Return a short description for the file dialog.""" return "StereoLithography" description = staticmethod(description) # importFile def importFile(self, filename): """Import a STL file.""" reader = STLImport(filename) reader.read() ###################################################################### # Register the Importer class as a plugin class pluginmanager.register(STLImporter)
class X3DImporter: _protocols = ["Import"] # extension def extension(): """Return the file extensions for this format.""" return ["x3d"] extension = staticmethod(extension) # description def description(self): """Return a short description for the file dialog.""" return "Extensible 3D (X3D)" description = staticmethod(description) # importFile def importFile(self, filename): """Import a X3D file.""" imp = _core.X3DReader() imp.read(filename) ###################################################################### # Register the Importer class as a plugin class if hasattr(_core, "cyber"): pluginmanager.register(VRMLImporter) pluginmanager.register(X3DImporter)
class STLImporter: _protocols = ["Import"] # extension def extension(): """Return the file extensions for this format.""" return ["stl"] extension = staticmethod(extension) # description def description(self): """Return a short description for the file dialog.""" return "StereoLithography" description = staticmethod(description) # importFile def importFile(self, filename): """Import a STL file.""" reader = STLImport(filename) reader.read() ###################################################################### # Register the Importer class as a plugin class pluginmanager.register(STLImporter)
if not isinstance(geom, PolyhedronGeom): # Try to convert into a polyhedron... pg = PolyhedronGeom() try: geom.convert(pg) geom = pg except: pass # Is it a PolyhedronGeom that has no polys with holes? then return # the geom... if isinstance(geom, PolyhedronGeom) and not geom.hasPolysWithHoles(): return geom # Try to convert into a triangle mesh... tm = TriMeshGeom() try: geom.convert(tm) return tm except: pass return None ###################################################################### # Register the exporter class as a plugin class pluginmanager.register(OffExporter)
# Check for an ASF file with the same name than the AMC file asf, ext = os.path.splitext(filename) asf += ".asf" if not os.path.exists(asf): dir = os.path.dirname(filename) asflist = glob.glob(os.path.join(dir, "*.asf")) if len(asflist)==1: asf = asflist[0] elif len(asflist)==0: raise ValueError("No skeleton file found.") else: raise ValueError("There are several skeleton files in the directory, please specify one or rename the ASF file so it is identical with the AMC file.") asf = ASFReader(asf) asf.read() amc = AMCReader(filename) # print 'Reading motion file "%s"...'%amcfile amc.read() # print "Applying motion..." amc.applyMotion(asf, framerate=framerate) ###################################################################### # Register the Importer class as a plugin class pluginmanager.register(ASFImporter) pluginmanager.register(AMCImporter)
if header[:1] == "n": self.ndim_flag = True header = header[1:] if header != "OFF": print >> sys.stderr, "Warning: Unknown prefixes in the header keyword" return True # readLine def readLine(self): """Read the next line. Returns the next line (without the trailing newline) that is not empty or a comment. If the end of the file was reached, an exception is thrown. """ while 1: z = self.fhandle.readline() if z == "": raise SyntaxError("premature end of file") z = z.strip() if z == "" or z[0] == '#': continue return z ###################################################################### # Register the OffImporter class as a plugin class pluginmanager.register(OffImporter)
# Euler-angle rotation (todo: quat) sx = sin(radians(r.x)) cx = cos(radians(r.x)) sy = sin(radians(r.y)) cy = cos(radians(r.y)) sz = sin(radians(r.z)) cz = cos(radians(r.z)) RX = mat4(1, 0, 0, 0, 0, cx, sx, 0, 0, -sx, cx, 0, 0, 0, 0, 1) RY = mat4(cy, 0, -sy, 0, 0, 1, 0, 0, sy, 0, cy, 0, 0, 0, 0, 1) RZ = mat4(cz, sz, 0, 0, -sz, cz, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1) a, b, c = ["XYZ", "YZX", "ZXY", "XZY", "YXZ", "ZYX"][ro] exec "R=R%s*R%s*R%s" % (a, b, c) WT = SP.inverse() * S * SH * SP * ST * RP.inverse( ) * RA * R * RP * RT * T WT = WT.transpose() args["transform"] = WT # Visibility args["visible"] = tnode.getAttrValue("visibility", "v", "bool", 1, True) return args ###################################################################### # Register the importer class as a plugin class pluginmanager.register(MAImporter)
"""Create a TextureMap3DS object (or None). \param texmap (\c Lib3dsTextureMap) Texture map """ if texmap.name == "": return None dir = os.path.dirname(self.filename) dir = os.path.abspath(dir) return TextureMap3DS( name=os.path.join(dir, texmap.name), flags=texmap.flags, percent=texmap.percent, blur=texmap.blur, scale=texmap.scale, offset=texmap.offset, rotation=texmap.rotation, tint1=texmap.tint_1, tint2=texmap.tint_2, tintr=texmap.tint_r, tintg=texmap.tint_g, tintb=texmap.tint_b, ) ###################################################################### # Register the Importer class as a plugin class if hasattr(_core, "File3ds"): pluginmanager.register(DDDSImporter)
if not isinstance(geom, PolyhedronGeom): # Try to convert into a polyhedron... pg = PolyhedronGeom() try: geom.convert(pg) geom = pg except: pass # Is it a PolyhedronGeom that has no polys with holes? then return # the geom... if isinstance(geom, PolyhedronGeom) and not geom.hasPolysWithHoles(): return geom # Try to convert into a triangle mesh... tm = TriMeshGeom() try: geom.convert(tm) return tm except: pass return None ###################################################################### # Register the exporter class as a plugin class pluginmanager.register(OBJExporter)
# BVHImporter class BVHImporter: _protocols = ["Import"] # extension def extension(): """Return the file extensions for this format.""" return ["bvh"] extension = staticmethod(extension) # description def description(self): """Return a short description for the file dialog.""" return "Biovision Hierarchical" description = staticmethod(description) # importFile def importFile(self, filename): """Import a BVH file.""" bvh = BVHReader(filename) bvh.read() ###################################################################### # Register the Importer class as a plugin class pluginmanager.register(BVHImporter)
numfaces = int(struct.unpack("<I", s)[0]) tm.faces.resize(numfaces) for i in range(numfaces): s = f.read(12) a,b,c = struct.unpack("<III", s) tm.faces[i] = (int(a), int(b), int(c)) # Create a world object obj = TriMesh(name=modelname) obj.geom = tm def readString(self, fhandle): """Read a string. \param fhandle Open file handle \return String """ s = fhandle.read(4) w = int(struct.unpack("<I", s)[0]) s = fhandle.read(w) # Return the string without the trailing \000 return s[:-1] ###################################################################### # Register the IfsImporter class as a plugin class pluginmanager.register(IfsImporter)
_protocols = ["Import"] # extension def extension(): """Return the file extensions for this format.""" return ["lwo"] extension = staticmethod(extension) # description def description(self): """Return a short description for the file dialog.""" return "Lightwave object file" description = staticmethod(description) # importFile def importFile(self, filename, parent=None): """Import an LWOB file.""" f = file(filename, "rb") reader = _LWOBReader(parent=parent) reader.read(f) f.close() ###################################################################### # Register the Importer class as a plugin class pluginmanager.register(LWOBImporter)
if not isinstance(geom, PolyhedronGeom): # Try to convert into a polyhedron... pg = PolyhedronGeom() try: geom.convert(pg) geom = pg except: pass # Is it a PolyhedronGeom that has no polys with holes? then return # the geom... if isinstance(geom, PolyhedronGeom) and not geom.hasPolysWithHoles(): return geom # Try to convert into a triangle mesh... tm = TriMeshGeom() try: geom.convert(tm) return tm except: pass return None ###################################################################### # Register the exporter class as a plugin class pluginmanager.register(OBJExporter)
if header[:1]=="n": self.ndim_flag = True header = header[1:] if header!="OFF": print >>sys.stderr, "Warning: Unknown prefixes in the header keyword" return True # readLine def readLine(self): """Read the next line. Returns the next line (without the trailing newline) that is not empty or a comment. If the end of the file was reached, an exception is thrown. """ while 1: z = self.fhandle.readline() if z=="": raise SyntaxError("premature end of file") z = z.strip() if z=="" or z[0]=='#': continue return z ###################################################################### # Register the OffImporter class as a plugin class pluginmanager.register(OffImporter)
_protocols = ["Import"] # extension def extension(): """Return the file extensions for this format.""" return ["obj"] extension = staticmethod(extension) # description def description(self): """Return a short description for the file dialog.""" return "Wavefront object file" description = staticmethod(description) # importFile def importFile(self, filename, parent=None): """Import an OBJ file.""" f = file(filename) reader = _OBJReader(root=parent) reader.read(f) ###################################################################### # Register the ObjImporter class as a plugin class pluginmanager.register(OBJImporter)
class BVHImporter: _protocols = ["Import"] # extension def extension(): """Return the file extensions for this format.""" return ["bvh"] extension = staticmethod(extension) # description def description(self): """Return a short description for the file dialog.""" return "Biovision Hierarchical" description = staticmethod(description) # importFile def importFile(self, filename): """Import a BVH file.""" bvh = BVHReader(filename) bvh.read() ###################################################################### # Register the Importer class as a plugin class pluginmanager.register(BVHImporter)
if not isinstance(geom, PolyhedronGeom): # Try to convert into a polyhedron... pg = PolyhedronGeom() try: geom.convert(pg) geom = pg except: pass # Is it a PolyhedronGeom that has no polys with holes? then return # the geom... if isinstance(geom, PolyhedronGeom) and not geom.hasPolysWithHoles(): return geom # Try to convert into a triangle mesh... tm = TriMeshGeom() try: geom.convert(tm) return tm except: pass return None ###################################################################### # Register the exporter class as a plugin class pluginmanager.register(PLYExporter)
s[0] = comment if objinfo!="": p.geom.newVariable("obj_info", CONSTANT, STRING) s = p.geom.slot("obj_info") s[0] = objinfo # Read the model imp.read(p.geom, vardecl, invertfaces) imp.close() # isVarAccepted def isVarAccepted(self, name): """Return True if the variable should be imported. name is the name of the primitive variable (which is not necessarily the ply property!). """ if self.includevar!=None: if name not in self.includevar: return False if self.excludevar!=None: if name in self.excludevar: return False return True ###################################################################### # Register the Importer class as a plugin class pluginmanager.register(PLYImporter)
if not isinstance(geom, PolyhedronGeom): # Try to convert into a polyhedron... pg = PolyhedronGeom() try: geom.convert(pg) geom = pg except: pass # Is it a PolyhedronGeom that has no polys with holes? then return # the geom... if isinstance(geom, PolyhedronGeom) and not geom.hasPolysWithHoles(): return geom # Try to convert into a triangle mesh... tm = TriMeshGeom() try: geom.convert(tm) return tm except: pass return None ###################################################################### # Register the exporter class as a plugin class pluginmanager.register(OffExporter)
s = f.read(4) numfaces = int(struct.unpack("<I", s)[0]) tm.faces.resize(numfaces) for i in range(numfaces): s = f.read(12) a, b, c = struct.unpack("<III", s) tm.faces[i] = (int(a), int(b), int(c)) # Create a world object obj = TriMesh(name=modelname) obj.geom = tm def readString(self, fhandle): """Read a string. \param fhandle Open file handle \return String """ s = fhandle.read(4) w = int(struct.unpack("<I", s)[0]) s = fhandle.read(w) # Return the string without the trailing \000 return s[:-1] ###################################################################### # Register the IfsImporter class as a plugin class pluginmanager.register(IfsImporter)
"""Create a TextureMap3DS object (or None). \param texmap (\c Lib3dsTextureMap) Texture map """ if texmap.name=="": return None dir = os.path.dirname(self.filename) dir = os.path.abspath(dir) return TextureMap3DS(name=os.path.join(dir, texmap.name), flags = texmap.flags, percent = texmap.percent, blur = texmap.blur, scale = texmap.scale, offset = texmap.offset, rotation = texmap.rotation, tint1 = texmap.tint_1, tint2 = texmap.tint_2, tintr = texmap.tint_r, tintg = texmap.tint_g, tintb = texmap.tint_b) ###################################################################### # Register the Importer class as a plugin class if hasattr(_core, "File3ds"): pluginmanager.register(DDDSImporter)