/* Photo3 Server - DMS - march 99 - by Sylvain HUET */ /* av3d January 2000 - by Sébastien DENEUX */ /*to do : - le unregister n'est jamais fait, ni sur les m3D, ni sur les textures du mesh -> pb du browser : on ne peut pas supprimer les unregister pour les clients qui ont encore le mesh, meme si il disparait du browser - le parse du m3D doit se faire uniquement du coté serveur, le serveur transmet le nom du m3D ainsi que les noms des textures associées */ defcom CgetPlugin=getPlugin I S;; defcom CsetSign=setSign I S I;; defcom CsetMesh=setMesh I S S S;; defcom CsetDefAvatarsList=setDefAvatarsList S;; defcom CsetAvatar=setAvatar S;; var type="av3d";; typeof defaultAvFile=S;; struct Pho=[cliPho:CLIENT,idPho:I,workPho:S,signPho:S,transPho:I]mkPho;; typeof av3dClis=[Pho r1];; typeof clis=[CLIENT r1];;/*all clients that have started the module*/ typeof defaultAvatarsDirectory=S;;/*default folder for avatars browser*/ typeof defaultAvatarsList=[S r1];; var m3dItemRef="meshAv3d";; /*reference of the item that correspond to the avatar mesh file of each client*/ /*----------------*/ /**parsing du fichier m3d*/ /*----------------*/ /*----------------*/ /*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;; /*----------------*/ 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];; /*----------------*/ /*register the texture*/ fun registerTexture(texture)= /*_DLGMessageBox _channel nil "register : texture name" textureFileName 0;*/ let cutnamefilter texture -> [textureFileName _] in ( _RSunregister this textureFileName; _RSregisterfiles this textureFileName::nil RSfile+RScontrol; 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;; /*----------------*/ /*register the textures of the m3d*/ fun registerM3dTextures(l)= if l== nil then nil else let l -> [tete queue] in ( if !strcmp hd tete "material" then ( let getTexture queue -> textureFileName in if textureFileName!=nil then registerTexture textureFileName else nil; registerM3dTextures (goToNextBloc queue) ) else if !strcmp hd tete "shell" then registerM3dTextures (goToNextBloc queue) else if !strcmp hd tete "mesh" then registerM3dTextures (goToNextBloc queue) else if !strcmp hd tete "anim" then registerM3dTextures (goToNextBloc queue) else if !strcmp hd tete "camera" then registerM3dTextures (goToNextBloc queue) else registerM3dTextures queue; 0 );; /*----------------*/ /*register a m3d file and associated textures*/ fun registerM3d(fileName)= /*_DLGMessageBox _channel nil "register : m3d" fileName 0;*/ _RSunregister this fileName; _RSregisterfiles this fileName::nil RSfile+RScontrol; let strextr _getpack _checkpack fileName -> l in registerM3dTextures l;; /*----------------*/ /*register the list of m3d files and associated textures*/ fun registerM3dList(l)= if l==nil then nil else let l -> [tete queue] in (registerM3d tete; registerM3dList queue; 0);; /*----------------*/ fun cliByCli(x,c)=x.cliPho==c;; /*----------------*/ fun cliById(x,id)=x.idPho==id;; /*----------------*/ fun broadReload(a,b)=_DMSsend this a b;; /*----------------*/ fun logout(cli)= _RSunregister this itoa _DMSgetId cli; set av3dClis=removef_from_list av3dClis @cliByCli cli; set clis=remove_from_list clis cli; 0;; /*----------------*/ /*returns the client avatar mesh filename*/ /*nil if no mesh or if mesh not on server*/ fun getCliAvFileName(cli)= let _DMSfindItem cli m3dItemRef -> meshItem in let meshItem.nameItem -> meshName in let _checkpack meshName -> res in if meshItem!=nil && res!=nil then meshName else nil;; /* let _DMSfindItem cli "Corps" -> Corps in let _DMSfindItem cli "Texture" -> Texture in if Corps!=nil && Texture!=nil then strcatn "graphes/avatars/Avatar_"::Corps.nameItem::"/m3d/S_Ava"::Corps.nameItem::"1"::Texture.nameItem::".M3D"::nil else nil;;*/ /*----------------*/ /*returns the files of list l that have the extension ext*/ fun getExtOnly(l,ext)= if l==nil then nil else let l -> [t q] in let strlen t -> long in if !strcmpi substr t long-(strlen ext) long ext then t::(getExtOnly q ext) else getExtOnly q ext;; /*----------------*/ /*register avatars meshes dans textures for default browser*/ fun registerBrowserAvatars()= /*unregisterBrowserFiles registeredBrowserFiles;*/ set defaultAvatarsList=getExtOnly _listoffiles defaultAvatarsDirectory ".m3d"; registerM3dList defaultAvatarsList; /*register all files in browser*/ 0;; /*----------------*/ fun activate(from,cli,action,param,rep)= if !strcmp action "start" then let getCliAvFileName cli -> fileName in ( set clis=cli::(remove_from_list clis cli); if fileName!=nil then registerM3d fileName /*register the client avatar m3d file and its textures*/ else nil; _DMScreateClientDMI this cli defaultAvFile ) else if !strcmp action "getPlugin" then ( _DMScreateClientDMI this cli defaultAvFile; _DMSsend this cli CgetPlugin [_DMSgetHandle from rep] ) else if !strcmp action "!ChgLogin" then let getCliAvFileName cli -> fileName in if fileName!=nil then ( registerM3d fileName; _DMSsend this cli CsetAvatar [fileName] ) else _DMSsend this cli CsetAvatar [nil] /*no avatar in item*/ else if !strcmp action "reload" then ( registerBrowserAvatars; let linebuild defaultAvatarsList -> s in apply_on_list clis @broadReload CsetDefAvatarsList [s]; 0 ) else nil;; /*----------------*/ fun IniDMI(param)= let strextr _getpack _checkpack param -> l in /*get default avatar file*/ ( /*set defaultAvFile=getInfo l "defaultAvFile"; registerM3d defaultAvFile*/ set defaultAvFile ="Dms/Avatar/av3d/avDefault.m3d"; set defaultAvatarsDirectory=getInfo l "defaultAvBrowserPath"; registerBrowserAvatars ); _DMSregisterDMI this @activate @logout nil nil;; /*----------------*/ fun __getSign(id)= let search_in_list av3dClis @cliById id -> q in _DMSsend this DMSsender CsetSign [id q.signPho q.transPho];; /*----------------*/ /*register the mesh filename and its textures*/ /*send the name of the mesh of the avatar*/ fun __getMesh(id)= let search_in_list av3dClis @cliById id -> q in /**/ let _DMSbyId id -> cli in let getCliAvFileName cli -> fileName in ( /*_fooS strcat "**** av3d : demande mesh au server = " fileName;*/ _DMSsend this DMSsender CsetMesh [id fileName q.signPho itoa q.transPho] );; /*----------------*/ fun __trans(f)= let search_in_list av3dClis @cliByCli DMSsender -> q in let if q!=nil then q else let mkPho[DMSsender DMSsender.idCLI "" nil nil] -> r in (set av3dClis=r::av3dClis;r) -> p in set p.transPho=f;; /*----------------*/ fun stringCompare(a,b)=!strcmpi a b;; /*----------------*/ /*change cli mesh*/ /*verify if mesh name authorised*/ fun __updateCliAvFile(s)= if (search_in_list defaultAvatarsList @stringCompare s)==nil && (strcmp s getCliAvFileName DMSsender) && (strcmp s defaultAvFile) then _DMSsend this DMSsender CsetAvatar [defaultAvFile] /*default avatar*/ else (_DMSsubItem DMSsender m3dItemRef 10000; /*to be sure !*/ let mkItem [m3dItemRef s 0 nil] -> item in _DMSaddItem DMSsender item);; /*----------------*/ /*client started*/ /*send avatars default list*/ fun __registered()= _DMSsend this DMSsender CsetDefAvatarsList [linebuild defaultAvatarsList /*strbuild defaultAvatarsList::nil*/];; /*----------------*/ /*not bitmap choosen*/ fun __nobitmap()= let getCliAvFileName DMSsender -> fileName in if fileName!=nil then /*register the client avatar m3d file and its textures*/ registerM3d fileName else nil; _DMSsetress DMSsender "Avatar" type; _DMSevent this DMSsender "changed" nil nil;; /*----------------*/ /*receive bitmap*/ fun __addbitmap(s)= let search_in_list av3dClis @cliByCli DMSsender -> q in let if q!=nil then q else let mkPho[DMSsender DMSsender.idCLI "" nil nil] -> r in (set av3dClis=r::av3dClis;r) -> p in if s==nil then set p.workPho="" else if strlen s then (set p.workPho= let strcat p.workPho s -> ns in if (strlen ns)<16384 then ns else "") else let itoa _DMSgetId DMSsender -> name in let _getlongname p.workPho "" "#" -> sign in (_storepack p.workPho strcat "tmp/photo/srv" sign; _RSunregister this name; _RSregister this name 0 p.workPho; set p.workPho=nil; set p.signPho=strcat "tmp/photo/" sign; let getCliAvFileName DMSsender -> fileName in if fileName!=nil then /*register the client avatar m3d file and its textures*/ registerM3d fileName else nil; _DMSsetress DMSsender "Avatar" type; _DMSevent this DMSsender "changed" nil nil; nil);;