コード例 #1
0
ファイル: glTFExport.py プロジェクト: kthulhu/maya-glTF
    def _create_metallic_roughness_map(self, metal_map, rough_map):

        metal = QImage(metal_map)
        rough = QImage(rough_map)
        metal_pixel = QColor()

        metal = metal.convertToFormat(QImage.Format_RGB32)
        rough = rough.convertToFormat(QImage.Format_RGB32)
        metal_uchar_ptr = metal.bits()
        rough_uchar_ptr = rough.bits()
        if (not metal.width() == rough.width()
                or not metal.height() == rough.height()):
            raise RuntimeError(
                "Error processing material: {}. Metallic map and roughness map must have same dimensions."
                .format(self.maya_node))
        width = metal.width()
        height = metal.height()

        i = 0
        for y in range(height):
            for x in range(width):
                metal_color = struct.unpack('I', metal_uchar_ptr[i:i + 4])[0]
                rough_color = struct.unpack('I', rough_uchar_ptr[i:i + 4])[0]
                metal_pixel.setRgb(0, qGreen(rough_color), qBlue(metal_color))
                metal_uchar_ptr[i:i + 4] = struct.pack('I', metal_pixel.rgb())
                i += 4

        output = ExportSettings.out_dir + "/" + self.name + "_metalRough.jpg"
        return output, metal
コード例 #2
0
ファイル: glTFExport.py プロジェクト: oxpi/maya-glTF
    def _create_metallic_roughness_map(self, metal_map, rough_map):

        metal = QImage(metal_map)
        rough = QImage(rough_map)
        metal_pixel = QColor()

        metal = metal.convertToFormat(QImage.Format_RGB32);
        rough = rough.convertToFormat(QImage.Format_RGB32);
        metal_uchar_ptr = metal.bits()
        rough_uchar_ptr = rough.bits()
        if (not metal.width() == rough.width()
                or not metal.height() == rough.height()):
            raise RuntimeError("Error processing material: {}. Metallic map and roughness map must have same dimensions.".format(self.maya_node))
        width = metal.width();
        height = metal.height();

        i = 0
        for y in range(height):
            for x in range(width):
                metal_color = struct.unpack('I', metal_uchar_ptr[i:i+4])[0]
                rough_color = struct.unpack('I', rough_uchar_ptr[i:i+4])[0]
                metal_pixel.setRgb(0, qGreen(rough_color), qBlue(metal_color))
                metal_uchar_ptr[i:i+4] = struct.pack('I', metal_pixel.rgb())
                i+=4
                
        output = ExportSettings.out_dir + "/"+self.name+"_metalRough.jpg"
        return output, metal
コード例 #3
0
ファイル: LabelMaker.py プロジェクト: NBor/SkyPython
 def end_adding(self, gl):
     self.texture.bind(gl)
     
     '''
     IMPORTANT IMPORTANT IMPORTANT IMPORTANT IMPORTANT IMPORTANT
     The image has to be mirrored for some reason
     '''
     img = QImage(self.bitmap.toImage()).mirrored()
     img = QGLWidget.convertToGLFormat(img)
     
     gl.glTexImage2D(gl.GL_TEXTURE_2D, 0, gl.GL_RGB, img.width(), img.height(), 0, gl.GL_RGBA, 
                     gl.GL_UNSIGNED_BYTE, str(img.bits()))
     
     # This particular bitmap is no longer needed
     self.bitmap = None
コード例 #4
0
 def create_texture_from_resource(self, gl, resource_id):
     '''
     Unlike the original java source, convertToGLFormat is used
     '''
     text = self.create_texture_internal(gl)
     
     img = QImage("assets/drawable/" + self.images[resource_id] + ".png")
     img = QGLWidget.convertToGLFormat(img)
     
     text.bind(gl)
     gl.glTexParameterf(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_MIN_FILTER, gl.GL_LINEAR);
     gl.glTexParameterf(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_MAG_FILTER, gl.GL_LINEAR);
     gl.glTexParameterf(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_WRAP_S, gl.GL_CLAMP_TO_EDGE);
     gl.glTexParameterf(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_WRAP_T, gl.GL_CLAMP_TO_EDGE);
     
     gl.glTexImage2D(gl.GL_TEXTURE_2D, 0, gl.GL_RGB, img.width(), img.height(), 0, gl.GL_RGBA, 
                     gl.GL_UNSIGNED_BYTE, str(img.bits()))
     
     return text