/******************************************************************************* Plugin Template Client part Version: 1.0 Authors: Sebastien DENEUX & Julien Zorko Last update: 09/05/2001 Template Plugin *******************************************************************************/ /******************************************************************************* This plugin is a template plugin which allows to understand the basic rules for plugins implentation. Its function is not usefull: it applies a flat color on the objects of an anchor and randomly changes this color when the user clicks on one of them. The mouse cursor shape changes when it is on one of these clickable objects. The random color comes from a server function and all the clients see the new color. *******************************************************************************/ typeof class=S;; /* Plugin class name (here is template) */ /******************************************************************************* Change the flat color of an object (the texture is hidden) x -> objAnchor : anchor col -> I : flat color *******************************************************************************/ fun AppFlat(x,col)= match x with (objAnchor [_ m _ _] -> (M3setType session m 0;M3setMaterialFlat session m col)) |(_->nil) ;; /******************************************************************************* Click action Callback ui -> UserI : user instance action -> S : action param -> S : parameters z -> [Ob I] : Ob and flat color <- I : not used *******************************************************************************/ fun cbSetFlat(ui,action,param,o)= apply_on_list ObAnchor o @AppFlat atoi param ;; /******************************************************************************* Defines the callbacks of the links in the anchor, and return the list of them o -> Ob : Object obj -> Obj : mat -> HMat3d : material button -> I : flag for the mouse button (1 is the left one) <- I : not used *******************************************************************************/ fun cbClickLink(o,obj,mat,button)= if button==1 then UsendMessage ObUi o "click" nil else nil ;; /******************************************************************************* Defines the callbacks of the links in the anchor, and return the list of them <- [[H3d HMat3d S ObjCursor fun [Ob H3d HMat3d I] I fun [Ob H3d HMat3d I] I fun [Ob H3d HMat3d] I] r1] *******************************************************************************/ proto GetLinks = fun [[Anchor r1]] [[H3d HMat3d S ObjCursor fun [Ob H3d HMat3d I] I fun [Ob H3d HMat3d I] I fun [Ob H3d HMat3d] I] r1];; fun GetLinks(l)= if l==nil then nil else match hd l with (objAnchor [ah am name _] -> ([ah am name CrossCursor @cbClickLink nil nil]::(GetLinks tl l))) | (_->(GetLinks tl l)) ;; /******************************************************************************* New object creation o -> Ob : object <- I : not used *******************************************************************************/ fun newOb(o)= UcbMessage ObUi o ["setFlat" mkfun4 @cbSetFlat o]::nil; ObSetLinks o GetLinks ObAnchor o; UsendMessage ObUi o "color?" nil; 0 ;; /******************************************************************************* Function called when plugin is initialised file -> S : '*.plug' file name <- I : not used *******************************************************************************/ fun IniPlug(file)= set class=getInfo strextr _getpack _checkpack file "name"; PlugRegister class @newOb nil; 0 ;;