/* Photo Avatar - DMS - mar 98 - by Sylvain HUET */ /* rev September 2001 - by sebastien DENEUX */ typeof avfile=S;; typeof class=S;; typeof avatar=H3d;; fun destroyPho(o) = M3delObj session M3getFather session ObGetMain o; 0 ;; fun destroy2Pho(o) = M3delObj session ObGetMain o; 0 ;; /*-----------------*/ /*modified 02-08-99 by Sebastien DENEUX : limitation of the speed of the photo avatar animation*/ fun animPho(o, q) = let q->[h x oldtick] in let _tickcount -> currenttick in let currenttick - oldtick -> deltaTick in if deltaTick>=50 then let (100+x)&4095 -> x in let if x&2048 then 3072-x else x-1024 -> z in ( let M3getObjAng session h -> [a _ c] in M3setObjAng session h [a z c]; let M3getObjVec session h -> [a _ c] in M3setObjVec session h [a (z>>6) c]; mutate q<-[_ x currenttick]; 0; ) else 0 ;; /*modified 10-99 by Sebastien DENEUX : transparency color of the photo = left top pixel*/ fun applyface(s, o, f) = let _LDbitmap _channel _checkpack s -> imagebmp in let if imagebmp==nil then _LDjpeg _channel _checkpack s else imagebmp -> image in /* NEW */ let if o==owner then let M3getFirstSon session ObGetMain o -> h in M3getBrother session h else M3getFirstSon session ObGetMain o -> h in /* FIN NEW */ /* let M3getFirstSon session ObGetMain o-> h in */ let M3copyObjMaterial session h hd M3listOfMaterials session h-> mat in let M3copyMaterialTexture session mat -> 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 nil; M3blitTexture16 session t image; _DSbitmap image ) ;; fun cbGetpho(param, ulist, o) = let strextr param -> l in /*sd*/ let getInfo l "sign" -> sign in let getInfo l "trans" -> trans in if sign==nil then applyface "logo.bmp" o 0 else applyface sign o atoi trans ;; fun newOb(o) = if o==owner then let M3createShell session -> sh in let M3createShell session -> sh0 in ( M3setObjVec session sh0 [0 160 0]; let M3createSphere session 100 ->h in ( M3setObjVec session h [0 110 0]; M3link session h sh ); M3link session sh0 sh; M3link session sh shellav; let M3copyObj session avatar -> hnew in /* NEW */ ( M3recursFillMatObj session hnew; M3link session hnew sh0; ObCbAnim o mkfun2 @animPho [hnew 0 _tickcount]; ); /* FIN NEW */ ObSetMain o sh0; ObCbDestroy o @destroyPho; ObSetCam o; _DMSeventTag this strcat class ".getPhoto" nil (UgetUser ObUi o)::nil [mkfun3 @cbGetpho o 3600 0]; /* NEW */ 0 ) else let M3createShell session -> sh in let M3copyObj session avatar -> hnew in ( M3link session hnew sh; ObSetMain o sh; ObCbAnim o mkfun2 @animPho [hnew 0 _tickcount]; ObCbDestroy o @destroy2Pho; _DMSeventTag this strcat class ".getPhoto" nil (UgetUser ObUi o)::nil [mkfun3 @cbGetpho o 3600 0]; 0 ) ;; fun IniPlug(file)= set class=getInfo strextr _getpack _checkpack file "name"; set avfile=strcat _DMSgetpath file "av.m3d"; M3load session avfile nil; set avatar=M3getObj session "avatar"; PlugRegister class @newOb nil; 0 ;;