typeof HandCursor = ObjCursor;; /* curseur main */ typeof ProfCursor = ObjCursor;; /* curseur profondeur */ typeof ListBmp = [ObjBitmap r1];; /* liste des bmps chargées */ var HandCursorBmp ="Dms/3d/Plugins/DynEditor/lib/hand.bmp";; var ProfCursorBmp ="Dms/3d/Plugins/DynEditor/lib/profcursor.bmp";; var HandCursorMACBmp ="Dms/3d/Plugins/DynEditor/lib/handMAC.bmp";; var ProfCursorMACBmp ="Dms/3d/Plugins/DynEditor/lib/profcursorMAC.bmp";; var DECAL = 3;; var DECAL_SELECT = 2;; var BOX_TRANSPARENCY_COEFF = 128;; var VIEW_FOUR = 1;; /* constantes pour le type de vue: 4 vues -1 vue */ var VIEW_ONE = 2;; var OP_VIEW =1 ;; /* constantes pour le type d'operations */ var OP_PAN =2 ;; var OP_PROF =4 ;; var OP_MOVEOBJ =8 ;; var OP_ROTOBJ =16 ;; var OP_SCALE =32 ;; typeof SELECTED_COLOR = I;; /* couleur de selection et de selection d'une vue */ typeof UNSELECTED_COLOR = I;; /* constante de type d'edition dynamique soft ou */ var DYN_NORM = 1;; /* totale */ var DYN_EDIT = 2;; var DYN_PLUGBROWS = 4;; var SELECT_OPENEDT = 1;; /* constantes de selection d'un elt dans une menu */ var SELECT_MODIFYTEXT = 2;; var SELECT_MODIFYFLAT = 3;; var SELECT_MODIFYFLATCOLOR = 4;; var SELECT_MODIFYFILTER = 5;; var SELECT_MODIFYTRANSP = 6;; var SELECT_MODIFYLIGHT = 7;; var SELECT_CLOSEEDT = 8;; var SELECT_OPENEFFECTS = 9;; var SELECT_ADDOBJECT = 10;; var SELECT_ADDSUBOBJECT = 11;; var SELECT_SUPPRESSOBJECT = 12;; var SELECT_SUPPRESSSUBOBJECT= 13;; var SELECT_OPENPBR = 14;; var SELECT_CLOSEPBR = 15;; var SELECT_MODIFYOBB = 16;; var SELECT_MODIFYFOND = 17;; var SELECT_SAVE = 18;; var SELECT_MODIFYLIGHTSCENE = 19;; var SELECT_POS = 20;; var SELECT_QUIT = 21;; var SELECT_MODIFYGRAVITY = 22;; var SELECT_BOX = 23;; var SELECT_MODIFYGOURAUD = 24;; var SELECT_MODIFYENVMAP = 25;; var SELECT_RESETOBJECT = 26;; var SELECT_RESETOBJECTFATHER= 27;; var COORDS_RELATIF = 1;; var COORDS_GLOBAL = 2;; /****************************************************************************************************/ /* Fonctions sur le Menu Popup s'ouvrant sur bouton droit */ /****************************************************************************************************/ proto closeGlobalEditorView=fun[] I;; proto openGlobalEditorView=fun[] I;; proto unselectObject=fun[DynEditorView View3d] I;; proto selectObject =fun [DynEditorView View3d H3d HMat3d I I] I;; /**************************************** Fonction evaluant si l'objet possede une boite de dialogue ajoutée: 0 pas de Obb 1 Obb 2 Obb mais dans le m3d ou manuel *****************************************/ fun isObb(session,o)= let [0 0] -> [res end] in let M3getFirstSon session o -> h in { while h!=nil && !end do { if (M3getObjType session h)==M3_COLL then { set res=if !strcmp (substr M3objName session h 0 1) "#" then 1 else 2; set end=1; } else nil; set h=M3getBrother session h; }; res };; /************************************** Fonction verifiant qu'un m3d a été modélisé avec le modeler ***************************************/ /*fun isRoomFile(l)= if l==nil then nil else let l -> [line nxt] in if !strcmp hd line "#SRFNAME" then nth_list line 1 else isRoomFile nxt;; */ /*********************************** Fonction d'initialisation de la room ************************************/ /*fun getRoom(view,o)= if o==nil then nil else { let getRoom view o.Obj3dBro -> bro in if bro!= nil then bro else let getRoom view o.Obj3dSon -> son in if son!=nil then son else let exec o.Obj3dGetFile with [] -> f in if f==nil then nil else let isRoomFile strextr _getpack _checkpack f -> srf in if srf!=nil then let M3objName view.V3dsession M3getFirstSon view.V3dsession M3getObj view.V3dsession o.Obj3dIndex -> n in let substr n search_point n 1000 -> room in [o.Obj3dIndex room f srf] else nil };; */ /************************************** Callback de fin d'ajout d'objet pour deselectionner l'objet courant Renvoie 0 ***************************************/ fun endaddObject(f,ndx,param)= let param -> [dev view] in /* let isRoomFile strextr _getpack _checkpack f -> srf in {*/ unselectObject dev view; /* if srf==nil then nil else let M3objName view.V3dsession M3getFirstSon view.V3dsession M3getObj view.V3dsession ndx -> n in set dev.DEVroom=[ndx n f srf] };*/ 0;; /************************************** Callback de fin de suppression d'objet Renvoie 0 ***************************************/ fun endremoveObject(param)= let param -> [dev view ndx] in /* let dev.DEVroom -> [i _ _ _] in { if (i!=nil) && (!strcmp i ndx) then set dev.DEVroom=nil else nil;*/ unselectObject dev view; 0 /*}*/;; fun unLinkCamera(view)= M3unLink view.V3dsession view.V3dcamera; 0;; fun reLinkCamera(view)= M3link view.V3dsession view.V3dcamera shell; 0;; fun remPos(pos,blurp)= let pos -> [n _ _] in { C3DdelPos n };; fun cbEndReset(dev)= /* on relink tts les cameras des vues 3d wire*/ reLinkCamera dev.DEVhg3d; reLinkCamera dev.DEVhd3d; reLinkCamera dev.DEVbg3d; 0;; /************************************** Callback de fin d'upload 'une room ***************************************/ /*fun cbUploadRoom(r,param)= if r==(-1) then nil else let param -> [m3d pos [dev view _ _]] in let dev.DEVroom -> [ndx n f sfr] in { unselectObject dev view; /*if sfr!=nil then let M3getObj view.V3dsession ndx -> o in { /* room deja presente: on la remplace */ _fooS "room deja presente"; nil } else*/ { /* pas de rooms presentes:on detruit tout */ /* et on ajoute la scene */ /* on delink tts les cameras des vues 3d wire*/ unLinkCamera dev.DEVhg3d; unLinkCamera dev.DEVhd3d; unLinkCamera dev.DEVbg3d; /* on reset la scene */ C3DsetCBreset mkfun1 @cbEndReset dev; C3DresetScene; /* on ajoute le nouveau m3d */ C3DsetCBaddM3d mkfun3 @endaddObject [dev view]; C3DaddM3d m3d [[0 0 0][0 0 0]] shell; }; /* on vire tts les positions et on ajoute la nouvelle*/ apply_on_list cel.Cel3dIpos @remPos nil; let pos -> [n v a] in { C3DaddPos n [v a]; C3DresetAvatarPos n; } }; 0;; */ /************************************** Callback de fin de boite de dialogue ***************************************/ /*fun endDlgConfirmReplace(dlg,p,i)= if i==1 then let p -> [m3d _ _] in DLupload m3d _getpack _checkpack m3d mkfun2 @cbUploadRoom p else nil; 0;; */ /************************************** Callback de fin d'edition de rooms Renvoie 0 ***************************************/ /*fun endeditRoom(m3d,pos,param)= if m3d==nil then nil else let param -> [dev view _ _] in let dev.DEVroom -> [_ _ _ sfr] in _DLGrflmessage _DLGMessageBox _channel dev.DEVmanager.MV3dWin _loc this "DELROOM" nil _loc this if sfr!=nil then "CREPROOM" else "CDELROOM" nil 1 @endDlgConfirmReplace [m3d pos param]; 0;; */ /************************************** Callback de fermeture du browser de plugins ***************************************/ fun CBendCloseBrowserPlugs(dev)= set dev.DEVtypeMenu = dev.DEVtypeMenu & ~DYN_PLUGBROWS; 0;; /************************************** Callback de selection d'objet a partir du browser de plugin ***************************************/ fun CBselectObjectInBrowser(o,m,param)= let param -> [dev view] in selectObject dev view M3getObj view.V3dsession o M3getMat view.V3dsession m nil nil;; proto DYNEDITOR_Close = fun [] I;; fun selectMenu(obj,param)= let param -> [sel dev view o m] in if sel==SELECT_QUIT then DYNEDITOR_Close else if sel==SELECT_OPENEDT then openGlobalEditorView else if sel==SELECT_CLOSEEDT then ( closeGlobalEditorView; set DEVview.DEVtypeMenu = DEVview.DEVtypeMenu & ~DYN_EDIT; ) else if sel==SELECT_SAVE then C3DsaveOnDisk nil nil 1 else if sel==SELECT_MODIFYTEXT then let M3textureName view.V3dsession M3textureFromMaterial view.V3dsession m -> t in let cutnamefilter t -> [text filter] in openExplorateur 200 20 EXPLO_SELECT|EXPLO_TEXTURE mkfun4 @modifyTexture m text (M3materialName view.V3dsession m) else if sel==SELECT_MODIFYFLAT then let M3getType session m -> type in C3DsetType m (if type&MAT_TEXTURED then type&(~MAT_TEXTURED) else type|MAT_TEXTURED) 1 else if sel==SELECT_MODIFYFLATCOLOR then openFlatColor dev.DEVmanager.MV3dWin (M3getMaterialFlat view.V3dsession m) m else if sel==SELECT_MODIFYFILTER then let M3textureName view.V3dsession M3textureFromMaterial view.V3dsession m -> t in let cutnamefilter t -> [text filter] in openFilterTexture dev.DEVmanager.MV3dWin 20 20 text filter m else if sel==SELECT_MODIFYTRANSP then openTranspTexture dev.DEVmanager.MV3dWin 20 20 (M3getType view.V3dsession m)&MAT_TRANSP M3getMaterialTransparency view.V3dsession m m else if sel==SELECT_MODIFYLIGHT then let M3getType view.V3dsession m -> type in C3DsetType m if type&MAT_LIGHT then type&(~MAT_LIGHT) else type|MAT_LIGHT 1 else if sel==SELECT_MODIFYGOURAUD then let M3getType view.V3dsession m -> type in C3DsetType m if type&MAT_GOURAUD then type&(~MAT_GOURAUD) else type|MAT_GOURAUD 1 else if sel==SELECT_MODIFYENVMAP then let M3getType view.V3dsession m -> type in C3DsetType m if type&MAT_ENV then type&(~MAT_ENV) else type|MAT_ENV 1 else if sel==SELECT_MODIFYOBB then C3DsetObb o !(isObb view.V3dsession o) 1 else if sel==SELECT_MODIFYFOND then openBackColor dev.DEVmanager.MV3dWin view.V3dfond else if sel==SELECT_MODIFYGRAVITY then openGravity dev.DEVmanager.MV3dWin 100 100 C3D_GetGravity else if sel==SELECT_MODIFYLIGHTSCENE then openLightGlobal dev.DEVmanager.MV3dWin 20 20 C3D_GetLight else if sel==SELECT_ADDOBJECT then openExplorateur 200 20 EXPLO_SELECT|EXPLO_M3D mkfun4 @addObject [view shell mkfun3 @endaddObject [dev view] ] nil nil else if sel==SELECT_ADDSUBOBJECT then openExplorateur 200 20 EXPLO_SELECT|EXPLO_M3D mkfun4 @addObject [nil o mkfun3 @endaddObject [dev view] ] nil nil else if sel==SELECT_SUPPRESSSUBOBJECT then if o==nil then nil else let M3objName view.V3dsession o -> s in let substr s 0 search_point s -> ndx in openRemoveObject s view.V3dchannel view.V3dwin M3objName view.V3dsession o 1 mkfun1 @endremoveObject [dev view ndx] else if sel==SELECT_RESETOBJECT then if o==nil then nil else ( C3DsetObjPosAngOrig o SAVE_NOW BROAD_ALL; nil ) else if sel==SELECT_RESETOBJECTFATHER then if o==nil then nil else let M3objName view.V3dsession o -> s in let substr s 0 search_point s -> ndx in ( C3DsetObjFatherPosAngOrig ndx SAVE_NOW BROAD_ALL; nil ) else if sel==SELECT_OPENPBR then ( set dev.DEVtypeMenu = dev.DEVtypeMenu | DYN_PLUGBROWS; openPluginBrowser mkfun3 @CBselectObjectInBrowser [dev view] mkfun1 @CBendCloseBrowserPlugs dev ) else if sel==SELECT_CLOSEPBR then ( closePluginBrowser; set dev.DEVtypeMenu = dev.DEVtypeMenu & ~DYN_PLUGBROWS ) else if sel==SELECT_POS then crPosBar 10 300 dev.DEVmanager.MV3dWin cel.Cel3dIpos view.V3dsession shell else if sel==SELECT_BOX then DYNBOX_CreateInterface 100 300 dev.DEVmanager.MV3dWin else nil; 0;; fun drawMenu(dev,view,x,y,o,m)= dyndebg "dyneditor.viewc.pkg"::"drawMenu"::nil; if !DEVview.DEVcanEdit then nil else { _DSmenu dev.DEVmenu; set dev.DEVmenu=_CRpopupMenu dev.DEVchannel; /* material */ let _APPpopup dev.DEVchannel dev.DEVmenu _loc this "MNU_MATERIAL" nil -> submod in { if o==nil then nil else { _CBmenu _APPitem dev.DEVchannel submod ME_ENABLED _loc this (if (M3getType view.V3dsession m)&MAT_TEXTURED then "MNU_TOFLAT" else "MNU_TOTEXTURED") nil @selectMenu [SELECT_MODIFYFLAT dev view o m]; _CBmenu _APPitem dev.DEVchannel submod ME_ENABLED _loc this "MNU_FLATCLR" nil @selectMenu [SELECT_MODIFYFLATCOLOR dev view o m]; _CHKmenu _CBmenu _APPitem dev.DEVchannel submod ME_ENABLED _loc this "MNU_TRANSP" nil @selectMenu [SELECT_MODIFYTRANSP dev view o m] if (M3getType view.V3dsession m)&MAT_TRANSP then 1 else 0; _CHKmenu _CBmenu _APPitem dev.DEVchannel submod ME_ENABLED _loc this "MNU_ENLIGHTENED" nil @selectMenu [SELECT_MODIFYLIGHT dev view o m] if (M3getType view.V3dsession m)&MAT_LIGHT then 1 else 0; if (M3getType view.V3dsession m)&MAT_TEXTURED then ( _APPitem dev.DEVchannel submod ME_SEPARATOR ""; _CBmenu _APPitem dev.DEVchannel submod ME_ENABLED _loc this "MNU_TEXT" nil @selectMenu [SELECT_MODIFYTEXT dev view o m]; _CBmenu _APPitem dev.DEVchannel submod ME_ENABLED _loc this "MNU_FILTER" nil @selectMenu [SELECT_MODIFYFILTER dev view o m]; _CHKmenu _CBmenu _APPitem dev.DEVchannel submod ME_ENABLED _loc this "MNU_GOURAUD" nil @selectMenu [SELECT_MODIFYGOURAUD dev view o m] if (M3getType view.V3dsession m)&MAT_GOURAUD then 1 else 0; _CHKmenu _CBmenu _APPitem dev.DEVchannel submod ME_ENABLED _loc this "MNU_ENVMAP" nil @selectMenu [SELECT_MODIFYENVMAP dev view o m] if (M3getType view.V3dsession m)&MAT_ENV then 1 else 0; ) else nil } }; /* objet */ let _APPpopup dev.DEVchannel dev.DEVmenu _loc this "MNU_OBJECT" nil -> submod in { _CBmenu _APPitem dev.DEVchannel submod ME_ENABLED strcatn (_loc this "MNU_ADD" nil):: " ":: (_loc this "MNU_OBJECT" nil)::nil @selectMenu [SELECT_ADDOBJECT dev view o m]; _CBmenu _APPitem dev.DEVchannel submod if o==nil then ME_DISABLED else ME_ENABLED strcatn (_loc this "MNU_ADD" nil):: " ":: (_loc this "MNU_SUBOBJECT" nil)::nil @selectMenu [SELECT_ADDSUBOBJECT dev view o m]; _CBmenu _APPitem dev.DEVchannel submod if o==nil then ME_DISABLED else ME_ENABLED _loc this "MNU_DELETE" nil @selectMenu [SELECT_SUPPRESSSUBOBJECT dev view o m]; _CBmenu _APPitem dev.DEVchannel submod if o==nil then ME_DISABLED else ME_ENABLED _loc this "MNU_RESET" nil @selectMenu [SELECT_RESETOBJECT dev view o m]; _CBmenu _APPitem dev.DEVchannel submod if o==nil then ME_DISABLED else ME_ENABLED _loc this "MNU_RESETFATHER" nil @selectMenu [SELECT_RESETOBJECTFATHER dev view o m]; _APPitem dev.DEVchannel submod ME_SEPARATOR ""; let _CBmenu _APPitem dev.DEVchannel submod if o==nil then ME_DISABLED else ME_ENABLED _loc this "MNU_COLL" nil @selectMenu [SELECT_MODIFYOBB dev view o m] -> coll in let isObb view.V3dsession o -> c in if c==2 then _DImenuItem coll else if c==1 then _CHKmenu coll 1 else nil; /* menu d'ouverture ou de fermeture de l'editeur */ if dev.DEVtypeMenu&DYN_EDIT then { _APPitem dev.DEVchannel submod ME_SEPARATOR ""; _CBmenu _APPitem dev.DEVchannel submod ME_ENABLED _loc this "MNU_CEDITOR" nil @selectMenu [SELECT_CLOSEEDT dev view o m]; } else if dev.DEVtypeMenu&DYN_NORM then { _APPitem dev.DEVchannel submod ME_SEPARATOR ""; _CBmenu _APPitem dev.DEVchannel submod ME_ENABLED _loc this "MNU_OEDITOR" nil @selectMenu [SELECT_OPENEDT dev view o m]; } else nil; }; /* scene */ let _APPpopup dev.DEVchannel dev.DEVmenu _loc this "MNU_SCENE" nil -> subscene in { _CBmenu _APPitem dev.DEVchannel subscene ME_ENABLED _loc this "MNU_BACKCLR" nil @selectMenu [SELECT_MODIFYFOND dev view o m]; _CHKmenu _CBmenu _APPitem dev.DEVchannel subscene ME_ENABLED _loc this "MNU_LIGHT" nil @selectMenu [SELECT_MODIFYLIGHTSCENE dev view o m] if (M3getObj session "global_light")!=nil then 1 else 0; _CHKmenu _CBmenu _APPitem dev.DEVchannel subscene ME_ENABLED _loc this "MNU_GRAVITY" nil @selectMenu [SELECT_MODIFYGRAVITY dev view o m] if C3D_GetGravity !=nil then 1 else 0; }; /* effects */ _APPitem dev.DEVchannel dev.DEVmenu ME_SEPARATOR ""; openPluginEditor o m (_APPpopup dev.DEVchannel dev.DEVmenu (_loc this "MNU_EFFECT" nil)); /* menu d'ouverture ou de fermeture du browser de plugins */ if dev.DEVtypeMenu&DYN_PLUGBROWS then { _CBmenu _APPitem dev.DEVchannel dev.DEVmenu ME_ENABLED _loc this "MNU_CBROWSER_EFFECT" nil @selectMenu [SELECT_CLOSEPBR dev view o m]; } else { _CBmenu _APPitem dev.DEVchannel dev.DEVmenu ME_ENABLED _loc this "MNU_OBROWSER_EFFECT" nil @selectMenu [SELECT_OPENPBR dev view o m]; }; _APPitem dev.DEVchannel dev.DEVmenu ME_SEPARATOR ""; _CBmenu _APPitem dev.DEVchannel dev.DEVmenu ME_ENABLED (_loc this "TOOL_POSITION" nil) @selectMenu [SELECT_POS dev view o m]; _CBmenu _APPitem dev.DEVchannel dev.DEVmenu ME_ENABLED (_loc this "TOOL_BOX" nil) @selectMenu [SELECT_BOX dev view o m]; if DYNautosave then nil else ( _APPitem dev.DEVchannel dev.DEVmenu ME_SEPARATOR ""; _CBmenu _APPitem dev.DEVchannel dev.DEVmenu ME_ENABLED _loc this "MNU_SAVE" nil @selectMenu [SELECT_SAVE dev view o m]; ); _APPitem dev.DEVchannel dev.DEVmenu ME_SEPARATOR ""; _CBmenu _APPitem dev.DEVchannel dev.DEVmenu ME_ENABLED _loc this "MNU_QUIT" nil @selectMenu [SELECT_QUIT dev view o m]; _DRAWmenu view.V3dwin dev.DEVmenu x y PM_LEFT_ALIGN|PM_TOP_ALIGN; }; 0;;