How would I remove specific points from a morph file via script?

I've got a Studio script creation question. I'm wondering if it's possible to create a script that can go thru a morph file and eliminate certain points from the morph from a prearranged set of points. Like say you've got a morph that you've created and all is well and good except there's an issue that causes distortion in say the eyeball area. The reason I ask is that I've got a few morphs I've created for Genesis 2 Male. I've managed to transfer them over to Genesis 3 Male. All seems to work fine except I get major distortion in the eyes and in the mouth area. I even get it on morphs that are only body shapes and nothing has been done to the head or face areas. What I've been doing is going thru the DUF file and manually editing and removing the points that correspond to those areas. And thru some morphs I made for those specific areas I know which points need to be removed. So I know the range of numbers that could be used. I just wondered if there was an easier way of editing the morph under than by hand.

Thanks,

David

Comments

  • simtenerosimtenero Posts: 383
    edited March 2016

    This is definitelyt doable.  I just tested this andx it seems to do what you are looking for:

    var node = Scene.getPrimarySelection();var obj = node.getObject();var morph = obj.findModifier("YourMorphName");var deltas = morph.getDeltas();//your list of verts to remove from the morphvar remove = new Array(4, 5, 6, 7, 8, 9);for (var i = 0; i < remove.length; i++){	deltas.removeDelta(remove[i]);}

     

    Post edited by simtenero on
  • Cool. Thanks, I appreciate the work. Forgive my ignorance here, but can you plug in like a range of numbers instead of the individual? Say like list 4-9 instead of writing out each instance? Reason I ask is because in the morph file there are long stretches of numbers and then there'll be some skips.

  • simtenerosimtenero Posts: 383

    No problem :-).  You could try the below to add ranges, its a little cumbersome but without getting really complicated, may be your best bet:

    var node = Scene.getPrimarySelection();var obj = node.getObject();var morph = obj.findModifier("YourMorphName");var deltas = morph.getDeltas();//your list of verts to remove from the morphvar remove = new Array();//Range 57 through 125for (var i = 57; i <= 125; i++){    remove.push(i);}//Range 245 through 290for (var i = 245; i <= 290; i++){    remove.push(i);}for (var i = 0; i < remove.length; i++){	deltas.removeDelta(remove[i]);}

    You would copy/paste the "range" section for each range and change its number accordingly.  Haven't tested this though, so you may need to experiment with it.

  • Ok, I think I'm grasping the concept. One thing I noticed though is that this script seems to be written for an OBJ file. How well would this work on a DUF file?

    David

  • simtenerosimtenero Posts: 383
    edited March 2016

    That's actually just a reference to the "object" stored with the node you are working on, not an .obj file, the name is just a coincidence laugh.

    You would paste this into the SciptIDE pane, select the figure (select the "root node", not a bone), and run the script (F5).  To see the changes you may need to remove and reapply your morph.  When it looks good (and assuming the script works, no promises :-)), just save a new morph preset and you should have your new .duf ready to go.

    Post edited by simtenero on
  • Thanks. I'll see about trying it out and see what happens.

Sign In or Register to comment.