/* Photo Avatar - DMS - mar 98 - by Sylvain HUET */ var avfile="Dms/Avatar/Photo3/av.m3d";; 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 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 cbcomm(ui,action,param,o)= if !strcmp action "setPhoto" then let hd strextr param ->[sign [f _]] in if sign==nil then nil else applyface sign o atoi f else nil;; 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; ObSetMain o sh0; ObCbDestroy o @destroyPho; ObSetCam o; 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; UcbComm this ObUi o mkfun4 @cbcomm o; Usend this ObUi o "getPhoto" nil; 0 );; fun IniPlug(file)= set class=getInfo strextr _getpack _checkpack file "name"; M3load session avfile nil; set avatar=M3getObj session "avatar"; PlugRegister class @newOb nil; 0;;