Where is Subset tool in WrapX and how to use it to exclude ploygons?

Recently I encountered with a problem with Genesis mesh, described in this topic (Wrapping full bodymesh to face mesh) - Faceform and the workflow given there was related to Wrap 2.3, but what is the alternative for WrapX? How can I select the subset of polygons for Genesis-like meshes and exclude the polygons of body, if I want to wrap just the head? I found a script on the forum but cannot alter it properly for Genesis instead of demo figure.
And one more problem. I know that Genesis and other similar meshes must be cleared from eyes, teeth and other unconnected pieces like described here -

[i]1. Export Genesis mesh from Daz 2. Remove all the separated pieces (eyeballs, eyelashes, teeth etc.) from the mesh. Verter order will be changed. 3. Load the cleaned mesh in WrapX and perform wrapping 4. Now you need to restore your original mesh back with eyeballs, eyelashes etc. and so that vertex order is preserved. You can use lattice deformer in WrapX, Maya or any 3rd-party editor. Use cleaned mesh and wrapped cleaned mesh as a source of deformation for lattice deformer and use original Daz mesh as a deformable object.[/i]
I did it and got a pure bodymesh, but what for polygroups? I found an advice how to break a mesh OBJ to polygroups - open it with the Notepad and replace all "usemtl" to "g". It simplifies subset selecting in Wrap, but how to use it in WrapX? The more after this Genesis meshes are broken to pieces - every groups becomes a separate piece of geometry. Can I use such unwelded mesh of Genesis to perform partial wrapping? I tested such a mesh and got WrapX hanging. I guess the mesh must be fully welded. But then - how to select polygons faster? I am noobish in Python scripts, so would be very grateful for explanation how to use the sample script for WrapX subset, to make it usable for any custom bodymesh. PS. I think it would be nice if WrapX had a function to select subset of polygons based on materials, which is written within OBJ files. Then all meshes could be left welded and users could choose polygons in the fastest and easiest way. I hope we'll see such option in the future releases of WrapX.

Hello,

First let me clarify about polygroups. If a mesh has polygroups it does not mean it is unwelded. Polygroups are just like materials. (However if you load mesh with polygroups into software like 3DsMax, by default the mesh will be splitten into different objects).

The basic scenario how to get integral mesh with polygroups:

  • load mesh in Max/Maya, assign materials to different pieces, name each material with some meaningful name, save it to OBJ-file.
  • open OBJ file in notepad and replace all occurance of "usemtl " to "g ". Save it. Note that it will not split your mesh.
  • inside WrapX when you do wrap.seletPolygons(mesh) between the “Shrink” and “Hide selected” buttons there is a drop-down list of all your polygroups. You can add/substract selection by clicking “+”/“-” buttons.

About subset tool, there is an analog of subset tool in WrapX . Here is example of how to detach a head from basemesh, wrap it and return back:
selection = wrap.selectPolygons(basemesh)
headmesh,vertexMapping = wrap.subset(basemesh,selection)
do wrapping on headmesh
wrap.applySubset(basemesh,headmesh,vertexMapping)

Please let me know if you need more help on this.

Thanks, Andrew, but how to built this code fragments into your Simple Wrapping script? I’ve just tested it and put it like this -

import wrap

# 1. Loading Basemesh
print "Loading basemesh..."
basemeshFileName = wrap.openFileDialog("Select Basemesh",filter = "OBJ-file (*.obj)",dir = wrap.demoModelsPath)
basemesh = wrap.Geom(basemeshFileName)
print "OK"

# 2. Loading Scan
print "Loading scan..."
scanFileName = wrap.openFileDialog("Select Scan",filter = "OBJ-file (*.obj)",dir = wrap.demoModelsPath)
scaleFactor = 1000
scan = wrap.Geom(scanFileName,scaleFactor = scaleFactor)
scan.wireframe = False
print "OK"

#3 Subset
selection = wrap.selectPolygons(basemesh)
headmesh,vertexMapping = wrap.subset(basemesh,selection)

# 4. Rigid Alignment
print "Rigid alignment..."
(pointsScan, pointsBasemesh) = wrap.selectPoints(scan,basemesh)
rigidTransformation = wrap.rigidAlignment(basemesh,pointsBasemesh,scan,pointsScan,matchScale = True)
basemesh.transform(rigidTransformation)
basemesh.fitToView()
print "OK"

# 5. Non-rigid Registration
print "Non-rigid Registration..."
(controlPointsScan,controlPointsBasemesh) = wrap.selectPoints(scan,basemesh)
freePolygonsBasemesh = wrap.selectPolygons(basemesh)
basemesh = wrap.nonRigidRegistration(basemesh,scan,controlPointsBasemesh,controlPointsScan,freePolygonsBasemesh,minNodes = 15,initialRadiusMultiplier = 1.0,smoothnessFinal = 0.1,maxIterations = 20)
print "OK"

