Dialogs

selectPoints(geomLeft,geomRight = None, ...) Creates modal dialog for selecting point correspondences.
selectPolygons(geom,selectedPolygonIndices = []) Creates modal dialog for selecting polygons on mesh.
openFileDialog(...) Creates a modal file dialog
openFilesDialog(...) Creates a modal file dialog.
saveFileDialog(...) Creates a modal save file dialog
blendShapesDialog(neutralGeom, targetGeoms, ...) Shows interactive blendshape dialog with sliders
wrap.selectPoints(geomLeft, geomRight = None, pointsLeft = [], pointsRight = [])

Creates modal dialog for selecting point correspondences. If geomRight is None then dialog shows just one viewport.

Returned points can be then saved by wrap.savePoints() and loaded by wrap.loadPoints()

Parameters:

geomLeft, geomRight : wrap.Geom

Left and right geometry that will be displayed in left and right window.

pointsLeft, pointsRight : sequence of wrap.PointOnTriangle, optional

For demonstration purposes you can provide user with some pre-defined selection.

Returns:

tuple of two lists of wrap.PointOnTriangle if geomRight is not None.

if geomRight is None then function returns list of wrap.PointOnTriangle

Notes

This function was updated in 1.3.3.

Examples

geom = wrap.Geom(wrap.demoModelsPath + '/HeadPolygroups_MakeHuman.obj')

# Show dialog with just one geom and no predefined points
wrap.selectPoints(geom)

# Predefined points from left side of the head
points = [
   wrap.PointOnTriangle(3640,0.5,0.0),
   wrap.PointOnTriangle(3753,0.3,0.0),
   wrap.PointOnTriangle(4399,0.19,0.0),
   wrap.PointOnTriangle(3132,0.0,0.6)]

# Show dialog with just one geom and predefined points
points = wrap.selectPoints(geom,None,points)

geomScan = wrap.Geom(wrap.demoModelsPath + '/FaceScan_Ten24.obj')

# Select corresponding points between two geometries
(pointsGeom, pointsGeomScan) = wrap.selectPoints(geom,geomScan)
wrap.selectPolygons(geom, selectedPolygonIndices = [])

Creates modal dialog for selecting polygons on mesh. It is possible to use mesh’s polygon groups to speed up selection.

Returned list of polygons can be then saved by wrap.savePolygons() and loaded by wrap.loadPolygons().

Parameters:

geom : wrap.Geom

Input geometry can contain polygon groups.

selectedPolygonIndices : sequence of int, optional

For demonstration purposes you can provide user with pre-defined selection. Each polygon index should be >= 0 and < geom.nPolygons.

Returns:

result : list of int

Returns a list of polygon indices selected by the user.

wrap.openFileDialog(title = "Select file", dir = "", filter = "Files (*.*)")

Creates a modal file dialog

Parameters:

title : string, optional

Will be displayed as dialog title

dir : string, optional

The dialog’s working directory will be set to dir

filter : string, optional

Only files that match the given filter are shown. If you want multiple filters, separate them with ‘;;’, for example: Images (*.png *.xpm *.jpg);;Text files (*.txt);;XML files (*.xml)

Returns:

result : string

Returns file name selected by user. If the user presses Cancel, it returns None

wrap.openFilesDialog(title = "Select file", dir = "", filter = "Files (*.*)")

Creates a modal file dialog. Similar to wrap.openFileDialog but allows multiple selections. Returns a list of file names selected by the user.

wrap.saveFileDialog(title = "Save file", dir = "", filter = "Files (*.*)")

Creates a modal save file dialog

Parameters:

title : string, optional

Will be displayed as dialog title

dir : string, optional

The dialog’s working directory will be set to dir

filter : string, optional

Only files that match the given filter are shown. If you want multiple filters, separate them with ‘;;’, for example: Images (*.png *.xpm *.jpg);;Text files (*.txt);;XML files (*.xml)

Returns:

result : string

Returns file name selected by user. If the user presses Cancel, it returns None

wrap.blendShapesDialog(neutralGeom, targetGeoms, targetNames = [], neutralTexture = [], targetTextures = [])

Shows interactive blendshape dialog with sliders

Parameters:

neutralGeom : wrap.Geom

Neutral geometry.

targetGeoms : list of wrap.Geom

List of target geometries. Number of vertices of each target must match to the number of vertices of neutral geometry.

targetNames : list of string

List of target names which will be displayed with sliders to corresponding targets. If empty then names are are numbered as “Target 1”,”Target 2”, etc.

neutralTexture : wrap.Image

Texture of neutral geometry.

targetTextures : list of wrap.Image

List of target textures. Format and dimensions of each target texture must match to neutral texture.

Returns:

result: wrap.Geom

Computed blendshape with last sliders positions. If textures are passed then result has assigned texture.

Examples

To compute blendshape with textures interpolated:

# specify names
neutralGeomFilename = 'Neutral.obj'
neutralTextureFilename = 'Neutral.jpg'
targetGeomFilenames = ['Fear.obj','Pain.obj','Smile.obj']
targetTextureFilenames = ['Fear.jpg','Pain.jpg','Smile.jpg']
targetNames = ['Fear','Pain','Smile']

# loading models
neutralGeom = wrap.Geom(wrap.demoModelsPath + '/Blendshapes/' + neutralGeomFilename)
neutralGeom.texture = wrap.Image(wrap.demoModelsPath + '/Blendshapes/' + neutralTextureFilename)
targetGeoms = [ wrap.Geom(wrap.demoModelsPath + '/Blendshapes/' + filename) for filename in targetGeomFilenames ]
targetTextures = [ wrap.Image(wrap.demoModelsPath + '/Blendshapes/' + filename) for filename in targetTextureFilenames ]

# hiding neutral and target geoms to make visible only blendshape
neutralGeom.hide()
for targetGeom in targetGeoms: targetGeom.hide()

# computing blendshape
blendshapeGeom = wrap.blendShapeDialog(neutralGeom, targetGeoms, targetNames, neutralGeom.texture, targetTextures)

And if you need only geometry without textures just not pass texture parameters:

# computing blendshape
blendshapeGeom = wrap.blendShapeDialog(neutralGeom, targetGeoms, targetNames)

When you don’t want to generate blendshaped texture and see in the viewport just one texture then pass only neutralTexture parameter:

# computing blendshape
blendshapeGeom = wrap.blendShapeDialog(neutralGeom, targetGeoms, targetNames, neutralGeom.texture)