meshlabxml/texture.py
def project_rasters(script, tex_file_out="TEMP3D.png", tex_size=1024,
                    fill_atlas_gaps=False, depth_threshold=0.5,
                    selected=False, use_angle=True, use_distance=True,
                    use_borders=True, use_silhouettes=True, use_alpha=False):
    """Set texture

    Creates new texture file
    tex_file_out = must be png
    fill_atlas_gaps  = setting this to false will leave the unprojected area transparent. This can then be easily composed with the original texture with PIL

    """
    filter_xml = ''.join([
        '  <filter name="Project active rasters color to current mesh, filling the texture">\n',
        '    <Param name="textName"',
        'value="%s"' % tex_file_out,
        'description="Texture file"',
        'type="RichString"',
        'tooltip="The texture file to be created"',
        '/>\n',
        '    <Param name="texsize"',
        'value="%d"' % tex_size,
        'description="pixel size of texture image"',
        'type="RichInt"',
        'tooltip="pixel size of texture image, the image will be a square tsize X tsize, most applications do require that tsize is a power of 2"',
        '/>\n',
        '    <Param name="dorefill"',
        'value="%s"' % str(fill_atlas_gaps).lower(),
        'description="fill atlas gaps"',
        'type="RichBool"',
        'tooltip="If true, unfilled areas of the mesh are interpolated, to avoid visible seams while mipmapping"',
        '/>\n',
        '    <Param name="deptheta"',
        'value="%s"' % depth_threshold,
        'description="depth threshold"',
        'type="RichFloat"',
        'tooltip="threshold value for depth buffer projection (shadow buffer)"',
        '/>\n',
        '    <Param name="onselection"',
        'value="%s"' % str(selected).lower(),
        'description="Only on selecton"',
        'type="RichBool"',
        'tooltip="If true, projection is only done for selected vertices"',
        '/>\n',
        '    <Param name="useangle"',
        'value="%s"' % str(use_angle).lower(),
        'description="use angle weight"',
        'type="RichBool"',
        'tooltip="If true, color contribution is weighted by pixel view angle"',
        '/>\n',
        '    <Param name="usedistance"',
        'value="%s"' % str(use_distance).lower(),
        'description="use distance weight"',
        'type="RichBool"',
        'tooltip="If true, color contribution is weighted by pixel view distance"',
        '/>\n',
        '    <Param name="useborders"',
        'value="%s"' % str(use_borders).lower(),
        'description="use image borders weight"',
        'type="RichBool"',
        'tooltip="If true, color contribution is weighted by pixel distance from image boundaries"',
        '/>\n',
        '    <Param name="usesilhouettes"',
        'value="%s"' % str(use_silhouettes).lower(),
        'description="use depth discontinuities weight"',
        'type="RichBool"',
        'tooltip="If true, color contribution is weighted by pixel distance from depth discontinuities (external and internal silhouettes)"',
        '/>\n',
        '    <Param name="usealpha"',
        'value="%s"' % str(use_alpha).lower(),
        'description="use image alpha weight"',
        'type="RichBool"',
        'tooltip="If true, alpha channel of the image is used as additional weight. In this way it is possible to mask-out parts of the images that should not be projected on the mesh. Please note this is not a transparency effect, but just influences the weighting between different images"',
        '/>\n',
        '  </filter>\n'])
    util.write_filter(script, filter_xml)
    return None
def project_rasters(script, tex_file_out="TEMP3D.png", tex_size=1024,
                    fill_atlas_gaps=False, depth_threshold=0.5,
                    selected=False, use_angle=True, use_distance=True,
                    use_borders=True, use_silhouettes=True, use_alpha=False):
    """Set texture

    Creates new texture file
    tex_file_out = must be png
    fill_atlas_gaps  = setting this to false will leave the unprojected area transparent. This can then be easily composed with the original texture with PIL

    """
    filter_xml = ''.join([
        '  <filter name="Project active rasters color to current mesh, filling the texture">\n',
        '    <Param name="textName"',
        'value="%s"' % tex_file_out,
        'description="Texture file"',
        'type="RichString"',
        'tooltip="The texture file to be created"',
        '/>\n',
        '    <Param name="texsize"',
        'value="%d"' % tex_size,
        'description="pixel size of texture image"',
        'type="RichInt"',
        'tooltip="pixel size of texture image, the image will be a square tsize X tsize, most applications do require that tsize is a power of 2"',
        '/>\n',
        '    <Param name="dorefill"',
        'value="%s"' % str(fill_atlas_gaps).lower(),
        'description="fill atlas gaps"',
        'type="RichBool"',
        'tooltip="If true, unfilled areas of the mesh are interpolated, to avoid visible seams while mipmapping"',
        '/>\n',
        '    <Param name="deptheta"',
        'value="%s"' % depth_threshold,
        'description="depth threshold"',
        'type="RichFloat"',
        'tooltip="threshold value for depth buffer projection (shadow buffer)"',
        '/>\n',
        '    <Param name="onselection"',
        'value="%s"' % str(selected).lower(),
        'description="Only on selecton"',
        'type="RichBool"',
        'tooltip="If true, projection is only done for selected vertices"',
        '/>\n',
        '    <Param name="useangle"',
        'value="%s"' % str(use_angle).lower(),
        'description="use angle weight"',
        'type="RichBool"',
        'tooltip="If true, color contribution is weighted by pixel view angle"',
        '/>\n',
        '    <Param name="usedistance"',
        'value="%s"' % str(use_distance).lower(),
        'description="use distance weight"',
        'type="RichBool"',
        'tooltip="If true, color contribution is weighted by pixel view distance"',
        '/>\n',
        '    <Param name="useborders"',
        'value="%s"' % str(use_borders).lower(),
        'description="use image borders weight"',
        'type="RichBool"',
        'tooltip="If true, color contribution is weighted by pixel distance from image boundaries"',
        '/>\n',
        '    <Param name="usesilhouettes"',
        'value="%s"' % str(use_silhouettes).lower(),
        'description="use depth discontinuities weight"',
        'type="RichBool"',
        'tooltip="If true, color contribution is weighted by pixel distance from depth discontinuities (external and internal silhouettes)"',
        '/>\n',
        '    <Param name="usealpha"',
        'value="%s"' % str(use_alpha).lower(),
        'description="use image alpha weight"',
        'type="RichBool"',
        'tooltip="If true, alpha channel of the image is used as additional weight. In this way it is possible to mask-out parts of the images that should not be projected on the mesh. Please note this is not a transparency effect, but just influences the weighting between different images"',
        '/>\n',
        '  </filter>\n'])
    util.write_filter(script, filter_xml)
    return None
Set texture

    Creates new texture file
    tex_file_out = must be png
    fill_atlas_gaps  = setting this to false will leave the unprojected area transparent. This can then be easily composed with the original texture with PIL