@warnings @version 2.1 /* (c) Alexandre Labedade 2008 http://earthwormjim.free.fr - earthwormjim@free.fr This script allows to store relative morph maps as absolute morph maps, to allow base meshe modifications and keep actual relative morph maps. Usage : - Create your relative morph maps as usually - Run this script ans select "FREEZE MORPH" to copy each relative morph map as an absolute one. - Do your modifications on the base mesh - Run the script again and select "RESTORE MORPH" to get back every relative morph maps - Delete all absolute morph maps manually (with the FREEZE_ prefix) to keep the mesh clean Since I don't know how to completely delete a custom vertex map with lscript I'm using VMSPOT (absolute morph map) wich can be seen in the morphmaps list and so be deleted by the user, instead of my defined VMAP_FRZD custom vertex map format wich cannot be displayed in modeler panels and cannot be deleted manually. If a solution exists to delete a given vertex map with a lscript function or if you do some enhancements on this script please drop me a line at : earthwormjim@free.fr */ @define VMAP_FRZD @'F','R','Z','D'@ main{ // get the currently selected morph map to substract its value var selected_morphmap = VMap(VMMORPH,0); // get the list of all present morphmaps var morphlist = array; vmapObj = VMap(VMMORPH); while(vmapObj && vmapObj.type == VMMORPH) { morphlist += vmapObj; vmapObj = vmapObj.next(); } // GUI reqbegin("FREEZE MORPH v0.1"); c1 = ctlchoice("Action",1,@"FREEZE MORPH","RESTORE MORPH"@); if(reqpost()){ action = getvalue(c1); }else{ return; } reqend(); // if(!morphlist.isNil()){ // define var morph_offset = @0,0,0@; editbegin(); // loop on all morph maps foreach(map,morphlist){ // define the name of storage map var mapname = ("FREEZE_"+map.name).asStr(); // find the storage map var freeze_map = VMap(VMSPOT); while(freeze_map && freeze_map.type == VMSPOT){ if(freeze_map.name == mapname) break; } // if the storage map doesn't exists create it if(freeze_map.isNil() && action==1) freeze_map = VMap(VMSPOT , mapname , 3); if(!freeze_map.isNil()){ // loop on all points foreach(p,points){ // if a morphmap is currently selected then get its offset if(!selected_morphmap.isNil()){ morph_offset = selected_morphmap.getValue(p); if(morph_offset.isNil()) morph_offset = @0,0,0@; } if(action==1){ // FREEZE var val = map.getValue(p); if(val.isNil()) val = @0,0,0@; tmp = array(3); tmp[1] = (p.x - morph_offset[1]) + val[1]; tmp[2] = (p.y - morph_offset[2]) + val[2]; tmp[3] = (p.z - morph_offset[3]) + val[3]; freeze_map.setValue(p,tmp); }else if(action==2){ // RESTORE var val = freeze_map.getValue(p); if(!val.isNil()){ tmp = array(3); tmp[1] = p.x - morph_offset[1]; tmp[2] = p.y - morph_offset[2]; tmp[3] = p.z - morph_offset[3]; tmp[1] = val[1] - tmp[1]; tmp[2] = val[2] - tmp[2]; tmp[3] = val[3] - tmp[3]; map.setValue(p,tmp); } } } } } editend(); } }