How to use the pyassimp.pyassimp.GetMaterialProperties function in pyassimp

To help you get started, we’ve selected a few pyassimp examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github adamlwgriffiths / PyGLy / pygly / attic / oai_mesh.py View on Github external
def apply_material( self, material ):
        properties = pyassimp.GetMaterialProperties( material )
        # FIXME:
        # Materials are done in a stack
        # http://assimp.sourceforge.net/lib_html/materials.html
        # http://assimp.svn.sourceforge.net/viewvc/assimp/trunk/samples/SimpleTexturedOpenGL/SimpleTexturedOpenGL/src/model_loading.cpp?revision=1084&view=markup
        
        
        # check for a texture
        if MaterialKeys[ 'texture' ] in properties:
            filename = properties[ MaterialKeys[ 'texture' ] ]
            if filename in self.images:
                texture = self.images[ filename ][ 1 ]
                #glActiveTexture( GL_TEXTURE0 )
                glBindTexture( GL_TEXTURE_2D, texture.id )
        
        # diffuse
        if MaterialKeys[ 'diffuse' ] in properties:
github adamlwgriffiths / PyGLy / pygly / attic / oai_mesh.py View on Github external
def load_textures( self, scene ):
        # textures should be loaded into a key, value store
        # to avoid loading the same texture multiple times
        # http://assimp.svn.sourceforge.net/viewvc/assimp/trunk/samples/SimpleTexturedOpenGL/SimpleTexturedOpenGL/src/model_loading.cpp?revision=1084&view=markup
        
        images = {}
        for material in scene.materials:
            properties = pyassimp.GetMaterialProperties( material )
            
            if MaterialKeys[ 'texture' ] in properties:
                filename = properties[ MaterialKeys[ 'texture' ] ]
                if filename not in self.images:
                    try:
                        absFilename = "%s/%s" % (
                            os.path.dirname( self.filename ),
                            filename
                            )
                        print absFilename
                        image = pyglet.image.load( absFilename )
                        images[ filename ] = image
                    except:
                        print "Exception loading texture %s" % filename
github adamlwgriffiths / PyGLy / pygly / attic / oai_mesh.py View on Github external
print "    first:", mesh.vertices[:3]
        print "    colors:", len(mesh.colors)
        tc = mesh.texcoords
        print "    texture-coords 1:", len(tc[0]), "first:", tc[0][:3]
        print "    texture-coords 2:", len(tc[1]), "first:", tc[1][:3]
        print "    texture-coords 3:", len(tc[2]), "first:", tc[2][:3]
        print "    texture-coords 4:", len(tc[3]), "first:", tc[3][:3]
        print "    uv-component-count:", len(mesh.mNumUVComponents)
        print "    faces:", len(mesh.faces), "first:", [f.indices for f in mesh.faces[:3]]
        print "    bones:", len(mesh.bones), "first:", [b.mName for b in mesh.bones[:3]]
        print

    print "MATERIALS:"
    for index, material in enumerate(scene.materials):
        print "  MATERIAL", index+1
        properties = pyassimp.GetMaterialProperties(material)
        for key in properties:
            print "    %s: %s" % (key, properties[key])
    print
    
    print "TEXTURES:"
    if scene.textures != None:
        for index, texture in enumerate(scene.textures):
            print "  TEXTURE", index+1
            print "    width:", texture.mWidth
            print "    height:", texture.mHeight
            print "    hint:", texture.achFormatHint
            print "    data (size):", texture.mWidth*texture.mHeight
   
    # Finally release the model
    pyassimp.release(scene)
github adamlwgriffiths / PyGLy / pygly / attic / oai_mesh.py View on Github external
def load_texture( self, material ):   
        properties = pyassimp.GetMaterialProperties( material )
        
        if MaterialKeys[ 'texture' ] in properties:
            filename = properties[ MaterialKeys[ 'texture' ] ]
            if filename not in self.images:
                try:
                    absFilename = "%s/%s" % (
                        os.path.dirname( self.filename ),
                        filename
                        )
                    print absFilename
                    image = pyglet.image.load( absFilename )
                    texture = image.get_texture( rectangle = False )
                    self.images[ filename ] = (image, texture)
                except:
                    print "Exception loading texture"