var VIEW_AVATAR =1;; /* constantes pour les differentes vues */ var VIEW_LEFT =2;; var VIEW_RIGHT =4;; var VIEW_FRONT =8;; var VIEW_BACK =16;; var VIEW_TOP =32;; var VIEW_BOTTOM =64;; /*********************************************** Triedre des axes ***************************************/ /* cette struture definie un une vue 3d dans laquelle est representée le triedre des axes de la vue */ /********************************************************************************************************/ struct AxisView=[ AVtypeaxis :I, AVsession :S3d, AVcamera :H3d, AVshell :H3d, AVaxis :H3d, AVbuff :ObjSurface, AVbackground :I, AVsize :[I I], AVpos :[I I], AVrefobject :H3d, AVcursorpos :[I I], AVlasth :H3d, AVh3dx :H3d, AVh3dy :H3d, AVh3dz :H3d, AVh3dxT :H3d, AVh3dyT :H3d, AVh3dzT :H3d, AVh3dselx :H3d, AVh3dsely :H3d, AVh3dselz :H3d, AVtype :I, AVclicked :I ]mkAxisView;; var AxisM3d ="Dms/3d/Edit3d3/lib/axis.m3d";; var ScaleM3d ="Dms/3d/Edit3d3/lib/scale.m3d";; var MoveSelectBmp ="Dms/3d/Edit3d3/lib/movecursor.bmp";; typeof MoveSelectCursor =ObjCursor;; /* curseur de selection deplacement */ var AXIS_NONE=0;; var AXIS_X=1;; var AXIS_Y=2;; var AXIS_Z=4;; var AXIS_TRIEDRE=1;; var AXIS_SINGLE=2;; fun setAxisLetterTarget(axis,h)= M3setObjAng axis.AVsession h (GetRefAngularTarget axis.AVsession h axis.AVcamera (M3getFather axis.AVsession h)) ;; fun evalCamPos(axis,view)= M3setObjVec axis.AVsession axis.AVcamera [0 0 0]; M3setObjAng axis.AVsession axis.AVcamera [0 0 0]; 0;; fun evalAxisPos(axis,view)= M3setCamera axis.AVsession axis.AVcamera M3getCamera view.V3dsession view.V3dcamera; let M3getCamera axis.AVsession axis.AVcamera ->[[_ d] [_ sy] _] in if view.V3drenderType==WIRE then let M3calcPosRef view.V3dsession axis.AVrefobject view.V3dcamera -> [[x y z /*_*/] _] in let M3calcPosRef view.V3dsession axis.AVshell view.V3dcamera -> [ _ mat] in let M3angularFromMatrix mat -> a in ( M3setObjVec axis.AVsession axis.AVaxis [0 0 /* x y */ 1000]; if (axis.AVtypeaxis&AXIS_TRIEDRE) then M3setObjAng axis.AVsession axis.AVaxis a else nil; M3setObjScale axis.AVsession axis.AVaxis 50*sy/d /*max 1 333*sy/d*/ ; 0 ) else let M3calcPosRef view.V3dsession axis.AVrefobject view.V3dcamera -> [pos mat] in let M3angularFromMatrix mat -> a in ( M3setObjVec axis.AVsession axis.AVaxis pos; if (axis.AVtypeaxis&AXIS_TRIEDRE) then M3setObjAng axis.AVsession axis.AVaxis a else nil; let pos->[_ _ z] in M3setObjScale axis.AVsession axis.AVaxis max 1 sy*z/(3*d) ); 0 ;; fun evalAxisColor(axis)= let make_rgb 0 0 255 -> blue in let make_rgb 0 255 0 -> green in let make_rgb 255 0 0 -> red in let make_rgb 255 255 0 -> yellow in let if axis.AVtype==AXIS_X then [yellow green blue] else if axis.AVtype==AXIS_Y then [red yellow blue] else if axis.AVtype==AXIS_Z then [red green yellow] else if axis.AVtype==AXIS_NONE then [red green blue] else nil -> [mat1 mat2 mat3] in { M3setMaterialFlat axis.AVsession M3getMat axis.AVsession "Material__x" mat1; M3setMaterialFlat axis.AVsession M3getMat axis.AVsession "Material__y" mat2; M3setMaterialFlat axis.AVsession M3getMat axis.AVsession "Material__z" mat3; 0 };; fun newAxisView(refobj,w,h,type)= if (refobj==nil) then nil else let mkAxisView[type nil nil nil nil nil make_rgb 0 0 0 [w h] nil refobj nil nil nil nil nil nil nil nil nil nil nil AXIS_NONE 0 ] -> axis in { set axis.AVsession=MX3create _channel 1024 1024 1024 1024 1024*1024*4; if axis.AVsession==nil then nil else { set axis.AVshell=M3createShell axis.AVsession; M3load axis.AVsession (if type&AXIS_TRIEDRE then AxisM3d else ScaleM3d) axis.AVshell; set axis.AVaxis=M3getFirstSon axis.AVsession axis.AVshell; M3load axis.AVsession "Dms/3d/cam1.m3d" axis.AVshell; M3recursFillMatObj axis.AVsession axis.AVshell; /* la camera */ set axis.AVcamera = M3getObj axis.AVsession "camera"; let M3getCamera axis.AVsession axis.AVcamera->[[d _] [x _] z] in M3setCamera axis.AVsession axis.AVcamera [[d*(w>>1)/x d*(w>>1)/x] [w>>1 h>>1] z]; /* les axes */ set axis.AVh3dx=M3getObj axis.AVsession "x"; set axis.AVh3dy=M3getObj axis.AVsession "y"; set axis.AVh3dz=M3getObj axis.AVsession "z"; set axis.AVh3dxT=M3getObj axis.AVsession "textX"; set axis.AVh3dyT=M3getObj axis.AVsession "textY"; set axis.AVh3dzT=M3getObj axis.AVsession "textZ"; set axis.AVh3dselx=M3getObj axis.AVsession "sel_x"; set axis.AVh3dsely=M3getObj axis.AVsession "sel_y"; set axis.AVh3dselz=M3getObj axis.AVsession "sel_z"; axis } };; fun dsAxisView(axis)= if axis!=nil then { M3destroy axis.AVsession; 0 } else nil;; fun resizeAxisView(axis,w,h)= if axis==nil then nil else { set axis.AVsize=[w h]; let M3getCamera axis.AVsession axis.AVcamera->[[d _] [x _] z] in M3setCamera axis.AVsession axis.AVcamera [[d*(w>>1)/x d*(w>>1)/x] [w>>1 h>>1] z]; };; fun renderAxisView(num,axis,view,selectview,type)= if axis!=nil then { evalCamPos axis view; evalAxisPos axis view; setAxisLetterTarget axis axis.AVh3dxT; setAxisLetterTarget axis axis.AVh3dyT; setAxisLetterTarget axis axis.AVh3dzT; if num==0 then (M3unLink axis.AVsession axis.AVh3dy; M3unLink axis.AVsession axis.AVh3dyT) else if num==1 then (M3unLink axis.AVsession axis.AVh3dx; M3unLink axis.AVsession axis.AVh3dxT) else if num==2 then (M3unLink axis.AVsession axis.AVh3dz; M3unLink axis.AVsession axis.AVh3dzT) else nil; let view.V3dcursor -> [x y] in let if type&VIEW_AVATAR then MX3renderm axis.AVsession view.V3dbuf axis.AVcamera x y nil else MX3wireOrtho axis.AVsession view.V3dbuf axis.AVcamera x y nil -> [h _] in /* let view.V3dcursor -> [x y] in let MX3renderm axis.AVsession view.V3dbuf axis.AVcamera x y nil -> [h _] in */ let view.V3dsize -> [_ hg] in let axis.AVsize -> [ws hs] in { if num==0 then (M3link axis.AVsession axis.AVh3dy axis.AVaxis; M3link axis.AVsession axis.AVh3dyT axis.AVaxis) else if num==1 then (M3link axis.AVsession axis.AVh3dx axis.AVaxis; M3link axis.AVsession axis.AVh3dxT axis.AVaxis) else if num==2 then (M3link axis.AVsession axis.AVh3dz axis.AVaxis; M3link axis.AVsession axis.AVh3dzT axis.AVaxis) else nil; /* evaluation de l'axe sous le curseur */ if (view==selectview) && (h!=axis.AVlasth) && (!axis.AVclicked) then { set axis.AVlasth=h; set axis.AVtype=if h==axis.AVh3dselx then AXIS_X else if h==axis.AVh3dsely then AXIS_Y else if h==axis.AVh3dselz then AXIS_Z else AXIS_NONE; evalAxisColor axis; } else nil; 0 } } else 0;; /*******************************************************************************************************/ /* La vue Editeur Dynamique */ /********************************************************************************************************/ struct DynEditorView=[ DEVchannel :Chn, /* canal de construction */ DEVmanager :View3dManager, /* 3d manager */ DEVhg3d :View3d, /* vue 3d haut gauche */ DEVhd3d :View3d, /* vue 3d haut droit */ DEVbg3d :View3d, /* vue 3d bas gauche */ DEVbd3d :View3d, /* vue 3d bas droite */ DEVaxis :AxisView, /* vue de l'axe de selection de deplacement */ DEVselected3d :View3d, /* vue 3d selectionnée */ DEVmenu :ObjMenu, /* menu click bouton droit */ DEVfont :ObjFont, /* font du text */ DEVtypeView :I, /* type de vue: VIEW_FOUR VIEW_ONE */ DEVtypeMenu :I, /* type de menu DYN_NORM DYN_EDIT */ DEVtypeCoords :I, /* type de repere: global ou relatif */ DEVselectedObj :H3d, /* H3d selectionné dans les vues */ DEVselectedMat3d:HMat3d, /* materiau selectionné */ DEVselectbox :H3d, /* boite de selection */ DEVselectboxpos :[I I I], /* position de la boite de selection */ DEVselectcolor :I, /* couleur de la boite de selection */ DEVtypeOperation:I, DEVlasth :H3d, /* dernier h3d sur lequel est la souris */ DEVlastm :HMat3d, /* dernier materiau sous la souris */ DEVsaveMoveObject:fun [[I I I] [I I I]] I, DEVsaveCursorMoveObject:fun [View3d H3d HMat3d I I] I, DEVsaveClickObject:fun [H3d HMat3d I] I, DEVsaveDClickObject:fun [H3d HMat3d I] I, DEVsavePostRender:fun [ObjSurface [I I]] I /* sauvegarde de la callback de postrender */ ]mkDynEditorView;; fun viewbynum(dev,view)= if view==dev.DEVhg3d then 0 else if view==dev.DEVhd3d then 1 else if view==dev.DEVbg3d then 2 else if view==dev.DEVbd3d then 3 else nil;; typeof DEVview =DynEditorView;; typeof HandCursor =ObjCursor;; /* curseur main */ typeof ProfCursor =ObjCursor;; /* curseur profondeur */ typeof ListBmp =[ObjBitmap r1];; /* liste des bmps chargées */ var HandCursorBmp ="Dms/3d/Edit3d3/lib/hand.bmp";; var ProfCursorBmp ="Dms/3d/Edit3d3/lib/profcursor.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;; var DYN_NORM =1;; /* constante de type d'edition dynamique soft ou */ var DYN_EDIT =2;; /* totale */ var DYN_PLUGBROWS =4;; var SELECT_OPENEDT =1;; /* constantes de selection d'un elt dans une menu */ var SELECT_MODIFYTEXT =2;; var SELECT_MODIFYFLAT =4;; var SELECT_MODIFYFLATCOLOR =8;; var SELECT_MODIFYFILTER =16;; var SELECT_MODIFYTRANSP =32;; var SELECT_MODIFYLIGHT =64;; var SELECT_CLOSEEDT =128;; var SELECT_OPENEFFECTS =256;; var SELECT_ADDOBJECT =512;; var SELECT_ADDSUBOBJECT =1024;; var SELECT_SUPPRESSOBJECT =2048;; var SELECT_SUPPRESSSUBOBJECT=4096;; var SELECT_OPENPBR =8192;; var SELECT_CLOSEPBR =16384;; var SELECT_MODIFYOBB =32768;; var SELECT_MODIFYFOND =65536;; var SELECT_MODIFYFOG =131072;; var SELECT_MODIFYLIGHTSCENE =262144;; var SELECT_OPENMODELER =524288;; var SELECT_COPYMAT = 0x100000;; var SELECT_PASTEMAT = 0x200000;; var SELECT_TAKEOBJ = 0x400000;; var SELECT_LINKOBJ = 0x800000;; var SELECT_ADDLINK = 0x1000000;; var SELECT_ADDOPOS = 0x2000000;; var SELECT_GOURAUD = 0x4000000;; var SELECT_ENVMAP = 0x8000000;; var SELECT_CENTER = 0x10000000;; var SELECT_DUPOBJECT= 0x20000000;; 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;; /**************************************** Fonction evaluant la position d'un objet nouvellement crée en fonction de la position de la camera de de 'objet reference Renvoie la nouvelle position *****************************************/ fun evalNewM3dPos(view,o,father)= let if o!=nil then M3calcPosRef view.V3dsession o father else [[0 0 0] nil] -> [[xo yo zo] _] in let M3calcPosRef view.V3dsession view.V3dcamera father -> [[x y z] _] in let GetRefPosAndAngle view.V3dsession father shell -> [_ [a b c]] in [[(x+xo)/2 (y+yo)/2 (z+zo)/2] [(-a) (-b) (-c)]] ;; /**************************************** 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 testObb(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 (0==strlen M3objName session h) then 1 else 2; set end=1; } else nil; set h=M3getBrother session h; }; res };; fun selectMenu(obj,param)= let param -> [sel dev view o m] in if sel&SELECT_OPENEDT then openGlobalEditorView else if sel&SELECT_CLOSEEDT then closeGlobalEditorView else if sel&SELECT_COPYMAT then _copymat MainEdit3d m else if sel&SELECT_PASTEMAT then _pastemat MainEdit3d m else if sel&SELECT_TAKEOBJ then _takeobj nil MainEdit3d else if sel&SELECT_LINKOBJ then _putobj nil MainEdit3d else if sel&SELECT_DUPOBJECT then _dupobj MainEdit3d o else if sel&SELECT_MODIFYTEXT then let M3textureName view.V3dsession M3textureFromMaterial view.V3dsession m -> t in let cutnamefilter t -> [text filter] in (inibook MainEdit3d.E3dInterf.chE3d MainEdit3d.E3dInterf.winE3d 600 500 loc "TEXTU_SEL" mkfun2 @_chgmat [MainEdit3d m] "" SEL_TEXTURE text; 0) else if sel&SELECT_MODIFYFLAT then _selflat2 MainEdit3d m else if sel&SELECT_MODIFYFILTER then _selfilt2 MainEdit3d m else if sel&SELECT_MODIFYTRANSP then _seltrans2 MainEdit3d m else if sel&SELECT_MODIFYLIGHT then _sellight2 MainEdit3d m else if sel&SELECT_GOURAUD then _selgouraud2 MainEdit3d m else if sel&SELECT_ENVMAP then _selmatenv2 MainEdit3d m else if sel&SELECT_MODIFYOBB then _ocoll2 MainEdit3d o else if sel&SELECT_ADDLINK then _ladd2 MainEdit3d o m else if sel&SELECT_ADDOPOS then AddObjectPos MainEdit3d o else if sel&SELECT_CENTER then _ocenter MainEdit3d o else if sel&SELECT_ADDSUBOBJECT then (inibook MainEdit3d.E3dInterf.chE3d MainEdit3d.E3dInterf.winE3d 600 500 loc "OBJ_SEL" mkfun2 @_OpenObj [MainEdit3d o] "" SEL_M3D previousBrowsedObject; 0) else if sel&SELECT_ADDOBJECT then (inibook MainEdit3d.E3dInterf.chE3d MainEdit3d.E3dInterf.winE3d 600 500 loc "OBJ_SEL" mkfun2 @_OpenObj [MainEdit3d nil] "" SEL_M3D previousBrowsedObject; 0) else if sel&SELECT_SUPPRESSSUBOBJECT then orem2 MainEdit3d o else nil; 0;; fun drawMenu(dev,view,x,y,o,m)= _DSmenu dev.DEVmenu; set dev.DEVmenu=_CRpopupMenu dev.DEVchannel; /* creation du menu de modification */ let _APPpopup dev.DEVchannel dev.DEVmenu loc "MODIFY" -> submod in let if dev.DEVtypeMenu&DYN_EDIT then _APPpopup dev.DEVchannel submod loc "OBJECT" else submod -> subobj in { /* le menu de modification d'objet */ _CBmenu _APPitem dev.DEVchannel subobj ME_ENABLED loc "TEXTURE" @selectMenu [SELECT_MODIFYTEXT dev view o m]; _CBmenu _APPitem dev.DEVchannel subobj ME_ENABLED loc "FLAT" @selectMenu [SELECT_MODIFYFLAT dev view o m]; let _CBmenu _APPitem dev.DEVchannel subobj ME_ENABLED loc "FILTER" @selectMenu [SELECT_MODIFYFILTER dev view o m] -> filt in if !(M3getType view.V3dsession m)&MAT_TEXTURED then _DImenuItem filt else nil; _CBmenu _APPitem dev.DEVchannel subobj ME_ENABLED loc "TRANSP" @selectMenu [SELECT_MODIFYTRANSP dev view o m]; _CHKmenu _CBmenu _APPitem dev.DEVchannel subobj ME_ENABLED loc "ENLIGHTENED" @selectMenu [SELECT_MODIFYLIGHT dev view o m] if (M3getType view.V3dsession m)&MAT_LIGHT then 1 else 0; _CHKmenu _CBmenu _APPitem dev.DEVchannel subobj ME_ENABLED loc "GOURAUD" @selectMenu [SELECT_GOURAUD dev view o m] if (M3getType view.V3dsession m)&MAT_GOURAUD then 1 else 0; _CHKmenu _CBmenu _APPitem dev.DEVchannel subobj ME_ENABLED loc "ENVMAP" @selectMenu [SELECT_ENVMAP dev view o m] if (M3getType view.V3dsession m)&MAT_ENV then 1 else 0; let _CBmenu _APPitem dev.DEVchannel subobj ME_ENABLED loc "COLL" @selectMenu [SELECT_MODIFYOBB dev view o m] -> coll in let testObb view.V3dsession o -> c in if c==2 then _DImenuItem coll else if c==1 then _CHKmenu coll 1 else nil; }; if dev.DEVtypeMenu&DYN_EDIT then { /* le menu d'ajout */ let _APPpopup dev.DEVchannel dev.DEVmenu loc "ADD"-> submod in { _CBmenu _APPitem dev.DEVchannel submod ME_ENABLED loc "OBJECT" @selectMenu [SELECT_ADDOBJECT dev view o m]; _CBmenu _APPitem dev.DEVchannel submod ME_ENABLED loc "SUBOBJECT" @selectMenu [SELECT_ADDSUBOBJECT dev view o m] }; _CBmenu _APPitem dev.DEVchannel dev.DEVmenu ME_ENABLED loc "DELETE" @selectMenu [SELECT_SUPPRESSSUBOBJECT dev view o m]; } else nil; /* menu d'ouverture ou de fermeture de l'editeur */ if dev.DEVtypeMenu&DYN_EDIT then { _APPitem dev.DEVchannel dev.DEVmenu ME_SEPARATOR ""; _CBmenu _APPitem dev.DEVchannel dev.DEVmenu ME_ENABLED loc "MNU_CEDITOR" @selectMenu [SELECT_CLOSEEDT dev view o m]; } else if dev.DEVtypeMenu&DYN_NORM then { _APPitem dev.DEVchannel dev.DEVmenu ME_SEPARATOR ""; _CBmenu _APPitem dev.DEVchannel dev.DEVmenu ME_ENABLED loc "MNU_OEDITOR" @selectMenu [SELECT_OPENEDT dev view o m]; } else nil; _APPitem dev.DEVchannel dev.DEVmenu ME_SEPARATOR ""; _CBmenu _APPitem dev.DEVchannel dev.DEVmenu ME_ENABLED loc "MAT_COPY" @selectMenu [SELECT_COPYMAT dev view o m]; _CBmenu _APPitem dev.DEVchannel dev.DEVmenu ME_ENABLED loc "MAT_PASTE" @selectMenu [SELECT_PASTEMAT dev view o m]; _APPitem dev.DEVchannel dev.DEVmenu ME_SEPARATOR ""; _CBmenu _APPitem dev.DEVchannel dev.DEVmenu ME_ENABLED loc "OBJ_CENTER" @selectMenu [SELECT_CENTER dev view o m]; _CBmenu _APPitem dev.DEVchannel dev.DEVmenu ME_ENABLED loc "OBJ_TAKE" @selectMenu [SELECT_TAKEOBJ dev view o m]; _CBmenu _APPitem dev.DEVchannel dev.DEVmenu ME_ENABLED loc "OBJ_LINK" @selectMenu [SELECT_LINKOBJ dev view o m]; _CBmenu _APPitem dev.DEVchannel dev.DEVmenu ME_ENABLED loc "OBJ_DUP" @selectMenu [SELECT_DUPOBJECT dev view o m]; _APPitem dev.DEVchannel dev.DEVmenu ME_SEPARATOR ""; _CBmenu _APPitem dev.DEVchannel dev.DEVmenu ME_ENABLED loc "LINK_ADD" @selectMenu [SELECT_ADDLINK dev view o m]; _CBmenu _APPitem dev.DEVchannel dev.DEVmenu ME_ENABLED loc "OPOS_ADD" @selectMenu [SELECT_ADDOPOS dev view o m]; _DRAWmenu view.V3dwin dev.DEVmenu x y PM_LEFT_ALIGN|PM_TOP_ALIGN; 0;; /**************************************** Fonction de mise à jour des controles textes relatifs à la position d'un objet dans la toolbar Remarque la position est dans le repere global Renvoie la position dans le repere de son pere *****************************************/ fun setToolBarPos(h,view,type)= let if type&COORDS_GLOBAL then M3convVrt view.V3dsession h shell [0 0 0] else M3getObjVec view.V3dsession h -> pos in { setTextVal TEXT_X::TEXT_Y::TEXT_Z::nil (if pos!=nil then let pos -> [x y z] in (itoa x)::(itoa y)::(itoa z)::nil else ""::""::""::nil ); M3getObjVec view.V3dsession h };; /**************************************** Fonction de mise à jour des controles textes relatifs à l'angle d'un objet dans la toolbar *****************************************/ fun setToolBarAng(h,view,type)= let if type&COORDS_GLOBAL then let GetRefPosAndAngle view.V3dsession h shell -> [_ a] in a else M3getObjAng view.V3dsession h -> ang in { setTextVal TEXT_A::TEXT_B::TEXT_C::nil (if ang!=nil then let ang -> [a b c] in (itoa IntToDeg b)::(itoa IntToDeg a)::(itoa IntToDeg c)::nil else ""::""::""::nil ); M3getObjAng view.V3dsession h };; /**************************************** Fonction de mise à jour des controles textes relatifs au scale d'un objet dans la toolbar *****************************************/ fun setToolBarScale(h,view)= let M3getObjScale view.V3dsession h -> scale in { setTextVal TEXT_SCALE::nil (if scale!=nil then (itoa scale)::nil else ""::""::""::nil ); scale };; /**************************************** Fonction de mise à jour des controles textes relatifs à la taille de la boite englobante dans la toolbar *****************************************/ fun setToolBarSize(h,view)= let M3getObjScale view.V3dsession h -> scale in let M3calcObb view.V3dsession h -> [_ size] in setTextVal TEXT_W::TEXT_H::TEXT_D::nil if size==nil then ""::""::""::nil else let size -> [w h d] in (itoa 2*scale*w/100)::(itoa 2*scale*h/100)::(itoa 2*scale*d/100)::nil; 0;; /* Cette fonction redessine le rectangle autour d'une vue 3d de couleur color */ /* Si test n'e reaffiche pas les cotés communs avec la vue selectionnée */ /* si pas test redessinne tout */ fun paintSelectionDEV(mainwin,dev,color,test,seldev)= if dev==nil then nil else let _GETwindowPositionSize dev.V3dwin -> [x y w h] in let _GETwindowPositionSize seldev.V3dwin -> [sx sy sw sh] in { /* lignes horizontales */ if (test && y-DECAL!=sy+sh)||(!test) then _PAINTrectangle mainwin x-DECAL y-DECAL w+2*DECAL DECAL DRAW_SOLID 1 color DRAW_SOLID color else nil; if (test && y+h!=sy-DECAL)||(!test) then _PAINTrectangle mainwin x-DECAL y+h w+2*DECAL DECAL DRAW_SOLID 1 color DRAW_SOLID color else nil; /* lignes verticales */ if (test && x-DECAL!=sx+sw)||!test then _PAINTrectangle mainwin x-DECAL y-DECAL DECAL h+2*DECAL DRAW_SOLID 1 color DRAW_SOLID color else nil; if (test && x+w!=sx-DECAL)||!test then _PAINTrectangle mainwin x+w y-DECAL DECAL h+2*DECAL DRAW_SOLID 1 color DRAW_SOLID color else nil; };; /**************************************** Fonction evaluant l'etat des boutons pan et profondeur suivant la situation dans dev *****************************************/ fun evalStateViewBtn(dev)= if dev.DEVselected3d==dev.DEVbd3d || dev.DEVtypeOperation&(OP_ROTOBJ|OP_MOVEOBJ|OP_SCALE) then { uncheckBtn CHECK_PAN 0; uncheckBtn CHECK_PROFONDEUR 0; hideObj CHECK_PAN 1; hideObj CHECK_PROFONDEUR 1; } else if (dev.DEVselected3d!=dev.DEVbd3d && dev.DEVtypeOperation&(OP_VIEW|OP_PAN|OP_PROF)) then { if dev.DEVtypeOperation&OP_PAN then { checkBtn CHECK_PAN 1; enableObj CHECK_PROFONDEUR; } else if dev.DEVtypeOperation&OP_PROF then { enableObj CHECK_PAN; checkBtn CHECK_PROFONDEUR 1 } else { enableObj CHECK_PAN; enableObj CHECK_PROFONDEUR; }; nil } else nil;; /* callback de focus d'une vue 3d */ fun cbUserFocus(view,dev)= /* affichage de la selection de vue */ paintSelectionDEV dev.DEVmanager.MV3dWin dev.DEVselected3d UNSELECTED_COLOR 0 dev.DEVselected3d; paintSelectionDEV dev.DEVmanager.MV3dWin (set dev.DEVselected3d=view) SELECTED_COLOR 0 dev.DEVselected3d; evalStateViewBtn dev; 0;; /***************************************** Fonction pan ******************************************/ fun movePAN(view,x,y,typeview)= let if typeview&VIEW_LEFT then [(-x) y 0] else if typeview&VIEW_TOP then [(-x) y 0] else if typeview&VIEW_BACK then [(-x) y 0] else nil -> vect in M3movObj view.V3dsession view.V3dcamera vect; 0 ;; /***************************************** Fonction profondeur ******************************************/ fun movePROF(view,x,y,typeview)= let if typeview&VIEW_LEFT then (-y) else if typeview&VIEW_TOP then (-y) else if typeview&VIEW_BACK then (-y) else nil -> delta in let M3getCamera view.V3dsession view.V3dcamera -> [[d _] x z] in let max 10 d*(200+delta)/200 -> newd in M3setCamera view.V3dsession view.V3dcamera [[newd newd] x z]; 0 ;; /***************************************** Fonction de deplacement d'un objet ******************************************/ fun moveOBJ(dev,view,x,y)= if dev.DEVaxis!=nil then ( evalCamPos dev.DEVaxis view; evalAxisPos dev.DEVaxis view; let if dev.DEVaxis.AVtype==AXIS_X then [dev.DEVaxis.AVh3dx dev.DEVaxis.AVh3dxT] else if dev.DEVaxis.AVtype==AXIS_Y then [dev.DEVaxis.AVh3dy dev.DEVaxis.AVh3dyT] else if dev.DEVaxis.AVtype==AXIS_Z then [dev.DEVaxis.AVh3dz dev.DEVaxis.AVh3dzT] else nil -> [axe letter] in if axe==nil then nil else let M3calcProj dev.DEVaxis.AVsession dev.DEVaxis.AVcamera axe -> [xa ya _ _] in let M3calcProj dev.DEVaxis.AVsession dev.DEVaxis.AVcamera letter -> [xl yl _ _] in let itof 5*(M3getObjScale dev.DEVaxis.AVsession dev.DEVaxis.AVaxis)/if _keybdstate&2 then 8 else 2 -> k in let [xl-xa ya-yl] -> [u v] in let ftoi (k*.itof (u*x+v*y))/.sqr((atof ".001")+.sqrt((sqr itof u)+.(sqr itof v))) -> coeff in let if dev.DEVaxis.AVtype==AXIS_X then [coeff 0 0] else if dev.DEVaxis.AVtype==AXIS_Y then [0 coeff 0] else if dev.DEVaxis.AVtype==AXIS_Z then [0 0 coeff] else nil -> [xv yv zv] in ( if view.V3drenderType==WIRE then let M3getFather view.V3dsession dev.DEVaxis.AVrefobject -> father in M3movObjExt view.V3dsession dev.DEVaxis.AVrefobject M3convVec view.V3dsession shell father [xv yv zv] else M3movObj view.V3dsession dev.DEVaxis.AVrefobject [xv yv zv]; ); setToolBarPos dev.DEVaxis.AVrefobject view dev.DEVtypeCoords ) else nil; 0 ;; /***************************************** Fonction de rotation d'un objet ******************************************/ fun rotateOBJ(dev,view,x,y)= if dev.DEVaxis!=nil then ( evalCamPos dev.DEVaxis view; evalAxisPos dev.DEVaxis view; let (if _keybdstate&2 then -10 else -40)*y -> newy in let if dev.DEVaxis.AVtype==AXIS_X then [0 (-newy) 0] else if dev.DEVaxis.AVtype==AXIS_Y then [(-newy) 0 0] else if dev.DEVaxis.AVtype==AXIS_Z then [0 0 newy] else nil -> ang in if ang==nil then nil else if view.V3drenderType==WIRE then let GetRefPosAndAngle session dev.DEVaxis.AVrefobject shell -> [_ a] in ( M3setObjAng session shell1 a; M3setObjAng session shell0 ang; let GetRefPosAndAngle session shell1 M3getFather session dev.DEVaxis.AVrefobject -> [_ a] in M3setObjAng session dev.DEVaxis.AVrefobject a ) else M3rotateObj view.V3dsession dev.DEVaxis.AVrefobject ang; setToolBarAng dev.DEVaxis.AVrefobject view dev.DEVtypeCoords; ) else nil; 0 ;; /***************************************** Fonction de scale d'un objet ******************************************/ fun scaleOBJ(dev,view,x,y)= if dev.DEVaxis!=nil then ( evalCamPos dev.DEVaxis view; evalAxisPos dev.DEVaxis view; let if dev.DEVaxis.AVtype==AXIS_Z then (-y) else 0 -> newdif in let M3getObjScale view.V3dsession dev.DEVaxis.AVrefobject -> scale in ( M3setObjScale view.V3dsession dev.DEVaxis.AVrefobject scale+newdif; setToolBarScale dev.DEVaxis.AVrefobject view; setToolBarSize dev.DEVaxis.AVrefobject view ) ) else nil; 0 ;; /* callback de mouvement de la souris sur un axe */ fun SetMouseCursorOnAxis(view,h,m,x,y,param)= let param -> [dev view typeview] in if (view!=dev.DEVselected3d) || (h!=dev.DEVlasth && m!=dev.DEVlastm) then { set dev.DEVlasth=h; set dev.DEVlastm=m; if dev.DEVtypeOperation&(OP_ROTOBJ|OP_MOVEOBJ|OP_SCALE) then { if dev.DEVlasth!=nil then setCursorView3d view MoveSelectCursor else resetCursorView3d view; } else nil; } else nil; 0;; /* callback de mouvement de la vue avec bouton appuye*/ fun cbUserCursorMove(x,y,param)= let param -> [dev view typeview] in if dev.DEVtypeOperation&OP_PAN then movePAN view x y typeview else if dev.DEVtypeOperation&OP_PROF then movePROF view x y typeview else if dev.DEVtypeOperation&OP_VIEW then nil else if dev.DEVtypeOperation&OP_MOVEOBJ then moveOBJ dev view x y else if dev.DEVtypeOperation&OP_ROTOBJ then rotateOBJ dev view x y else if dev.DEVtypeOperation&OP_SCALE then scaleOBJ dev view x y else nil; 0;; fun cbUserDestroy(view,cam)= M3delObj view.V3dsession cam; set view.V3dsession=nil; 0;; /************************************** Fonction renvoyant le texte correspondant à la vue de type ***************************************/ fun getView3dName(type)= if type&VIEW_AVATAR then loc "VIEW_AVAT" else if type&VIEW_LEFT then loc "VIEW_LEFT" else if type&VIEW_RIGHT then loc "VIEW_RIGHT" else if type&VIEW_BOTTOM then loc "VIEW_BOTTOM" else if type&VIEW_TOP then loc "VIEW_TOP" else if type&VIEW_FRONT then loc "VIEW_FRONT" else if type&VIEW_BACK then loc "VIEW_BACK" else nil;; fun cbUserPostRender(surface,wh,param)= let param -> [dev view type] in { exec dev.DEVsavePostRender with [surface wh]; _SDRAWtext surface dev.DEVfont 0 0 0 make_rgb 255 255 255 getView3dName type; renderAxisView (viewbynum dev view) dev.DEVaxis view dev.DEVselected3d type; }; 0;; fun testinterO(buf,b)= let DEVview->dev in if dev.DEVaxis==nil then nil else if nil==M3testInter b.s3dE3d dev.DEVaxis.AVrefobject b.shellE3d then nil else _SDRAWrectangle buf 0 0 20 20 DRAW_SOLID 2 0 DRAW_SOLID 0xff; 0;; /********************************************* Fonction de construction du cube de selection d'un objet Renvoie le h3d du cube crée **********************************************/ fun evalSelectCube(session,h,name,color)= let M3calcObb session h -> [pos [xsize ysize zsize]] in let xsize+DECAL_SELECT-> x in let ysize+DECAL_SELECT-> y in let zsize+DECAL_SELECT-> z in let strbuild ("material"::"mat_selection"::"{"::nil):: ("color"::(itoh color)::nil):: ("}"::nil):: ("mesh"::name::"{"::nil):: ("0 0 0 0 0 0"::nil):: ((itoa (-x))::(itoa y)::(itoa (-z))::nil):: ((itoa x)::(itoa y)::(itoa (-z))::nil):: ((itoa (-x))::(itoa (-y))::(itoa (-z))::nil):: ((itoa x)::(itoa (-y))::(itoa (-z))::nil):: ((itoa (-x))::(itoa y)::(itoa z)::nil):: ((itoa x)::(itoa y)::(itoa z)::nil):: ((itoa (-x))::(itoa (-y))::(itoa z)::nil):: ((itoa x)::(itoa (-y))::(itoa z)::nil):: ("mat_selection"::nil):: ("0 2 3 1"::nil):: ("4 5 7 6"::nil):: ("0 1 5 4"::nil):: ("1 3 7 5"::nil):: ("3 2 6 7"::nil):: ("2 0 4 6"::nil):: ("}"::nil):: nil -> strbox in { M3loadString session strbox h; let M3getMat session "mat_selection" -> m in { M3setMaterialTransparency session m BOX_TRANSPARENCY_COEFF; M3setType session m (M3getType session m)|4 }; let M3getFirstSon session h -> cube in { M3renameObj session cube ""; M3setObjVec session cube pos; [pos cube] }; };; fun setSelectCubeColor(session,color)= M3setMaterialFlat session M3getMat session "mat_selection" color;; fun GetReal3DClickSelection (dev, view, o, m, x, y) = if dev.DEVselectbox!=nil && dev.DEVselectbox==o then /* boite de selection: reevaluation de l'objet sous la souris et le materiau */ ( M3unLink view.V3dsession dev.DEVselectbox; let view.V3dsize->[w h] in let MX3renderInfo view.V3dsession view.V3dcamera x-(w>>1) (h>>1)-y ->[no nmat _ _ _] in let if no == nil then nil else if (dev.DEVselectedObj) != no then [no nmat] else if (dev.DEVselectedMat3d)==nmat then /* aucun changement */ nil else /* material change ! */ [nil nmat] -> result in ( M3link view.V3dsession dev.DEVselectbox dev.DEVselectedObj; M3setObjVec view.V3dsession dev.DEVselectbox dev.DEVselectboxpos; result ) ) else [o m] ;; /******************************************* Fonction de selection d'un objet dans l'editeur dynamique ********************************************/ fun selectObject(dev,view,o)= set dev.DEVselectedObj = o; /* modification des coordonées dans le toolbar */ setToolBarPos dev.DEVselectedObj view dev.DEVtypeCoords; setToolBarAng dev.DEVselectedObj view dev.DEVtypeCoords; setToolBarScale dev.DEVselectedObj view; setToolBarSize dev.DEVselectedObj view; /* destruction de la boite precedente et creation de la nouvelle */ M3delObj view.V3dsession dev.DEVselectbox; set dev.DEVselectcolor=htoi "ffffff"; let evalSelectCube view.V3dsession dev.DEVselectedObj "select" dev.DEVselectcolor -> [pos cube] in ( set dev.DEVselectboxpos=pos; set dev.DEVselectbox=cube; 0 ); /* creation de l'axe de l'objet si besoin */ if dev.DEVtypeOperation&(OP_ROTOBJ|OP_MOVEOBJ|OP_SCALE) && dev.DEVselectedObj!=dev.DEVaxis.AVrefobject then ( dsAxisView dev.DEVaxis; set dev.DEVaxis=nil; let view.V3dsize -> [w h] in set dev.DEVaxis= newAxisView dev.DEVselectedObj w h (if dev.DEVtypeOperation&OP_SCALE then AXIS_SINGLE else AXIS_TRIEDRE) ) else nil; 0 ;; /************************************ Fonction de deselection de l'objet selectionné Renvoie 0 *************************************/ fun unselectObject(dev,view)= /* destrcution de la boite de selection */ M3delObj view.V3dsession dev.DEVselectbox; set dev.DEVselectbox=nil; set dev.DEVselectedObj=nil; set dev.DEVselectedMat3d=nil; /* destruction de l'axe */ dsAxisView dev.DEVaxis; set dev.DEVaxis=nil; /* mise à jour du toolbar */ setToolBarPos nil view dev.DEVtypeCoords; setToolBarAng nil view dev.DEVtypeCoords; setToolBarScale nil view; setToolBarSize nil view; 0;; fun UnselectObjectIn3DView()= unselectObject DEVview DEVview.DEVbd3d ;; fun SelectObjectIn3DView(o)= selectObject DEVview DEVview.DEVbd3d o ;; fun ClickOnAxis(axis,view,x,y)= if axis!=nil then ( evalCamPos axis view; evalAxisPos axis view; set axis.AVclicked=1; let axis.AVsize -> [w h] in let MX3renderInfo axis.AVsession axis.AVcamera x-(w>>1) (h>>1)-y ->[o m _ _ _] in (o==axis.AVh3dselx) || (o==axis.AVh3dsely) || (o==axis.AVh3dselz) ) else 0 ;; fun SelectObjectFrom3dView (dev, view, o, m, x, y) = let GetReal3DClickSelection dev view o m x y -> result in if result == nil then nil else let result -> [newo newm] in ( if newo == nil then nil else ( set TargetingObject = 0; SelectObjectInTree MainEdit3d newo; set TargetingObject = 1; ); set dev.DEVselectedMat3d=newm; SelectMatInList MainEdit3d newm ) ;; fun cbUserClick (x,y,btn,o,m,param) = let param-> [dev view] in if btn==2 then if o!=nil then ( SelectObjectFrom3dView dev view o m x y; drawMenu dev view x y dev.DEVselectedObj dev.DEVselectedMat3d; 0 ) else 0 else if dev.DEVtypeOperation&(OP_MOVEOBJ|OP_ROTOBJ|OP_SCALE) then !ClickOnAxis dev.DEVaxis view x y else 1 ;; fun cbUserDClick (x,y,btn,o,m,param) = let param-> [dev view] in if btn==1 && o!=nil then ( SelectObjectFrom3dView dev view o m x y ) else nil; 0 ;; fun UnClickOnAxis(dev,axis,view,x,y)= if axis!=nil then ( set axis.AVclicked=0; if axis.AVtypeaxis&AXIS_TRIEDRE then ( setToolBarPos axis.AVrefobject view dev.DEVtypeCoords; setToolBarAng axis.AVrefobject view dev.DEVtypeCoords; 0 ) else if axis.AVtypeaxis&AXIS_SINGLE then ( setToolBarScale axis.AVrefobject view; 0 ) else 0 ) else nil ;; fun cbUserUnClick(x,y,btn,o,m,param)= let param -> [dev view] in if btn==1 then ( if dev.DEVtypeOperation&(OP_MOVEOBJ|OP_ROTOBJ|OP_SCALE) then UnClickOnAxis dev dev.DEVaxis view x y else nil ) else nil; 0 ;; fun cbUserResize(view,w,h,dev)= if (dev.DEVtypeView&VIEW_FOUR) then let (w-3*DECAL)/2 -> w2 in let (h-3*DECAL)/2 -> h2 in let 2*DECAL+w2 -> posx2 in let 2*DECAL+h2 -> posy2 in let if view==dev.DEVhg3d then [DECAL DECAL] else if view==dev.DEVhd3d then [posx2 DECAL] else if view==dev.DEVbg3d then [DECAL posy2] else if view==dev.DEVbd3d then [posx2 posy2] else nil -> [x y] in { resizeView3d view x y w2 h2; resizeAxisView dev.DEVaxis w2 h2 } else { resizeView3d view 0 0 w h; resizeAxisView dev.DEVaxis w h }; 0;; fun cbUserMngPreRender(mng,dev)= if dev.DEVselectedObj!=nil then { let htoi "7f7f7f" -> ndx in set dev.DEVselectcolor=dev.DEVselectcolor&ndx+ndx; setSelectCubeColor dev.DEVbd3d.V3dsession dev.DEVselectcolor; } else nil; 0;; /************************************** Fonction initialisant la camera d'une vue suivant son type ***************************************/ fun setView3dCameraAngle(view,type)= if type&VIEW_AVATAR then nil else if type&VIEW_LEFT then { M3setObjVec view.V3dsession view.V3dcamera [0 0 0]; M3setObjAng view.V3dsession view.V3dcamera [-16384 0 0]; } else if type&VIEW_RIGHT then { M3setObjVec view.V3dsession view.V3dcamera [0 0 0]; M3setObjAng view.V3dsession view.V3dcamera [(16384) 0 0]; } else if type&VIEW_BOTTOM then { M3setObjVec view.V3dsession view.V3dcamera [0 1000 0]; M3setObjAng view.V3dsession view.V3dcamera [0 16384 0]; } else if type&VIEW_TOP then { M3setObjVec view.V3dsession view.V3dcamera [0 1000 0]; M3setObjAng view.V3dsession view.V3dcamera [0 (-16384) 0]; } else if type&VIEW_FRONT then { M3setObjVec view.V3dsession view.V3dcamera [0 0 0]; M3setObjAng view.V3dsession view.V3dcamera [0 0 0]; } else if type&VIEW_BACK then { M3setObjVec view.V3dsession view.V3dcamera [0 0 0]; M3setObjAng view.V3dsession view.V3dcamera [(-32768) 0 0]; } else nil;; /* fonction d' affectation des callbacks utilisateurs d'une vue 3d */ fun setView3dCallbacks(view,session,cam,dev,type)= let M3createShell session -> newcam in { M3load session camfile newcam; M3link session newcam shell; setView3dcbEnd view mkfun2 @cbUserDestroy newcam; setView3dCameraSession view session (if (view!=dev.DEVbd3d) then M3getFirstSon session newcam else cam); }; setView3dCameraAngle view type; setView3dcbPostRender view mkfun3 @cbUserPostRender [dev view /*getView3dName*/ type]; setView3dcbFocus view mkfun2 @cbUserFocus dev; setView3dcbResize view mkfun4 @cbUserResize dev; if view!=dev.DEVbd3d then { setView3dcbClick view mkfun6 @cbUserClick [dev view]; setView3dcbDClick view mkfun6 @cbUserDClick [dev view]; setView3dcbUnClick view mkfun6 @cbUserUnClick [dev view]; setView3dcbCursorMoveCoords view mkfun3 @cbUserCursorMove [dev view type]; setView3dcbReflexesObject view nil nil nil mkfun6 @SetMouseCursorOnAxis [dev view type]; } else nil;; /* fonction reflexe de paint sur le view manager */ fun cbDEVpaint(v3dmng,dev)= if (dev.DEVtypeView&VIEW_FOUR) then { if dev.DEVselected3d==dev.DEVhg3d then nil else paintSelectionDEV v3dmng.MV3dWin dev.DEVhg3d UNSELECTED_COLOR 1 dev.DEVselected3d; if dev.DEVselected3d==dev.DEVhd3d then nil else paintSelectionDEV v3dmng.MV3dWin dev.DEVhd3d UNSELECTED_COLOR 1 dev.DEVselected3d; if dev.DEVselected3d==dev.DEVbg3d then nil else paintSelectionDEV v3dmng.MV3dWin dev.DEVbg3d UNSELECTED_COLOR 1 dev.DEVselected3d; if dev.DEVselected3d==dev.DEVbd3d then nil else paintSelectionDEV v3dmng.MV3dWin dev.DEVbd3d UNSELECTED_COLOR 1 dev.DEVselected3d; paintSelectionDEV v3dmng.MV3dWin dev.DEVselected3d SELECTED_COLOR 0 dev.DEVselected3d; } else nil; 0;; /************************************ Fonction d'initialisation de l' editeur dynamique *************************************/ fun newDynEditorView(mng,view)= let view.V3dsize -> [w h] in let mkDynEditorView[mng.MV3dChannel mng nil nil nil view nil nil nil /* menu */ _CRfont mng.MV3dChannel 16 0 0 "Arial" VIEW_ONE DYN_NORM COORDS_GLOBAL nil nil nil nil htoi "ffffff" OP_VIEW nil nil view.V3dcbMoveObject view.V3dcbCursorMoveObject view.V3dcbClickObject view.V3dcbDClickObject view.V3dcbPostRender ]-> dev in { /* initialisation du click dans la vue 3d */ setView3dcbClick view mkfun6 @cbUserClick [dev view]; setView3dcbDClick view mkfun6 @cbUserDClick [dev view]; setView3dcbUnClick view mkfun6 @cbUserUnClick [dev view]; setView3dManagerPreRender mng mkfun2 @cbUserMngPreRender dev; dev };; /************************************ Fonction de creation de la vue editeur dynamique *************************************/ fun crDynEditorView(dev)= let dev.DEVmanager.MV3dSize -> [w h] in let (w-3*DECAL)/2 -> w2 in let (h-3*DECAL)/2 -> h2 in let 2*DECAL+w2 -> posx2 in let 2*DECAL+h2 -> posy2 in let make_rgb 128 128 128 -> grey in ( /* initialisation du menu */ set dev.DEVtypeMenu=DYN_EDIT; set dev.DEVtypeOperation=OP_VIEW; /* construction des trois vues filaires */ set dev.DEVtypeView=VIEW_FOUR; set dev.DEVhg3d=iniView3d dev.DEVmanager WIRE [DECAL DECAL ] [w2 h2] grey; set dev.DEVhd3d=iniView3d dev.DEVmanager WIRE [posx2 DECAL ] [w2 h2] grey; set dev.DEVbg3d=iniView3d dev.DEVmanager WIRE [DECAL posy2 ] [w2 h2] grey; resizeView3d dev.DEVbd3d posx2 posy2 w2 h2; set dev.DEVsavePostRender=dev.DEVbd3d.V3dcbPostRender; /* on fixe les reflexes */ setView3dCallbacks dev.DEVhg3d dev.DEVbd3d.V3dsession dev.DEVbd3d.V3dcamera dev VIEW_TOP; setView3dCallbacks dev.DEVhd3d dev.DEVbd3d.V3dsession dev.DEVbd3d.V3dcamera dev VIEW_LEFT; setView3dCallbacks dev.DEVbg3d dev.DEVbd3d.V3dsession dev.DEVbd3d.V3dcamera dev VIEW_BACK; setView3dCallbacks dev.DEVbd3d dev.DEVbd3d.V3dsession dev.DEVbd3d.V3dcamera dev VIEW_AVATAR; setView3dManagerPaint dev.DEVmanager mkfun2 @cbDEVpaint dev; /* focus sur la vue avatar */ _SETfocus dev.DEVbd3d.V3dwin; setToolBarPos dev.DEVselectedObj dev.DEVbd3d dev.DEVtypeCoords; setToolBarAng dev.DEVselectedObj dev.DEVbd3d dev.DEVtypeCoords; setToolBarScale dev.DEVselectedObj dev.DEVbd3d; setToolBarSize dev.DEVselectedObj dev.DEVbd3d; dev ) ;; /************************************ Fonction qui reset les reflexes relatifs aux objets dans la vue 3d view *************************************/ fun resetAvatarViewMoveReflexes(dev)= setView3dcbReflexesObject dev.DEVbd3d nil nil mkfun3 @movcam [MainEdit3d MainEdit3d.s3dE3d MainEdit3d.camE3d] mkfun6 @SetMouseCursorOnAxis [dev dev.DEVbd3d VIEW_AVATAR]; setView3dcbCursorMoveCoords dev.DEVbd3d mkfun3 @cbUserCursorMove [dev dev.DEVbd3d VIEW_AVATAR]; 0;; /************************************ Fonction qui restaure les reflexes relatifs aux objets dans la vue 3d view *************************************/ fun restoreAvatarViewReflexes(dev)= setView3dcbReflexesObject MainEdit3d.w3dE3d nil nil mkfun3 @movcam [MainEdit3d MainEdit3d.s3dE3d MainEdit3d.camE3d] mkfun6 @SetMouseCursorOnLink MainEdit3d; setView3dcbCursorMoveCoords dev.DEVbd3d nil; 0;; /************************************* Fonction de destruction de la vue editeur dynamique **************************************/ fun dsDynEditorView(dev)= /* destruction des trois vues filaires */ dsView3d dev.DEVhg3d; dsView3d dev.DEVhd3d; dsView3d dev.DEVbg3d; set dev.DEVhg3d=nil; set dev.DEVhd3d=nil; set dev.DEVbg3d=nil; set dev.DEVtypeView=VIEW_ONE; set dev.DEVtypeOperation=OP_VIEW; set dev.DEVtypeMenu=DYN_NORM; /* restauration des callbacks de la vue avatar */ restoreAvatarViewReflexes dev; dsAxisView dev.DEVaxis; set dev.DEVaxis=nil; resetCursorView3d dev.DEVbd3d; setView3dcbPostRender dev.DEVbd3d dev.DEVsavePostRender; /* restauration de la taille de la vue avatar */ let dev.DEVmanager.MV3dSize -> [w h] in resizeView3d dev.DEVbd3d 0 0 w h; 0;; /*********************************************************************************************************/ /* Les fonctions relatives à la selection d'un bouton dans la barre d'outils */ /*********************************************************************************************************/ /* click sur le bouton view */ fun clickView(node,state,dev)= /* desactivation de tous les objest texte */ disableObj TEXT_X; disableObj TEXT_Y; disableObj TEXT_Z; disableObj TEXT_A; disableObj TEXT_B; disableObj TEXT_C; disableObj TEXT_SCALE; set dev.DEVtypeOperation=OP_VIEW; evalStateViewBtn dev; restoreAvatarViewReflexes dev; dsAxisView dev.DEVaxis; set dev.DEVaxis=nil; resetCursorView3d dev.DEVhg3d; resetCursorView3d dev.DEVhd3d; resetCursorView3d dev.DEVbg3d; 0;; /* click sur le bouton pan */ fun clickPan(node,state,dev)= set dev.DEVtypeOperation=OP_PAN; setCursorView3d dev.DEVhg3d HandCursor; setCursorView3d dev.DEVhd3d HandCursor; setCursorView3d dev.DEVbg3d HandCursor; 0;; /* click sur le bouton arc rotate */ fun clickProfondeur(node,state,dev)= set dev.DEVtypeOperation=OP_PROF; setCursorView3d dev.DEVhg3d ProfCursor; setCursorView3d dev.DEVhd3d ProfCursor; setCursorView3d dev.DEVbg3d ProfCursor;; /* click sur le bouton moveobject */ fun clickMoveObject(node,state,dev)= /* activation des texts */ enableObj TEXT_X; enableObj TEXT_Y; enableObj TEXT_Z; disableObj TEXT_A; disableObj TEXT_B; disableObj TEXT_C; disableObj TEXT_SCALE; set dev.DEVtypeOperation=OP_MOVEOBJ; evalStateViewBtn dev; resetAvatarViewMoveReflexes dev; if dev.DEVaxis!=nil && dev.DEVaxis.AVtypeaxis&AXIS_SINGLE then { dsAxisView dev.DEVaxis; set dev.DEVaxis=nil; } else nil; if dev.DEVaxis==nil then let dev.DEVselected3d.V3dsize -> [w h] in set dev.DEVaxis=newAxisView dev.DEVselectedObj w h AXIS_TRIEDRE else nil; resetCursorView3d dev.DEVhg3d; resetCursorView3d dev.DEVhd3d; resetCursorView3d dev.DEVbg3d;; /* click sur le bouton min/max toggle */ fun clickMinMaxToggle(node,state,dev)= set dev.DEVtypeView=if (dev.DEVtypeView&VIEW_FOUR) then VIEW_ONE else VIEW_FOUR; let dev.DEVmanager.MV3dSize -> [w h] in if (dev.DEVtypeView&VIEW_ONE) then { resizeView3d dev.DEVselected3d 0 0 w h; resizeAxisView dev.DEVaxis w h; topView3d dev.DEVselected3d; nil } else { cbUserResize dev.DEVhg3d w h dev; cbUserResize dev.DEVhd3d w h dev; cbUserResize dev.DEVbg3d w h dev; cbUserResize dev.DEVbd3d w h dev; 0 };; /* click sur le bouton rotate */ fun clickRotate(node,state,dev)= /* activation des texts */ enableObj TEXT_A; enableObj TEXT_B; enableObj TEXT_C; disableObj TEXT_X; disableObj TEXT_Y; disableObj TEXT_Z; disableObj TEXT_SCALE; set dev.DEVtypeOperation=OP_ROTOBJ; evalStateViewBtn dev; resetAvatarViewMoveReflexes dev; if dev.DEVaxis!=nil && dev.DEVaxis.AVtypeaxis&AXIS_SINGLE then { dsAxisView dev.DEVaxis; set dev.DEVaxis=nil; } else nil; if dev.DEVaxis==nil then let dev.DEVselected3d.V3dsize -> [w h] in set dev.DEVaxis=newAxisView dev.DEVselectedObj w h AXIS_TRIEDRE else nil; resetCursorView3d dev.DEVhg3d; resetCursorView3d dev.DEVhd3d; resetCursorView3d dev.DEVbg3d;; /* click sur le bouton scale */ fun clickScale(node,state,dev)= /* activation des texts */ disableObj TEXT_A; disableObj TEXT_B; disableObj TEXT_C; disableObj TEXT_X; disableObj TEXT_Y; disableObj TEXT_Z; enableObj TEXT_SCALE; set dev.DEVtypeOperation=OP_SCALE; evalStateViewBtn dev; resetAvatarViewMoveReflexes dev; if dev.DEVaxis!=nil && dev.DEVaxis.AVtypeaxis&AXIS_TRIEDRE then { dsAxisView dev.DEVaxis; set dev.DEVaxis=nil; } else nil; if dev.DEVaxis==nil then let dev.DEVselected3d.V3dsize -> [w h] in set dev.DEVaxis=newAxisView dev.DEVselectedObj w h AXIS_SINGLE else nil; resetCursorView3d dev.DEVhg3d; resetCursorView3d dev.DEVhd3d; resetCursorView3d dev.DEVbg3d;; fun clickGlobalRef(node,state,dev)= set dev.DEVtypeCoords=if state==CHK_CHECKED then COORDS_GLOBAL else COORDS_RELATIF; setToolTip node if dev.DEVtypeCoords&COORDS_GLOBAL then loc "REF_GLOBAL" else loc "REF_PARENT"; setToolBarPos dev.DEVselectedObj dev.DEVbd3d dev.DEVtypeCoords; setToolBarAng dev.DEVselectedObj dev.DEVbd3d dev.DEVtypeCoords; setToolBarScale dev.DEVselectedObj dev.DEVbd3d; setToolBarSize dev.DEVselectedObj dev.DEVbd3d; 0;; /* click sur le bouton close */ fun clickClose(node,state,dev)= closeGlobalEditorView; 0;; /****************************************** Modification du contenu d'un texte relatif à la position de l'objet selectionné dans la toolbar *******************************************/ fun ChangePosInToolBar(pos,ang,dev)= let let dev.DEVselected3d.V3dsession -> ss in let M3getFather ss dev.DEVselectedObj-> father in if dev.DEVtypeCoords&COORDS_GLOBAL then ( M3setObjVec session shell0 pos; M3setObjAng session shell0 ang; GetRefPosAndAngle ss shell0 father ) else [pos ang] -> [posref angref] in { /* C3DsetObjPosAng dev.DEVselectedObj [posref angref] SAVE_NOW BROAD_OTHER;*/ M3setObjVec session dev.DEVselectedObj posref; M3setObjAng session dev.DEVselectedObj angref; 0 };; /****************************************** Modification du contenu d'un texte relatif à la taille de l'objet selectionné dans la toolbar *******************************************/ fun ChangeScaleInToolBar(scale,dev)= /* C3DsetObjScale dev.DEVselectedObj scale SAVE_NOW BROAD_OTHER;*/ M3setObjScale session dev.DEVselectedObj scale; 0;; /************************************ Fonction d'initialisation de la vue globale d'edition dynamique *************************************/ fun initGlobalEditorView(mng,v3d)= /* initialisation de la vue globale */ set DEVview=newDynEditorView mng v3d; 0;; /************************************ Fonction d'ouverture de la vue globale d'edition dynamique *************************************/ fun openGlobalEditorView()= set SELECTED_COLOR=make_rgb 255 0 0; set UNSELECTED_COLOR=make_rgb 255 255 255; /* initialisation des curseurs */ let _LDbitmap _channel _checkpack HandCursorBmp -> cur in { set HandCursor = _CRcursor _channel cur 9 3 0 0xFFFFFF; set ListBmp=cur::ListBmp; }; let _LDbitmap _channel _checkpack ProfCursorBmp -> cur in { set ProfCursor = _CRcursor _channel cur 16 16 0 0xFFFFFF; set ListBmp=cur::ListBmp; }; let _LDbitmap _channel _checkpack MoveSelectBmp -> cur in { set MoveSelectCursor=_CRcursor _channel cur 16 16 0 0xFFFFFF; set ListBmp=cur::ListBmp; }; /* initialisation et affichage de la toolbar */ crToolBar 350 10 DEVview.DEVmanager.MV3dWin; initFuncBtn CHECK_VIEW mkfun3 @clickView DEVview; initFuncBtn CHECK_PAN mkfun3 @clickPan DEVview; initFuncBtn CHECK_PROFONDEUR mkfun3 @clickProfondeur DEVview; initFuncBtn CHECK_MOVE mkfun3 @clickMoveObject DEVview; initFuncBtn ROL_MINMAXTOGGLE mkfun3 @clickMinMaxToggle DEVview; initFuncBtn CHECK_ROTATE mkfun3 @clickRotate DEVview; initFuncBtn CHECK_SCALE mkfun3 @clickScale DEVview; initFuncBtn ROL_CLOSE mkfun3 @clickClose DEVview; initFuncBtn CHECK_GLOBALREF mkfun3 @clickGlobalRef DEVview; initEnterTextPos mkfun3 @ChangePosInToolBar DEVview; initEnterTextScale mkfun2 @ChangeScaleInToolBar DEVview; crDynEditorView DEVview; 0;; fun dsBmps(l)= if l==nil then 0 else let l -> [bmp nxt] in { _DSbitmap bmp; dsBmps nxt; };; /************************************ Fonction de fermeture de la vue globale d'edition dynamique *************************************/ fun closeGlobalEditorView()= /* destruction bmps et curseurs */ dsBmps ListBmp; _DScursor HandCursor; _DScursor ProfCursor; /* destruction de la vue editeur et reaafichage de la vue 3d*/ dsDynEditorView DEVview; /* on cache l'explorateur et on ferme la barre d'outils*/ dsToolBar; /* closeExplorateur;;*/ 0;; /************************************ Fonction de desinitialisation de la vue globale d'edition dynamique *************************************/ fun unInitGlobalEditorView()= _DSfont DEVview.DEVfont; dsAxisView DEVview.DEVaxis; set DEVview.DEVaxis=nil; set DEVview=nil; 0;;