/* Morph Editor - DMS2 - Feb 2000 - by Christophe LOREK */ typeof plugin=S;; typeof class=S;; typeof instancename=S;; fun InstName(UI)=UI.nameInst;; fun InstParam(UI)=UI.paramInst;; typeof ed = PluginEditor;; typeof SrvAnimAutoStart = ObjCheck;; typeof LBframerate = ObjText;; typeof Framerate = ObjText;; typeof LBmolfilename = ObjText;; typeof ELmolfilename = ObjText;; typeof BrowseMOLfile = ObjButton;; typeof MOLfilename = S;; typeof LBmorphObjects = ObjText;; typeof LSmorphObjects = ObjList;; typeof MorphObjectslist = [[S S] r1];; typeof ELmorphObject = ObjText;; typeof BrowseMorphObject = ObjButton;; typeof AddMorphObject = ObjButton;; typeof RemoveMorphObject = ObjButton;; typeof LBframeEvents = ObjText;; typeof LSframeEvents = ObjList;; typeof frameEventslist = [I r1];; typeof ELframeEvent = ObjText;; typeof AddFrameEvent = ObjButton;; typeof RemoveFrameEvent = ObjButton;; typeof LBsequences = ObjText;; typeof LSsequences = ObjList;; typeof sequenceslist = [S r1];; typeof ELsequence = ObjText;; typeof AddSequence = ObjButton;; typeof RemoveSequence = ObjButton;; proto save=fun [[Inst r1]] [[S r1] [S r1] [[S r1] r1] [[S r1] r1]];; /* generates a list of strings containing the name of the sequences coming from the sequence parameters of a given instance of the plugin. */ fun paramSequences(paramlist)= if paramlist == nil then nil else let paramlist -> [paramline nparamlist] in let paramline -> [paramname paramvalues] in if !strcmp paramname "sequence" then let strextr hd paramvalues -> [[name keyparams] _] in [name ]::(paramSequences nparamlist) else (paramSequences nparamlist);; /* generates a list of actions corresponding to the sequence parameters of a given instance of the plugin. */ fun suppsequences(l,UIname)= if l == nil then nil else let l -> [[seqName ] nl] in ("actionC"::(strcatn UIname::"."::seqName::".playonce"::nil)::nil):: ("actionC"::(strcatn UIname::"."::seqName::".playloop"::nil)::nil):: ("actionC"::(strcatn UIname::"."::seqName::".stop"::nil)::nil):: ("action"::(strcatn UIname::"."::seqName::".playonceS"::nil)::nil):: ("action"::(strcatn UIname::"."::seqName::".playloopS"::nil)::nil):: ("action"::(strcatn UIname::"."::seqName::".stopS"::nil)::nil):: (suppsequences nl UIname);; /* generates a list of strings containing the number of the frames coming from the FrameEvent parameters of a given instance of the plugin. */ fun paramFrames(paramlist)= if paramlist == nil then nil else let paramlist -> [[name r] nparamlist] in ( if !strcmp name "FrameEvent" then let r -> [frameNum _] in (strcat ".Frame#" (itoa (atoi frameNum)))::(paramFrames nparamlist) else (paramFrames nparamlist) );; /* generates a list of events corresponding to the FrameEvent parameters of a given instance of the plugin. */ fun suppframes(l,UIname)= if l == nil then nil else let l -> [currentFrame nl] in ("eventC"::(strcatn UIname::currentFrame::nil)::nil):: (suppframes nl UIname);; /* generates the list of supp. events for all the instances of the plugin. */ fun suppevents(l)= if l == nil then nil else let l -> [UI nl] in let (InstName UI) -> name in listcat (suppframes (paramFrames strextr (InstParam UI)) name) (suppevents nl);; /* generates the list of supp. actions for all the instances of the plugin. */ fun suppactions(l)= if l == nil then nil else let l -> [UI nl] in let (InstName UI) -> name in listcat (suppsequences (paramSequences strextr (InstParam UI)) name) (suppactions nl);; fun save(l)= if l==nil then [nil nil nil nil] else [ /* registerF */ nil /* register */ nil /* supplemental dat */ ("plugin"::plugin::nil)::nil /* supplemental dmi */ listcat (suppactions l) (suppevents l) ];; /* MORPHOBJECT EDITOR */ fun listVert2liststring(l)= if l == nil then nil else let l -> [[x y z] nl] in ((itoa x)::(itoa y)::(itoa z)::nil)::(listVert2liststring nl);; fun AddMorphObjectInList(l,morphObjectName,pos)= if !strcmp morphObjectName "" then nil else if l == nil then let MX3create _channel 1024 1024 1024 1024 1024*1024 -> MOsession in let M3createShell MOsession -> MOshell in let M3load MOsession morphObjectName MOshell -> status in let M3getFirstSon MOsession MOshell -> MOh3d in let M3listOfVertices MOsession MOh3d -> MOlistvert in ( M3destroy MOsession; _ADDlist LSmorphObjects pos morphObjectName; [[morphObjectName strbuild listVert2liststring MOlistvert] nil] ) else let l -> [currentmorphObject nl] in [currentmorphObject (AddMorphObjectInList nl morphObjectName pos+1)];; fun RemoveMorphObjectFromList(l,morphObjectName,pos)= if l == nil then nil else let l -> [currentmorphObject nl] in let currentmorphObject -> [currentmorphObjectName _] in ( if !strcmp morphObjectName currentmorphObjectName then ( _DELlist LSmorphObjects pos; nl ) else currentmorphObject::(RemoveMorphObjectFromList nl morphObjectName pos+1) );; fun _CBaddMorphObject(a,b)= set MorphObjectslist = AddMorphObjectInList MorphObjectslist _GETtext ELmorphObject 0; _SETtext ELmorphObject nil;; fun _CBremoveMorphObject(a,b)= let _GETlist LSmorphObjects -> [_ morphObject] in set MorphObjectslist = RemoveMorphObjectFromList MorphObjectslist morphObject 0;; fun getMorphObjectList(l)= if l == nil then nil else let l -> [[param [morphObjectName [MOdata _]]] nl] in if !strcmp param "morphObject" then let getMorphObjectList nl -> fmor in ( _ADDlist LSmorphObjects 0 morphObjectName; [[morphObjectName MOdata] fmor] ) else getMorphObjectList nl;; fun _ValidateFile (d,b,s)= let _PtoScol s -> name in if name==nil then nil else _SETtext ELmorphObject name;; fun BrowseMorphObjectCB(a,b)= _DLGrflopen (_DLGOpenFile _channel nil nil nil "m3d\0*.m3d\0\0") @_ValidateFile nil;; fun _ValidateFile2 (d,b,s)= let _PtoScol s -> name in if name==nil then nil else _SETtext ELmolfilename name;; fun BrowseMOLfileCB(a,b)= _DLGrflopen (_DLGOpenFile _channel nil "tmp" nil "mol\0*.mol\0\0") @_ValidateFile2 nil;; /* FRAME EVENT EDITOR */ fun AddFrameEventInList(l,frame,pos)= if l == nil then ( _ADDlist LSframeEvents pos itoa frame; [frame nil] ) else let l -> [currentframe nl] in ( if frame == currentframe then l else if frame < currentframe then ( _ADDlist LSframeEvents pos itoa frame; [frame [currentframe nl]] ) else [currentframe (AddFrameEventInList nl frame pos+1)]; );; fun RemoveFrameEventFromList(l,frame,pos)= if l == nil then nil else let l -> [currentframe nl] in ( if frame == currentframe then ( _DELlist LSframeEvents pos; nl ) else currentframe::(RemoveFrameEventFromList nl frame pos+1) );; fun _CBaddFrameEvent(a,b)= set frameEventslist = AddFrameEventInList frameEventslist atoi _GETtext ELframeEvent 0; _SETtext ELframeEvent nil;; fun _CBremoveFrameEvent(a,b)= let _GETlist LSframeEvents -> [_ frame] in set frameEventslist = RemoveFrameEventFromList frameEventslist atoi frame 0;; fun _CBeditlineOk(a,b,c)= _CBaddFrameEvent 0 0;; fun getFrameEventList(l)= if l == nil then nil else let l -> [[param [value _]] nl] in if !strcmp param "FrameEvent" then let getFrameEventList nl -> fel in ( _ADDlist LSframeEvents 0 value; [atoi value fel] ) else getFrameEventList nl;; /* SEQUENCE EDITOR */ fun AddSequenceInList(l,sequence,pos)= if !strcmp sequence "" then nil else if l == nil then ( _ADDlist LSsequences pos sequence; [sequence nil] ) else let hd hd strextr sequence -> name in let l -> [currentsequence nl] in let hd hd strextr currentsequence -> currentname in ( if !strcmp name currentname then l else if (strcmp name currentname) < 0 then ( _ADDlist LSsequences pos sequence; [sequence [currentsequence nl]] ) else [currentsequence (AddSequenceInList nl sequence pos+1)]; );; fun RemoveSequenceFromList(l,sequence,pos)= if l == nil then nil else let l -> [currentsequence nl] in let hd hd strextr sequence -> name in let hd hd strextr currentsequence -> currentname in ( if !strcmp name currentname then ( _DELlist LSsequences pos; nl ) else currentsequence::(RemoveSequenceFromList nl sequence pos+1) );; fun _CBaddSequence(a,b)= set sequenceslist = AddSequenceInList sequenceslist _GETtext ELsequence 0; _SETtext ELsequence nil;; fun _CBremoveSequence(a,b)= let _GETlist LSsequences -> [_ sequence] in set sequenceslist = RemoveSequenceFromList sequenceslist sequence 0;; fun concatlist(l)= if l == nil then "" else let l -> [word nl] in strcatn word::" "::(concatlist nl)::nil;; fun getSequenceList(l)= if l == nil then nil else let l -> [[param rl] nl] in if !strcmp param "sequence" then let getSequenceList nl -> fseq in let (concatlist rl) -> sequence in ( _ADDlist LSsequences 0 sequence; [sequence fseq] ) else getSequenceList nl;; fun openedit(win,param)= let strextr param -> l in let _GETwindowSizePosition win -> [w h x y] in ( set ed = startPluginEditor _channel win 0 0 w h WN_CHILDINSIDE|WN_NOBORDER class; set SrvAnimAutoStart = _CRcheck _channel ed.PluginEditorEditWin 5 1 120 20 0 "SrvAnimAutoStart"; let getInfo l "SrvAnimAutoStart" -> string in if string == nil then _SETcheck SrvAnimAutoStart 1 else if (atoi string) then _SETcheck SrvAnimAutoStart 1 else _SETcheck SrvAnimAutoStart 0; set LBframerate = _CRtext _channel ed.PluginEditorEditWin 5 22 80 16 ET_ALIGN_LEFT "framerate :"; set Framerate = _CReditLine _channel ed.PluginEditorEditWin 85 21 40 18 ET_DOWN|ET_NUMBER|ET_AHSCROLL let getInfo l "Framerate" -> string in if (nil == string) then "30" else string; set LBmolfilename = _CRtext _channel ed.PluginEditorEditWin 5 43 60 16 ET_ALIGN_LEFT "MOL file"; set ELmolfilename = _CReditLine _channel ed.PluginEditorEditWin 65 42 75 18 ET_DOWN|ET_NUMBER|ET_AHSCROLL set MOLfilename = let getInfo l "MOLfilename" -> string in if (nil == string) then "tmp/tmp.mol" else string; set BrowseMOLfile = _CRbutton _channel ed.PluginEditorEditWin 140 42 20 20 0 "+"; _CBbutton BrowseMOLfile @BrowseMOLfileCB 0; set LBmorphObjects = _CRtext _channel ed.PluginEditorEditWin 5 60 80 16 ET_ALIGN_LEFT "Morph Objects"; set LSmorphObjects = _CRlist _channel ed.PluginEditorEditWin 5 75 155 150 LB_DOWN|LB_VSCROLL; set ELmorphObject = _CReditLine _channel ed.PluginEditorEditWin 5 230 135 20 ET_ALIGN_LEFT|ET_DOWN|ET_AHSCROLL nil; set BrowseMorphObject = _CRbutton _channel ed.PluginEditorEditWin 140 230 20 20 0 "+"; set AddMorphObject = _CRbutton _channel ed.PluginEditorEditWin 5 255 75 20 0 "Add"; set RemoveMorphObject = _CRbutton _channel ed.PluginEditorEditWin 85 255 75 20 0 "Remove"; _CBbutton BrowseMorphObject @BrowseMorphObjectCB 0; _CBbutton AddMorphObject @_CBaddMorphObject 0; _CBbutton RemoveMorphObject @_CBremoveMorphObject 0; set MorphObjectslist = getMorphObjectList strextr _getpack _checkpack MOLfilename; set LBframeEvents = _CRtext _channel ed.PluginEditorEditWin 170 5 80 16 ET_ALIGN_LEFT "Frame Events"; set LSframeEvents = _CRlist _channel ed.PluginEditorEditWin 170 25 155 200 LB_DOWN|LB_VSCROLL; set ELframeEvent = _CReditLine _channel ed.PluginEditorEditWin 170 230 155 20 ET_ALIGN_LEFT|ET_DOWN|ET_NUMBER|ET_AHSCROLL nil; set AddFrameEvent = _CRbutton _channel ed.PluginEditorEditWin 170 255 75 20 0 "Add"; set RemoveFrameEvent = _CRbutton _channel ed.PluginEditorEditWin 250 255 75 20 0 "Remove"; _CBbutton AddFrameEvent @_CBaddFrameEvent 0; _CBlineOk ELframeEvent @_CBeditlineOk 0; _CBbutton RemoveFrameEvent @_CBremoveFrameEvent 0; set frameEventslist = getFrameEventList l; set LBsequences = _CRtext _channel ed.PluginEditorEditWin 340 5 80 16 ET_ALIGN_LEFT "Sequences"; set LSsequences = _CRlist _channel ed.PluginEditorEditWin 340 25 155 200 LB_DOWN|LB_VSCROLL; set ELsequence = _CReditLine _channel ed.PluginEditorEditWin 340 230 155 20 ET_ALIGN_LEFT|ET_DOWN|ET_AHSCROLL nil; set AddSequence = _CRbutton _channel ed.PluginEditorEditWin 340 255 75 20 0 "Add"; set RemoveSequence = _CRbutton _channel ed.PluginEditorEditWin 420 255 75 20 0 "Remove"; _CBbutton AddSequence @_CBaddSequence 0; _CBbutton RemoveSequence @_CBremoveSequence 0; set sequenceslist = getSequenceList l; 0 );; fun genMorphObjectsStrings(l)= if l == nil then nil else let l-> [[morphObjectName MOdata] nl] in ("morphObject"::morphObjectName::MOdata::nil)::(genMorphObjectsStrings nl);; fun genFrameEventsStrings(l)= if l == nil then nil else let l-> [currentframe nl] in ("FrameEvent"::(itoa currentframe)::nil)::(genFrameEventsStrings nl);; fun gensequencesStrings(l)= if l == nil then nil else let l-> [sequence nl] in ("sequence"::sequence::nil)::(gensequencesStrings nl);; fun closeedit()= let _GETtext ELmolfilename -> MOLfilename in ( _storepack (strbuild genMorphObjectsStrings MorphObjectslist) MOLfilename; strbuild listcat ("SrvAnimAutoStart"::(itoa _GETcheck SrvAnimAutoStart)::nil):: ("Framerate"::(_GETtext Framerate)::nil):: ("MOLfilename"::MOLfilename::nil)::nil listcat genFrameEventsStrings frameEventslist gensequencesStrings sequenceslist );; fun IniPlug(file)= set plugin=file; set class=getInfo strextr _getpack _checkpack file "name"; PlugRegister class @save nil @openedit @closeedit;;