/* Photo3 Client - DMS - march 99 - by Sylvain HUET */ /* av3d January 2000 - by Sébastien DENEUX */ defcom Cregistered=registered;; defcom Ctrans=trans I;; defcom Caddbitmap=addbitmap S;; defcom Cnobitmap=nobitmap;; defcom CgetSign=getSign I;; defcom CgetMesh=getMesh I;; defcom CupdateCliAvFile=updateCliAvFile S;; var anim_stop_begin=40;;/*provisoire*/ var anim_stop_end=100;;/*provisoire*/ var pref="locked/conf/photo.conf";; var plugfile="Dms/Avatar/av3d/av3d.plug";; typeof defaultAvatarsList=[S r1];;/*list of the default avatars for the browser*/ var currentAvListPos=-2;;/*pos while browsing*/ /*-1 = default avatar -2 = avatar sets by server others = pos in default avatars list*/ typeof photo=S;; /*current photo name*/ typeof avfile=S;; /*current avfile name*/ var avpos = -2;;/*current pos*/ typeof loadingBitmap=ObjBitmap;; var meshDownloading=0;;/*1 when downloading an avatar mesh for the browser*/ typeof winInterface=ObjWin;;/*interface to change photo and avatar*/ typeof bufPhoto=ObjBitmap;;/*photo viex on this interface*/ typeof button=ObjButton;;/*show interface button*/ var flag=0;; /*flag transparency for photo*/ typeof avDefaultFile=S;;/*default avatar file*/ proto showInterface = fun [] I;; proto changeAvatarViewMesh = fun [] I;; typeof uis=[UserI r1];; /*ui courant*/ /*----------------*/ fun stringCompare(a,b)=!strcmp a b;; /*--------------*/ /*send photo and current avatar mesh name to server*/ fun updateAvatar()= _DMSsend this CupdateCliAvFile [avfile]; if (search_in_list defaultAvatarsList @stringCompare avfile)!=nil then /*we only save avatars from default browser list*/ _storepack strbuild (photo::(itoa flag)::avfile::nil)::nil pref else _storepack strbuild (photo::(itoa flag)::nil)::nil pref; _DMSsend this Ctrans [flag]; let _getpack _checkpack photo -> s in if s==nil then _DMSsend this Cnobitmap [] else (_DMSsend this Caddbitmap [nil]; let 0->i in while i t in if f then let _GETpixel16 image 0 0 -> colRGB in let ((colRGB&16252928)>>16)+(colRGB&63488)+((colRGB&248)<<16) -> colBGR in (M3setType session mat MAT_TRANSP|M3getType session mat; M3setTransparencyColor session t colBGR) else M3setType session mat 251&M3getType session mat; /*4 = MAT_TRANSP*/ M3blitTexture16 session (M3copyMaterialTexture session mat) image;; /*--------------------*/ /*parcours l'arboresence de l'objet 3D*/ fun setMaterial(session,h,mat,image,f)= if h==nil then nil else (let M3copyObjMaterial session h mat -> mat2 in if mat2!=nil then applyPhotoToMaterial session mat2 image f else nil; setMaterial session (M3getFirstSon session h) mat image f; setMaterial session (M3getBrother session h) mat image f; 0);; /*--------------------*/ /*mappage visage avatar*/ fun applyface (session,s,avObj,f)= let _LDbitmap _channel _checkpack s -> imagebmp in let if imagebmp==nil then _LDjpeg _channel _checkpack s else imagebmp -> image in (let M3getMat session "photo" -> mat in setMaterial session avObj mat image f; _DSbitmap image;0);; /*--------------*/ /*informe les ui que la vue doit changer*/ fun broad(a,b)=Usend this a "changeView" b;; /*--------------*/ fun activate(from,action,param,rep)= if !strcmp action "showInterface" then showInterface else if !strcmp action "changeView" then /*cht vue*/ (apply_on_list uis @broad param;0) else nil;; /*partie en lien avec le plugin*/ typeof req=[UserI r1];; typeof req2=[UserI r1];; /*--------------*/ fun reqbyid(r,i)= r.userUI.idU==i;; /*--------------*/ fun getphot(ui)= if findList req ui then nil else (set req=conc req ui::nil; _DMSsend this CgetSign [ui.userUI.idU]);; /*--------------*/ /*get the current mesh of the avatar*/ fun getMes(ui)= if findList req2 ui then nil /*used to limit to one asked to the server at the same time*/ else (set req2=conc req2 ui::nil; _DMSsend this CgetMesh [ui.userUI.idU]);; /*--------------*/ fun cbcomm(ui,action,param)= if !strcmp action "getMeshPhoto" then getphot ui else if !strcmp action "init" then (set uis=ui::uis;0) else if !strcmp action "avDefFile" then /*default avatar mesh file name*/ Usend this ui "setAvDefFile" avDefaultFile else 0;; /*--------------*/ fun cbdel(ui,r)= _RSCabort this r; set uis=remove_from_list uis ui; /*SD*/ set req=remove_from_list req ui; set req2=remove_from_list req2 ui; UcbDel this ui nil; 0;; /*--------------*/ fun newInst(ui)= UcbComm this ui @cbcomm; UcbDel this ui mknode @cbdel nil; 0;; /*--------------*/ fun closeInterface()= if winInterface!=nil then (_DSwindow winInterface; set winInterface=nil; _DSbitmap bufPhoto; 0) else nil;; /*--------------*/ fun _end(s)= _DMSreleaseZone this "Button"; set button=nil; closeInterface; 0;; /*--------------*/ /*button show interface*/ fun _resizeI(x,s)= let x->[wn x y w h] in _SIZEbutton button w h x y; 0;; /*--------------*/ fun pressbut(a,b)=showInterface;; /*--------------*/ /*m3d and associated textures have been downloaded*/ fun endDownTextures2(f,b)= let b->[meshFileName textureFileName nb nbTotal origin param] in let nb -> [nb2] in ( if nb2==nbTotal then /*all textures have been downloaded*/ if !strcmp origin "default" then ( _DMSregisterDMI this @activate nil; UcbCreate this @newInst; let _DMSgetZone this "Button" nil @_resizeI @_end ->[wn x y w h] in if wn==nil then nil else set button=_CBbutton _CRbutton _channel wn x y w h 0 "Avatar" @pressbut 0; _DMSsend this Cregistered []; _DMSevent this "in" nil nil ) else if (!strcmp origin "browser") then let param -> [trans button1 button2 z] in let z -> [sessionAvInterfView shellAv3dView av3dViewObj _ _] in ( set meshDownloading=0; if winInterface!=nil then ( M3delObj sessionAvInterfView av3dViewObj; M3freeMemory sessionAvInterfView; M3load sessionAvInterfView meshFileName shellAv3dView; M3recursFillMatObj sessionAvInterfView shellAv3dView; let M3getObj sessionAvInterfView "avatar" -> newAv3dViewObj in (applyface sessionAvInterfView photo newAv3dViewObj _GETcheck trans; /*apply photo on avatar*/ mutate z <- [_ _ newAv3dViewObj _ _];0)) else changeAvatarViewMesh; /*change mesh in the avatar view*/ _ENbutton button1 1;/*show next-previous button*/ _ENbutton button2 1; 0 ) else nil else nil; mutate nb <- [nb2+1]; 0; );; /*----------------*/ /*returns the bloc after the next "}" in l*/ fun goToNextBloc(l)= if l==nil then nil else let l-> [tete queue] in if !strcmp hd tete "}" then queue else goToNextBloc queue;; /*----------------*/ /*returns the texture name*/ fun getTexture(l)= if l==nil then nil else let l -> [tete queue] in if !strcmp hd tete "texture" then hd tl tete /*texture name*/ else if !strcmp hd tete "}" then nil else getTexture queue;; /*----------------*/ /*register the textures of the m3d*/ fun getM3dTextures(l,texturesToDownload)= if l== nil then texturesToDownload /*returns the list of the textures to downlaod*/ else let l -> [tete queue] in if !strcmp hd tete "material" then (let getTexture queue -> textureFileName in if textureFileName!=nil then getM3dTextures (goToNextBloc queue) textureFileName::texturesToDownload else getM3dTextures (goToNextBloc queue) texturesToDownload) else if !strcmp hd tete "mesh" then getM3dTextures (goToNextBloc queue) texturesToDownload else if !strcmp hd tete "shell" then getM3dTextures (goToNextBloc queue) texturesToDownload else if !strcmp hd tete "anim" then getM3dTextures (goToNextBloc queue) texturesToDownload else if !strcmp hd tete "camera" then getM3dTextures (goToNextBloc queue) texturesToDownload else getM3dTextures queue texturesToDownload;; /*----------------*/ fun lastpercent(n,i,l)= if i>=strlen n then l else lastpercent n i+1 if (nth_char n i)=='% then i else l;; /*----------------*/ fun cutnamefilter(n)= let lastpercent n 0 nil-> i in if i==nil then [n nil] else [substr n i+1 1000 substr n 1 i-1];; /*----------------*/ /*download the default avatar mesh textures*/ fun downloadM3dTextures2(meshFileName,textureFileNameList,nb,nbTotal,origin,param)= if textureFileNameList==nil then nil else let textureFileNameList -> [tete queue] in let cutnamefilter tete -> [textureName _] in (_RSCdownload this textureName textureName mknode @endDownTextures2 [meshFileName textureName nb nbTotal origin param] 3; downloadM3dTextures2 meshFileName queue nb nbTotal origin param;0);; /*--------------*/ /*the avatar mesh is downloaded*/ fun endDownAvatarMesh2(f,z)= let z -> [meshFileName origin param] in let strextr _getpack _checkpack meshFileName -> l in let getM3dTextures l nil -> texturesNameList in (downloadM3dTextures2 meshFileName texturesNameList [1] (sizelist texturesNameList) origin param;0);; /*--------------*/ /*download m3d file and associated textures*/ fun downloadM3D(meshFileName,origin,param)= _RSCdownload this meshFileName meshFileName mknode @endDownAvatarMesh2 [meshFileName origin param] 3; 0;; /*--------------*/ /*the avatar photo is downloaded*/ fun endDown(f,z)= let z->[ui fl] in (set req=remove_from_list req ui; getMes ui);; /*get mesh*/ /*--------------*/ fun __setSign(id,sign,f)= let search_in_list req @reqbyid id -> ui in if ui==nil then nil else if sign==nil then (endDown nil [ui nil];nil) else UcbDel this ui mknode @cbdel _RSCdownload this itoa id sign mknode @endDown [ui f] 3;; /*----------------*/ /*parsing du fichier m3d*/ /*download des textures*/ /*----------------*/ /*----------------*/ /*CB end download texture*/ fun endDownTextures(f,z)= let z->[ui meshFileName textureFileName nb nbTotal sign f] in let nb -> [nb2] in (if nb2==nbTotal then /*Usend this ui "setMeshPhoto" strbuild (sign::f::meshFileName::nil)::nil*/ Usend this ui "setMeshPhoto" strbuild ("sign"::sign::nil)::("f"::f::nil)::("meshFileName"::meshFileName::nil)::nil else nil; mutate nb <- [nb2+1];0);; /*----------------*/ /*download the avatar mesh textures*/ fun downloadM3dTextures(meshFileName,textureFileNameList,ui,nb,nbTotal,sign,f)= if textureFileNameList==nil then nil else let textureFileNameList -> [tete queue] in let cutnamefilter tete -> [textureName _] in (_RSCdownload this textureName textureName mknode @endDownTextures [ui meshFileName textureName nb nbTotal sign f] 3; downloadM3dTextures meshFileName queue ui nb nbTotal sign f;0);; /*--------------*/ /*the avatar mesh is downloaded*/ fun endDown2(f,z)= let z->[ui meshFileName sign f] in (set req2=remove_from_list req2 ui; let strextr _getpack _checkpack meshFileName -> l in let getM3dTextures l nil -> texturesNameList in /*_DLGMessageBox _channel nil "list" linebuild texturesNameList 0;*/ downloadM3dTextures meshFileName texturesNameList ui [1] (sizelist texturesNameList) sign f );; /*download the avatar mesh*/ /*set the avatar mesh when avatar mesh file and associated textures are downloaded*/ /*--------------*/ fun __setMesh(id,meshFileName,sign,f)= /*_DLGMessageBox _channel nil "__setMesh" meshFileName 0;*/ let search_in_list req2 @reqbyid id -> ui in if ui==nil then nil else if meshFileName==nil then ( set req2=remove_from_list req2 ui; Usend this ui "setMeshPhoto" strbuild (sign::f::nil)::nil /*inform that the mesh does not exist*/ ) else ( UcbDel this ui mknode @cbdel _RSCdownload this meshFileName meshFileName mknode @endDown2 [ui meshFileName sign f] 3;/*download m3d, download textures in CB endDown2*/ 0 );; /*--------------*/ fun __setDefAvatarsList(s)= if winInterface==nil then nil else ( _DSwindow winInterface; set winInterface=nil ); set defaultAvatarsList=lineextr s;; /*--------------*/ /*when login changed, item loaded if item not nil*/ fun __setAvatar(s)= if winInterface==nil then (if s!=nil then (set currentAvListPos=-2;set avpos=-2) else nil; set avfile=if s==nil then let hd strextr _getpack _checkpack pref -> l2 in let hd tl tl l2 -> cook in if (_checkpack cook)==nil then avDefaultFile else cook /*try to load cookie else default mesh*/ else s) else nil;; /*--------------*/ fun IniDMI(param)= let hd strextr _getpack _checkpack pref -> l2 in ( set avDefaultFile=param; /*default avatar file*/ set photo=hd l2; set flag=atoi hd tl l2; let hd tl tl l2 -> cook in set avfile = if (_checkpack cook)==nil then avDefaultFile else cook /*we load cookie only if item empty*/ ); _DMSregisterDMI this @activate nil; UcbCreate this @newInst; let _DMSgetZone this "Button" nil @_resizeI @_end ->[wn x y w h] in if wn==nil then nil else set button=_CBbutton _CRbutton _channel wn x y w h 0 _loc this "AV_AVATAR" nil @pressbut 0; _DMSsend this Cregistered []; _DMSevent this "in" nil nil; set loadingBitmap=_LDjpeg _channel _checkpack "Dms/avatar/av3d/loading.jpg"; 0;; /*--------------*/ fun __getPlugin(h,rep)= let _DMSgetByHandle h-> d in if d==nil then nil else _DMSreply this d rep plugfile nil;;