Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def __init__(self, filename):
self.model = pyassimp.load(filename)
self.vertices = numpy.array(flatten(self.model.meshes[0].vertices), numpy.float32)
self.make_indices()
# NOTE: this drops the W from UVW-coordinates.
self.texcoords = numpy.array([item for sublist in self.model.meshes[0].texcoords[0] for item in sublist[:2]], numpy.float32)
self.normals = numpy.array(flatten(self.model.meshes[0].normals), numpy.float32)
def load_model(filename):
return pyassimp.load(filename)
def __init__(self, filename):
self.model = pyassimp.load(filename)
self.vertices = numpy.array(flatten(self.model.meshes[0].vertices), numpy.float32)
self.make_indices()
# NOTE: this drops the W from UVW-coordinates.
self.texcoords = numpy.array([item for sublist in self.model.meshes[0].texcoords[0] for item in sublist[:2]], numpy.float32)
self.normals = numpy.array(flatten(self.model.meshes[0].normals), numpy.float32)
def load_model(filename):
return pyassimp.load(filename)
def makeMesh(self, name, ps, filename):
'''
Make a mesh collision object
:param name: Name of the object
:param ps: A pose stamped object pose message
:param filename: The mesh file to load
'''
if not use_pyassimp:
rospy.logerr('pyassimp is broken on your platform, cannot load meshes')
return
scene = pyassimp.load(filename)
if not scene.meshes:
rospy.logerr('Unable to load mesh')
return
mesh = Mesh()
for face in scene.meshes[0].faces:
triangle = MeshTriangle()
if len(face.indices) == 3:
triangle.vertex_indices = [face.indices[0],
face.indices[1],
face.indices[2]]
mesh.triangles.append(triangle)
for vertex in scene.meshes[0].vertices:
point = Point()
point.x = vertex[0]
point.y = vertex[1]
def test1():
import os
#get a model out of assimp's test-data
#MODEL = r'C:\Users\adam\workspace\python\3d_engine\test_app\src\data\sydney.md2'
#MODEL = r'C:\Users\adam\workspace\python\3d_engine\BomberCommand\data\meshes\b17\b17g.3ds'
#MODEL = r'C:\Users\adam\Downloads\development\3d\aircraft\me109\Messerschmitt\Bf109G6.3DS'
MODEL = r'C:\Users\adam\Downloads\development\3d\aircraft\b17\B-17\b17g.3ds'
scene = pyassimp.load(MODEL)
#the model we load
print "MODEL:", MODEL
print
#write some statistics
print "SCENE:"
print " meshes:", len(scene.meshes)
print " materials:", len(scene.materials)
print " textures:", len(scene.textures)
print
print "MESHES:"
for index, mesh in enumerate(scene.meshes):
print " MESH", index+1
print " material:", mesh.mMaterialIndex+1
def load( self ):
scene = pyassimp.load( self.filename )
# drop the existing materials
# TODO: drop the existing materials
# load the materials
self.load_textures( scene )
# clear the existing display lists
self.displayList = None
self.displayList = glGenLists( 1 )
glNewList( self.displayList, GL_COMPILE )
glEnable( GL_TEXTURE_2D )
# render the meshes