/******************************************************************************* Grid3d Plugin Client part Version: 1.0 Authors: Jérôme Icard Last update: 16/05/2001 *******************************************************************************/ typeof class = S;; typeof NbLines = I;; typeof NbColumns = I;; typeof CboardW = I;; typeof CboardH = I;; typeof CboardSca = I;; typeof CboardPos = [ I I I ];; typeof SquareW = I;; typeof SquareH = I;; typeof H3DGRID = tab tab H3d;; typeof h3dnil = H3d;; /*---------------------------------------------------------------*/ fun getCboardInfo (CboardH3D)= let M3objName session CboardH3D -> name in _DLGMessageBox _channel nil "fun getCboardInfo" name 0; let M3getObjScale session CboardH3D -> sc in let M3getObjVec session CboardH3D -> [ x y z ] in let M3calcObb session CboardH3D -> [ [_ _ _] [Wid Hei _] ] in ( set CboardSca = sc; set CboardPos = [ x y z ]; set CboardW = Wid*2; set CboardH = Hei*2; set SquareW = (CboardW/ NbLines); set SquareH = (CboardH/NbColumns); _DLGMessageBox _channel nil "fun getCboardInfo" strcatn "value de CboardSca :"::(itoa CboardSca):: "\n value de CboardW :"::(itoa CboardW):: "\n value de CboardH :"::(itoa CboardH):: "\n value de SquareW :"::(itoa SquareW):: "\n value de SquareH :"::(itoa SquareH):: nil 0; 0 );; /*---------------------------------------------------------------*/ fun getObjInfo (Obj3D)= let M3getObjVec session Obj3D -> [ x y z ] in let CboardPos -> [ X2 _ Z2 ] in let (x-X2)/SquareW -> i in let (z-Z2)/SquareH -> j in set H3DGRID.(i).(j) = Obj3D;; /*---------------------------------------------------------------*/ fun CreateCell(col_index,x)= let x -> [li c constructor] in exec constructor with [li col_index];; fun CreateLine(line_index,t)= let t -> [l c x] in create_tab c @CreateCell [line_index c x];; fun CreateArray(l,c,x)= create_tab l @CreateLine [l c x];; fun mycellH3D(l,c)= h3dnil;; //::::: ici on recherche parmi la liste des ancres une contenant le lien damier /*-------------------------------------------------------------*/ fun getgameinfo (Ancres)= if (Ancres == nil) then ( _DLGMessageBox _channel nil "valeur de Name est à nil !!!" nil nil; 0) else let Ancres -> [first next] in ( match first with ( objAnchor [h _ Name _] -> ( _DLGMessageBox _channel nil "valeur de Name : " Name nil; if !strcmp Name "damier" then ( getCboardInfo h; 0 ) else ( getObjInfo h; 0 ); getgameinfo next; 0 ) ) | (_-> 0); );; /*-------------------------------------------------------------*/ fun makeMove (StrVec)= let (atoi (ctoa nth_char StrVec 0))-1 -> PrecedI in let (atoi (ctoa nth_char StrVec 1))-1 -> PrecedJ in let (atoi (ctoa nth_char StrVec 2))-1 -> NewI in let (atoi (ctoa nth_char StrVec 3))-1 -> NewJ in let NewI-PrecedI -> DeltaI in let NewJ-PrecedJ -> DeltaJ in let H3DGRID.(PrecedI).(PrecedJ) -> Obj3D in ( _showconsole; _fooS strcatn "PI "::(itoa PrecedI)::" PJ "::(itoa PrecedJ)::nil; _fooS strcatn "I "::(itoa NewI)::" J "::(itoa NewJ)::nil; M3movObj session Obj3D [ ((SquareW*DeltaI)) (-(SquareH*DeltaJ)) nil ]; set H3DGRID.(NewI).(NewJ) = Obj3D; 0 );; /*-------------------------------------------------------------*/ fun activate(o,from,action,param,rep)= if !strcmp action (strcat (ObName o) ".mov") then (_DLGMessageBox _channel nil "valeur de param : " "??" 0; makeMove param) else nil; 0;; /***************************************************************/ /*-------------------------------------------------------------*/ fun newOb(o)= _showconsole; set NbLines = atoi hd UgetParam ObUi o "lines"; set NbColumns = atoi hd UgetParam ObUi o "columns"; set H3DGRID = CreateArray NbLines NbColumns @mycellH3D; getgameinfo (ObAnchor o); ObRegisterAction o (strcatn (ObName o)::".mov"::nil) @activate;; fun IniPlug(file)= set class=getInfo strextr _getpack _checkpack file "name"; PlugRegister class @newOb nil; 0;; /*-------------------------------------------------------------*/ /***************************************************************/