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, 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/plugins/DynEditor/lib/axis.m3d";; var ScaleM3d ="Dms/3d/plugins/DynEditor/lib/scale.m3d";; var MoveSelectBmp ="Dms/3d/plugins/DynEditor/lib/movecursor.bmp";; var MoveSelectMACBmp ="Dms/3d/plugins/DynEditor/lib/movecursorMAC.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;; /*******************************************************************************************************/ /* 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 */ DEVcanEdit :I, /* mode edition actif */ 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 */ /* DEVroom :[S S S S], /* liste des rooms modelisées par le modeleur */*/ 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;; typeof DEVview =DynEditorView;; fun setAxisLetterTarget(axis, h) = let M3getFather axis.AVsession h -> father in let M3calcPosRef axis.AVsession h father -> [src _] in let M3calcPosRef axis.AVsession axis.AVcamera father -> [dst _] in let M3angularTarget src dst -> [an bn cn] in M3setObjAng axis.AVsession h [an bn cn] ;; 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==WIREORTHO 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 1000]; if (axis.AVtypeaxis&AXIS_TRIEDRE) then M3setObjAng axis.AVsession axis.AVaxis a else nil; M3setObjScale axis.AVsession axis.AVaxis 200*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 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(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; 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 getView3dSize view -> [_ hg] in let axis.AVsize -> [ws hs] in ( /* 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; /* copie de l'axe dans la vue 3d*/ 0 ) ) else 0 ;; fun testClickOnAxis(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 ((axis.AVtypeaxis&AXIS_TRIEDRE) && ((o==axis.AVh3dselx) || (o==axis.AVh3dsely) || (o==axis.AVh3dselz))) || ((axis.AVtypeaxis&AXIS_SINGLE) && (o==axis.AVh3dselz)) ) else 0 ;; proto setToolBarPos = fun [H3d View3d I] [I I I];; proto setToolBarAng = fun [H3d View3d I] [I I I];; proto setToolBarScale = fun [H3d View3d] I;; fun testUnClickOnAxis(dev, axis, view, x, y) = if axis!=nil then ( set axis.AVclicked=0; if axis.AVtypeaxis&AXIS_TRIEDRE then let setToolBarPos axis.AVrefobject view dev.DEVtypeCoords -> vect in let setToolBarAng axis.AVrefobject view dev.DEVtypeCoords -> ang in C3DsetObjPosAng axis.AVrefobject [vect ang] SAVE_NOW BROAD_OTHER else if axis.AVtypeaxis&AXIS_SINGLE then let setToolBarScale axis.AVrefobject view -> scale in C3DsetObjScale axis.AVrefobject scale SAVE_NOW BROAD_OTHER else nil; 0 ) else nil ;;