#6 Apply subset
wrap.applySubset(basemesh,headmesh,vertexMapping)

# 7. Subdivision
print "Subdivision..."
basemesh = wrap.subdivide(basemesh)
print "OK"

# 8. Projection
print "Projection..."
disabledPolygons = wrap.selectPolygons(basemesh)
basemesh = wrap.projectMesh(basemesh,scan,maxRelativeDist = 1,disabledPolygonIndicesSrc = disabledPolygons)
print "OK"

# 9. Saving Result
print "Saving result..."
fileName = wrap.saveFileDialog("Save resulting model",filter = "OBJ-file (*.obj)")
basemesh.save(fileName,scaleFactor = 1.0 / scaleFactor)
if scan.texture is not None:
    textureFileName = wrap.saveFileDialog("Save resulting texture",filter = "Image (*.jpg *.png *.bmp *.tga)")
    basemesh.texture.save(textureFileName)
print "OK"

And after #3 Subset I got not the separate head, but the full body-mesh again and after Non-rigid Registration I got two meshes aligned and an error

Traceback (most recent call last):
File “*SimpleWrappingDemo.py”, line 33, in
ValueError: GeomFloating contains 42 disconnected from each other polygon groups, must be 1. One can use wrap.subset() to extract main part.

And WrapX stops at this step.
Couldn’t you post this script with included polygon selection ability and saving subset ability in the right places?

One more question - after Rigid Alignment and Non-Rigid Registration - how can I save all control points for these 2 steps? Where must I put this command? Lately I wanted to use Batch Wizard script set from Github, but the first script 0_GenerateConfig_ManyScansOneBasemesh.py
( https://github.com/Russian3DScanner/WrapXScripts/blob/master/BatchWizard/0_GenerateConfig_ManyScansOneBasemesh.py) gives me some indentation errors. What is this, is there the right version of this script? The version of this Wizard with demo models works nice, but it misses the very first script, to create my own config TXT file. How to fix that script?

PS - I tested the Sample Script for subsets (http://russian3dscanner.com/downloads/ForumAnswers/2016.March.02.SubsetExample.zip) , but it works with Demo Models only. How to alter this script for working with any custom models without loading the demo Control Points and polygons from files? I mean the universal version of the script, where I can select my rigid points, select my subset and save it to the corresponding files, and so on. As many others, I am a noob in Python scripting.

Hello!

I answered your question via personal message as you requested.

Ivan

Thanks, Ivan, your new Batch Wizard worked fine, but new Subset Example gives some errors, I wrote you in PM. One question more - how to use Lattice deformer with WrapX for Genesis-like meshes. I found the advice in another thread -
No, actually it can. The process goes like this:

1. Export Genesis mesh from Daz
2. Remove all the separated pieces (eyeballs, eyelashes, teeth etc.) from the mesh. Verter order will be changed.
3. Load the cleaned mesh in WrapX and perform wrapping
4. Now you need to restore your original mesh back with eyeballs, eyelashes etc. and so that vertex order is preserved. You can use lattice deformer in WrapX, Maya or any 3rd-party editor. Use cleaned mesh and wrapped cleaned mesh as a source of deformation for lattice deformer and use original Daz mesh as a deformable object.
As a result you should get new Daz mesh with the same vertex order. After importing the mesh back into Daz there is a function to recalculate rig for edited mesh. 

But I don’t know how to load properly all three meshes in the Lattice Deformer demo script. When I load the full non-cleaned Genesis mesh as geomTarget, and initial non-wrapped clean bodymesh as geomSource and wrapped clean bodymesh as geomReference, the full Genesis mesh deforms into a spike-shaped form. What is the deformable object and deformers in this script?

import wrap
#FIXME

geomTarget    = wrap.Geom('C:/Program Files/R3DS/WrapX1.3/PythonScripts/01DAZWizard/SampleConfig/Basemeshes/G2M_Zero_Mesh_Full.obj')
geomSource    = wrap.Geom('C:/Program Files/R3DS/WrapX1.3/PythonScripts/01DAZWizard/SampleConfig/Basemeshes/g2m_zero_bodymesh.obj')
geomReference = wrap.Geom('C:/Program Files/R3DS/WrapX1.3/PythonScripts/01DAZWizard/SampleConfig/Results_Wrapped/TalionWrapped.obj', 0.001)

res = wrap.latticeDeform(geomTarget, geomSource, geomReference, 0.05)
res.fitToView()
geomTarget.hide()
geomSource.hide()
geomReference.hide()

Hey, I have just sent you a PM